View Full Version : cel shading : my model appears in black

08-10-2005, 07:42 AM
The code is very simple and i don't understand why it don't work :
i use a 1d texture for the shading, and there aren't any error at compilation (i use renderMonkey 1.6)

the vertex shader
varying vec3 normal ;
varying vec4 lightVector ;

void main(void)
normal = gl_NormalMatrix * gl_Normal;//to transform in eye coordinates

lightVector = normalize(gl_LightSource[0].position) ;

gl_Position = ftransform();//gl_ModelViewProjectionMatrix * gl_Vertex ;
} the fragment shader :

varying vec3 normal ;
varying vec4 lightVector ;
uniform sampler1D hTex;//a handle for accessing a 1D texture
float intensity ;
vec4 color ;

void main(void)
intensity = max(dot (normal, lightVector.xyz), 0.0);

//texture1D access to a texture's pixel
color = texture1D(hTex, intensity);//intensity is the texture coordinate

//color computation
gl_FragColor = color ;


08-10-2005, 10:17 PM
Check if you set the sampler correctly.
I wouldn't normalize the light position as vec4.
Use some hardcoded s-values to see if the color is taken from the texture.
Check if the normal is normalized.

08-11-2005, 04:07 AM
it seems that it is a problem with renderMonkey cause when i set the texture as a 2d texture it works, nevertheless my texture has a height of one.