Problem with NVidia FX Composer

Started by
5 comments, last by JoCCo 18 years, 10 months ago
Hey Im having a bit of trouble when writting two shaders ( two materials ) in FX composer. I have one object that is partly occluded by another transparent object. I have set up my Z-Buffers so that the transparent object should write to the Z Buffer (thereby occluding the object behind it). My problem is that it dosent work, it looks like I have disabled the Z Buffer. I will post a picture and some code to clarify. Is it so that FX Composer resets the buffer in between objects so I get a new Z Buffer in every material? Here is a picture of my problem, parts of the sphere should not be seen. A note about the picture, I dont use the spotlight visible in the picture. Here is the material for the sphere ( the VS and PS just do standard transformation and texture lookup)

technique t0
{
    pass p0
    {
        ZEnable          = TRUE;
        ZWriteEnable     = TRUE;
        AlphaBlendEnable = FALSE;
        CullMode         = NONE;
        Ambient			 = 0xFFFFFF;
        
  	 	VertexShader = compile vs_1_1 VSpassthrough();
		PixelShader  = compile ps_1_1 PSpassthrough();
    }
}
Here is the materual for the transparent surface, the vertex does some standard transformation and the PS just writes a color ( White ).

technique t0
{
	pass p0
	{
			ZEnable          = TRUE;
			ZWriteEnable     = TRUE;

			AlphaBlendEnable = TRUE;
			DestBlend 	 = srcalpha;
			SrcBlend 	 = invsrcColor;
			CullMode         = NONE;
			StencilEnable 	 = FALSE;

			VertexShader = compile vs_1_1 VSlighting();
			PixelShader  = compile ps_2_0 test();
	}
}
Advertisement
Do you in any way change the rendering order? I mean, how do you know FX Composer is drawing one object before the other? I'm not too savy with that program, but I don't know how to change it, but if you do, maybe you should check that the render order is correct.
Sirob Yes.» - status: Work-O-Rama.
Quote:Original post by sirob
Do you in any way change the rendering order? I mean, how do you know FX Composer is drawing one object before the other? I'm not too savy with that program, but I don't know how to change it, but if you do, maybe you should check that the render order is correct.


I can't change the rendering order, at least not in anyway I'm familiar with, but that shouldn't matter should it? The Zbuffer test is done no matter what order you draw the objects...
Order DOES matter when dealing with transparent objects. If your sphere gets drawn first then it will draw the whole thing (zbuffer is empty), and then your transparent object will also be fully drawn (it is closer). The order independence of the zbuffer ONLY applies when dealing with totally opaque objects or more specifically, drawing that does not depend on the current state of the framebuffer (i.e. no blending).
Okay, so the order is important, okay, thanks, do you or anyone else know how I can effect the order in which FX Composer draw the objects?
The order in which you add objects to the scene is probably the order FX composer renders them. Though it might treat transparent objects specially and make sure they are rendered last.

If you say abit more about what you are trying to achieve theres probably a different way to go about it (using the stencil buffer for instance).
You were right, it rendered objects in the order I added them, so I just deleted the sphere and added it again and it worked, thanks...

This topic is closed to new replies.

Advertisement