AO baked ground plates for your mod!

AO baked ground plates for your mod!

Share and discuss visual creations and creation practices like texturing, modelling and musing on the meaning of life.

Moderators: MR.D, Moderators

User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

AO baked ground plates for your mod!

Post by Beherith »

How it works:
Parses .fbi and .lua files in 'units'
Checks wether they are static units, and not floating units.
Checks them for preexisting ground plates
Loads the s3o/3do files
Creates an OBJ file, with a groundplate of specified size( if preexisting ground plate exists, then that size, else it estimates a size based on footprintx and footprintz
Launches xnormal with the pregenerated bake options, which bakes the AO on.
Performs lots of magickal operations on the plate, to make it look good (TM)
Compresses the plate to .dds dxt5
Edits the lua or fbi file to contain the defs.
Repeat for each static unit.

Needs the following to run:
Windows (sorry guys, i dont have linux, prolly wont work for it, no nvdxt)
Imagemagick
Python 2.6
PIL (Python Image library)
xNormal (by Santiago Orgaz)
Nvdxt (included)
Misc external files (images, .xml file, all included)
A fast multi core cpu (batteries not included)
Time (about an hour on my nucular powerplant)

When its done, all you gotta do is copy the *aoplate.dds files and .lua or .fbi files to their respective places.

It generates a ton of trash and intermediate files after each run (intermediate files for the imagemagick, obj files, etc) Delete them once your done.

Performance: Takes about 5% off my fps when there are a lot of buildings on screen

Future considerations:
Thinking of asking for engine support for plate UV coords, so they can be atlassed

Mod file size increase:
For all of BA's buildings, this is low: about 3 megs.

Note: I cant provide screenies atm, since my monitor is broken, and running spring through vnc is a nightmare.
Attachments
aobakerv1.0.7z
(399.96 KiB) Downloaded 74 times
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: AO baked ground plates for your mod!

Post by Beherith »

Also, if you dont feel like running this, but still want the results, then feel free to post here, with a link to your mod (not rapid)
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: AO baked ground plates for your mod!

Post by hoijui »

with Tobis rapid client, you can get an .sdd folder of any mod.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: AO baked ground plates for your mod!

Post by Beherith »

I tried, and it failed. I apologize but I lack the will or time (after spending 2 hours in #sy talking to people that know how to use it) to try again.
User avatar
Cremuss
Posts: 364
Joined: 28 Oct 2006, 21:38

Re: AO baked ground plates for your mod!

Post by Cremuss »

you can do it with blender and gimp too, you just need to find the correct size in blender so 1 unit in spring = 1 unit in blender. Once you did that it's really easy :
  • - create a plane
    - scale the plane to fit the unit model (it has to be bigger in fact. The scale value in blender is the value you need to put in grounddecalsizeX and Y in the unit's fbi)
    - select your plane, go to edit mode (tab)
    - select all (a)
    - press 'u' and select unwrap
    - go to uv/image editor window and go to image menu and press new. Then Select the size you want
    - go to the bake panel in the menu window
    - select Ambiant Occlusion and turn on "normalized"
    - click Bake. Once it's finished, go back to the uv/image editor window, go to the image menu and press save.
Since the texture output will be a black shadow on a white background, you need to convert it to a black shadow on a transparent background.

To do that, open the AO texture in Gimp.
  • - ctrl a, ctrl c to copy to buffer the full image.
    - fill black the whole image
    - right click on the layer name in the layer panel and click "add layer mask"
    - ctrl v
    - go to colors menu and click "invert"
    - click outside the image canvas to past the mask.
    - you'r good to save your .dds
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: AO baked ground plates for your mod!

Post by Beherith »

Yeah Cremuss, everything you posted there, and more, is done automatically by this script.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: AO baked ground plates for your mod!

Post by Forboding Angel »

http://evolutionrts.info/random/rapid.zip << just unzip to your spring folder and run rapid.bat (or open a cmd window and type in the commands yourself).
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: AO baked ground plates for your mod!

Post by Beherith »

Ran it on BAR:

No AO, no shadows:

Image

AO
Image

Shadows
Image

AO+shadows
Image
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: AO baked ground plates for your mod!

Post by Gota »

Beherith wrote:Also, if you dont feel like running this, but still want the results, then feel free to post here, with a link to your mod (not rapid)
base file:
http://www.springfiles.com/show_file.php?id=1677
mutator:
http://www.springfiles.com/show_file.php?id=2565
User avatar
SirArtturi
Posts: 1164
Joined: 23 Jan 2008, 18:29

Re: AO baked ground plates for your mod!

Post by SirArtturi »

Yep, though the operation is minor, difference is significant. Looks good!
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: AO baked ground plates for your mod!

Post by Beherith »

Imo the best part is how it masks the bad shadows of buildings that are floating above ground a tiny bit (compare the annihilator in the last two screens)
User avatar
tyran_nick
Posts: 47
Joined: 07 Mar 2010, 12:42

Re: AO baked ground plates for your mod!

Post by tyran_nick »

I gave it a try and I got the following error:
Definition type is fbi
fbi parsed armafus.fbi
objtype s3o
header: (0, 45.0, 100.0, -0.089204363524913788, 30.0, 0.054122611880302429, 52, 0, 54683, 54699)
working on: armafus.fbi vertices: 1459 parts: 16
found .obj in xml
found .obj in xml
found .bmp in xml
"C:\Program Files\Santiago Orgaz\xNormal\3.17.2\xnormal.exe" xnormalsettings.xml
Traceback (most recent call last):
File "C:\Documents and Settings\User\Desktop\Spring WIP\aobaker.py", line 434, in <module>
img=Image.open(outfname.partition('.')[0]+'_ao_occlusion.bmp')
File "C:\Python26\lib\site-packages\PIL\Image.py", line 1952, in open
fp = __builtin__.open(fp, "rb")
IOError: [Errno 2] No such file or directory: 'armafus_ao_occlusion.bmp'
I installed all the software and unzipped in a folder the file you provided. In that folder I created a units, 3dobjects and unittextures folders and copied into units my fbi files and into 3dobjects my 3do and s3o files. Run the script and I got the error above. Any ideas?

That particular unit is a building and currently has no groundplate.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: AO baked ground plates for your mod!

Post by Beherith »

First off, does xNormal throw any errors?
Does it create a .bmp file next to aobaker.py?
Check the path in xnormalsettings.xml (for file armafus_ao_occlusion.bmp)
Does this file exist in the path specified?


Also, for gota: http://beherith.eat-peet.net/stuff/sa.7z
Youll have to manually remove them from units where you dont want ao plates (mostly units that are cloaked).
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: AO baked ground plates for your mod!

Post by Gota »

Beherith wrote:First off, does xNormal throw any errors?
Does it create a .bmp file next to aobaker.py?
Check the path in xnormalsettings.xml (for file armafus_ao_occlusion.bmp)
Does this file exist in the path specified?


Also, for gota: http://beherith.eat-peet.net/stuff/sa.7z
Youll have to manually remove them from units where you dont want ao plates (mostly units that are cloaked).
thx
User avatar
tyran_nick
Posts: 47
Joined: 07 Mar 2010, 12:42

Re: AO baked ground plates for your mod!

Post by tyran_nick »

I had to reinstall xNormal. Not sure why...
Anyway, it worked this time and the effect is great! Thanks

Does it look for parts of the model that are below surface or does it consider only what is on y=0? I already noticed that it ignores parts y>0
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: AO baked ground plates for your mod!

Post by Beherith »

It ignores untextured faces in 3do models, as this was an easy way to ignore the selection plates in each 3do.

I'm super stoked that it works for you, cause its just 500+ lines of badly thrown together spaghetti code.
User avatar
tyran_nick
Posts: 47
Joined: 07 Mar 2010, 12:42

Re: AO baked ground plates for your mod!

Post by tyran_nick »

In your example pics it seems that you have AO baked plates and the normal plates for the factories, or is it my impression?

How did you do that, did you just photoshop the plate or somehow you have both plates in the unitdef?
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: AO baked ground plates for your mod!

Post by Beherith »

That is also scripted into the code. It looks for preexisting ground plates, and burns the AO onto that.
User avatar
tyran_nick
Posts: 47
Joined: 07 Mar 2010, 12:42

Re: AO baked ground plates for your mod!

Post by tyran_nick »

I ll have a look when I go back home and check again. I tried to bake the typical OTA buildings (from BA) and the result didn't have the default groundplate. Though I suspect I know what I did wrong. I guess I should copy the original groundplate texture in the unittextures folder so that the python code can find it... :oops:
Post Reply

Return to “Art & Modelling”