Jump to content
Jasoncw

BAT - Getting Started Guide / FAQ / Resources / Help

682 posts in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 
3 hours ago, Barroco Hispano said:

By the way, can you give us a hand with this?

Looking at the code the thing that stands out is the setPreMultAlpha command, try changing its value to false.

Premultiplied alpha changes the color channel values to match the alpha channel when the alpha value is partially or fully transparent.

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

@Null 45 Unfortunately it seems that "setpremultalpha" is not the cause of the problem (The problem seems not to be in the alpha channel). ^_^


As you can see the 3Ds Max (or mental ray) .tga format is completely broken in the night renders, for some reason it makes the dark parts of the BAT completely black (As if it was a completely inadvertent compression of the image having Note that the image is 32-bit). The .png format does not seem to have this problem.

Please turn up all the brightness on your screen so that you can appreciate the problem.

unknown.png

a

unknown.png

For many this may seem silly but the reality is that it makes many BAT's that have dark parts or textures look horrible.

 

  • Like 1

Discord: JLeCoultre#9124

My Simtropolis BAT Thread

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 
1 hour ago, Barroco Hispano said:

Unfortunately it seems that "setpremultalpha" is not the cause of the problem (The problem seems not to be in the alpha channel).

I do not have a copy of 3ds max, so there is no way for me to debug the BuildingMill script.

Looking at the code it appears that the script is rendering the color image in memory, saving it as TGA, and then reading the TGA file from disk for the BMP conversion. That seems like a very roundabout method of saving a bitmap, but it may have been copied from the GMAX scripts and adapted to work with FSHTool.

You may be able to use the in-memory image by replacing "sourceTgaCP = openbitmap (RenfilenameCP + ".tga")" with "copy sourceCP sourceTgaCP", but I am just guessing at that.

 

  • Like 1

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

@Null 45 ^_^

unknown.png

I'm sure the problem is in 3DsMax/Mentalray, I already did a test removing BATMAX plugin and got the same result.

This is how it should look like (3dsmax .png format works fine):

Lorinas_test.png

When you try to save this image as .tga in PS or Paint.net there is no color loss or compression, instead if you save it in .dds (DXT1) format then the same thing happens as .tga in 3Dsmax . In short, the only way to fix this is to have BAT4MAX convert from png to bmp instead of tga to bmp but the problem is that I don't know how to do it.


Discord: JLeCoultre#9124

My Simtropolis BAT Thread

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 
6 hours ago, Barroco Hispano said:

In short, the only way to fix this is to have BAT4MAX convert from png to bmp instead of tga to bmp but the problem is that I don't know how to do it.

I do not know either. The FnDoRender2 method is hard to decipher, it is several hundred lines long and contains a mix of code for the different types of rendering.

Here is another attempt. I copied the TGA rendering code, changed it to save a PNG, and then updated the BMP loading code to use it.

Make a backup copy of the original BuildingMill.ms script and paste the following code between lines 702-741.

Spoiler

--Null45 HACK: copy the TGA rendering code and save the color image as PNG
	portable_network_graphics.ipngio.settype #true24
	portable_network_graphics.ipngio.setalpha false
	portable_network_graphics.ipngio.setinterlaced false
	
	sourceNU = bitmap tempGamma.width tempGamma.height fileName:(RenfilenameCP + ".png") gamma:(1/displayGamma)
	copy tempGamma sourceNU
	
-- SF checks for the Max (Mental Ray) version and fixes framing problem produced by MR in Max2009+

	if ((maxversion())[1])>=11000 do (
	sourceNU = autoadjust sourceNU
	)
	save sourceNU

--CP SET BMP INTERFACE FOR 8 BIT SAVE
    bmp.ibmpio.settype #paletted
    AlphaTempCP = bitmap tempGamma.width tempGamma.height filename:(RenfilenameCP + "-a.Bmp") gamma:(1/displayGamma)
	save alphaTempCP

--CP CONVERT FROM TARGA TO BMP 
	alphaSplitCP = openbitmap (RenfileAlphaNameCP + ".tga")
    AlphaCopyCP = copy alphaSplitCP
	copy alphaCopyCP alphaTempCP

--CP SAVE THE ALPHA MAP IN BMP FORMAT
	save alphaTempCP
	close alphaCopyCP
	close alphaSplitCP
	
