Revision: 8919
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8919&view=rev
Author:   natepak
Date:     2010-09-22 20:50:29 +0000 (Wed, 22 Sep 2010)

Log Message:
-----------
Renamed shadow receiver

Modified Paths:
--------------
    code/gazebo/branches/wx/Media/materials/programs/shadow_caster_fp.glsl
    code/gazebo/branches/wx/Media/materials/programs/shadow_caster_vp.glsl

Added Paths:
-----------
    
code/gazebo/branches/wx/Media/materials/programs/spot_shadow_receiver_fp.glsl
    
code/gazebo/branches/wx/Media/materials/programs/spot_shadow_receiver_vp.glsl

Removed Paths:
-------------
    code/gazebo/branches/wx/Media/materials/programs/shadow_receiver_fp.glsl
    code/gazebo/branches/wx/Media/materials/programs/shadow_receiver_vp.glsl

Modified: code/gazebo/branches/wx/Media/materials/programs/shadow_caster_fp.glsl
===================================================================
--- code/gazebo/branches/wx/Media/materials/programs/shadow_caster_fp.glsl      
2010-09-22 07:56:54 UTC (rev 8918)
+++ code/gazebo/branches/wx/Media/materials/programs/shadow_caster_fp.glsl      
2010-09-22 20:50:29 UTC (rev 8919)
@@ -5,7 +5,8 @@
 
 void main()
 {
-  float depth = length(vertexDepth.xyz)/500.0;
+  float depth = length(vertexDepth.xyz)/2.4;
+  //float depth = 0.1;
   gl_FragColor = vec4(depth, depth*depth, 0.0, 1.0);
 
   //gl_FragColor = vec4(d, d * d, 0.0, 1.0);

Modified: code/gazebo/branches/wx/Media/materials/programs/shadow_caster_vp.glsl
===================================================================
--- code/gazebo/branches/wx/Media/materials/programs/shadow_caster_vp.glsl      
2010-09-22 07:56:54 UTC (rev 8918)
+++ code/gazebo/branches/wx/Media/materials/programs/shadow_caster_vp.glsl      
2010-09-22 20:50:29 UTC (rev 8919)
@@ -1,8 +1,8 @@
 uniform mat4 wvpMat;
-uniform mat4 wvMat;
-uniform mat4 pMat;
-uniform vec4 texel_offsets;
-uniform vec4 depth_range;
+//uniform mat4 wvMat;
+//uniform mat4 pMat;
+//uniform vec4 texel_offsets;
+//uniform vec4 depth_range;
 
 attribute vec4 vertex;
 
@@ -13,7 +13,8 @@
 {
   vertexDepth = wvpMat * vertex;
   //d = (vertexDepth.z - depthRange.x) * depthRange.w;
+  //d = vertexDepth.z;
 
-  gl_Position = vertexDepth;
-  gl_Position.xy += texel_offsets.zw * gl_Position.w;
+  gl_Position = wvpMat * vertex;
+  //gl_Position.xy += texel_offsets.zw * gl_Position.w;
 }

Deleted: 
code/gazebo/branches/wx/Media/materials/programs/shadow_receiver_fp.glsl
===================================================================
--- code/gazebo/branches/wx/Media/materials/programs/shadow_receiver_fp.glsl    
2010-09-22 07:56:54 UTC (rev 8918)
+++ code/gazebo/branches/wx/Media/materials/programs/shadow_receiver_fp.glsl    
2010-09-22 20:50:29 UTC (rev 8919)
@@ -1,121 +0,0 @@
-uniform vec4 invShadowMapSize;
-uniform vec3 derived_light_diffuse_color;
-uniform vec4 derived_light_specular_color;
-uniform float surface_shininess;
-
-uniform vec4 light_position_view_space;
-uniform vec4 light_position_world_space;
-uniform vec4 light_direction_view_space;
-uniform vec4 light_attenuation;
-uniform vec4 spotlight_params;
-
-uniform float light_casts_shadows;
-
-uniform sampler2D shadowMap;
-uniform sampler2D diffuseMap;
-
-varying vec3 vertexWorldViewPos;
-varying vec3 vertexWorldPos;
-varying vec3 vertexWorldNorm;
-varying vec4 vertexLightPos;
-
-vec4 Blur(sampler2D map, vec2 uv, float radius, float steps)
-{
-  float stepSize = 2.0 * radius / steps;
-  uv.xy -= vec2(radius);
-
-  vec4 total = vec4(0.0, 0.0, 0.0, 0.0);
-  for (float x = 0.0; x < steps; x+=1.0)
-    for (float y = 0.0; y < steps; y+=1.0)
-      total +=
-        texture2D(map, vec2(uv.xy + vec2(x * stepSize, y * stepSize)));
-
-  return total / (steps * steps);
-}
-
-float ShadowPCF()
-{
-  // Get the shadow map position
-  vec4 shadowMapPos = vertexLightPos / vertexLightPos.w;
-  vec2 uv = shadowMapPos.xy;
-
-  float dist = length(light_position_world_space.xyz - vertexWorldPos)/500.0;
-
-  vec2 c = Blur(shadowMap, uv, invShadowMapSize.x, 4.0).xy;
-
-  if ( dist <= c.x + 0.0001)
-    return 1.0;
-
-  // standard variance shadow mapping code
-  float variance = min(max( c.y - (c.x * c.x), 0.0), 1.0);
-  float m_d = c.x - dist;
-  float p = variance / (variance + m_d * m_d);
-
-  return smoothstep(0.3, 1.0, p);
-}
-  
-
-void main()
-{
-  float spot = 1.0;
-  float shadowFactor = 1.0;
-  float specular = 0.0;
-
-  // Normalized fragment normal
-  vec3 N = normalize(vertexWorldNorm);
-
-  // Direction from the fragment to the light 
-  vec3 lightDirView = light_position_view_space.xyz - vertexWorldViewPos.xyz * 
light_position_view_space.w;
-
-  // light_position_view_space.w == 0 for directional lights
-  float lightDist = length(lightDirView);
-  lightDirView = normalize(lightDirView);
-
-  float lambertTerm = max( dot(N, lightDirView), 0.0 );
-
-  
//////////////////////////////////////////////////////////////////////////////
-  // COMPUTE DIFFUSE CONTRIBUTION
-  vec4 diffuseTex = texture2D(diffuseMap, gl_TexCoord[0].st);
-  vec4 diffuseContrib = vec4(derived_light_diffuse_color * diffuseTex.rgb * 
lambertTerm,1.0);
-
-
-  
//////////////////////////////////////////////////////////////////////////////
-  // COMPUTE SPOT AND SPECULAR COMPONENTS
-  if (lambertTerm > 0.0 && lightDist <= light_attenuation.x) 
-  {
-    vec3 view = -normalize(vertexWorldViewPos.xyz);
-    vec3 halfway = normalize( view + lightDirView );
-    float nDotH = dot(N, halfway);
-
-    float fAtten = 1.0 / (light_attenuation.y + 
-                          light_attenuation.z*lightDist + 
-                          light_attenuation.w*lightDist*lightDist);    
-
-    float rho = dot(-light_direction_view_space.xyz, lightDirView);
-
-    float fSpotE  = clamp((rho - spotlight_params.y) / 
-        (spotlight_params.x - spotlight_params.y),0.0,1.0);
-
-    float fSpotT  = pow(fSpotE, spotlight_params.z);
-
-    // Make sure we have a spot light
-    if ( !(spotlight_params.x == 1.0 && spotlight_params.y == 0.0 && 
-           spotlight_params.z == 0.0 && spotlight_params.w == 1.0) )
-    {
-      spot = lambertTerm * fAtten * fSpotT;
-    }
-
-    // Works for all light types
-    specular = pow(clamp(nDotH, 0.0, 1.0), surface_shininess) * fAtten, fSpotT;
-  }
-
-  
//////////////////////////////////////////////////////////////////////////////
-  // COMPUTE SHADOW CONTRIBUTION
-  //shadowFactor = ShadowPCF();
-  if (light_casts_shadows)
-    shadowFactor = ShadowPCF();
-
-  vec4 specularContrib = specular * derived_light_specular_color;
-
-  gl_FragColor = (diffuseContrib+ specularContrib) * spot * shadowFactor;
-}

Deleted: 
code/gazebo/branches/wx/Media/materials/programs/shadow_receiver_vp.glsl
===================================================================
--- code/gazebo/branches/wx/Media/materials/programs/shadow_receiver_vp.glsl    
2010-09-22 07:56:54 UTC (rev 8918)
+++ code/gazebo/branches/wx/Media/materials/programs/shadow_receiver_vp.glsl    
2010-09-22 20:50:29 UTC (rev 8919)
@@ -1,37 +0,0 @@
-uniform mat4 wMat;
-uniform mat4 wvMat;
-uniform mat4 wvpMat;
-uniform mat4 inv_trans_wvMat;
-uniform vec4 lightWorldPos;
-
-uniform mat4 twvpMat;
-uniform vec4 spotDir;
-uniform vec4 shadow_depth_range;
-
-attribute vec3 normal;
-attribute vec4 vertex;
-
-varying vec3 vertexWorldNorm;
-varying vec3 vertexWorldViewPos;
-varying vec3 vertexWorldPos;
-
-varying vec4 vertexLightPos;
-
-void main()
-{
-  gl_Position = wvpMat * vertex;
-
-  // Vertex in world space
-  vertexWorldViewPos = (wvMat * vertex).xyz;
-  vertexWorldPos = (wMat * vertex).xyz;
-
-  // Vertex normal in world space
-  vertexWorldNorm = (inv_trans_wvMat * vec4(normal, 1.0)).xyz;
-
-  // Position of the vertex in light space (shadow map texture coords)
-  vertexLightPos = twvpMat * vertex;
-  //vertexLightPos.z = (vertexLightPos.z - shadow_depth_range.x) * 
shadow_depth_range.w;
-
-  // Pass through the diffuse component
-  gl_TexCoord[0] = gl_MultiTexCoord0;
-}

Copied: 
code/gazebo/branches/wx/Media/materials/programs/spot_shadow_receiver_fp.glsl 
(from rev 8918, 
code/gazebo/branches/wx/Media/materials/programs/shadow_receiver_fp.glsl)
===================================================================
--- 
code/gazebo/branches/wx/Media/materials/programs/spot_shadow_receiver_fp.glsl   
                            (rev 0)
+++ 
code/gazebo/branches/wx/Media/materials/programs/spot_shadow_receiver_fp.glsl   
    2010-09-22 20:50:29 UTC (rev 8919)
@@ -0,0 +1,121 @@
+uniform vec4 invShadowMapSize;
+uniform vec3 derived_light_diffuse_color;
+uniform vec4 derived_light_specular_color;
+uniform float surface_shininess;
+
+uniform vec4 light_position_view_space;
+uniform vec4 light_position_world_space;
+uniform vec4 light_direction_view_space;
+uniform vec4 light_attenuation;
+uniform vec4 spotlight_params;
+
+uniform float light_casts_shadows;
+
+uniform sampler2D shadowMap;
+uniform sampler2D diffuseMap;
+
+varying vec3 vertexWorldViewPos;
+varying vec3 vertexWorldPos;
+varying vec3 vertexWorldNorm;
+varying vec4 vertexLightPos;
+
+vec4 Blur(sampler2D map, vec2 uv, float radius, float steps)
+{
+  float stepSize = 2.0 * radius / steps;
+  uv.xy -= vec2(radius);
+
+  vec4 total = vec4(0.0, 0.0, 0.0, 0.0);
+  for (float x = 0.0; x < steps; x+=1.0)
+    for (float y = 0.0; y < steps; y+=1.0)
+      total +=
+        texture2D(map, vec2(uv.xy + vec2(x * stepSize, y * stepSize)));
+
+  return total / (steps * steps);
+}
+
+float ShadowPCF()
+{
+  // Get the shadow map position
+  vec4 shadowMapPos = vertexLightPos / vertexLightPos.w;
+  vec2 uv = shadowMapPos.xy;
+
+  float dist = length(light_position_world_space.xyz - vertexWorldPos)/500.0;
+
+  vec2 c = Blur(shadowMap, uv, invShadowMapSize.x, 4.0).xy;
+
+  if ( dist <= c.x + 0.0001)
+    return 1.0;
+
+  // standard variance shadow mapping code
+  float variance = min(max( c.y - (c.x * c.x), 0.0), 1.0);
+  float m_d = c.x - dist;
+  float p = variance / (variance + m_d * m_d);
+
+  return smoothstep(0.3, 1.0, p);
+}
+  
+
+void main()
+{
+  float spot = 1.0;
+  float shadowFactor = 1.0;
+  float specular = 0.0;
+
+  // Normalized fragment normal
+  vec3 N = normalize(vertexWorldNorm);
+
+  // Direction from the fragment to the light 
+  vec3 lightDirView = light_position_view_space.xyz - vertexWorldViewPos.xyz * 
light_position_view_space.w;
+
+  // light_position_view_space.w == 0 for directional lights
+  float lightDist = length(lightDirView);
+  lightDirView = normalize(lightDirView);
+
+  float lambertTerm = max( dot(N, lightDirView), 0.0 );
+
+  
//////////////////////////////////////////////////////////////////////////////
+  // COMPUTE DIFFUSE CONTRIBUTION
+  vec4 diffuseTex = texture2D(diffuseMap, gl_TexCoord[0].st);
+  vec4 diffuseContrib = vec4(derived_light_diffuse_color * diffuseTex.rgb * 
lambertTerm,1.0);
+
+
+  
//////////////////////////////////////////////////////////////////////////////
+  // COMPUTE SPOT AND SPECULAR COMPONENTS
+  if (lambertTerm > 0.0 && lightDist <= light_attenuation.x) 
+  {
+    vec3 view = -normalize(vertexWorldViewPos.xyz);
+    vec3 halfway = normalize( view + lightDirView );
+    float nDotH = dot(N, halfway);
+
+    float fAtten = 1.0 / (light_attenuation.y + 
+                          light_attenuation.z*lightDist + 
+                          light_attenuation.w*lightDist*lightDist);    
+
+    float rho = dot(-light_direction_view_space.xyz, lightDirView);
+
+    float fSpotE  = clamp((rho - spotlight_params.y) / 
+        (spotlight_params.x - spotlight_params.y),0.0,1.0);
+
+    float fSpotT  = pow(fSpotE, spotlight_params.z);
+
+    // Make sure we have a spot light
+    if ( !(spotlight_params.x == 1.0 && spotlight_params.y == 0.0 && 
+           spotlight_params.z == 0.0 && spotlight_params.w == 1.0) )
+    {
+      spot = lambertTerm * fAtten * fSpotT;
+    }
+
+    // Works for all light types
+    specular = pow(clamp(nDotH, 0.0, 1.0), surface_shininess) * fAtten, fSpotT;
+  }
+
+  
//////////////////////////////////////////////////////////////////////////////
+  // COMPUTE SHADOW CONTRIBUTION
+  //shadowFactor = ShadowPCF();
+  if (light_casts_shadows)
+    shadowFactor = ShadowPCF();
+
+  vec4 specularContrib = specular * derived_light_specular_color;
+
+  gl_FragColor = (diffuseContrib+ specularContrib) * spot * shadowFactor;
+}

Copied: 
code/gazebo/branches/wx/Media/materials/programs/spot_shadow_receiver_vp.glsl 
(from rev 8918, 
code/gazebo/branches/wx/Media/materials/programs/shadow_receiver_vp.glsl)
===================================================================
--- 
code/gazebo/branches/wx/Media/materials/programs/spot_shadow_receiver_vp.glsl   
                            (rev 0)
+++ 
code/gazebo/branches/wx/Media/materials/programs/spot_shadow_receiver_vp.glsl   
    2010-09-22 20:50:29 UTC (rev 8919)
@@ -0,0 +1,37 @@
+uniform mat4 wMat;
+uniform mat4 wvMat;
+uniform mat4 wvpMat;
+uniform mat4 inv_trans_wvMat;
+uniform vec4 lightWorldPos;
+
+uniform mat4 twvpMat;
+uniform vec4 spotDir;
+uniform vec4 shadow_depth_range;
+
+attribute vec3 normal;
+attribute vec4 vertex;
+
+varying vec3 vertexWorldNorm;
+varying vec3 vertexWorldViewPos;
+varying vec3 vertexWorldPos;
+
+varying vec4 vertexLightPos;
+
+void main()
+{
+  gl_Position = wvpMat * vertex;
+
+  // Vertex in world space
+  vertexWorldViewPos = (wvMat * vertex).xyz;
+  vertexWorldPos = (wMat * vertex).xyz;
+
+  // Vertex normal in world space
+  vertexWorldNorm = (inv_trans_wvMat * vec4(normal, 1.0)).xyz;
+
+  // Position of the vertex in light space (shadow map texture coords)
+  vertexLightPos = twvpMat * vertex;
+  //vertexLightPos.z = (vertexLightPos.z - shadow_depth_range.x) * 
shadow_depth_range.w;
+
+  // Pass through the diffuse component
+  gl_TexCoord[0] = gl_MultiTexCoord0;
+}


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to