Skip to content

Commit

Permalink
renamed file
Browse files Browse the repository at this point in the history
  • Loading branch information
jdupuy committed Jan 19, 2013
1 parent e3e805c commit abfd5e0
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions whitecap_precompute.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#extension GL_EXT_gpu_shader4 : enable


varying vec2 uv; // texcoords

#ifdef _VERTEX_
void main() {
uv = gl_Vertex.zw;
gl_Position = vec4(gl_Vertex.xy, 0.0, 1.0);
}

#endif

#ifdef _FRAGMENT_

#define LAYER_JACOBIAN_XX 5.0
#define LAYER_JACOBIAN_YY 6.0
#define LAYER_JACOBIAN_XY 7.0

uniform sampler2DArray fftWavesSampler;
uniform vec4 choppy;

void main() {

// fftWavesSampler has 4 height values
// heights.r : Lx, Lz = x0
// heights.b : Lx, Lz = x1
// heights.b : Lx, Lz = x2
// heights.a : Lx, Lz = x3
// with x0 < x1 < x2 < x3
vec4 heights = texture2DArray(fftWavesSampler, vec3(uv, 0.0));

gl_FragData[0] = vec4(heights.x, heights.x * heights.x, heights.y, heights.y * heights.y);
gl_FragData[1] = vec4(heights.z, heights.z * heights.z, heights.w, heights.w * heights.w);

// store Jacobian coeff value and variance
vec4 Jxx = choppy*texture2DArray(fftWavesSampler, vec3(uv, LAYER_JACOBIAN_XX));
vec4 Jyy = choppy*texture2DArray(fftWavesSampler, vec3(uv, LAYER_JACOBIAN_YY));
vec4 Jxy = choppy*choppy*texture2DArray(fftWavesSampler, vec3(uv, LAYER_JACOBIAN_XY));

// Store partial jacobians
vec4 res = 0.25 + Jxx + Jyy + choppy*Jxx*Jyy - Jxy*Jxy;
vec4 res2 = res*res;
gl_FragData[2] = vec4(res.x, res2.x, res.y, res2.y);
gl_FragData[3] = vec4(res.z, res2.z, res.w, res2.w);

}

#endif

0 comments on commit abfd5e0

Please sign in to comment.