News:

Welcome to World of Banished!

Main Menu

Beginner's Guide to Modding for Banished PART 4 - AO, Points, and Scale

Started by scoutae4, December 09, 2023, 12:10:36 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

scoutae4

PART 4 - AO, Points, and Scale / Beginner's Guide to Modding for Banished: a simple fence

*updated part 13 to save AO in BW instead of RGBA 12.10.2023

In the ModKit guide the developer tells us that:

QuoteThe first UV channel for a building is used by the material with the primary texture...
(we created this in PART 3)

QuoteThe second UV channel is used for an ambient occlusion texture. Each construction model needs its own AO texture.
let's add this now!


Open your last save and we will pick up exactly where we left off:



1.   ADD A PLANE / Adding a plane that will sit underneath our fence will help create AO shadows where the plane meets the ground, as well as seal out potential light leaks because we deleted the bottom faces in PART 2 (some don't use this method - it's a creator's choice). Tab into OBJECT MODE, then press SHIFT + A > MESH > PLANE. Tap "S" to initiate the SCALE tool, then drag the plane to be completely under our fence something like the example below, and then left click to confirm placement.



2.   CREATE AN AO TEXTURE / In the UV EDITOR in the top left of your screen, click the "x" between the pin and the folder to unlink our wood texture. Then click on NEW and in the popup box enter the name "TutorialFenceAO" and change the width and height to 512 x 512 and click OK. You will have a black texture that we will shortly map our AO to.



3.   MOVE THE 3D VIEWPORT / In the viewport on the bottom left, change your editor to a 3D VIEWPORT to view your fence there. If you can't see your wood texture applied, temporarily stretch your screen to the right and enable the MATERIAL PREVIEW button.



4.   OPEN THE SHADER EDITOR / Switch the viewport on the right to a SHADER EDITOR. Tap "N" to dock the SIDEBAR in the SHADER EDITOR to give us more space. Click the TutorialFence mesh in our OUTLINER to make it active and display the nodes we created in the last tutorial. Box select and move theses nodes up to give yourself a bit more room.



5.   ADD OUR NODES / With your cursor in the SHADER EDITOR, press SHIFT + A and then search for and add the following nodes:

• IMAGE TEXTURE
• AMBIENT OCCLUSION
• COLOR RAMP

Unplug and move the MATERIAL OUTPUT node to the end our new node tree.



6.   NOODLE / In our new IMAGE TEXTURE, select the "TutorialFenceAO" from the dropdown options. Noodle the other nodes into the sockets as per below. *In my example I have the COLOR socket from AMBIENT OCCLUSION plugged into the FACTORIAL of the COLOR RAMP. It probably should be from the AO socket so it's grey to grey, but I've seen this done both ways so I'm leaving my "mistake" here. Doesn't seem to make a difference to the result.



7.   PREVIEW AMBIENT OCCLUSION / If we want to preview our effect, we need to go into the render tab and select the EEVEE render option, and then enable AMBIENT OCCLUSION. Now we can see shadows applied to our model that make it look more dynamic.



8.   REFINE YOUR AO / Change the DISTANCE in the AMBIENT OCCLUSION node to .3 and in the COLOR RAMP node drag the shadow box (not sure what it's officially called) to somewhere around .4 These are just my preferences - play around with the formula to get what you like!



9.   ADD A UV CHANNEL / Go to your OBJECT DATA PROPERTIES and under UV CHANNELS, click the "+" symbol to add a new UV map and select it to make it active. Make sure your TutorialFenceAO image texture is active (it should have a highlight around it to show that it's selected) and your fence should be active too (orange outlined).



10.   CYCLES / With all these selected, click back into the RENDER PANEL and this time select CYCLES from the RENDER ENGINE options. You can only bake textures in Cycles. Select your desired device to perform the render. If you're not sure which device to designate, just leave it to default. I don't think this matters unless you are rendering something that will tax your system. (you can read more about this here: https://docs.blender.org/manual/en/latest/render/cycles/gpu_rendering.html)



11.   BAKE / Scroll down to the BAKE toggle to open the options. Select COMBINED as the BAKE TYPE with INFLUENCE selected as below, change the size to 8 px, and then click the grey BAKE button at the top of the bake section. Your progress will appear at the bottom of the screen. (Play around with these options - I know this works but I'm sure it can be finessed) 



12.   A NEW AO MAP / You should now have a nice AO in your UV editor. The asterix next to image is your cue that you have not yet saved your Image, so let's do that now.



13.   SAVE YOUR AO / Select IMAGE > SAVE AS > and then navigate to the MOD ASSETS folder we created in PART 3. Use the settings as below (png, BW, 8bit). We can now close our UV EDITOR viewport by clicking on an empty area in it's menu and selecting CLOSE AREA. *Note I am selecting BW because our AO is a black and white image and there is no need for color or an alpha transparency. This option will give you the smallest file size result and it works, but the developer has his AO files set to RGB so I leave this choice to you.



14.   RENOODLE YOUR FENCE / Unplug the MATERIAL OUTPUT node and plug it back in to the BSDF Node. Add a MIX COLOR node and noodle the sockets as below. Change the MIX to MULTIPLY and the FACTOR to 2.5. You can box select and delete the AO and Color Ramp nodes as we are done with those.



15.   SELECT CHANNEL 1 & DELETE PLANE / Switch the UV Map back to the first channel and delete the plane we created. You can now close the Shader Editor.



16.    ADD POINTS / We are creating a ghosted item, but we still need to create the pick points to guide our Bannies. The points need to be created at 0,0,0 which is where our origin point is so we can get started. While in Object Mode, press SHIFT + A and select EMPTY > PLAIN AXES. In your OUTLINER, rename this "points". Repeat the previous step and this time rename it "build_001". Nest "build_001" under "points" (select and drag, then press SHIFT as per the tool tip). I'm still not 100% on how to work with points but this will work for our little fence mod. :)



17.   RESIZE & EXPORT / Tap "A" to Select All, tap "S" to call up the SCALE TOOL, then on your keyboard type in .01 and press enter. Export as TutorialFence.fbx to your Mod Assets folder (leave the options as is)

 

Done with Blender! Next part is the last part, folder build out and (finally) create our mod with the kit!!


kid1293

Just a note on step 13.
The black or transparent area is outside the mapped model. It has no impact on the result.

I will add a plane under my models in the future. It gives great shadowing of the lower part.
Thanks for showing it. :)

scoutae4

QuoteJust a note on step 13. The black or transparent area is outside the mapped model. It has no impact on the result.

Thank you friend! I updated the tutorial to incorporate this information. :)  I *think* the AO map can be even smaller to reduce file size but I haven't played around with this. Luke has an AO map at 256 x 256px paired with a 1024px material texture in his apiary example which makes sense, you don't need detail in an AO map. But I am much confused by his AO maps. Why the alpha? Why RGB? I know black and white works, but maybe it's not optimal.

kid1293

I have learned that using alpha is a bit of an acquired taste.
Some are used to have an alpha layer in everything.
Some graphics editors have it as the default output.

Use common sense when handling pictures with or without alpha.
If any part is to be transparent - use alpha.