Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Realtime GI not working?

Discussion in 'Unity 5 Pre-order Beta' started by AustinRichards, Nov 16, 2014.

  1. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    So I have Unity 5 Beta 13, and have a sphere with high emission. Color red, emission around 20 or so. When I set it to static and other objects around it to static, it gives a nice red glow as it should. But this is entirely baked.... How can I make the emission pulse/change color, with the glow on the other objects changing with it?

    It seems everything is baked, and not a single thing is realtime. Reflection probes don't support dynamic objects from what I can tell, and emission is not realtime. Am I doing something wrong?
    I watched a Unity 5 Lighting video, where it showed red lights in a very futuristic metal room, pulsing red light dynamically.

    Here's a picture with the sphere set to non-static as well as my lighting tab.


    Here's a picture with the sphere set to static:
     
  2. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    The only things you can change in real time to affect the GI are the position, direction, colour and intensity of regular lights, as well as the intensity and colour of emissive materials on static objects.

    If you want your dynamic sphere to emit light, try putting a regular light inside it.
     
  3. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    Ok. So in the video unity showed, they were using point lights and not emissive materials?

    I have tried changing the intensity and colour of emissive materials on static objects and it will not change the GI. So for this sphere, and it's set to static, and the game is playing, if I change the color and intensity the bridge stays red.
     
  4. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    I think there's a function you need to call if you want it to update the emissive stuff. Unfortunately I don't remember what it is off the top of my head. It was in one of the threads on the subject, you might be able to find it if you search for it.
     
  5. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    Hmmmm. I searched for it, I don't think I'll be able to find it without reading through every single thread. I hope we get Unity 5 Docs up soon. If anyone else remembers the function please let me know.
     
  6. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    Docs are already installed locally.

    DynamicGI.UpdateMaterials?
     
    SUmmAgo likes this.
  7. AustinRichards

    AustinRichards

    Joined:
    Apr 4, 2013
    Posts:
    321
    yes! thank you! it works perfectly now.


    Code (CSharp):
    1.     // Update is called once per frame
    2.     void Update () {
    3.         DynamicGI.UpdateMaterials(gameObject.renderer);
    4.     }
     
    Omita likes this.
  8. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Hi! I am going to add some performance details here, hope this helps.

    SetEmissive is a fast path on the CPU and allows you to specify one emissive color to the GI system for the whole object.

    You can change the material and then call DynamicGI.UpdateMaterials. Which reads back albedo & emissive textures from the GPU. Due to the readback it might be questionable for a 60 FPS game or on mobile, but if you want to have albedo / emissive updating with accurate texture information then you can use this function. For optimized games, always author geometry so that Dynamic.SetEmissive with a single color for the whole object can be used.
     
  9. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    I'm just trying this - both with DynamicGI.UpdateMaterials(renderer) as well as DynamicGI.SetEmissive(...) but neither seems to work. When I make everything static, emissive lighting seems to work quite well - but with dynamic objects not at all.

    I've also tried disabling Baked GI, and set DynamicGI.synchronousMode = true - but that also doesn't seem to make a difference.

    When I set the objects receiving the light to static, I do seem to get some white light - but the emissive color is a strong red. Only when the emissive objects are also set to static, it does work and results in the expected effect.

    So are there any other things that need to be in place?

    This is on Unity 5.0 beta 20, btw.
     
  10. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Hi jashan! Yes, the emitting object has be be lightmap static for this to work.
     
  11. Gokcan

    Gokcan

    Joined:
    Aug 15, 2013
    Posts:
    289
    Are you using standart shader for your emmisive material?
    Note: "currently using the Universal shader doesn’t allow to switch to dynamic emission. To try it out you can use surface shaders with legacy deferred rendering path"

    I wrote a shader. Try this

    Shader "SimgeSimulation/Self-Illumin/Transparent/Cutout/Diffuse" {
    Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
    _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
    _Illum ("Illumin (A)", 2D) = "white" {}
    _EmissionLM ("Emission (Lightmapper)", Float) = 0
    [Toggle] _DynamicEmissionLM ("Dynamic Emission (Lightmapper)", Int) = 0
    }

    SubShader {
    Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
    LOD 200

    CGPROGRAM
    #pragma surface surf Lambert alphatest:_Cutoff

    sampler2D _MainTex;
    sampler2D _Illum;
    fixed4 _Color;

    struct Input {
    float2 uv_MainTex;
    float2 uv_Illum;
    };

    void surf (Input IN, inout SurfaceOutput o) {
    fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    o.Albedo = c.rgb;
    o.Emission = c.rgb * tex2D(_Illum, IN.uv_Illum).a;
    o.Alpha = c.a;
    }
    ENDCG
    }

    Fallback "Transparent/Cutout/VertexLit"
    }