Forums > Jitter

Very Simple Shader Question


January 7, 2013 | 5:45 pm

Hi everyone, I am using an "explosion" jxs file posted by Rob Ramirez here a couple days ago. I went into the code to try and add a very basic adjustable RGBA functionality, but keep on receiving Error 0:67 undeclared identifier. I essentially just tried to mimic his method of creating parameters, but am clearly missing a step. If someone could tell me why the variables Rcolor, Gcolor,Bcolor, and Acolor receive the Error 0:67 undeclared identifier error, that would be great. Thx for your time :)









< ![CDATA[
//uniform vec3 Offset;
uniform float ScaleIn;
uniform float ScaleOut;
uniform float Rcolor;
uniform float Gcolor;
uniform float Bcolor;
uniform float Acolor;

void main()
{
//vec3 vertex = gl_Vertex.xyz + noise3(Offset + gl_Vertex.xyz * ScaleIn) * ScaleOut;
vec3 vertex = gl_Vertex.xyz + noise3(gl_Vertex.xyz * ScaleIn) * ScaleOut;
vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
//vec3 position = vec3(gl_ModelViewMatrix * vec4(vertex,1.0));

float nDotVP; // normal . light direction
//float nDotHV; // normal . light half vector
//float pf; // power factor
vec4 amb;
vec4 diff;
//vec4 spec;

nDotVP = max(0.0, dot(normal, normalize(vec3(gl_LightSource[0].position))));
//nDotHV = max(0.0, dot(normal, vec3(gl_LightSource[0].halfVector)));

//if (nDotVP == 0.0) pf = 0.0;
//else pf = pow(nDotHV, gl_FrontMaterial.shininess);

amb += gl_LightSource[0].ambient;
diff += gl_LightSource[0].diffuse * nDotVP;
//specular += gl_LightSource[i].specular * pf;
gl_FrontColor = gl_FrontLightModelProduct.sceneColor + amb * gl_FrontMaterial.ambient + diff * gl_FrontMaterial.diffuse;

//gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * vec4(vertex,1.0);
}
]]>

< ![CDATA[
void main()
{
gl_FragColor = vec4 (Rcolor, Gcolor, Bcolor, Acolor);
}
]]>

January 7, 2013 | 8:32 pm

These:


uniform float Rcolor;
uniform float Gcolor;
uniform float Bcolor;
uniform float Acolor;

Need to go in the fragment shader, not the vertex shader like you have them.

January 8, 2013 | 2:54 pm

great thx!

Viewing 3 posts - 1 through 3 (of 3 total)

Forums > Jitter