x


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"
}
more ▼

asked Oct 02 '10 at 04:10 PM

alexnode gravatar image

alexnode
1k 27 33 50

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 .. .!!!

Oct 02 '10 at 06:03 PM alexnode
(comments are locked)
10|3000 characters needed characters left

4 answers: sort voted first

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"
}
more ▼

answered Oct 02 '10 at 06:27 PM

alexnode gravatar image

alexnode
1k 27 33 50

(comments are locked)
10|3000 characters needed characters left

Worked for me aswell, I had RenderType instead of Queue

more ▼

answered Mar 07 at 12:23 PM

angelrubio gravatar image

angelrubio
1

(comments are locked)
10|3000 characters needed characters left

excellent.... thanks

more ▼

answered Oct 13 '10 at 10:37 PM

rafa gravatar image

rafa
7

(comments are locked)
10|3000 characters needed characters left

awesome! i wish i could vote this up, thanks!

more ▼

answered Feb 20 '13 at 10:51 PM

tkcast gravatar image

tkcast
11 1 1 2

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2594
x237
x186
x95
x26

asked: Oct 02 '10 at 04:10 PM

Seen: 7291 times

Last Updated: Mar 07 at 12:23 PM