In both Rendermonkey and Shaderdesigner programs used for testing glsl shading, I get a complete black model while I’m trying to learn and test different shaders. Image: http://oi46.tinypic.com/dpg6mu.jpg This image shows the black model in Shaderdesigner, with the following vertex and fragment files:
Vert:
out vec4 color; void main(void)
{
color = gl_Color;
vec4 v = vec4(gl_Vertex);
v.z = sin(5.0*v.x )*0.25;
gl_Position = gl_ModelViewProjectionMatrix * v;
}
Frag:
in vec4 color;
void main()
{
gl_FragColor = color;
}
What I think is happening, is the shaderdesigner is send the gl_Color from the opengl application to the shader with a black value, and I have no clue how to change that value. I have tried messing around with ALL the menus, options, anything relates to changing color and nothing is working. Why is my model black and how can I fix it?
I think you will have to change the type of your attribute from out to varying that is change this in both vs and fs
out vec4 color;
to this
varying vec4 color;
or simply if you want, you can remove your output varying altogether by using the gl_FrontColor varying in the vertex shader and gl_Color in the fragment shader like this
[QUOTE=mobeen;1249668]I think you will have to change the type of your attribute from out to varying that is change this in both vs and fs
out vec4 color;
to this
varying vec4 color;
or simply if you want, you can remove your output varying altogether by using the gl_FrontColor varying in the vertex shader and gl_Color in the fragment shader like this
if possible can u share your shader designer/rm prject. And what happens if you directly output a constant color from the fragment shader or store positions as color and output in fragment shader?
OK it does not work for me as well. You shader is correect I have checked it in RenderMonkey which is much more stable. Seems to me that there are some problems with the ShaderDesigner. For me, I even cant see the contents of the vertex/fragment shaders (editor area is all white).
O ok. Since you said it appears to work in RenderMonkey, may I ask what color is sent through gl_Color as default to the shader? And how do you change the value of gl_Color passed to the shader in RenderMonkey?
By default it passes in white color in gl_Color attribute. As far as I know, you can’t change this. You can however change the binding sematics of you per-vertex attributes through Stream Mapping.
In the old GLSL shaders (pre OpenGL 3.0), you can access the fixed function light position using gl_LightSource[0].position
BUT I dont think RenderMonkey passes any GL lights nor does it exposes these to your workspace.
Either way, I think you can just create your own uniform vec3 variable to store the light position/s.