x


blob shadow z-fighting on iphone

I can't seem to get my blob shadow from z-fighting with the ground plane on iphone. The shadow looks fine in Unity. I'm using the blob from iPhone Standard Assets.

I've followed suggestions on other threads: turned off mips, tried RGBA 16 and 32 bit, set it to orthographic, scripted it to follow my player rather than parenting to get rid of rotations, turned off cast/receive shadows on the ground planes, etc.

My ground geometry is a maya .mb with "meshes have colliders" checked. The ground texture is using the Diffuse shader, but I've tried iphone/Vertex Colored and just about ever other shader. Basically I have the same setup as the Penelope project.

I'm starting to wonder if this is a bug.

alt text

more ▼

asked Mar 14 '10 at 11:07 PM

rocket5tim gravatar image

rocket5tim
859 12 17 33

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

3 answers: sort voted first

I found the solution. Add the following line under Pass {} in the ProjectorMultiply.shader:

Offset -1, -1

Here's the complete shader with the line added.

Shader "Projector/Multiply" {
   Properties {
      _ShadowTex ("Cookie", 2D) = "gray" { TexGen ObjectLinear }
      _FalloffTex ("FallOff", 2D) = "white" { TexGen ObjectLinear   }
   }

   Subshader {
      Tags { "RenderType"="Transparent-1" }
      Pass {
         ZWrite Off
         Offset -1, -1
         //Fog { Color (1, 1, 1) }
         AlphaTest Greater 0
         ColorMask RGB
         Blend DstColor Zero
         SetTexture [_ShadowTex] {
            combine texture, ONE - texture
            Matrix [_Projector]
         }
         SetTexture [_FalloffTex] {
            constantColor (1,1,1,0)
            combine previous lerp (texture) constant
            Matrix [_ProjectorClip]
         }
      }
   }
}

Offset is described in the Culling & Depth Testing doc: "For example Offset 0, -1 pulls the polygon closer to the camera ignoring the polygon's slope, whereas Offset -1, -1 will pull the polygon even closer when looking at a grazing angle."

more ▼

answered Mar 16 '10 at 02:36 PM

rocket5tim gravatar image

rocket5tim
859 12 17 33

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

I can imagine you're tired of trying everything but one more thing you could try is modifying the Camera near and far plane, increasing value for near, decreasing value for far as much as possible. If you basically have a flat underground you could also consider using a plane with the shadow on it instead of a shadow projector, easier and faster. Place the plane a few cm above ground (and/or modify the texture offset of the shader).

more ▼

answered Mar 15 '10 at 05:57 AM

Jaap Kreijkamp gravatar image

Jaap Kreijkamp
6.4k 20 26 70

I tried the camera changes, but it didn't fix the z-fighting. FYI, my near clip is now 12 and far clip is 250 (was default 0.3 and 1000 before). And I don't have flat terrain so I can't do the shadow plane trick.

Mar 15 '10 at 04:17 PM rocket5tim
(comments are locked)
10|3000 characters needed characters left

I'm using shadows on Unity too, and they are a little CPU intensive for my proyects, but try this:

The projector ignore layers property is also useful for some glitches like that, just put your ground in a completely different layer and make the projector ignore all layers except that. It worked for me :)

more ▼

answered Mar 16 '10 at 10:54 AM

Dwair gravatar image

Dwair
358 1 2 4

Thanks for the response. But sadly that still didn't fix it.

Mar 16 '10 at 02:09 PM rocket5tim
(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:

x1999
x1655
x217
x109

asked: Mar 14 '10 at 11:07 PM

Seen: 2467 times

Last Updated: Mar 14 '10 at 11:07 PM