- Home /
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.
Answer by rocket5tim · Mar 16, 2010 at 02:36 PM
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."
Answer by Jaap Kreijkamp · Mar 15, 2010 at 05:57 AM
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).
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.
Answer by Dwair · Mar 16, 2010 at 10:54 AM
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 :)
Thanks for the response. But sadly that still didn't fix it.
Your answer
Follow this Question
Related Questions
Do blob shadow projectors work on iPhone? 1 Answer
how to make a shader that only shows the shadow while the rest becomes completly transparent? 5 Answers
Support for dynamic shadows on newer iOS devices (supporting OpenGL ES 2.0) 1 Answer
Optimise adding shadows in scene using Unity iPhone 2 Answers
Need help with projector shader 0 Answers