Skip to main content
gamedev.net
🔒 Locked

Another PerPixel Lighting!

Started by golgoth Nov 27, 2004 at 10:45 PM 0 replies 600+ views
Original Post
golgoth
golgoth
Hi all! I m looking for sample code of pplighting! 1 - not using vertex or pixel shaders... 2 - idealy with normalized cube map for attenuation... (one texture 1d is fine) 3 - using glDrawElements and not glBegins... I m convinced it can be done but i have problems placing with uv s coordinates vs ligth position... I m trying hard... but not hard enought it seams... I need help at this point!!! Who s my hero?! THX Ive
golgoth
golgoth
Its me again... maybe my request was near impossible to find... well then maybe someone can help me out finding what am I missing.... here s a snip of my code... for now... I just want to find the right uv coordinates of a 2D radial map texture using glTexgen:

GLfloat l_radius = 5.0f;
GLfloat l_intensity = 1.0f / l_radius;
Vector3 l_lightPosition = Vector3(3.0f, 1.0f, 0.0f);

GLfloat l_plane_x[4] = {l_intensity, 0.0f, 0.0f, 0.5f - l_lightPosition.x / l_radius};
GLfloat l_plane_y[4] = {0.0f, l_intensity, 0.0f, 0.5f - l_lightPosition.y / l_radius};
GLfloat l_plane_z[4] = {0.0f, 0.0f, l_intensity, 0.5f - l_lightPosition.z / l_radius};
GLfloat l_plane_w[4] = {0.0f, 0.0f, 0.0f, 1.0f};

Texture *l_texture;
// Texture 2D radial map texture.
l_texture = in_state->GetScopeMap(); // Bind texture.
glActiveTextureARB(GL_TEXTURE0_ARB);
GenerateTexture2D(l_texture);

glTexGenfv(GL_S, GL_EYE_PLANE, l_plane_x);
glTexGenfv(GL_T, GL_EYE_PLANE, l_plane_y);
glTexGenfv(GL_R, GL_EYE_PLANE, l_plane_z);
glTexGenfv(GL_Q, GL_EYE_PLANE, l_plane_w);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
glEnable(GL_TEXTURE_GEN_Q);

... // goes on with texture 1d... and draw a cube!

with this code... my texture map behave well on x,y axis but streches toward the z axis... i ve tried millions of different possibilities... but non of them gaved a descent result...

got a be close...

any ideas?

THX

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.