Rendering Errors: Diffuse Shader "Force Pixel&quo

Hi,

I get lots of rendering errors when I use either
1.)Diffuse Shader on the object AND render mode “Force Pixel” on the light source
2.) Vertex Shader on the object AND render mode “Force Vertex” on the light source

My object is a character mesh that has a shirt mesh above. There is always space between the 2 so they never overlap in any point. The result looks like a z-buffer problem. It is always slightly present but with higher distance more skin pixels are rendered as if above the shirt. As in the rendered skin area increases. The error area only increases for lightened model areas and dont occur in shadow.

Why so??? Is there a solution for this??

problem well..not solved..but found:

“Vertex Shader based Vertex Lighting”:
http://blogs.unity3d.com/2009/04/10/unity-roadmap/

At the moment, pixel lights use the programmable pipeline, whereas ambient light and vertex lights use the fixed function pipeline. In order to work around the differences in precision between the two pipelines, the pixel light pass has its vertices offset by a small amount towards the camera. This prevents Z-fighting between the ambient/vertex pass and pixel passes on the same mesh, but it can cause Z-fighting in situations where two meshes are already quite close to one another, as the offset can mean that they are rendered on top of one another.

Increasing the distance between the meshes should fix the issue. Moving entirely to vertex lighting will fix the problem too, but at the cost of lighting quality.

Sounds like the problem described here:

http://forum.unity3d.com/viewtopic.php?t=20806&start=0&postdays=0&postorder=asc&highlight=

It’s a DirectX problem “only”. As far as I know it will be solved in Unity 2.6.

Right, I forgot to explain why I said “at the moment”, but you’ve got it.

Hehe… everybody at the same time. :wink:

But you could try to add an Offset to the pixel-light pass:

[..]
// Pixel lights
Pass {
	Name "PPL"
	Tags { "LightMode" = "Pixel" }
	
	ZWrite On
	Offset 1,1

CGPROGRAM
#pragma vertex vert
#pragma fragment frag
[..]

Thanks for the replies.

DerWoDaSo, i have tried to follow your suggestion.
But I cant see any improvement at all.
Did shaders work for you? If so, would you mind posting an example shader (maybe i got something wrong in mine, but basically i copied the built in shader and extended it as u suggested).

thanks

I have applied the new shader to the skin now instead of the clothing - so this solves the artifacts.
BUT: now the skin sometimes gets colored weirdly.
As in, it is being enlightened just fine, i get a step closer and the skin gets black, i get another step closer and its being enlightened just fine…etc.

Does someone have any experience with this shader pixel offset workaround?

I am not really familiar with shader programming.

Thanx

Ok, I am sorry! My workaround seems to work only in a very special cases for me…

Strange, I got a shader that is modified in the way described above. On on graphics card it works, on another it doesn’t (I get ugly flickering / Z-fighting).
But it is the same chip: both a GeForce 8800 GTS 512

Hmmm… well, we will have to wait for 2.6 I guess.

Maybe it depends on the DirectX / OpenGL version?
Not very likely i admit but its an idea.

B.t.w. I could make the offset workaround work.
Though it does not always work the same, depending on the light settings and camera position i have to change / play around with the z offset. With several offsets i get this flickering too (GeForce 7300GT).

check the driver settings.
Potentially one of the two is enforcing something which generally is a bad idea as that can overwrite the behavior defined by the application, at worst crashing the application