- Home /
Get the default reflection source in shader?
I created a pretty heavily modified version of the legacy reflective specular shader for my mobile car game. The game has realtime reflections on devices that support it, and to create these realtime reflections, I have a script that creates a new cubemap rendertexture and then updates it. As of right now, my shader cannot access the default scene reflection source in the lighting window, so I am forced to load all reflective materials into memory and then set the rendertexture as the cubemap. Is there a way for my shader to access the default reflection source in the lighting window so I can just set the cubemap there?
Answer by remigillig · Nov 06, 2018 at 09:01 PM
For anyone looking for an answer: https://forum.unity.com/threads/possible-to-get-skybox-cubemap-ref-from-within-shader.519570/
// sample the default reflection cubemap, using the reflection vector
half4 skyData = UNITY_SAMPLE_TEXCUBE(unity_SpecCube0, i.worldRefl);
// decode cubemap data into actual color
half3 skyColor = DecodeHDR (skyData, unity_SpecCube0_HDR);
Your answer
Follow this Question
Related Questions
Different reflection cubemaps for different materials? 0 Answers
Reflective materials showing up black in RenderToCubeMap 2019.2 standard pipeline 1 Answer
Cubemaps using the camera 0 Answers
Real time reflection probes feasible on mobile devices? 0 Answers
Reflection probes and legacy shaders? 0 Answers