Jump to content
  • Advertisement
Sign in to follow this  
JoCCo

Problem with NVidia FX Composer

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

If you intended to correct an error in the post then please contact us.

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;
        
  	 	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();
	}
}

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Guest Anonymous Poster
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 this post


Link to post
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...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!