Sign in to follow this  

Can a shader not draw a specific location?

This topic is 4332 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

Is there a way for a pixel shader not draw a location (I want to have an area of a mesh completely not visible). I tried to return no color in the pixel shader, but it was just black. Will it have to use alpha blending or can I just not draw a location/pixel? Thanks

Share this post


Link to post
Share on other sites
You can use alpha blending, or you can use texkill. Note that texkill will let you write to the Z buffer where you write; with alpha blending, even "killed" pixels will write to the Z buffer (or none of them).

Note that texkill will invalidate early Z tests until the next Z clear, so if you have lots of overdraw and complex shaders, it may have a negative performance impact.

Share this post


Link to post
Share on other sites
Thanks, I looked up texkill and clip() is the non-assembly version of it. I plan ion rendering the items I want to clip first, Is this good? or should they be last.
(I am clipping a hole in a terrain mesh) in this case I assume clipping the pixel would be faster than useing alpha blending, no?

Also, is there a way to tell the pixel position? say I need to clip only with height > 50. how would I do that? I tried to add position, but it just gives me errors.

[Edited by - Valor Knight on January 28, 2006 9:37:04 PM]

Share this post


Link to post
Share on other sites
User clip plane should be able to do the job and tex kill would hinder performance a lot. So, if user clip plane is the way you want, just clip away all the pixels out of the clip plane, then, use it.

Share this post


Link to post
Share on other sites
Well the height was an example. but I want to clip out areas of my terrain mesh to add holes, caves and other models which you would like to go "below" the terrain (Input would be coordinates for squares to clip out). How does a user clip plane work/what is it? Is it in shaders, or in normal processing

Share this post


Link to post
Share on other sites
Basically you define a D3DXPLANE and then enable/disable it using the IDirect3DDevice9::SetClipPlane() function. The good thing about them is that they're hardware accelerated (on geforce fx and above) and you don't have to implement them, although I don't know if they would be useful for your purposes since you can only clip by a plane. You could only enable them when you were drawing the patches with holes(to avoid clipping other areas of the terrain), but that might not be ideal. There's also this clipping sample that uses alpha testing. I don't consider that a very elegant solution, but you can probably get something out of it.

If you do decide to try out user clip planes be aware that SetClipPlane() assumes the plane is in world space if you are using the FFP, and clip space if you are using shaders. Check out thisthread for more info.

Share this post


Link to post
Share on other sites

This topic is 4332 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this