Question by
MrrGingerNinja · Feb 17, 2016 at 02:06 PM ·
c#scripting problemlightingglobal illumination
Global Illumination at Runtime
Hi, so I have a question about realtime Global Illumination... I instantiate a material at runtime with Global Illumination turned on, using the below code;
Material material = new Material ( Shader.Find ( "Standard" ) );
material.name = "Test";
Texture texture = Resources.Load<Texture> ( "Test" );
material.mainTexture = texture;
material.SetFloat ( "_Mode", 1 );
material.SetFloat ( "_Glossiness", 0 );
material.SetTexture ( "_EmissionMap", texture );
Color color = Color.white * Mathf.LinearToGammaSpace ( 1.0F );
material.SetColor ( "_EmissionColor", color );
material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeEmissive;
DynamicGI.SetEmissive ( meshRenderer, color );
When I run the project, however, I get this result; ![alt text][1]
If I open the material in the Editor, then the object then lights up;
![alt text][2]
Any idea how I can force this refresh via the code?
Many thanks!
Tom! [1]: /storage/temp/64093-unlit.png [2]: /storage/temp/64095-lit.png
Comment
Your answer
Follow this Question
Related Questions
Disable light not working 0 Answers
Add object using other scene,Change something in scene from the menu 2 Answers
Sun Variable Rotation 1 Answer
Problem with my script 0 Answers