Jump to content
  • Advertisement
Sign in to follow this  
TheSeb

[GLSL] cel shading : my model appears in black

This topic is 4846 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, 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 fragement 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 ; 
                  
}




[Edited by - TheSeb on August 10, 2005 12:10:34 PM]

Share this post


Link to post
Share on other sites
Advertisement
i did not use 1D textures with rendermonkey (even there is no 1D texture variable, maybe no support) so tried it with 2D textures(with same 1D intesity texture), it works... the problem should be something about generating texture coordinates or render monkey's 1D texture usage (i think my second 2nd guess true, because it is black even if no black pixel in texture ^^ )..

Share this post


Link to post
Share on other sites
and i found that rendermonkeys own example projects uses sampler2D for 1D textures too.. just change your fragment shader to :

varying vec3 normal ;
varying vec4 lightVector ;
uniform sampler2D 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 = texture2D(hTex, vec2(intensity));//intensity is the texture coordinate

//color computation
gl_FragColor = color ;

}

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!