Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualpolyfrag

Posted 25 October 2012 - 10:29 AM

Fragment shader
#version 120
uniform sampler2D texture1;
uniform sampler2D texture2;
uniform sampler2D shadowMap;
varying vec4 lpos;
varying vec3 normal;
varying vec3 light_vec;
varying vec3 light_dir;

void main (void)
{
  vec3 smcoord = lpos.xyz / lpos.w;
  float shadow = max(0.5, float(smcoord.z <= texture2D(shadowMap, smcoord.xy).x));
  vec3 lvec = normalize(light_vec);
  float diffuse = max(dot(-lvec, normal), 0.0);
  vec4 texColor = texture2D(texture1, gl_TexCoord[0].st) * texture2D(texture2, gl_TexCoord[1].st);
  gl_FragColor = vec4(gl_Color.xyz * texColor.xyz * shadow * diffuse * 2.0, texColor.w);
}

Vertex shader
uniform mat4 lightMatrix;
uniform vec3 lightPos;
uniform vec3 lightDir;
varying vec4 lpos;
varying vec3 normal;
varying vec3 light_vec;
varying vec3 light_dir;

void main(void)
{
  gl_TexCoord[0] = gl_MultiTexCoord0;
  gl_TexCoord[1] = gl_MultiTexCoord1;
  vec4 vpos = gl_ModelViewMatrix * gl_Vertex;
  lpos = lightMatrix * vpos;
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  light_vec = vpos.xyz - lightPos;
  light_dir = gl_NormalMatrix * lightDir;
  normal = normalize(gl_NormalMatrix * gl_Normal);
  gl_FrontColor = gl_Color;
}

#1polyfrag

Posted 25 October 2012 - 10:29 AM

Fragment shader
#version 120
uniform sampler2D texture1;
uniform sampler2D texture2;
uniform sampler2D shadowMap;
varying vec4 lpos;
varying vec3 normal;
varying vec3 light_vec;
varying vec3 light_dir;

void main (void)
{
  vec3 smcoord = lpos.xyz / lpos.w;
  float shadow = max(0.5, float(smcoord.z <= texture2D(shadowMap, smcoord.xy).x));
  vec3 lvec = normalize(light_vec);
  float diffuse = max(dot(-lvec, normal), 0.0);
  vec4 texColor = texture2D(texture1, gl_TexCoord[0].st) * texture2D(texture2, gl_TexCoord[1].st);
  gl_FragColor = vec4(gl_Color.xyz * texColor.xyz * shadow * diffuse * 2.0, texColor.w);
}

Vertex shader:
uniform mat4 lightMatrix;
uniform vec3 lightPos;
uniform vec3 lightDir;
varying vec4 lpos;
varying vec3 normal;
varying vec3 light_vec;
varying vec3 light_dir;

void main(void)
{
  gl_TexCoord[0] = gl_MultiTexCoord0;
  gl_TexCoord[1] = gl_MultiTexCoord1;
  vec4 vpos = gl_ModelViewMatrix * gl_Vertex;
  lpos = lightMatrix * vpos;
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  light_vec = vpos.xyz - lightPos;
  light_dir = gl_NormalMatrix * lightDir;
  normal = normalize(gl_NormalMatrix * gl_Normal);
  gl_FrontColor = gl_Color;
}

PARTNERS