Sign in to follow this  
kovacsp

Making part of the screen grayscale

Recommended Posts

Hi all, I have to make most parts of the screen grayscale, while leaving focused objects coloured. This thing should work on pre-shader hardware too. I have the following indeas: - render everything to a texture, then pass it throuh a pixel shader that makes it gray, then render the focused object on top of it (but this does not work with old cards) - make a grayscale version of all textures and material definitions, and render them as such (it's baaaad to duplicate everything) - blend a grey quad on the renmdered image, and then render the focused object (but this will not be real grayscale, it will be just "more gray") Use a combination of the above, eg. use the shader version when available, and use something else when not.. Is there a simpler soultion? Maybe some hidden renderstate that makes everything grayscale before drawing my pixel? :) Thanks for your help, kp

Share this post


Link to post
Share on other sites
As far as I know, with pre shader hardware there is no way to calculate how light reacts with a surface. My basic idea would be to somehow set the green and blue channels of the mesh to equal the red channel (its not true grey scale, but its not tooo much off), if this is possible in directx I'd be interested to hear it but I dont think it can be done.

I do recall a friend creating a demo in DirectX 7 however, that used negative light values and a positive ambient light value to somehow stimulate grey scale.. (but then I think the scene had no textures so that may be why :P).

Sorry I'm not very helpful, but you may be able to go off those ideas.

Share this post


Link to post
Share on other sites
Quote:
Original post by kovacsp
- blend a grey quad on the renmdered image, and then render the focused object (but this will not be real grayscale, it will be just "more gray")

This would definitely look bad and not give the effect that you want... I don't know the easiest way to do it but duplicating your lights/materials/textures might not be TOO bad, especially if you can find an efficient way to store it. For your materials/textures, etc. you are already storing <R,G,B> and maybe <R, G, B, A>. Changing to <R, G, B, A, luminance> (with luminance as your grayscale preprocess) might only increase your resource usage by 20%-25%, right? What this means depends on the scale of your project.

You can easily find a formula to weigh R/G/B into a grayscale value -- 33/33/33 won't work as green is brightest, then red, then blue... or just use Photoshop...

If you do have to duplicate textures, you might be able to blend the two versions in some way to create an interesting transition into your focus area or some other effect.

Share this post


Link to post
Share on other sites
Duplicating the textures seems like a waste of resources. I suggest you render your scene to a texture and then render a fullscreen quad using D3DTOP_DOTPRODUCT3 to generate a scalar (eg. using D3DTA_TFACTOR) that is replicated to all color channels. If you have free texture stage you can probably also use D3DTOP_DOTPRODUCT3 directly and save the render to texture step.

Share this post


Link to post
Share on other sites
You can't write a fixed function for pre-shader hardware that will render to a texture and convert it to grayscale? If not, why not?

That seems like the best method..then you just have a 2nd render pass for objects in color.

Share this post


Link to post
Share on other sites
The way you do this with the fixed-function pipeline is exactly like DonnieDarko stated in his post - use D3DTOP_DOTPRODUCT3 with D3DTA_TFACTOR.

Share this post


Link to post
Share on other sites
Hey, thanks for your help guys!
DonnieDarko, thanks for your answer, seems to be OK for what I want!
MasterWorks, the transition effect is a great idea! Now I want to do it, no matter what it costs :)

kp

Share this post


Link to post
Share on other sites

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