0 Replies - 236 Views - Last Post: 19 April 2013 - 03:38 AM Rate Topic: -----

#1 FrozenSnake  Icon User is offline

  • En man från Sverige!

Reputation: 122
  • View blog
  • Posts: 998
  • Joined: 30-July 08

Shaders with RenderMonkey, diff computer shader wont compile/link

Posted 19 April 2013 - 03:38 AM

Hi!

We have started our shader course at the university and now we have been assigned a task where we use RenderMonkey 1.82
to do our shaders. I have been working on my shader at home on my own computer, where the Shader compiles and links.
When I open my shader in school the exact same code in the same version of RenderMonkey refuses to work.

The error I get is this:
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.


I zip:ed down the entire folder and moved it to the schools computer, and it refuses to work.
Anyone know why RenderMonkey behave this way and what I can try to fix this?

Here is the Vertex code
uniform vec3 uLight1Position;
uniform vec3 uLight2Position;
uniform vec3 uEyePosition;

varying vec3 vColor;
varying vec3 vLightDir;
varying vec3 vNormal;
varying vec3 vEyeVec, uOpacity;
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);
   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);
}


Here is the Fragment code
// 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));
   specular += rimLight;
   
   // Diffuse Attenuation
   specular *= diffuse;

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


It feels very weird that my code work on a different computer with the same version of the same software.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1