Advertisement

Per pixel bump mapping with ATI pixel shader

Started by July 16, 2004 05:51 AM
14 comments, last by vincoof 20 years, 4 months ago
i did it :D (i still can't believe)
i noticed that the normals weren't in the right directions so i exchanged normal.y with normal.z and now everything works fine :D


if got ~50 fps with 2 lights, attenuation, specular and diffuse, bezier patches with tessellation at 8 and a md3 model, but.. but only in the worse case :) the average is ~80fps ^__^
good work !
once again, I'm glad you got it working.
KUTGW
Advertisement
@vincoof: and how can i do the attenuation of the diffuse light? i tryed to use the code you gave me some time ago, binding the 3d texture to GL_TEXTURE4 and multiplying this with the diffuse light, but doesn't work..
When you get pixel shaders, you can do without 3D texture.
Simply pass the unnormalized light to vertex vector and compute the attenuation from it.

For instance, after the calls to glSampleMapATI, call :
glPassTexCoordATI(GL_REG_3_ATI, GL_TEXTURE0_ARB, GL_SWIZZLE_STR_ATI); // get the unnormalized "light to vertex" vector

and in the end of your shader, call :
// compute |light to vertex|^2
glColorFragmentOp2ATI(GL_DOT3_ATI, GL_REG_3_ATI, GL_NONE, GL_NONE,
GL_REG_3_ATI, GL_NONE, GL_NONE,
GL_REG_3_ATI, GL_NONE, GL_NONE);

// compute |light to vertex|^2 * (1/radius^2)
glColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_2_ATI, GL_NONE, GL_SATURATE_BIT_ATI,
GL_CON_0_ATI, GL_RED, GL_NONE, // use CONSTANT 0 to specify the inverted squared attenuation radius
GL_REG_2_ATI, GL_NONE, GL_NONE);

// apply attenuation, per pixel
glColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, GL_SATURATE_BIT_ATI,
GL_REG_0_ATI, GL_NONE, GL_NONE,
GL_REG_2_ATI, GL_RED, GL_COMP_BIT_ATI);
here:
glColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_2_ATI, GL_NONE, GL_SATURATE_BIT_ATI,
GL_CON_0_ATI, GL_RED, GL_NONE, // use CONSTANT 0 to specify the inverted squared attenuation radius
GL_REG_2_ATI, GL_NONE, GL_NONE);

// apply attenuation, per pixel
glColorFragmentOp2ATI(GL_MUL_ATI, GL_REG_0_ATI, GL_NONE, GL_SATURATE_BIT_ATI,
GL_REG_0_ATI, GL_NONE, GL_NONE,
GL_REG_2_ATI, GL_RED, GL_COMP_BIT_ATI);

shouldn't i use GL_REG_3_ATI instead of GL_REG_2_ATI ?
Yeah, sure :)
Sorry about that it was some abusive copy'n'paste.

This topic is closed to new replies.

Advertisement