LWJGL
May 21, 2012, 00:50:45 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: GLSL error  (Read 1788 times)
Dansas
Newbie
*
Posts: 5


« on: May 12, 2007, 10:51:31 »

http://www.jmonkeyengine.com/jmeforum/index.php?topic=4955.0
Can anyone here tell me if this is a jME or a lwjgl related error?
I cannot get this shadow shader to work in either one
Thanks

Vertex
Code:
attribute float Accessibility;

varying vec4 ShadowCoord;

const float As = 1.0/1.5;
const float Ds = 1.0/3.0;

void main(){
   vec4 ecPosition = gl_ModelViewMatrix*gl_Vertex;
   vec3 ecPosition3 = (vec3(ecPosition))/ecPosition.w;
   vec3 VP = vec3(gl_LightSource[0].position)-ecPosition3;
   VP = normalize(VP);
   vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
   float diffuse = max(0.0,dot(normal,VP));
  float scale = min(1.0,Accessibility * As + diffuse * Ds);
   vec4 texCoord = gl_TextureMatrix[1] * gl_Vertex;
   ShadowCoord = texCoord / texCoord.w;
   gl_FrontColor = vec4(scale * gl_Color.rgb,gl_Color.a);
   gl_Position = ftransform();
}
Fragment
Code:
uniform sampler2DShadow ShadowMap;
uniform float Epsilon;
uniform bool SelfShadowed;
uniform float SelfShadowedVal;
uniform float NonSelfShadowedVal;

varying vec4 ShadowCoord;

float Illumination;

float lookup(float x, float y)
{
   float depth = shadow2D(ShadowMap,
      ShadowCoord.wxy + vec3(x,y,0) * Epsilon).x;
   return depth != 1.0 ? Illumination : 1.0;

}
void main(void)
{
   Illumination = SelfShadowed ? SelfShadowedVal: NonSelfShadowedVal;
  // vec2 o = mod(floor(gl_FragCoord.xy),2.0);
   float sum = 0.0;
   
   //sum += lookup(vec2(-1.5,1.5)  + o);
  // sum += lookup(vec2(0.5,1.5)   + o);
  // sum += lookup(vec2(-1.5,-0.5) + o);
  // sum += lookup(vec2(0.5,-0.5)  + o);

   sum += lookup(-0.5,-0.5);
   sum += lookup(0.5,-0.5);
   sum += lookup(-0.5,0.5);
   sum += lookup(0.5,0.5);
   
   gl_FragColor = vec4(sum*0.25*gl_Color.rgb,gl_Color.a);
}
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!