x


Shadows not visible through transparent object

I have a very special case of which I could use some input.

I have an object with transparency with the use of a shader. Some parts are discarded, some not. This object does not cast shadows, but does receive them.

         v2f vert( a2v v ) {
             v2f o;
             o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
             o.vpos = v.vertex;
             o.normal = v.normal;
             o.uv[0] = TRANSFORM_TEX(v.texcoord, _MainTex);
             o.uv[1] = TRANSFORM_TEX (v.texcoord, _BumpMap);
             TANGENT_SPACE_ROTATION;
             o.lightDir = mul(rotation, ObjSpaceLightDir(v.vertex));
             
             float3 worldPos = mul(_Object2World, v.vertex).xyz;
             float3 worldNormal = mul((float3x3)_Object2World, SCALED_NORMAL);
             o.vlight = float3(0);
             #ifdef LIGHTMAP_OFF
                 float3 shlight = ShadeSH9(float4(worldNormal, 1.0));
                 o.vlight = shlight;
                 #ifdef VERTEXLIGHT_ON
                     o.vlight += Shade4PointLights (
                         unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0,
                         unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb,
                         unity_4LightAtten0, worldPos, worldNormal
                         );
                 #endif // VERTEXLIGHT_ON
             #endif // LIGHTMAP_OFF
             TRANSFER_VERTEX_TO_FRAGMENT(o);

                     // stuff is discarded about here

             return o;
         }
 
 
         void frag(v2f IN, out float4 finalColor : COLOR) {
                 float3 normalBump =  UnpackNormal(tex2Dlod (_BumpMap, float4 (IN.uv[1],0,0)));
                 float3 texColor = tex2Dlod(_MainTex, float4(IN.uv[0], 0, 0)).rgb;  
                 IN.lightDir = normalize ( IN.lightDir );
                 IN.normal = normalize ( IN.normal );
                 float atten = LIGHT_ATTENUATION(IN);
                 float3 color;
                 float NdotL = saturate( dot (normalBump, IN.lightDir ));
                 color = UNITY_LIGHTMODEL_AMBIENT.rgb * 2;
                 color += IN.vlight;
                 color += _LightColor0.rgb * NdotL * ( atten * 2);
                 finalColor = half4(color * texColor, 1.0f);
 }

Second, I have an object wrapped around that object which does nothing more than to cast a shadow and is invisible.

 Shader "InvisibleShadowCaster"
 {
     Subshader
     {  
        UsePass "VertexLit/SHADOWCASTER"
     }
  
     Fallback off
 }

Now my problem is that if I look through the object(s) which are rendered this way, I cannot view any shadows.

alt text

Question: Is this a fundemental problem? If so, can I work around it somehow or is there an alternative?

more ▼

asked May 20, 2013 at 09:31 PM

Kajos gravatar image

Kajos
79 46 71 88

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

0 answers: sort voted first
Be the first one to answer this question
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:

x3093
x425

asked: May 20, 2013 at 09:31 PM

Seen: 529 times

Last Updated: May 21, 2013 at 09:09 AM