# Problem with NVidia FX Composer

This topic is 4724 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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;

}
}

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;

}
}


##### Share on other sites
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.

##### Share on other sites
Quote:
 Original post by sirobDo 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...

##### Share on other sites
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).

##### Share on other sites
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?

##### Share on other sites
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).

##### Share on other sites
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...

• 36
• 15
• 9
• 23
• 10