Jump to content
  • Advertisement
Sign in to follow this  
mvi

[Solved]Pixel Shader shade when object is on screen

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

Hi there, I'm attempting to create a post-processing shader using HLSL which will shade the entire screen if a certain model is on screen and visible in some way (i.e. if you renderred everything black except for that model then they'd be some non-black pixels on screen). Currently I'm able to get it to render a black filled outline of the object in question at an offset to the originally renderred object. My question is, firstly, is it definately possible to use HLSL to accomplish this task? And if so any recommendations on how to go about it? Thanks. [Edited by - mvi on January 21, 2009 6:18:33 PM]

Share this post


Link to post
Share on other sites
Advertisement
What you can do is draw the model, and use an occlusion query to determine if drawing the model resulted in any pixels actually being written. If it did result in pixels being drawn, you could then do your full-screen pass.

Share this post


Link to post
Share on other sites
I've just had a brief stab at it, but won't an occlusion query only work for determing whether or not any pixels potentially could be renderred? Correct me if I'm wrong (which I very much hope I am because it'd make it a lot easier.) I should have mentioned in the first post that I mean for it to take into account whether or not it is visible on screen as opposed to being on screen behind something and therefore invisible.

Share this post


Link to post
Share on other sites
An easy approach would be to convert the model's bounds to screen space and determine if they are in the displayable range. You don't need HLSL to do this step, it can easily be done on the CPU.

Share this post


Link to post
Share on other sites
Sorry, my explanation really did suck :( I want it only to be in effect when the model is visible and pixels are being renderred from it.

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!