Jump to content
  • Advertisement
Sign in to follow this  
golgoth

Another PerPixel Lighting!

This topic is 5134 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!