Jump to content
  • Advertisement
Sign in to follow this  
_OskaR

GLSL and strange errors/artifacts

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

Sth is bad with my shaders (GLSL 1.5, nVidia). In fragment shader for:
if(param>0.5)
color=vec4(0,0,1,0);
everything's good. But after small modification:
if(param>0.5)
color=vec4(0,0,1,0);
else
color=vec4(0,1,0,0);
:
Quote:
Fragment shader compile error:
0(145) : error C0000: syntax error, unexpected '=' at token "="
0(145) : error C0501: type name expected at token "="
0(145) : warning C7022: unrecognized profile specifier "C"
0(145) : warning C7022: unrecognized profile specifier "loat"
0(148) : error C0000: syntax error, unexpected '=' at token "="
0(148) : error C0501: type name expected at token "="
0(148) : warning C7022: unrecognized profile specifier "gl_FragDepth"
0(148) : error C0000: syntax error, unexpected '*' at token "*"
0(148) : error C0501: type name expected at token "*"
0(148) : warning C7022: unrecognized profile specifier "C"
0(148) : error C7531: pointers require "#extension GL_NV_shader_buffer_load : en
able" before use
0(148) : error C0502: syntax error at token "C"

Another vesrion:
if(param>0.5)
{
color=vec4(0,0,1,0);
}
else
{
color=vec4(0,1,0,0);
}
and:
Quote:
Fragment shader compile error:
0(149) : warning C7022: unrecognized profile specifier "st"
0(149) : error C0502: syntax error at token "st"
0(152) : error C0000: syntax error, unexpected '=' at token "="
0(152) : error C0501: type name expected at token "="
0(152) : warning C7022: unrecognized profile specifier "gl_FragDepth"
Also I have errors when I use:
if(param>0.5)
{
color=vec4(0,0,1,0);
}

What's going on?

This is very strange for me but I have more important problem. I have
uniform int numLOD;
In fragment shader:
if(numLOD==1)
terrain=vec4(0.1,0.9,0.1,0);
When I run my application I see only first LOD so whole model is green and it's ok (max level is 15). But when I use
	if(numLOD<1000)
{
//
}
else
{
vertex2.xyz=vec3(0,0,0);
}
in vertex shader, I have a lot of artifacts, when I use normals instead vertex2 - I have same artifacts too - even if I don't use normals later. Also it should be impossible that this number was greather than 1000.

I installed new drivers - nothing helped.

Share this post


Link to post
Share on other sites
Advertisement
Hey!

What is 'color' ?, GLSL is very picky...

It's good that the first example works, but even that may just be undefined behaviour that luckily works the way you want it to on your hardware.

GLSL errors are a pain in the back. Hope you manage to deal with your problem.

Share this post


Link to post
Share on other sites
could you please show us the full shader because its hard to tell without seeing whats you "uniformed" etc.

Share this post


Link to post
Share on other sites
I can understand very well your frustrtation..

I had exactly the same problems.. and a very similar post of mine can be found here as well..

I resolved EVERY issue buying a GeForce.. maybe a simple driver update can be enough for you.. for me, it wasnt, and I had to change card.. (and the old one was a Nvidia too)

the good part is that as I changed card, everything just worked fine and I got rid of all that mess..

Share this post


Link to post
Share on other sites
After few modifications sth's wrong too. So code:
// Vertex
#version 150 core

precision highp float;

uniform mat4 projectionMatrix;
uniform mat4 modelViewMatrix;
uniform mat4 cameraMatrix;

uniform float param1;
uniform float timer;
uniform int numLOD;

in vec4 vertex;
in vec3 normal;
in vec3 binormal;
in vec4 tangent;
in vec2 texCoord;

out vec2 fragmentTexCoord;//
out vec3 nvec;//
out vec4 point;//
out vec2 t_shape;//
out vec4 glPositionIn;//

vec4 vertex2;
vec3 cameraLocation;


void main(void)
{
fragmentTexCoord = texCoord;
vec3 normal2 = normal;
vertex2=vertex;
if(numLOD==1)
{
// vertex2.xyz=tangent;//tangent;
// normal2=binormal;
}
else
{
vertex2=tangent;//tangent;
normal2=normalize(binormal);
}

nvec = normalize(normal2);
vec3 terrAngle=normalize(vertex2.xyz);
float tAngle=dot(nvec,terrAngle);

float odl=sqrt(vertex2[0]*vertex2[0]+vertex2[1]*vertex2[1]+vertex2[2]*vertex2[2]);
float factor=0.2*0.5;
float radius=7000000;
float maxHeight=200000;

vec4 point2 = projectionMatrix*modelViewMatrix*vertex2;
t_shape=vec2(tAngle,((radius+maxHeight-odl)/maxHeight));

glPositionIn = point2;
}
In tangents/binormals I have 2nd model (vertices/normals).
...

Share this post


Link to post
Share on other sites
...
// Geometry
#version 150 core
#extension GL_EXT_geometry_shader4 : enable

precision highp float;
layout(triangles) in;
layout(max_vertices = 3) out;

uniform int numLOD[];

in vec2 fragmentTexCoord[];//
in vec3 nvec[];//
in vec4 point[];
in vec2 t_shape[];
in vec4 glPositionIn[];

out vec2 fragmentTexCoord2;
out vec4 point2;//
out float param;//
out vec3 normal;//
out vec2 tShape;//
out float tc6;//

