Can a shader not draw a specific location?

Started by
6 comments, last by jamesw 18 years, 2 months ago
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
There is no life without honor
Advertisement
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.
enum Bool { True, False, FileNotFound };
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]
There is no life without honor
From the vertex shader you can pass the height to the pixel shader in a texture coordinate and kill the pixel if it is higher than the threshold, which you could set in a constant.
.
Are you sure a user clip plane wouldn't do the job?
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.
The poorest programmer in the game industry!!
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
There is no life without honor
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.

This topic is closed to new replies.

Advertisement