~ubuntu-branches/ubuntu/vivid/meshlab/vivid

« back to all changes in this revision

Viewing changes to meshlab/src/fgt/decorate_shadow/shader/vsm/objectVSM.frag

  • Committer: Bazaar Package Importer
  • Author(s): Teemu Ikonen
  • Date: 2009-10-08 16:40:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20091008164041-0c2ealqv8b8uc20c
Tags: 1.2.2-1
* New upstream version
* Do not build filter_isoparametrization because liblevmar dependency
  is not (yet) in Debian
* Fix compilation with gcc-4.4, thanks to Jonathan Liu for the patch
  (closes: #539544)
* rules: Add compiler variables to the qmake call (for testing with new
  GCC versions)
* io_3ds.pro: Make LIBS and INCLUDEPATH point to Debian version of lib3ds
* io_epoch.pro: Make LIBS point to Debian version of libbz2
* control:
  - Move Homepage URL to the source package section
  - Update to standards-version 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
uniform mat4 mvpl;
 
2
uniform sampler2D shadowMap;
 
3
uniform float texSize;
 
4
varying vec4 shadowCoord; 
 
5
 
 
6
 
 
7
vec4 shadowCoordPostW;
 
8
float chebyshevUpperBound( float distance) {
 
9
  // We retrive the two moments previously stored (depth and depth*depth) 
 
10
  vec2 moments = texture2D(shadowMap,shadowCoordPostW.xy).rb; 
 
11
  // Surface is fully lit. as the current fragment is before the light occluder 
 
12
  if (distance <= moments.x) 
 
13
    return 1.0 ; 
 
14
 
 
15
  float variance = moments.y - (moments.x*moments.x); 
 
16
  //variance = max(variance,0.00002);
 
17
  variance = max(variance,0.000195);  
 
18
  float d = distance - moments.x; 
 
19
  float p_max = variance / (variance + d*d); 
 
20
  return p_max;
 
21
}
 
22
 
 
23
void main() {
 
24
  shadowCoordPostW = shadowCoord / shadowCoord.w;
 
25
  shadowCoordPostW = shadowCoordPostW * 0.5 + 0.5;
 
26
  float shadow = chebyshevUpperBound(shadowCoordPostW.z);
 
27
 
 
28
  vec4 kd = gl_LightSource[0].diffuse;
 
29
  if (shadow > 0.4)
 
30
    discard;
 
31
 
 
32
  gl_FragColor = vec4(vec3(0.0), 0.5 - shadow);
 
33
 
 
b'\\ No newline at end of file'