void main()
{
float coordParam=1024;//65536.0f;
for(int i=0;i<numLOD[0];i++)
coordParam=coordParam*0.5f;
coordParam=1.0;
vec3 tcx;
vec3 tcy;
param=1;
if((fragmentTexCoord[0].x==fragmentTexCoord[2].x))
{
tcx=vec3(0.0,0.25,0.0);
tcy=vec3(0.25,0.25,0.0);
}
else
{
tcx=vec3(0,0.25,0.25);
tcy=vec3(0,0.25,0);
}
int i=0;
for(int i = 0; i < 3; i++) //2
{
// fragmentTexCoord2 = fragmentTexCoord;
tShape=t_shape;
normal = nvec;
point2=point;
fragmentTexCoord2 = vec2(tcx*coordParam,tcy*coordParam);
gl_Position = glPositionIn;
tc6 = gl_Position.z;
EmitVertex();
}
EndPrimitive();
}

...

Share this post


Link to post
Share on other sites
...
// Fragment
#version 150
precision highp float;

uniform sampler2D firstTexture;
uniform sampler2D gridTexture;
uniform sampler2D noiseTexture;
uniform sampler2D lut;
uniform float param2;
uniform float timer;
uniform int numLOD;

in vec2 fragmentTexCoord2;
in vec3 normal;
in vec4 point2;
in vec2 tShape;
in float tc6;

out vec4 fragColor;

void main (void)
{
vec2 fragmentTexCoord3=fragmentTexCoord2;//+(eye.xy*height*0.01);

vec4 terrain;
float rnd=texture2D(noiseTexture,fragmentTexCoord3).r*0.2;
fragmentTexCoord3=(fragmentTexCoord3*0.9+0.05*0.25);

if(param2>0.5)
{
vec4 type=texture2D(lut,vec2(tShape[1]+rnd,tShape[0]+rnd));

if(type.x>0.99)
type.x=0.99;
if(type.y>0.99)
type.y=0.99;

terrain=texture2D(firstTexture,fragmentTexCoord3+vec2(type[0],type[1]));//*ok
// if(numLOD==1)
// terrain=vec4(0.1,0.9,0.1,0);//*************

vec3 light_position2=vec3(0.3*cos(0.03*timer),0,0.3*sin(0.03*timer));
vec3 light=normalize(light_position2);
float intensity3 = max(dot(normal,light), 0.0);
fragColor = 0.5* terrain * (0.3+0.7*intensity3);
}
else
{
// fragColor=vec4(0,0,1,0);//
fragColor = texture2D(gridTexture,fragmentTexCoord3);
}
const float C = 1.0;
const float far = 1000000000.0;
const float offset = 1.0;
gl_FragDepth = (log(C * tc6 + offset) / log(C * far + offset));

}
I'm using param2 to switch between shaded, textured terrain and terrain with grid texture (I don't draw lines - too slow). If numLOD==1 I draw 1st only. For other values - 2nd, 3rd etc. (using "tangents/binormals" as vertices/normals.
...

[Edited by - _OskaR on August 21, 2010 5:00:18 PM]

Share this post


Link to post
Share on other sites
...
// Fragment
#version 150
precision highp float;

uniform sampler2D firstTexture;
uniform sampler2D gridTexture;
uniform sampler2D noiseTexture;
uniform sampler2D lut;
uniform float param2;
uniform float timer;
uniform int numLOD;

in vec2 fragmentTexCoord2;
in vec3 normal;
in vec4 point2;
in vec2 tShape;
in float tc6;

out vec4 fragColor;

void main (void)
{
vec2 fragmentTexCoord3=fragmentTexCoord2;//+(eye.xy*height*0.01);

vec4 terrain;
float rnd=texture2D(noiseTexture,fragmentTexCoord3).r*0.2;
fragmentTexCoord3=(fragmentTexCoord3*0.9+0.05*0.25);

if(param2>0.5)
{
vec4 type=texture2D(lut,vec2(tShape[1]+rnd,tShape[0]+rnd));

if(type.x>0.99)
type.x=0.99;
if(type.y>0.99)
type.y=0.99;

terrain=texture2D(firstTexture,fragmentTexCoord3+vec2(type[0],type[1]));//*ok
// if(numLOD==1)
// terrain=vec4(0.1,0.9,0.1,0);//*************

vec3 light_position2=vec3(0.3*cos(0.03*timer),0,0.3*sin(0.03*timer));
vec3 light=normalize(light_position2);
float intensity3 = max(dot(normal,light), 0.0);
fragColor = 0.5* terrain * (0.3+0.7*intensity3);
}
else
{
// fragColor=vec4(0,0,1,0);//
fragColor = texture2D(gridTexture,fragmentTexCoord3);
}
const float C = 1.0;
const float far = 1000000000.0;
const float offset = 1.0;
gl_FragDepth = (log(C * tc6 + offset) / log(C * far + offset));

}
I'm using param2 to switch between shaded, textured terrain and terrain with grid texture (I don't draw lines - too slow). If numLOD==1 I draw 1st only. For other values - 2nd, 3rd etc. (using "tangents/binormals" as vertices/normals.
...

Share this post


Link to post
Share on other sites
Everything works good. But when I change small part:
	//	terrain=texture2D(firstTexture,fragmentTexCoord3+vec2(type[0],type[1]));//+0.5*texture2D(firstTexture,fragmentTexCoord3);
// if(numLOD==1)
terrain=vec4(0.1,0.9,0.1,0);//
- terrain should be shader and green or not modified (with grid texture). But I don't see 1st LOD (I see few long lines only) Other LODs are ok. I don't understand why - I changed color only - the geometry should be the same.
If it will be helpful - I store vertices/normals as tangents/binormals in 2nd LOD or next - 1st is empty. Magic? When I change color, numLOD==1, my shader wants to use data which doesn't exist?


//Sorry for few posts - I lost whole day to put it on this forum - afer posting, I couldn't connect to the forum, after connecting 1hr later - empty post. Mod can connect parts if necessary.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!