- Home /
Unity 3, Why custom Surface Shader (Transparent Reflective) doesn't render against background?
Hi i am experimenting a bit with the Surface Shaders. I try to write a Transparent Reflective one, But i have a problem,
It works perfectly in things that they are close, but against the skybox and far objects it dissapears. Doesn't render.
am trying to tweek LOD with no success , ZWrite On and Off Cull Off ... it seems that I am missing something . It is my first time trying to write a shader so I think that I make a basic mistake. Any help ?
Shader "Myshaders/TransparentReflective" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _Cube ("Cubemap", CUBE) = "" {} } SubShader { Tags {"RenderQueue"="transparent" "RenderType"="transparent" } LOD 4000 ZWrite On Cull Off
CGPROGRAM
#pragma surface surf Lambert alpha
struct Input {
float3 worldRefl;
float4 _Color;
};
samplerCUBE _Cube;
float4 _Color;
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = _Color.rgb;
o.Emission = texCUBE (_Cube, IN.worldRefl).rgb*_Color.rgb;
o.Alpha = _Color.a;
}
ENDCG
}
FallBack "Transparent/Diffuse"
}
It appears that it doesn't render more than 7 textures in the background ! IF a put a huge sphere for example in the background with the default shader the shader renders the cubemap properly. if i assign a texture to the sphere then the shader doesn't render in front of the object. It can render around ten objects with textrues but no more than that .. .!!!
Answer by alexnode · Oct 02, 2010 at 06:27 PM
Super Stupid ... I had "RenderQueue" = "transparent" instead of "Queue".!!! It works now ...
Shader "Myshaders/TransparentReflective" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _Cube ("Cubemap", CUBE) = "" {} } SubShader { Tags {"Queue"="transparent" "RenderType"="transparent" }
Cull Off
CGPROGRAM
#pragma surface surf Lambert alpha
struct Input {
float3 worldRefl;
float4 _Color;
};
samplerCUBE _Cube;
float4 _Color;
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = _Color.rgb;
o.Emission = texCUBE (_Cube, IN.worldRefl).rgb*_Color.rgb;
o.Alpha = _Color.a;
}
ENDCG
}
FallBack "Transparent/Diffuse"
}
Yep, helped me too mate, slightly different issue, but again custom transparency issues. The thread from 2010 that just keep on giving :)
Answer by angelonit · Mar 07, 2014 at 12:23 PM
Worked for me aswell, I had RenderType instead of Queue
Your answer
![](https://koobas.hobune.stream/wayback/20220613074542im_/https://answers.unity.com/themes/thub/images/avi.jpg)