Displaying in greyscales? Urgent, please help!

I have following problem: I have a 3D model using a bunch of colored textures. And I need to display the model in greyscale instead.
I thought I could use the pixel shader/register combiner for this, but I can’t access the RGB channels seperately =/.

Is there any way to get this done?

Please help,

 BlackJack

r*.333 + g*.333 + b*.333 is one way. thats a 3 component dotproduct… you can do that in a pixelshader…

you can use another “grayscaler”, there are documents about this… dunno wich constant vector is the one wich adobts normal grayscale look the best… but there are documents about this on ati.com, i remember there seen it in some pixelshader (right before the sepiafilter, wich is a brownscaler )

http://www.ati.com/developer/gdc/ATI_GDC02_PixelShaders.PDF

page 17:
ps.1.4
def c0,0.30f,0.59f,0.11f,1.0f
texld r0,t0
dp3 r0,r0,c0

or simply:

color.r*.3 + color.g*.59 + color.b*.11

Thanks a bunch… just one problem:
I converted it to PS1.0 now but anyway the nvparse doesn’t take ps.1.0 at all and I searched my to death to find the dp3 function for register combiners =/. They are able to do it… after all it’s also enabled in the ps10 parse sourcecode… but what is the command for a dp3 for a general combiner? Or how else to do it in GL?

BlackJack

p.s. Doesn’t matter what pixel shader code I pass, it always fails with “error in line” 0… which line 0??? =/ May be it has got problems with 0x0D and 0x0A or so?

[This message has been edited by BlackJack (edited 07-24-2002).]

In combiners, I think you get it with the “CombinerOutputNV” routines, it lets you specify where to put Dot Products.

Check the extension spec: http://oss.sgi.com/projects/ogl-sample/registry/NV/register_combiners.txt

It’s pretty good at explaining what goes where.

-EDIT-

Actually, you might be able to do this with un-extended OpenGL 1.3 if you make good use the TexEnv() operations.

-Mezz

[This message has been edited by Mezz (edited 07-24-2002).]

void CombinerOutputNV(GLenum stage,
GLenum portion,
GLenum abOutput,
GLenum cdOutput,
GLenum sumOutput,
GLenum scale,
GLenum bias,
GLboolean abDotProduct,
GLboolean cdDotProduct,
GLboolean muxSum);

set a to your color, b to the grayscaler, and abDotProduct to GL_TRUE, set abOutput to the resultregister

Hm… Any !!RC1.0 or 1.1 command reffering to this? I searched already a lot, but couldn’t find it within this heavy sourcecode. I would prefer to keep everything inside scripts… ok… in worst case I’ll simply add it to the parser myself… but would normally prefer to don’t do any changes on nvparse.

BlackJack

{
rgb {
spare0 = value0 . value1; // . means dotproduct
}
}

wohooooooo thanks =)