--CP RETURN BMP INTERFACE TO 24 BIT TRUE COLOR
    bmp.ibmpio.settype #true24
	
--CP NOW CONVERT THE OTHER TARGA TO BMP
    sourceTgaCP = openbitmap (RenfilenameCP + ".png")
	outputBmpCP = bitmap renderbox.w renderbox.h filename:(RenfilenameCP + ".Bmp")
    idxCP = 0
    for idxCP in 0 to (renderbox.h - 1) do
	(
        local PixelRowCP = getPixels sourceTgaCP (point2 0 idxCP) renderbox.w
        setPixels outputBmpCP (point2 0 idxCP) PixelRowCP
	)
	save outputBmpCP
	close sourceTgaCP
	
--CP DELETE THE TGA FILES AS THEY ARE NO LONGER NEEDED
	deleteFile alphaSplitCP.filename
	deleteFile sourceTgaCP.filename
	deleteFile sourceCP.filename
	if (gRenderTypeCP != 1) do
	(
		close SourceCP
		close sourceNU		
		close outputBmpCP
	)

 

It is unfortunate @SimFox is inactive. Changing the rendering pipeline to use PNG with alpha would likely make it simpler.

  • Sad 1

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

@Null 45 The problem still persists (The good news is that I didn't get any errors, everything exported successfully.) :(

By the way, I just realized that the 3ds max .bmp format is also broken. I think the only thing we can do is remove the conversion to bmp, make the output files BAT4MAX generates 0000.png and 0000-a.png and let fshwrite do the conversion from .png to .fsh ^_^

 

 


Discord: JLeCoultre#9124

My Simtropolis BAT Thread

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 
15 hours ago, Barroco Hispano said:

By the way, I just realized that the 3ds max .bmp format is also broken. I think the only thing we can do is remove the conversion to bmp, make the output files BAT4MAX generates 0000.png and 0000-a.png and let fshwrite do the conversion from .png to .fsh ^_^

I do not think that 3ds max would have 2 different file formats broken, it is more likely an issue with the export script. I noticed that Bat4Max appears to be performing some kind of gamma correction before it saves the image.

While I agree that using PNG with alpha would be simpler, it would require a large number of changes to BuildingMill.ms and possibly other scripts.

  • Like 1

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

All of a sudden I find myself unable to move things along the X, Y and Z axis. This little trick was very helpful for me when repeating detail along the same axis. (such as window advertisements) I'm finding it to be a tedious task to make things now with this issue. Got around for now by manually typing in numbers to get things to be where they need to be, but there's no way I'll be able to continue doing this in the long term.  

Anyone know what is up with this? Can't figure out what caused it or how to fix it. 

  • Sad 1

Slowly bringing new retail to life because we can never have enough strip malls....

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 
1 hour ago, RRetail said:

All of a sudden I find myself unable to move things along the X, Y and Z axis. This little trick was very helpful for me when repeating detail along the same axis. (such as window advertisements) I'm finding it to be a tedious task to make things now with this issue. Got around for now by manually typing in numbers to get things to be where they need to be, but there's no way I'll be able to continue doing this in the long term.  

Anyone know what is up with this? Can't figure out what caused it or how to fix it. 

I had the same issue and as suddenly as it appeared it disappeared again - computer restarts or reinstallation of gmax can also be helpful. If you need to have the same window in a row, I highly recommend the array function, which I am sure you are aware of.

(In case you are not: just instead of a ring like in this tutorial you would of course use the linear function)

Flange_6.png

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 
On 02/04/2022 at 9:31 PM, Barroco Hispano said:

@Null 45 ^_^

unknown.png

I'm sure the problem is in 3DsMax/Mentalray, I already did a test removing BATMAX plugin and got the same result.

This is how it should look like (3dsmax .png format works fine):

Lorinas_test.png

When you try to save this image as .tga in PS or Paint.net there is no color loss or compression, instead if you save it in .dds (DXT1) format then the same thing happens as .tga in 3Dsmax . In short, the only way to fix this is to have BAT4MAX convert from png to bmp instead of tga to bmp but the problem is that I don't know how to do it.

Totally off topic and not to be picky, but you have a port lantern on the fore and a stbd lantern on the aft mast, is that intentional? :D

  • Haha 1

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

@AP Weird thing was that I also was having issues connecting endpoints yesterday. Booted up the computer today and that was fixed. Thanks. Hopefully it will resolve itself.

  • Like 1

Slowly bringing new retail to life because we can never have enough strip malls....

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

I uploaded FSHWrite version 1.3.1 to the STEX:

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 

@Null 45 You forgot to mention that the new version reduces the size of the BAT's between 40% and 70%. :thumb:

btw, your fsh plugin for photoshop has a bug when you try to "save as" a file for the second time, you get an error and then you have to click "save as" again to be able to choose the options and be able to save it.


Discord: JLeCoultre#9124

My Simtropolis BAT Thread

Share this post


Link to post
Share on other sites
Posted:
Last Online:  
 
1 hour ago, Barroco Hispano said:

@Null 45 You forgot to mention that the new version reduces the size of the BAT's between 40% and 70%. :thumb:

Interesting, I did not know that. The file size reduction is likely the result of the DXT1, transparent pixel and uncompressed 24-bit items in the change log.

1 hour ago, Barroco Hispano said:

btw, your fsh plugin for photoshop has a bug when you try to "save as" a file for the second time, you get an error and then you have to click "save as" again to be able to choose the options and be able to save it.

Thanks, I will have to investigate that.

  • Yes 1

Share this post


Link to post
Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    19 hours ago, Barroco Hispano said:

    @Null 45 You forgot to mention that the new version reduces the size of the BAT's between 40% and 70%. :thumb:

    btw, your fsh plugin for photoshop has a bug when you try to "save as" a file for the second time, you get an error and then you have to click "save as" again to be able to choose the options and be able to save it.

    Even the uncompressed "/hd" exports have reduced file sizes?

    • Yes 1

    patreon.png    PATREON    •    MIPRO    •    MY BAT & TUTORIAL THREAD

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    3 hours ago, Jasoncw said:

    Even the uncompressed "/hd" exports have reduced file sizes?

    Yes, you can even reduce the size of a BAT that you have already exported, just go to C:\Program Files\Autodesk\3ds Max 2012\gamepacks\BAT\NameoftheBAT.bat click, then go to \Outputfiles\NameoftheBATfolder\ and click on the .bat file at the bottom of the list.

     

    • Like 1

    Discord: JLeCoultre#9124

    My Simtropolis BAT Thread

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    @Null 45There are 3 places in CPBuildingMills.ms where there is " fshwrite /b", do I need to add /hd to all of those or just the first one?

    @Barroco HispanoSo this means that by default we should just use /hd, to increase the quality for all of the zooms while also reducing the file size?


    patreon.png    PATREON    •    MIPRO    •    MY BAT & TUTORIAL THREAD

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    6 hours ago, Jasoncw said:

    Even the uncompressed "/hd" exports have reduced file sizes?

    Do not!

    What I meant is that if you use the "HD" command, the size of the sc4model will be smaller than if you insert the uncompressed fsh's manually. I don't recommend that you use that command with a building (I only use it with props).

    If you keep using compression then the BAT size will be reduced by 40-60%, in that case you just have to replace the 3 files without modifying the script (The HD command can increase the size of a BAT by between 100% and 150%).

     


    Discord: JLeCoultre#9124

    My Simtropolis BAT Thread

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    On 4/12/2022 at 6:25 PM, Jasoncw said:

    There are 3 places in CPBuildingMills.ms where there is " fshwrite /b", do I need to add /hd to all of those or just the first one?

    You will need to edit all 3. You can probably just use a global search and replace for "fshwrite /b:"

    On 4/12/2022 at 6:37 PM, Barroco Hispano said:

    If you keep using compression then the BAT size will be reduced by 40-60%, in that case you just have to replace the 3 files without modifying the script (The HD command can increase the size of a BAT by between 100% and 150%).

    The 40-60% reduction with DXT compressed images comes from the fact that fshwrite now uses DXT1 compression for images with opaque or 1-bit alpha (an alpha image where all values are either 0 or 255), the version included with BAT4Max 4.5 and 5 (1.2.0) has a bug where it saves all images as DXT3.

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    5 hours ago, Barroco Hispano said:

    This is the bug

    Fixed in version 1.1.1.0.

    • Thanks 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Does anyone know if there is something to update the parameters of a spline that has been edited so that it reads the measurements accurately? Example; I make a door then clone it to make the surrounding frame and use edit spline to widen it, it will still reads the width and length of the frame the same as the door even though I manually widened it.

    I know I can just snap a new rectangle over the frame so it has the correct measurements but I'm just curious if that feature exists.

    • Like 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     
    43 minutes ago, Rott said:

    Does anyone know if there is something to update the parameters of a spline that has been edited so that it reads the measurements accurately? Example; I make a door then clone it to make the surrounding frame and use edit spline to widen it, it will still reads the width and length of the frame the same as the door even though I manually widened it.

    I know I can just snap a new rectangle over the frame so it has the correct measurements but I'm just curious if that feature exists.

    Good question, I have noticed that before as well and having the correct measurements would be handy indeed!

    • Yes 1

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    OK, this is probably a very simple fix but I can't get it to work in gmax.  Self illumination is giving me a better effect on nightlit offices instead of spot or direct lighting it, but I want to replace the self illumination map with a reflection in the daytime.  Is this possible and how?

    Thanks!

    draft2.jpg.21c200320a5bdbe47a2be42ef3489228.jpg

     

    • Like 2

    20huskies

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     
    14 hours ago, 20huskies said:

    OK, this is probably a very simple fix but I can't get it to work in gmax.  Self illumination is giving me a better effect on nightlit offices instead of spot or direct lighting it, but I want to replace the self illumination map with a reflection in the daytime.  Is this possible and how?

    Thanks!

    Unfortunately it's not possible.

    For spotlights though, you can use a "Projector Map", which would let you project an image with the spotlight. This would improve the result over just a plain spotlight. The projector map stuff is in the "Spotlight Parameters" rollout of a spotlight, in the same section as the hotspot and falloff sections.

    Check the projector map setting, and then put a bitmap there. Then right above that, there are radio buttons for circle or rectangle spotlight shape, and pick rectangular. Below that is an option for the aspect ratio which you can press the bitmap fit button to have the aspect ratio match the night glass texture you're using. Then at the very top of the spotlight's parameters, click "exclude" and the in that window, click the "include" button and then move the glass objects over so that only the glass is getting the light from the spotlight.

    If that doesn't make sense let me know and I can make some images showing it more clearly.

    • Like 2
    • Thanks 1

    patreon.png    PATREON    •    MIPRO    •    MY BAT & TUTORIAL THREAD

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    :8)Thanks @Jasoncw.  Makes sense. I actually have use this before on the old city times building. I just thought the self illumination was better for these lights.  But I’ll make it work *:thumb:

    • Like 3

    20huskies

    Share this post


    Link to post
    Share on other sites
    Posted:
    Last Online:  
     

    Hi

    I have reinstalled GMAX and BAT now when i start BAT it crashes imidietly.

    This appers to happen after i choose render driver when starting,

    anyone have any hints on whats going on?

    Edit:

    Upon further investigation this is what came up

    first

    first.jpg.378ce68243de118da1bcdf6668588bd8.jpg

    secondsecond.jpg.f61c80f764b8e950b35b0ed2f1067753.jpg

    third

    third.jpg.b0ff41560588856e96986d59e3d88184.jpg


      Edited by Oidaas  

    update
    • Sad 1

    Share this post


    Link to post
    Share on other sites
  • Original Poster
  • Posted:
    Last Online:  
     

    @Oidaas My guess is that the BAT was partially but not fully installed, and so when it looks for certain scripts it doesn't find them and crashes or something.

    I notice the "Program Files (x86)". Gmax by default installs directly under C: and iirc the BAT is going to try to install itself there too. If you go to C: you might find another gmax folder that has the BAT gamepack stuff in it. If that's the case then copy and paste the gamepacks folder from C: into your "Gmax" folder in Program Files, so that those files are in the right place.

    • Like 1

    patreon.png    PATREON    •    MIPRO    •    MY BAT & TUTORIAL THREAD

    Share this post


    Link to post
    Share on other sites

    Sign In or register to comment...

    To comment in reply, you must be a community member

    Sign In  

    Already have an account? Sign in here.

    Sign In Now

    Create an Account  

    Sign up to join our friendly community. It's easy!  

    Register a New Account


    ×

    Thank You for the Continued Support!

    Simtropolis depends on donations to fund site maintenance costs.
    Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

    But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

    Make a Donation, Get a Gift!

    Expand your city with the best from the Simtropolis Exchange.
    Make a Donation and get one or all three discs today!

    STEX Collections

    By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

    Each donation helps keep Simtropolis online, open and free!

    Thank you for reading and enjoy the site!

    More About STEX Collections