[Solved]Pixel Shader shade when object is on screen

Started by
4 comments, last by mvi 15 years, 2 months ago
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]
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.
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.
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.
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.
Thanks for the help guys, that occlusion query worked like a charm :)

This topic is closed to new replies.

Advertisement