TerrainTransformFeedback.tesh 1.16 KB
Newer Older
David Gilbert's avatar
David Gilbert committed
1 2 3 4
#version 410 core

layout(triangles, equal_spacing, ccw) in;

David Gilbert's avatar
David Gilbert committed
5 6 7
in vec2 tcTexCoord[];
in vec3 tcNormal[];
in vec3 tcPosition[];
David Gilbert's avatar
David Gilbert committed
8

David Gilbert's avatar
David Gilbert committed
9 10 11
out vec3 tNormal;
out vec2 tTexCoord;
out vec3 tPosition;
David Gilbert's avatar
David Gilbert committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

uniform mat4 uModelMatrix;
uniform vec3 cameraPostion;



vec2 interpolate2D(vec2 v0, vec2 v1, vec2 v2){
  return vec2(gl_TessCoord.x) * v0 + vec2(gl_TessCoord.y) * v1 + vec2(gl_TessCoord.z) * v2;	
}

vec3 interpolate3D(vec3 v0, vec3 v1, vec3 v2){
  return vec3(gl_TessCoord.x ) * v0 + vec3(gl_TessCoord.y) * v1 + vec3(gl_TessCoord.z) * v2;
}


void main(){
	
  tNormal = interpolate3D(tcNormal[0], tcNormal[1], tcNormal[2]);
30
  tNormal = normalize(tNormal);
David Gilbert's avatar
David Gilbert committed
31 32
  tTexCoord = interpolate2D(tcTexCoord[0], tcTexCoord[1], tcTexCoord[2]);
  
David Gilbert's avatar
David Gilbert committed
33
  //tPatchDistance = gl_TessCoord;
David Gilbert's avatar
David Gilbert committed
34
  tPosition = interpolate3D(tcPosition[0], tcPosition[1], tcPosition[2]);
35
  //tPosition = normalize(tPosition);
David Gilbert's avatar
David Gilbert committed
36 37
  //vec4 camWorld = uModelMatrix * vec4(tPosition, 1.0);

David Gilbert's avatar
David Gilbert committed
38
  //tPosition += tNormal * fBM( tPosition , 8, 32, 0.002 ) ;
David Gilbert's avatar
David Gilbert committed
39
  
40
  //tNormal = inverse(transpose(mat3(uModelMatrix))) * normalize(tNormal);
David Gilbert's avatar
David Gilbert committed
41 42 43 44 45
  //tPosition = (uModelMatrix * vec4(tPosition, 1)).xyz;

  //gl_Position = uViewProjectionMatrix * vec4(tPosition, 1);

}