- Home /
 
Reflection shader color issue
Hello, My name is Mark and I have been developing my game for over a year now, everytime I had a problem the internet, forum and answer section helped me alot. But unfortunatly it has come to a point that I have become stuck. Stuck with shader code to be specific.
Note that I am not a 100% pro shader writer, and this shader is my first advanced one.
The problem:
I am writing an advanced glass shader to simulate glass (ofcourse). Everything is working as expected without any problems, expept one thing. The reflection. I am using a stripped down version of the water script to on the side for my realtime reflection in the shader, I have checked it from top to bottom and there is no error from there. After some digging I found that my problem was inside my shader. In the first pass.
What's happening is that in editor mode with lights off it will reflect everything, but as soon as I put the lights on, it will only reflect the first object to come across.
This is very weird and I am blaffed by the reason for behavior like this.
I have made a stripped down version of my shader isolating the problem and made several screenshots for examples.
I am not asking for you to write to code for me, some insight into the problem would help alot and explaining what I did wrong would be great.
Thanks ahead.

Stripped down version of the shader, to isolate the problem.
Shader "Glass/Advanced Glass" { Properties { _TexColor ("Detail (RGB)Trans (A)", 2D) = "black" { } _ReflectionTex ("ReflectionTex", 2D) = "black" { TexGen ObjectLinear } }
     SubShader {
         Tags {
              "Queue"="Transparent"
              "IgnoreProjector"="True"
             "RenderType"="Opaque"
                      
         }
         LOD 300
          ZWrite Off
          ColorMask RGBA
         //Lights currently off, when On nothing gets reflected?
          Lighting Off
                // Set reflection to texture
              Pass{
              
                Blend One One 
             //  Blend SrcColor one
         SetTexture[_TexColor] { combine Texture} 
          SetTexture[_ReflectionTex] { Matrix [_ProjMatrix] combine Texture + Primary   }
 
         } 
 
 
 
 
 
         
         //Glass properties 
             CGPROGRAM
        // Upgrade NOTE: exclude shader from OpenGL ES 2.0 it does not contain a surface program or vertex and fragment programs.
             #pragma exclude_renderers gles
             #pragma surface surf BlinnPhong decal:add nolightmap
 //Glass////////////////////////////////////////////////////////////////////////////////////////////////
             sampler2D _TexColor;
             
                  struct Input {
                 float2 uv_TexColor;
                             
                 };
             
             void surf (Input IN, inout SurfaceOutput o) { 
             //draw texture and reflection options 
                 half4  reflcol = tex2D (_TexColor, IN.uv_TexColor);  
                     
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
 
     
             }
         ENDCG  
 
               Edit:
I found some more information about my problem, it seems that this only occurs with the unity buildin shaders, as I use my own shaders the realtime lightmaps are rendered. I am gonna dig trough the unity shaders and if needed rewrite them for my own purpose.
Edit: found the cause!! It seems that the problem is that my render texture's camera does not support pixel lights, It only seems to be rendering the standard ambient light. I used a stripped down version of the reflection script as mentioned before, found on the unity wiki: http://wiki.unity3d.com/index.php/MirrorReflection2
I have digged trough the sripts to enable diferred lighting but it seems that it will only render forward, with a few pixel lights.
Do you guy's have any idea how to enable it?
Your answer
 
             Follow this Question
Related Questions
transparent + reflection shader (river water problems) 2 Answers
Realtime reflection 1 Answer
Please help me resolve these errors related to shaders. 0 Answers
Surface Reflection Shader with Shadows 0 Answers
Shader Replacement Error 0 Answers