Rendermonkey issue

Post your questions, suggestions and experiences regarding to Image manipulation, 3d modeling and level editing for the Irrlicht engine here.
Post Reply
Dog-E
Posts: 28
Joined: Sun Mar 30, 2008 5:52 am

Rendermonkey issue

Post by Dog-E »

Hi,
I recently got the hang of RenderMonkey (if you don't know about it, it's a great shader IDE by ATI, free). I wrote the basic directional lighting shader in it, the one below:

Code: Select all

uniform mat4 matWorldInverse;
uniform mat4 matWorldTranspose;
uniform vec3 mLightPos;
uniform vec4 mLightDiffuse;
uniform vec4 mLightAmbient;
uniform float mLightRadius;

void main(void)
{
   gl_Position = ftransform();
   
   vec4 normal = vec4(gl_Normal, 0.0);
   normal = matWorldInverse * normal;
   normal = normalize(normal);
   
   vec4 worldpos = gl_Vertex * matWorldTranspose;
   
   vec4 lightVector = worldpos - vec4(mLightPos,1.0);
   lightVector = normalize(lightVector);

   float tmp2 = dot(-lightVector, normal);
   
   vec4 tmp = mLightAmbient + mLightDiffuse * tmp2;
   
   gl_FrontColor = gl_BackColor = vec4(tmp.x, tmp.y, tmp.z, 0.0);
   
}

void main(void)
{
   vec4 col = gl_Color;
   gl_FragColor = col*2.0;
}
Does anyone know why I keep getting a phong-like lighting even though my shader is per-vertex?

Image

I also used the same model and shader in Irrlicht and I got per vertex with vertex colors interpolated on each face.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

That text is probably high poly, thats why it may seem as if it would be per pixel lighted ..if thats what you mean.
Dog-E
Posts: 28
Joined: Sun Mar 30, 2008 5:52 am

Post by Dog-E »

I also used the same model and shader in Irrlicht and I got per vertex with vertex colors interpolated on each face
Dog-E
Posts: 28
Joined: Sun Mar 30, 2008 5:52 am

Post by Dog-E »

This is what I get in Irrlicht:

Image
Dog-E
Posts: 28
Joined: Sun Mar 30, 2008 5:52 am

Post by Dog-E »

My bad, forgot how terrible of a format .3DS is. Avoid it ! :)
Post Reply