Shader problem

Started by
2 comments, last by mido 18 years ago
Hi, I am using an example shader from Shader Designer from http://www.typhoonlabs.com (toon.frag and toon.vert). The shader, in shader designer is a cartoonish shader, but loaded into my program, it makes everything black. The fragment shader is using the variables DiffuseColor, Phong and PhongColor, not mentioned anywhere in the GLSL reference, i guess thats where my problem occours, but i'm very new to shaders. Do i need to set these variables my self? - where do they get their from - since it is not a part of the shader either... In my program, I set up light, normals, materials etc. and i see the objects without the shader. I tried a couble of example shaders from shader designer, and it seems like a general problem. :( The shader sources can be found in [Shader Designer\shaders] but i'll list them here too: // Fragment/Vertex shader for cartoon-style shading // Author: Philip Rideout // Copyright (c) 2004 3Dlabs Inc. Ltd. // See 3Dlabs-License.txt for license information uniform vec3 DiffuseColor; uniform vec3 PhongColor; uniform float Edge; uniform float Phong; varying vec3 Normal; void main (void){ vec3 color = DiffuseColor; float f = dot(vec3(0,0,1),Normal); if (abs(f) < Edge) color = vec3(0); if (f > Phong) color = PhongColor; gl_FragColor = vec4(color, 1); } .vert: varying vec3 Normal; void main(void){ Normal = normalize(gl_NormalMatrix * gl_Normal); gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; }
Advertisement
You need to set the values for all the uniform variables (as you already surmised). It's been a while for me, so I can't give you detailed help, but if you check out the glUniform functions you should be able to set them with that.
You have forgotten to set the uniform variables. http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=47
this is an example of how to use cg shaders in opengl.
Programming is not an art, It''s a way of life.
Thank you guys, that was the missing magic : )

This topic is closed to new replies.

Advertisement