• Advertisement
Sign in to follow this  

Strange GLSL problem

This topic is 4242 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

In the program I'm working on, I'm attempting to implement a shader to texture our terrain and give it some fringing (sure it's not the best looking method, but it'll do for us). In Render Monkey, the shader works fine, no problems at all. But, in the program after a call to glLinkProgram I check the info log and get the following from it: Fragment info ------------- (18) : error C1067: too little data in type constructor (21) : error C1067: too little data in type constructor Line 18 and 21 being (respectively): gl_FragColor = texture2D(high, gl_TexCoord[0].st * Tiles) * fringep + texture2D(fringe, gl_TexCoord[0].st * Tiles) * (1.0 - fringep); gl_FragColor = texture2D(low, gl_TexCoord[0].st * Tiles) * fringep + texture2D(fringe, gl_TexCoord[0].st * Tiles) * (1.0 - fringep); so. obviously, it doesn't work right. the error does not show up when Render Monkey compiles and Links the shaders and shader program. And Google has proven absolutely useless (is there no documentation on the GLSL errors and what they mean?) If you need it, I can dig up the shader code and post it as well. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
what card/drivers? the entire shader code could be useful.

You might want to replace the RHS with a lerp() call, btw.

Share this post


Link to post
Share on other sites
Card is GeForce 6800 with the latest stable drivers. full code of the fragment shader is:

uniform float HighAltDef;
uniform float Tiles;
uniform float HighFringeSize;
uniform float LowFringeSize;
uniform vec3 LightPos;
uniform sampler2D high;
uniform sampler2D low;
uniform sampler2D fringe;
uniform vec3 LightColor;

varying float height;
varying vec3 normal;
varying vec4 pos;

void main() {
if(height > HighAltDef) {
float fringep = clamp((height - HighAltDef) / HighFringeSize, 0.0, 1.0);
gl_FragColor = texture2D(high, gl_TexCoord[0].st * Tiles) * fringep + texture2D(fringe, gl_TexCoord[0].st * Tiles) * (1.0 - fringep);
} else {
float fringep = clamp((HighAltDef - height) / LowFringeSize, 0.0, 1.0);
gl_FragColor = texture2D(low, gl_TexCoord[0].st * Tiles) * fringep + texture2D(fringe, gl_TexCoord[0].st.st * Tiles) * (1.0 - fringep);
}

vec4 WorldPos = pos * gl_ModelViewProjectionMatrix;
vec3 light = normalize(LightPos - WorldPos.xyz);
float intense = clamp(dot(normal, light), 0.0, 1.0);
vec4 color = vec4(LightColor * intense, 1);
color.rgb += 0.5;

gl_FragColor *= color;
}


ad the vertex shader:
varying float height;
varying vec3 normal;
varying vec4 pos;

void main() {
height = gl_Vertex.y;
normal = gl_Normal;
pos = gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}


looking at it now: I should probably get rid of height altogether, I added lighting calcs after getting the texture part right :P

Share this post


Link to post
Share on other sites
nothing off the top of my head, but as a tip, you're doing manual lerp() on fringep, and you could (and it's preferred to) replace clamp (x, 0, 1) with saturate(x).

Share this post


Link to post
Share on other sites
I believe you're thinking of HLSL, in GLSL lerp() is mix() and saturate is not a function.

that's nice information for me to know in the future if I ever write another shader, but that, unfortunately, does not solve my problem.

Share this post


Link to post
Share on other sites
And 3D-labs syntax validator likes it, so it "should" work...

I would split that up into multiple lines and find out what the glsl compiler has a problem with... or just mail nVidia, if you arn't in a hurry.. ;]

Share this post


Link to post
Share on other sites
it might be complaining because you don't have .rgba at the end of the sampler calls, but that should not be an issue either.. this might seem odd, but try to first store the results from the sampler calls in a temporary variable and then use mix()... I have had all sorts of issues with nVidia's GLSL parser... just as a side note, and for others as well, you can use nVidia's Cg compiler to check if the nVidia driver will take the GLSL code on a variety of cards... by doing:

cgc -profile XXX file.GLSL.c -oglsl

where XXX can be -fp40 (fragment for GeForce6 and up,)
-vp40 (vertex, 6 and up)

and there are others too, like -fp30, -vp30, ect...

useufly to see what hardware the shader can run on..

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement