• Advertisement
Sign in to follow this  

Problem with shader in RenderMonkey

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

I hope this is in the correct forum, since I am programming the shader I decided to put the topic in here. 


I have been working on a shader in RenderMonkey on my desktop computer, and when I transferred the rfx-file to my laptop to continue the work in school I get two error messages that I do not get at home.


OpenGL Preview Window: Linking program .. failure

The fragment shader uses varying uDiffuseColor, but previous shader does not write to it.
The fragment shader uses varying uOpacity, but previous shader does not write to it.


This is the Fragment program

// Ljus 1
uniform vec3  uLight1Position;
uniform float uLight1DiffIntent, Light1SpecIntent;
float uLight1RimIntent;

// Ljus 2
uniform vec3  uLight2Position;
uniform float uLight2DiffIntent, uLight2SpecIntent, uLight2RimIntent;

varying vec3 uLight1Color, uDiffuseColor, vColor, vNormal, vLightDir, vEyeVec;
varying float uLight1Intent, luminosity1, luminosity2, uLight1RimLight, uOpacity;
varying vec2 vTexCoord;

uniform sampler2D baseMap;

void main(void)
   vec3 N = normalize(vNormal);
   vec3 L = normalize(vLightDir);
   vec3 E = normalize(vEyeVec);
   vec3 H = normalize(-L + E);
   // Lambert Diffuse Lighting.
   float diffuse = clamp(dot(N, -L), 0.0, 1.0);

   // Blinn Specular
   float specular = pow(max(dot(N, H), 0.0), 120.0);
   //float diffuse = dot(N, -L);
   // Rim Lighting.
   float rimLight = smoothstep(0.5, 0.05, dot(N,E));// * (uLight1RimIntent + uLight2RimIntent);
   specular += rimLight;
   // Diffuse Attenuation
   specular *= diffuse;

   vec3 base = texture2D( baseMap, vTexCoord ).xyz;
   // Lägg till kantljus till den diffusa komponenten.
   //vec4 finalColor = vec4(diffuse + rimLight, rimLight, rimLight, uLight1Intent) / (length(uLight1Position) * 0.02);
   vec3 vColor = mix(uDiffuseColor.xyz, base, uOpacity);// diffuse + finalColor;
   vec4 finalColor = vec4(base * diffuse, 2.0);
   gl_FragColor = vec4(vColor * finalColor + rimLight, 0.5);
   //gl_FragColor = finalColor;

The Vertex Program

uniform vec3 uLight1Position;
uniform vec3 uLight2Position;
uniform vec3 uEyePosition;

varying vec3 vColor;
varying vec3 vLightDir;
varying vec3 vNormal;
varying vec3 vEyeVec, uOpacity, uDiffuseColor;
varying float uLight1Intent, luminosity1, luminosity2;
varying vec2 vTexCoord;

void main( void )
   vec3 N = normalize(vNormal);
   vec3 L = normalize(vLightDir);
   vec4 vertex = gl_ModelViewProjectionMatrix * gl_Vertex;
   gl_Position = vertex;
   uLight1Intent = distance(gl_Position.xyz, uLight1Position.xyz);
   //uLight1RimIntent = distance(gl_Position.xyz, uLight1Position.xyz);   
   luminosity1 = smoothstep(120, 0, uLight1Intent);
   vLightDir = -vec3(gl_ModelViewMatrix * vec4(uLight1Position, 0.0));
   vNormal = gl_NormalMatrix * gl_Normal;
   vEyeVec = -vec3(gl_ModelViewMatrix * gl_Vertex);
   vTexCoord = vec2(gl_MultiTexCoord0);
   //float diffuse = dot(N, -L) * luminosity1; 

I use the exact same rfx file (the exact same code) on the two different computers, I tried it in school as well and the same problem is there as well. We just started to work with hardware shaders so I dont know how rendermonkey work and why this is happening. It only work at home, all the files are the same on the different systems. Anyone that has any idea what I can try to get this to work?

Edited by FrozenSnake

Share this post

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

  • Advertisement