Jump to content

Ambient Light / Emissive texture


grire974
 Share

Recommended Posts

@Deltakosh and @Sebavan ... Holy crap... It took me FOREVER to get my head around all the different options to provide a fully baked scene...

And delta... i finally understand your EITHER OR about the emissive or light map ... BUT that only applies IF the texture you are using ALREADY has all the light map channel stuff in it.. so that one texture has EVERYTHING it needs... JUST SET TO emissiveTexture and NO NEED for the separate lightmapTexture...

Now i my case... unity does not produce a single texture atlas (at lest not that i can tell or get to via the unity api) that has everything in it (basically the light map channel included)... So i have to use a light map as well... just for the shadow part...

But there other things that i needed to know WHAT TO SET and NOT TO SET...

Things like no need to iterate over meshes and push onto light.excludeMeshes... on the material...

1...material.disableLighting = true; (no need light exclude meshes)

2...material.useEmissiveAsIllumination = true;

3... ALWAYS USE STANDARD MATERIALS ON THE BABYLON SIDE FOR FULLY EMISSIVE MATERIALS (even if made from pbr setup... just use the data to create a standard material on the babylon side)

4... material.diffuse = WHITE (Sebastian says black here... but i get ALL black... White os working)

5... material.specualer = BLACK

6... IF just emissive color and NO texture... Set emissive color to whatever the color is... IF HAS TEXTURE... set emissive color to black

7... If also has light map ... stick unity generated .exr (exported to jpg) in material.lightmapTexture and use useLightmapAsShadowmap = true;

8... The exporter will take out all non mixed lights by default... (you could prob still MacGyver a realtime light in at runtime... but if you can afford that light... just use regular shadow baking and NOT FULLY EMISSIVE BAKING)

 NOTE: The fully emissive baking (no realtime shadows by default) should really only used in the extreme cases where you can't afford at least 1 ambient light and 1 directional light... like a slower mobile device... your just create a TOTALLY BAKED SCENE... WITH NO LIGHTS

So i am basically taking WHATEVER the main texture is and just sticking it in emissiveTexture (plus all these other settings)

THIS IS WORKING GREAT...

@Sebavan BUT THEN I JUST FOUND SOMETHING UNITY...

Using a standard shader... If you actually put your texture in Emission (and I DO NOT simply take your diffuse or albedo texture and stick in our babylon emissiveTexture like described above) and set the "Global Illumination" options to:

According to unity docs:

Baked - The emissive light from this material will be baked into the static lightmaps for the scene, so other nearby static objects will appear to be lit by this material, but dynamic objects will not be affected.

So if just let unity bake the emissive light into the static lightmap .exr...

How would i use that... I think i still use lightmapTexture and set useLightmapAsShadow = false... so it uses the emissive light in as well... Not sure...

i was just looking at a way to make sure we get all the light and use it effectively ... We talked about maybe LOOSING some specular colors and ambient occlusion just sticking what was diffuse texture into emissive texture and using the light map as a shadow map ... Would this solve that problem ???

That would be kool... then i don't even have to go thru all this trouble to provide full baking... You say whether or not the materials you are using will use Emission or not and select "Baked" to get that EXTRA global illumination in to the static light map (that you still use as lightmapTexture) I THINK :)

@Sebavan please take a look at Standard Material Emission and see if we can IMPROVE what we talked about on the phone... PRETTY PLEASE :)

 

Link to comment
Share on other sites

Yo @Sebavan remember you asked me if the unity produced light map image file (.exr converted to .jpg) had any colors in it and i said NO...

Well if you use the a standard material and set Emission and set Global Illumination to 'Baked"... Now i see colors in the light map image file.

Hit me up when you get a chance... Another few minutes on the phone and i think we could do FULL BAKING "Right-Way" and not LOOSE any global illumination baked into the light map texture :)

Emission GI on material set to NONE or REALTIME:

NONE_Level1Lightmap-1_comp_light.jpg

 

This one Emission GI on material set to 'BAKED'

BAKE_Level1Lightmap-1_comp_light.jpg

 

So it looks like it has the 1 and only Emissive blue color a setup on the floor plane just to see if it would produce a different lightmap file... and it seems too ... :)

 

Link to comment
Share on other sites

Yo @Sebavan and @Deltakosh ... Bro I think i just cleaned up all that code list above... Now just simply this couple lines added to DumpStandardMaterial and DumpPBRMaterial:

if (exportationOptions.DefaultLightmapMode == (int)BabylonLightmapMode.FullLightBaking) {
  bMat.disableLighting = true;
  bMat.useEmissiveAsIllumination = true;
}

Everything else can stay the same... If you want Fully Baked Lighting for your mobile version for example... Just set "Light Mapping Mode" in the toolkit to use "Full Light Baking" ... Besides the code above to disable lighting on material and set emissive to illuminate ... The only thing the FullLightBaking switch does it PREVENT lights from being added to scene... You must setup that material to be 'Emissive' via the normal material inspector.

Note:

- PBR Material using emissive texture set ALBEDO color BLACK 

- Standard Material (Basically any Unity Legacy Shader) using emissive texture set DIFFUSE color WHITE

Also... When using shaders that support 'Emission Global Illumination"... Just set that to BAKED... And will get the additional emissive light baked into the static lightmap (Not sure if i leave material.useLightmapAsShadowmap = true IF we ALSO have those emissive light colors baked into static lightmap... Right now i KEEP that switch ENABLED... If its wrong we can change it later)

Then you will have Fully Baked Lighting (via Emissive and Lightmap Textures)

This setup seems to be working pretty good.. WITH FAR LESS COMPLICATION :)

 

Link to comment
Share on other sites

This is utterly cool. Really impressive work

Thanks a lot for this contribution. We now need a decent documentation because you provided so many new features :)

We have a separate repo for it:
https://github.com/BabylonJS/Documentation 

and more precisely: https://github.com/BabylonJS/Documentation/blob/master/content/exporters/Unity/Unity.md 

You can edit it in the website or using this guide:http://www.html5gamedevs.com/topic/16365-contributing-to-documentation-101/ 

Link to comment
Share on other sites

15 hours ago, Deltakosh said:

This is utterly cool. Really impressive work

Thanks a lot for this contribution. We now need a decent documentation because you provided so many new features :)

We have a separate repo for it:
https://github.com/BabylonJS/Documentation 

and more precisely: https://github.com/BabylonJS/Documentation/blob/master/content/exporters/Unity/Unity.md 

You can edit it in the website or using this guide:http://www.html5gamedevs.com/topic/16365-contributing-to-documentation-101/ 

 

Wow... that seems just as intense as making the toolkit itself (Even the 101 helper site you fork is pretty involved). But i will give it a shot :) 

 

Link to comment
Share on other sites

@Deltakosh Wait minute... Is this the ACTUAL website documentation section???

If i do this, will all my documentation show up in the main website with all that fancy formatting???

Well heck... if thats the case... It might be worth the trouble... I will take look at it in a day or so (i gonna take little break and play with my toolkit... I still have not actually got to  use my toolkit for real... Spent all my spare time making the darn thing :))

Link to comment
Share on other sites

Obviously my friend :)

We want to showcase your excellent work!

And if you just want to send me a .md file I can update the doc for you or you can just edit it live here:  https://github.com/BabylonJS/Documentation/blob/master/content/exporters/Unity/Unity.md

Once updated, you will be right here:

http://doc.babylonjs.com/exporters/Unity

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...