From 1461deb308b3cb3d7e4531f756b5e32ccfac19fd Mon Sep 17 00:00:00 2001 From: David G Yu Date: Mon, 10 Jun 2013 12:53:04 -0700 Subject: [PATCH] Fixed glsl shader portability (input,output) --- examples/glBatchViewer/shader.glsl | 70 +++---- examples/glViewer/shader.glsl | 70 +++---- examples/mayaPtexViewer/shader.glsl | 96 ++++----- examples/mayaViewer/shader.glsl | 56 ++--- examples/paintTest/paintShader.glsl | 46 ++--- examples/paintTest/shader.glsl | 64 +++--- examples/ptexViewer/shader.glsl | 136 ++++++------- examples/ptexViewer/shader_gl3.glsl | 10 +- opensubdiv/osd/glslPatchBoundary.glsl | 54 ++--- opensubdiv/osd/glslPatchBoundaryGregory.glsl | 204 +++++++++---------- opensubdiv/osd/glslPatchCommon.glsl | 30 +-- opensubdiv/osd/glslPatchCorner.glsl | 52 ++--- opensubdiv/osd/glslPatchGregory.glsl | 134 ++++++------ opensubdiv/osd/glslPatchRegular.glsl | 54 ++--- opensubdiv/osd/glslPatchTransition.glsl | 88 ++++---- 15 files changed, 582 insertions(+), 582 deletions(-) diff --git a/examples/glBatchViewer/shader.glsl b/examples/glBatchViewer/shader.glsl index f921689f..fd419faf 100644 --- a/examples/glBatchViewer/shader.glsl +++ b/examples/glBatchViewer/shader.glsl @@ -65,12 +65,12 @@ layout (location=1) in vec3 normal; out block { OutputVertex v; -} output; +} outpt; void main() { - output.v.position = ModelViewMatrix * position; - output.v.normal = (ModelViewMatrix * vec4(normal, 0.0)).xyz; + outpt.v.position = ModelViewMatrix * position; + outpt.v.normal = (ModelViewMatrix * vec4(normal, 0.0)).xyz; } #endif @@ -90,7 +90,7 @@ void main() in block { OutputVertex v; - } input[4]; + } inpt[4]; #endif // PRIM_QUAD @@ -104,7 +104,7 @@ void main() in block { OutputVertex v; - } input[3]; + } inpt[3]; #endif // PRIM_TRI @@ -115,23 +115,23 @@ void main() in block { OutputVertex v; - } input[1]; + } inpt[1]; #endif // PRIM_POINT out block { OutputVertex v; -} output; +} outpt; void emit(int index, vec3 normal) { - output.v.position = input[index].v.position; + outpt.v.position = inpt[index].v.position; #ifdef SMOOTH_NORMALS - output.v.normal = input[index].v.normal; + outpt.v.normal = inpt[index].v.normal; #else - output.v.normal = normal; + outpt.v.normal = normal; #endif - gl_Position = ProjectionMatrix * input[index].v.position; + gl_Position = ProjectionMatrix * inpt[index].v.position; EmitVertex(); } @@ -147,18 +147,18 @@ float edgeDistance(vec4 p, vec4 p0, vec4 p1) void emit(int index, vec3 normal, vec4 edgeVerts[EDGE_VERTS]) { - output.v.edgeDistance[0] = + outpt.v.edgeDistance[0] = edgeDistance(edgeVerts[index], edgeVerts[0], edgeVerts[1]); - output.v.edgeDistance[1] = + outpt.v.edgeDistance[1] = edgeDistance(edgeVerts[index], edgeVerts[1], edgeVerts[2]); #ifdef PRIM_TRI - output.v.edgeDistance[2] = + outpt.v.edgeDistance[2] = edgeDistance(edgeVerts[index], edgeVerts[2], edgeVerts[0]); #endif #ifdef PRIM_QUAD - output.v.edgeDistance[2] = + outpt.v.edgeDistance[2] = edgeDistance(edgeVerts[index], edgeVerts[2], edgeVerts[3]); - output.v.edgeDistance[3] = + outpt.v.edgeDistance[3] = edgeDistance(edgeVerts[index], edgeVerts[3], edgeVerts[0]); #endif @@ -175,17 +175,17 @@ void main() #endif #ifdef PRIM_QUAD - vec3 A = (input[0].v.position - input[1].v.position).xyz; - vec3 B = (input[3].v.position - input[1].v.position).xyz; - vec3 C = (input[2].v.position - input[1].v.position).xyz; + vec3 A = (inpt[0].v.position - inpt[1].v.position).xyz; + vec3 B = (inpt[3].v.position - inpt[1].v.position).xyz; + vec3 C = (inpt[2].v.position - inpt[1].v.position).xyz; vec3 n0 = normalize(cross(B, A)); #if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE) vec4 edgeVerts[EDGE_VERTS]; - edgeVerts[0] = ProjectionMatrix * input[0].v.position; - edgeVerts[1] = ProjectionMatrix * input[1].v.position; - edgeVerts[2] = ProjectionMatrix * input[2].v.position; - edgeVerts[3] = ProjectionMatrix * input[3].v.position; + edgeVerts[0] = ProjectionMatrix * inpt[0].v.position; + edgeVerts[1] = ProjectionMatrix * inpt[1].v.position; + edgeVerts[2] = ProjectionMatrix * inpt[2].v.position; + edgeVerts[3] = ProjectionMatrix * inpt[3].v.position; edgeVerts[0].xy /= edgeVerts[0].w; edgeVerts[1].xy /= edgeVerts[1].w; @@ -205,15 +205,15 @@ void main() #endif // PRIM_QUAD #ifdef PRIM_TRI - vec3 A = (input[1].v.position - input[0].v.position).xyz; - vec3 B = (input[2].v.position - input[0].v.position).xyz; + vec3 A = (inpt[1].v.position - inpt[0].v.position).xyz; + vec3 B = (inpt[2].v.position - inpt[0].v.position).xyz; vec3 n0 = normalize(cross(B, A)); #if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE) vec4 edgeVerts[EDGE_VERTS]; - edgeVerts[0] = ProjectionMatrix * input[0].v.position; - edgeVerts[1] = ProjectionMatrix * input[1].v.position; - edgeVerts[2] = ProjectionMatrix * input[2].v.position; + edgeVerts[0] = ProjectionMatrix * inpt[0].v.position; + edgeVerts[1] = ProjectionMatrix * inpt[1].v.position; + edgeVerts[2] = ProjectionMatrix * inpt[2].v.position; edgeVerts[0].xy /= edgeVerts[0].w; edgeVerts[1].xy /= edgeVerts[1].w; @@ -241,7 +241,7 @@ void main() in block { OutputVertex v; -} input; +} inpt; out vec4 outColor; @@ -303,12 +303,12 @@ edgeColor(vec4 Cfill, vec4 edgeDistance) #if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE) #ifdef PRIM_TRI float d = - min(input.v.edgeDistance[0], min(input.v.edgeDistance[1], input.v.edgeDistance[2])); + min(inpt.v.edgeDistance[0], min(inpt.v.edgeDistance[1], inpt.v.edgeDistance[2])); #endif #ifdef PRIM_QUAD float d = - min(min(input.v.edgeDistance[0], input.v.edgeDistance[1]), - min(input.v.edgeDistance[2], input.v.edgeDistance[3])); + min(min(inpt.v.edgeDistance[0], inpt.v.edgeDistance[1]), + min(inpt.v.edgeDistance[2], inpt.v.edgeDistance[3])); #endif vec4 Cedge = vec4(1.0, 1.0, 0.0, 1.0); float p = exp2(-2 * d * d); @@ -326,11 +326,11 @@ edgeColor(vec4 Cfill, vec4 edgeDistance) void main() { - vec3 N = (gl_FrontFacing ? input.v.normal : -input.v.normal); - vec4 Cf = lighting(input.v.position.xyz, N); + vec3 N = (gl_FrontFacing ? inpt.v.normal : -inpt.v.normal); + vec4 Cf = lighting(inpt.v.position.xyz, N); #if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE) - Cf = edgeColor(Cf, input.v.edgeDistance); + Cf = edgeColor(Cf, inpt.v.edgeDistance); #endif outColor = Cf; diff --git a/examples/glViewer/shader.glsl b/examples/glViewer/shader.glsl index f921689f..fd419faf 100644 --- a/examples/glViewer/shader.glsl +++ b/examples/glViewer/shader.glsl @@ -65,12 +65,12 @@ layout (location=1) in vec3 normal; out block { OutputVertex v; -} output; +} outpt; void main() { - output.v.position = ModelViewMatrix * position; - output.v.normal = (ModelViewMatrix * vec4(normal, 0.0)).xyz; + outpt.v.position = ModelViewMatrix * position; + outpt.v.normal = (ModelViewMatrix * vec4(normal, 0.0)).xyz; } #endif @@ -90,7 +90,7 @@ void main() in block { OutputVertex v; - } input[4]; + } inpt[4]; #endif // PRIM_QUAD @@ -104,7 +104,7 @@ void main() in block { OutputVertex v; - } input[3]; + } inpt[3]; #endif // PRIM_TRI @@ -115,23 +115,23 @@ void main() in block { OutputVertex v; - } input[1]; + } inpt[1]; #endif // PRIM_POINT out block { OutputVertex v; -} output; +} outpt; void emit(int index, vec3 normal) { - output.v.position = input[index].v.position; + outpt.v.position = inpt[index].v.position; #ifdef SMOOTH_NORMALS - output.v.normal = input[index].v.normal; + outpt.v.normal = inpt[index].v.normal; #else - output.v.normal = normal; + outpt.v.normal = normal; #endif - gl_Position = ProjectionMatrix * input[index].v.position; + gl_Position = ProjectionMatrix * inpt[index].v.position; EmitVertex(); } @@ -147,18 +147,18 @@ float edgeDistance(vec4 p, vec4 p0, vec4 p1) void emit(int index, vec3 normal, vec4 edgeVerts[EDGE_VERTS]) { - output.v.edgeDistance[0] = + outpt.v.edgeDistance[0] = edgeDistance(edgeVerts[index], edgeVerts[0], edgeVerts[1]); - output.v.edgeDistance[1] = + outpt.v.edgeDistance[1] = edgeDistance(edgeVerts[index], edgeVerts[1], edgeVerts[2]); #ifdef PRIM_TRI - output.v.edgeDistance[2] = + outpt.v.edgeDistance[2] = edgeDistance(edgeVerts[index], edgeVerts[2], edgeVerts[0]); #endif #ifdef PRIM_QUAD - output.v.edgeDistance[2] = + outpt.v.edgeDistance[2] = edgeDistance(edgeVerts[index], edgeVerts[2], edgeVerts[3]); - output.v.edgeDistance[3] = + outpt.v.edgeDistance[3] = edgeDistance(edgeVerts[index], edgeVerts[3], edgeVerts[0]); #endif @@ -175,17 +175,17 @@ void main() #endif #ifdef PRIM_QUAD - vec3 A = (input[0].v.position - input[1].v.position).xyz; - vec3 B = (input[3].v.position - input[1].v.position).xyz; - vec3 C = (input[2].v.position - input[1].v.position).xyz; + vec3 A = (inpt[0].v.position - inpt[1].v.position).xyz; + vec3 B = (inpt[3].v.position - inpt[1].v.position).xyz; + vec3 C = (inpt[2].v.position - inpt[1].v.position).xyz; vec3 n0 = normalize(cross(B, A)); #if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE) vec4 edgeVerts[EDGE_VERTS]; - edgeVerts[0] = ProjectionMatrix * input[0].v.position; - edgeVerts[1] = ProjectionMatrix * input[1].v.position; - edgeVerts[2] = ProjectionMatrix * input[2].v.position; - edgeVerts[3] = ProjectionMatrix * input[3].v.position; + edgeVerts[0] = ProjectionMatrix * inpt[0].v.position; + edgeVerts[1] = ProjectionMatrix * inpt[1].v.position; + edgeVerts[2] = ProjectionMatrix * inpt[2].v.position; + edgeVerts[3] = ProjectionMatrix * inpt[3].v.position; edgeVerts[0].xy /= edgeVerts[0].w; edgeVerts[1].xy /= edgeVerts[1].w; @@ -205,15 +205,15 @@ void main() #endif // PRIM_QUAD #ifdef PRIM_TRI - vec3 A = (input[1].v.position - input[0].v.position).xyz; - vec3 B = (input[2].v.position - input[0].v.position).xyz; + vec3 A = (inpt[1].v.position - inpt[0].v.position).xyz; + vec3 B = (inpt[2].v.position - inpt[0].v.position).xyz; vec3 n0 = normalize(cross(B, A)); #if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE) vec4 edgeVerts[EDGE_VERTS]; - edgeVerts[0] = ProjectionMatrix * input[0].v.position; - edgeVerts[1] = ProjectionMatrix * input[1].v.position; - edgeVerts[2] = ProjectionMatrix * input[2].v.position; + edgeVerts[0] = ProjectionMatrix * inpt[0].v.position; + edgeVerts[1] = ProjectionMatrix * inpt[1].v.position; + edgeVerts[2] = ProjectionMatrix * inpt[2].v.position; edgeVerts[0].xy /= edgeVerts[0].w; edgeVerts[1].xy /= edgeVerts[1].w; @@ -241,7 +241,7 @@ void main() in block { OutputVertex v; -} input; +} inpt; out vec4 outColor; @@ -303,12 +303,12 @@ edgeColor(vec4 Cfill, vec4 edgeDistance) #if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE) #ifdef PRIM_TRI float d = - min(input.v.edgeDistance[0], min(input.v.edgeDistance[1], input.v.edgeDistance[2])); + min(inpt.v.edgeDistance[0], min(inpt.v.edgeDistance[1], inpt.v.edgeDistance[2])); #endif #ifdef PRIM_QUAD float d = - min(min(input.v.edgeDistance[0], input.v.edgeDistance[1]), - min(input.v.edgeDistance[2], input.v.edgeDistance[3])); + min(min(inpt.v.edgeDistance[0], inpt.v.edgeDistance[1]), + min(inpt.v.edgeDistance[2], inpt.v.edgeDistance[3])); #endif vec4 Cedge = vec4(1.0, 1.0, 0.0, 1.0); float p = exp2(-2 * d * d); @@ -326,11 +326,11 @@ edgeColor(vec4 Cfill, vec4 edgeDistance) void main() { - vec3 N = (gl_FrontFacing ? input.v.normal : -input.v.normal); - vec4 Cf = lighting(input.v.position.xyz, N); + vec3 N = (gl_FrontFacing ? inpt.v.normal : -inpt.v.normal); + vec4 Cf = lighting(inpt.v.position.xyz, N); #if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE) - Cf = edgeColor(Cf, input.v.edgeDistance); + Cf = edgeColor(Cf, inpt.v.edgeDistance); #endif outColor = Cf; diff --git a/examples/mayaPtexViewer/shader.glsl b/examples/mayaPtexViewer/shader.glsl index 89cf01c4..ad4ff50a 100644 --- a/examples/mayaPtexViewer/shader.glsl +++ b/examples/mayaPtexViewer/shader.glsl @@ -94,11 +94,11 @@ vec4 PTexLookup(vec4 patchCoord, #ifdef USE_PTEX_DISPLACEMENT -#define OSD_DISPLACEMENT_CALLBACK \ - output.v.position = \ - displacement(output.v.position, \ - output.v.normal, \ - output.v.patchCoord); +#define OSD_DISPLACEMENT_CALLBACK \ + outpt.v.position = \ + displacement(outpt.v.position, \ + outpt.v.normal, \ + outpt.v.patchCoord); uniform sampler2DArray textureDisplace_Data; uniform samplerBuffer textureDisplace_Packing; @@ -124,12 +124,12 @@ layout (location=1) in vec3 normal; out block { OutputVertex v; -} output; +} outpt; void main() { - output.v.position = vec4(position, 1); - output.v.normal = normal; + outpt.v.position = vec4(position, 1); + outpt.v.normal = normal; } #endif // VERTEX_SHADER @@ -153,7 +153,7 @@ void main() in block { OutputVertex v; - } input[4]; + } inpt[4]; #endif // PRIM_QUAD @@ -171,23 +171,23 @@ void main() in block { OutputVertex v; - } input[3]; + } inpt[3]; #endif // PRIM_TRI out block { OutputVertex v; -} output; +} outpt; void emit(int index, vec4 position, vec3 normal, vec4 patchCoord) { - output.v.position = position; - output.v.normal = normal; - output.v.patchCoord = patchCoord; + outpt.v.position = position; + outpt.v.normal = normal; + outpt.v.patchCoord = patchCoord; - output.v.tangent = input[index].v.tangent; + outpt.v.tangent = inpt[index].v.tangent; - gl_Position = ProjectionMatrix * output.v.position; + gl_Position = ProjectionMatrix * outpt.v.position; EmitVertex(); } @@ -210,15 +210,15 @@ void main() patchCoord[3] = GeneratePatchCoord(vec2(0, 1)); #ifdef USE_PTEX_DISPLACEMENT - position[0] = displacement(input[0].v.position, input[0].v.normal, patchCoord[0]); - position[1] = displacement(input[1].v.position, input[1].v.normal, patchCoord[1]); - position[2] = displacement(input[2].v.position, input[2].v.normal, patchCoord[2]); - position[3] = displacement(input[3].v.position, input[3].v.normal, patchCoord[3]); + position[0] = displacement(inpt[0].v.position, inpt[0].v.normal, patchCoord[0]); + position[1] = displacement(inpt[1].v.position, inpt[1].v.normal, patchCoord[1]); + position[2] = displacement(inpt[2].v.position, inpt[2].v.normal, patchCoord[2]); + position[3] = displacement(inpt[3].v.position, inpt[3].v.normal, patchCoord[3]); #else - position[0] = input[0].v.position; - position[1] = input[1].v.position; - position[2] = input[2].v.position; - position[3] = input[3].v.position; + position[0] = inpt[0].v.position; + position[1] = inpt[1].v.position; + position[2] = inpt[2].v.position; + position[3] = inpt[3].v.position; #endif #ifdef FLAT_NORMALS @@ -231,10 +231,10 @@ void main() normal[2] = normal[0]; normal[3] = normal[0]; #else - normal[0] = input[0].v.normal; - normal[1] = input[1].v.normal; - normal[2] = input[2].v.normal; - normal[3] = input[3].v.normal; + normal[0] = inpt[0].v.normal; + normal[1] = inpt[1].v.normal; + normal[2] = inpt[2].v.normal; + normal[3] = inpt[3].v.normal; #endif emit(0, position[0], normal[0], patchCoord[0]); @@ -257,18 +257,18 @@ void main() vec3 normal[3]; // patch coords are computed in tessellation shader - patchCoord[0] = input[0].v.patchCoord; - patchCoord[1] = input[1].v.patchCoord; - patchCoord[2] = input[2].v.patchCoord; + patchCoord[0] = inpt[0].v.patchCoord; + patchCoord[1] = inpt[1].v.patchCoord; + patchCoord[2] = inpt[2].v.patchCoord; #ifdef USE_PTEX_DISPLACEMENT - position[0] = displacement(input[0].v.position, input[0].v.normal, patchCoord[0]); - position[1] = displacement(input[1].v.position, input[1].v.normal, patchCoord[1]); - position[2] = displacement(input[2].v.position, input[2].v.normal, patchCoord[2]); + position[0] = displacement(inpt[0].v.position, inpt[0].v.normal, patchCoord[0]); + position[1] = displacement(inpt[1].v.position, inpt[1].v.normal, patchCoord[1]); + position[2] = displacement(inpt[2].v.position, inpt[2].v.normal, patchCoord[2]); #else - position[0] = input[0].v.position; - position[1] = input[1].v.position; - position[2] = input[2].v.position; + position[0] = inpt[0].v.position; + position[1] = inpt[1].v.position; + position[2] = inpt[2].v.position; #endif #ifdef FLAT_NORMALS // emit flat normals for displaced surface @@ -278,9 +278,9 @@ void main() normal[1] = normal[0]; normal[2] = normal[0]; #else - normal[0] = input[0].v.normal; - normal[1] = input[1].v.normal; - normal[2] = input[2].v.normal; + normal[0] = inpt[0].v.normal; + normal[1] = inpt[1].v.normal; + normal[2] = inpt[2].v.normal; #endif emit(0, position[0], normal[0], patchCoord[0]); @@ -303,7 +303,7 @@ void main() in block { OutputVertex v; -} input; +} inpt; uniform int ptexFaceOffset; @@ -398,7 +398,7 @@ void main() { #ifdef USE_PTEX_COLOR - vec4 texColor = PTexLookup(input.v.patchCoord, + vec4 texColor = PTexLookup(inpt.v.patchCoord, textureImage_Data, textureImage_Packing, textureImage_Pages); @@ -407,16 +407,16 @@ main() #endif #if USE_PTEX_NORMAL - vec3 objN = perturbNormalFromDisplacement(input.v.position.xyz, - input.v.normal, - input.v.patchCoord); + vec3 objN = perturbNormalFromDisplacement(inpt.v.position.xyz, + inpt.v.normal, + inpt.v.patchCoord); #else - vec3 objN = input.v.normal; + vec3 objN = inpt.v.normal; #endif #ifdef USE_PTEX_OCCLUSION - float occ = PTexLookup(input.v.patchCoord, + float occ = PTexLookup(inpt.v.patchCoord, textureOcclusion_Data, textureOcclusion_Packing, textureOcclusion_Pages).x; @@ -432,7 +432,7 @@ main() vec4 d = vec4(1); #endif - vec3 eye = normalize(input.v.position.xyz - eyePositionInWorld); + vec3 eye = normalize(inpt.v.position.xyz - eyePositionInWorld); #ifdef USE_SPECULAR_ENV_MAP vec3 reflect = reflect(eye, objN); diff --git a/examples/mayaViewer/shader.glsl b/examples/mayaViewer/shader.glsl index 1e4c8ffa..b574a785 100644 --- a/examples/mayaViewer/shader.glsl +++ b/examples/mayaViewer/shader.glsl @@ -65,11 +65,11 @@ layout (location=0) in vec4 position; out block { OutputVertex v; -} output; +} outpt; void main() { - output.v.position = ModelViewMatrix * position; + outpt.v.position = ModelViewMatrix * position; } #endif // VERTEX_SHADER @@ -95,7 +95,7 @@ uniform samplerBuffer g_uvFVarBuffer; in block { OutputVertex v; - } input[4]; + } inpt[4]; #endif // PRIM_QUAD @@ -113,7 +113,7 @@ uniform samplerBuffer g_uvFVarBuffer; in block { OutputVertex v; - } input[3]; + } inpt[3]; #endif // PRIM_TRI @@ -124,21 +124,21 @@ uniform samplerBuffer g_uvFVarBuffer; in block { OutputVertex v; - } input[1]; + } inpt[1]; #endif // PRIM_POINT out block { OutputVertex v; -} output; +} outpt; void emitUniform(int index, vec3 normal) { - output.v.position = input[index].v.position; + outpt.v.position = inpt[index].v.position; #ifdef SMOOTH_NORMALS - output.v.normal = input[index].v.normal; + outpt.v.normal = inpt[index].v.normal; #else - output.v.normal = normal; + outpt.v.normal = normal; #endif // We fetch each uv component separately since the texture buffer @@ -151,32 +151,32 @@ void emitUniform(int index, vec3 normal) // prim 0 prim 1 int uvOffset = gl_PrimitiveID * 4; - output.v.patchCoord.st = + outpt.v.patchCoord.st = vec2( texelFetch( g_uvFVarBuffer, (uvOffset+index)*2 ).s, texelFetch( g_uvFVarBuffer, (uvOffset+index)*2+1 ).s ); - gl_Position = ProjectionMatrix * input[index].v.position; + gl_Position = ProjectionMatrix * inpt[index].v.position; EmitVertex(); } void emitAdaptive(int index, vec3 normal, vec2 uvs[4]) { - output.v.position = input[index].v.position; + outpt.v.position = inpt[index].v.position; #ifdef SMOOTH_NORMALS - output.v.normal = input[index].v.normal; + outpt.v.normal = inpt[index].v.normal; #else - output.v.normal = normal; + outpt.v.normal = normal; #endif // Bi-linear interpolation within the patch - output.v.patchCoord = input[index].v.patchCoord; - vec2 st = input[index].v.tessCoord; - output.v.patchCoord.st = + outpt.v.patchCoord = inpt[index].v.patchCoord; + vec2 st = inpt[index].v.tessCoord; + outpt.v.patchCoord.st = vec2( mix( mix(uvs[0].x, uvs[1].x, st.s ), mix(uvs[3].x, uvs[2].x, st.s ), st.t), mix( mix(uvs[0].y, uvs[1].y, st.s ), mix(uvs[3].y, uvs[2].y, st.s ), st.t) ); - gl_Position = ProjectionMatrix * input[index].v.position; + gl_Position = ProjectionMatrix * inpt[index].v.position; EmitVertex(); } @@ -221,8 +221,8 @@ void main() #elif defined ( PRIM_TRI) - vec3 A = (input[1].v.position - input[0].v.position).xyz; - vec3 B = (input[2].v.position - input[0].v.position).xyz; + vec3 A = (inpt[1].v.position - inpt[0].v.position).xyz; + vec3 B = (inpt[2].v.position - inpt[0].v.position).xyz; n0 = normalize(cross(B, A)); #ifdef FVAR_ADAPTIVE emitAdaptive(0, n0, uvs); @@ -245,9 +245,9 @@ void main() #elif defined ( PRIM_QUAD ) - vec3 A = (input[0].v.position - input[1].v.position).xyz; - vec3 B = (input[3].v.position - input[1].v.position).xyz; - //vec3 C = (input[2].v.position - input[1].v.position).xyz; + vec3 A = (inpt[0].v.position - inpt[1].v.position).xyz; + vec3 B = (inpt[3].v.position - inpt[1].v.position).xyz; + //vec3 C = (inpt[2].v.position - inpt[1].v.position).xyz; n0 = normalize(cross(B, A)); #ifdef GEOMETRY_OUT_FILL @@ -279,7 +279,7 @@ uniform sampler2D diffuseMap; in block { OutputVertex v; -} input; +} inpt; #define NUM_LIGHTS 2 @@ -349,12 +349,12 @@ main() void main() { - vec3 N = (gl_FrontFacing ? input.v.normal : -input.v.normal); + vec3 N = (gl_FrontFacing ? inpt.v.normal : -inpt.v.normal); #ifdef USE_DIFFUSE_MAP - vec4 texColor = texture(diffuseMap, input.v.patchCoord.st); - gl_FragColor = lighting(input.v.position.xyz, N, texColor); + vec4 texColor = texture(diffuseMap, inpt.v.patchCoord.st); + gl_FragColor = lighting(inpt.v.position.xyz, N, texColor); #else - gl_FragColor = lighting(input.v.position.xyz, N, vec4(1.0)); + gl_FragColor = lighting(inpt.v.position.xyz, N, vec4(1.0)); #endif } #endif // GEOMETRY_OUT_LINE diff --git a/examples/paintTest/paintShader.glsl b/examples/paintTest/paintShader.glsl index 47de444d..02a3e77a 100644 --- a/examples/paintTest/paintShader.glsl +++ b/examples/paintTest/paintShader.glsl @@ -94,11 +94,11 @@ layout (location=0) in vec4 position; out block { OutputVertex v; -} output; +} outpt; void main() { - output.v.position = ModelViewMatrix * position; + outpt.v.position = ModelViewMatrix * position; } #endif @@ -114,19 +114,19 @@ layout(triangle_strip, max_vertices = 3) out; in block { OutputVertex v; -} input[3]; +} inpt[3]; out block { OutputVertex v; vec4 depthPosition; -} output; +} outpt; void emit(int index, vec4 position) { - vec2 uv = vec2(input[index].v.patchCoord.xy); - output.v.position = ProjectionMatrix * position; - output.depthPosition = ProjectionWithoutPickMatrix * position; - output.v.patchCoord = input[index].v.patchCoord; + vec2 uv = vec2(inpt[index].v.patchCoord.xy); + outpt.v.position = ProjectionMatrix * position; + outpt.depthPosition = ProjectionWithoutPickMatrix * position; + outpt.v.patchCoord = inpt[index].v.patchCoord; gl_Position = vec4(uv*2-vec2(1.0), 0, 1); EmitVertex(); } @@ -139,18 +139,18 @@ void main() vec4 position[3]; // patch coords are computed in tessellation shader - patchCoord[0] = input[0].v.patchCoord; - patchCoord[1] = input[1].v.patchCoord; - patchCoord[2] = input[2].v.patchCoord; + patchCoord[0] = inpt[0].v.patchCoord; + patchCoord[1] = inpt[1].v.patchCoord; + patchCoord[2] = inpt[2].v.patchCoord; #ifdef USE_PTEX_DISPLACEMENT - position[0] = displacement(input[0].v.position, input[0].v.normal, patchCoord[0]); - position[1] = displacement(input[1].v.position, input[1].v.normal, patchCoord[1]); - position[2] = displacement(input[2].v.position, input[2].v.normal, patchCoord[2]); + position[0] = displacement(inpt[0].v.position, inpt[0].v.normal, patchCoord[0]); + position[1] = displacement(inpt[1].v.position, inpt[1].v.normal, patchCoord[1]); + position[2] = displacement(inpt[2].v.position, inpt[2].v.normal, patchCoord[2]); #else - position[0] = input[0].v.position; - position[1] = input[1].v.position; - position[2] = input[2].v.position; + position[0] = inpt[0].v.position; + position[1] = inpt[1].v.position; + position[2] = inpt[2].v.position; #endif emit(0, position[0]); @@ -169,7 +169,7 @@ void main() in block { OutputVertex v; vec4 depthPosition; -} input; +} inpt; layout(size1x32) uniform image2DArray outTextureImage; uniform sampler2D paintTexture; @@ -179,10 +179,10 @@ uniform int imageSize = 256; void main() { - vec4 p = input.v.position; + vec4 p = inpt.v.position; p.xyz /= p.w; - vec4 wp = input.depthPosition; + vec4 wp = inpt.depthPosition; wp.z -= 0.001; wp.xyz /= wp.w; @@ -190,9 +190,9 @@ main() float depth = texture(depthTexture, wp.xy*0.5+0.5).x; if (wp.z*0.5+0.5 >= depth) return; - ivec3 pos = ivec3(input.v.patchCoord.x * imageSize, - input.v.patchCoord.y * imageSize, - int(input.v.patchCoord.w)); + ivec3 pos = ivec3(inpt.v.patchCoord.x * imageSize, + inpt.v.patchCoord.y * imageSize, + int(inpt.v.patchCoord.w)); vec4 d = imageLoad(outTextureImage, pos); c = c + d; diff --git a/examples/paintTest/shader.glsl b/examples/paintTest/shader.glsl index 150521d6..93ec142e 100644 --- a/examples/paintTest/shader.glsl +++ b/examples/paintTest/shader.glsl @@ -97,19 +97,19 @@ vec4 displacement(vec4 position, vec3 normal, vec4 patchCoord) in block { OutputVertex v; - } input[3]; + } inpt[3]; out block { OutputVertex v; -} output; +} outpt; void emit(int index, vec4 position, vec3 normal, vec4 patchCoord) { - output.v.position = position; - output.v.patchCoord = patchCoord; - output.v.normal = normal; + outpt.v.position = position; + outpt.v.patchCoord = patchCoord; + outpt.v.normal = normal; - gl_Position = ProjectionMatrix * output.v.position; + gl_Position = ProjectionMatrix * outpt.v.position; EmitVertex(); } @@ -124,11 +124,11 @@ float edgeDistance(vec4 p, vec4 p0, vec4 p1) void emit(int index, vec4 position, vec3 normal, vec4 patchCoord, vec4 edgeVerts[EDGE_VERTS]) { - output.v.edgeDistance[0] = + outpt.v.edgeDistance[0] = edgeDistance(edgeVerts[index], edgeVerts[0], edgeVerts[1]); - output.v.edgeDistance[1] = + outpt.v.edgeDistance[1] = edgeDistance(edgeVerts[index], edgeVerts[1], edgeVerts[2]); - output.v.edgeDistance[2] = + outpt.v.edgeDistance[2] = edgeDistance(edgeVerts[index], edgeVerts[2], edgeVerts[0]); emit(index, position, normal, patchCoord); } @@ -144,29 +144,29 @@ void main() vec3 normal[3]; // patch coords are computed in tessellation shader - patchCoord[0] = input[0].v.patchCoord; - patchCoord[1] = input[1].v.patchCoord; - patchCoord[2] = input[2].v.patchCoord; + patchCoord[0] = inpt[0].v.patchCoord; + patchCoord[1] = inpt[1].v.patchCoord; + patchCoord[2] = inpt[2].v.patchCoord; #ifdef USE_PTEX_DISPLACEMENT - position[0] = displacement(input[0].v.position, input[0].v.normal, patchCoord[0]); - position[1] = displacement(input[1].v.position, input[1].v.normal, patchCoord[1]); - position[2] = displacement(input[2].v.position, input[2].v.normal, patchCoord[2]); + position[0] = displacement(inpt[0].v.position, inpt[0].v.normal, patchCoord[0]); + position[1] = displacement(inpt[1].v.position, inpt[1].v.normal, patchCoord[1]); + position[2] = displacement(inpt[2].v.position, inpt[2].v.normal, patchCoord[2]); #else - position[0] = input[0].v.position; - position[1] = input[1].v.position; - position[2] = input[2].v.position; + position[0] = inpt[0].v.position; + position[1] = inpt[1].v.position; + position[2] = inpt[2].v.position; #endif - normal[0] = input[0].v.normal; - normal[1] = input[1].v.normal; - normal[2] = input[2].v.normal; + normal[0] = inpt[0].v.normal; + normal[1] = inpt[1].v.normal; + normal[2] = inpt[2].v.normal; #if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE) vec4 edgeVerts[EDGE_VERTS]; - edgeVerts[0] = ProjectionMatrix * input[0].v.position; - edgeVerts[1] = ProjectionMatrix * input[1].v.position; - edgeVerts[2] = ProjectionMatrix * input[2].v.position; + edgeVerts[0] = ProjectionMatrix * inpt[0].v.position; + edgeVerts[1] = ProjectionMatrix * inpt[1].v.position; + edgeVerts[2] = ProjectionMatrix * inpt[2].v.position; edgeVerts[0].xy /= edgeVerts[0].w; edgeVerts[1].xy /= edgeVerts[1].w; @@ -193,7 +193,7 @@ void main() in block { OutputVertex v; -} input; +} inpt; out vec4 outColor; @@ -281,7 +281,7 @@ edgeColor(vec4 Cfill, vec4 edgeDistance) { #if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE) float d = - min(input.v.edgeDistance[0], min(input.v.edgeDistance[1], input.v.edgeDistance[2])); + min(inpt.v.edgeDistance[0], min(inpt.v.edgeDistance[1], inpt.v.edgeDistance[2])); vec4 Cedge = vec4(0.5, 0.5, 0.5, 1.0); float p = exp2(-2 * d * d); @@ -297,26 +297,26 @@ edgeColor(vec4 Cfill, vec4 edgeDistance) void main() { - vec3 N = (gl_FrontFacing ? input.v.normal : -input.v.normal); + vec3 N = (gl_FrontFacing ? inpt.v.normal : -inpt.v.normal); #ifdef USE_PTEX_DISPLACEMENT - N = perturbNormalFromDisplacement(input.v.position.xyz, + N = perturbNormalFromDisplacement(inpt.v.position.xyz, N, - input.v.patchCoord); + inpt.v.patchCoord); #endif vec4 Cf = vec4(1.0); #if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE) - Cf = edgeColor(Cf, input.v.edgeDistance); + Cf = edgeColor(Cf, inpt.v.edgeDistance); #endif #ifdef USE_PTEX_COLOR - Cf = Cf * (vec4(1) - vec4(PTexLookup(input.v.patchCoord, + Cf = Cf * (vec4(1) - vec4(PTexLookup(inpt.v.patchCoord, textureImage_Data, textureImage_Packing, textureImage_Pages).x)); #endif - Cf = lighting(Cf, input.v.position.xyz, N); + Cf = lighting(Cf, inpt.v.position.xyz, N); outColor = Cf; } diff --git a/examples/ptexViewer/shader.glsl b/examples/ptexViewer/shader.glsl index feca0551..5cf8fc7d 100644 --- a/examples/ptexViewer/shader.glsl +++ b/examples/ptexViewer/shader.glsl @@ -94,11 +94,11 @@ vec4 PTexLookup(vec4 patchCoord, #ifdef USE_PTEX_DISPLACEMENT -#define OSD_DISPLACEMENT_CALLBACK \ - output.v.position = \ - displacement(output.v.position, \ - output.v.normal, \ - output.v.patchCoord); +#define OSD_DISPLACEMENT_CALLBACK \ + outpt.v.position = \ + displacement(outpt.v.position, \ + outpt.v.normal, \ + outpt.v.patchCoord); uniform sampler2DArray textureDisplace_Data; uniform samplerBuffer textureDisplace_Packing; @@ -124,12 +124,12 @@ layout (location=1) in vec3 normal; out block { OutputVertex v; -} output; +} outpt; void main() { - output.v.position = ModelViewMatrix * position; - output.v.normal = (ModelViewMatrix * vec4(normal, 0)).xyz; + outpt.v.position = ModelViewMatrix * position; + outpt.v.normal = (ModelViewMatrix * vec4(normal, 0)).xyz; } #endif @@ -151,7 +151,7 @@ void main() in block { OutputVertex v; - } input[4]; + } inpt[4]; #endif // PRIM_QUAD @@ -165,23 +165,23 @@ void main() in block { OutputVertex v; - } input[3]; + } inpt[3]; #endif // PRIM_TRI out block { OutputVertex v; -} output; +} outpt; // -------------------------------------- void emit(vec4 position, vec3 normal, vec4 patchCoord) { - output.v.position = position; - output.v.patchCoord = patchCoord; - output.v.normal = normal; + outpt.v.position = position; + outpt.v.patchCoord = patchCoord; + outpt.v.normal = normal; - gl_Position = ProjectionMatrix * output.v.position; + gl_Position = ProjectionMatrix * outpt.v.position; EmitVertex(); } @@ -196,18 +196,18 @@ float edgeDistance(vec4 p, vec4 p0, vec4 p1) void emit(int index, vec4 position, vec3 normal, vec4 patchCoord, vec4 edgeVerts[EDGE_VERTS]) { - output.v.edgeDistance[0] = + outpt.v.edgeDistance[0] = edgeDistance(edgeVerts[index], edgeVerts[0], edgeVerts[1]); - output.v.edgeDistance[1] = + outpt.v.edgeDistance[1] = edgeDistance(edgeVerts[index], edgeVerts[1], edgeVerts[2]); #ifdef PRIM_TRI - output.v.edgeDistance[2] = + outpt.v.edgeDistance[2] = edgeDistance(edgeVerts[index], edgeVerts[2], edgeVerts[0]); #endif #ifdef PRIM_QUAD - output.v.edgeDistance[2] = + outpt.v.edgeDistance[2] = edgeDistance(edgeVerts[index], edgeVerts[2], edgeVerts[3]); - output.v.edgeDistance[3] = + outpt.v.edgeDistance[3] = edgeDistance(edgeVerts[index], edgeVerts[3], edgeVerts[0]); #endif @@ -232,15 +232,15 @@ void main() patchCoord[3] = GeneratePatchCoord(vec2(0, 1)); #ifdef USE_PTEX_DISPLACEMENT - position[0] = displacement(input[0].v.position, input[0].v.normal, patchCoord[0]); - position[1] = displacement(input[1].v.position, input[1].v.normal, patchCoord[1]); - position[2] = displacement(input[2].v.position, input[2].v.normal, patchCoord[2]); - position[3] = displacement(input[3].v.position, input[3].v.normal, patchCoord[3]); + position[0] = displacement(inpt[0].v.position, inpt[0].v.normal, patchCoord[0]); + position[1] = displacement(inpt[1].v.position, inpt[1].v.normal, patchCoord[1]); + position[2] = displacement(inpt[2].v.position, inpt[2].v.normal, patchCoord[2]); + position[3] = displacement(inpt[3].v.position, inpt[3].v.normal, patchCoord[3]); #else - position[0] = input[0].v.position; - position[1] = input[1].v.position; - position[2] = input[2].v.position; - position[3] = input[3].v.position; + position[0] = inpt[0].v.position; + position[1] = inpt[1].v.position; + position[2] = inpt[2].v.position; + position[3] = inpt[3].v.position; #endif #ifdef FLAT_NORMALS @@ -253,18 +253,18 @@ void main() normal[2] = normal[0]; normal[3] = normal[0]; #else - normal[0] = input[0].v.normal; - normal[1] = input[1].v.normal; - normal[2] = input[2].v.normal; - normal[3] = input[3].v.normal; + normal[0] = inpt[0].v.normal; + normal[1] = inpt[1].v.normal; + normal[2] = inpt[2].v.normal; + normal[3] = inpt[3].v.normal; #endif #if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE) vec4 edgeVerts[EDGE_VERTS]; - edgeVerts[0] = ProjectionMatrix * input[0].v.position; - edgeVerts[1] = ProjectionMatrix * input[1].v.position; - edgeVerts[2] = ProjectionMatrix * input[2].v.position; - edgeVerts[3] = ProjectionMatrix * input[3].v.position; + edgeVerts[0] = ProjectionMatrix * inpt[0].v.position; + edgeVerts[1] = ProjectionMatrix * inpt[1].v.position; + edgeVerts[2] = ProjectionMatrix * inpt[2].v.position; + edgeVerts[3] = ProjectionMatrix * inpt[3].v.position; edgeVerts[0].xy /= edgeVerts[0].w; edgeVerts[1].xy /= edgeVerts[1].w; @@ -289,18 +289,18 @@ void main() vec3 normal[3]; // patch coords are computed in tessellation shader - patchCoord[0] = input[0].v.patchCoord; - patchCoord[1] = input[1].v.patchCoord; - patchCoord[2] = input[2].v.patchCoord; + patchCoord[0] = inpt[0].v.patchCoord; + patchCoord[1] = inpt[1].v.patchCoord; + patchCoord[2] = inpt[2].v.patchCoord; #ifdef USE_PTEX_DISPLACEMENT - position[0] = displacement(input[0].v.position, input[0].v.normal, patchCoord[0]); - position[1] = displacement(input[1].v.position, input[1].v.normal, patchCoord[1]); - position[2] = displacement(input[2].v.position, input[2].v.normal, patchCoord[2]); + position[0] = displacement(inpt[0].v.position, inpt[0].v.normal, patchCoord[0]); + position[1] = displacement(inpt[1].v.position, inpt[1].v.normal, patchCoord[1]); + position[2] = displacement(inpt[2].v.position, inpt[2].v.normal, patchCoord[2]); #else - position[0] = input[0].v.position; - position[1] = input[1].v.position; - position[2] = input[2].v.position; + position[0] = inpt[0].v.position; + position[1] = inpt[1].v.position; + position[2] = inpt[2].v.position; #endif #ifdef FLAT_NORMALS // emit flat normals for displaced surface @@ -310,16 +310,16 @@ void main() normal[1] = normal[0]; normal[2] = normal[0]; #else - normal[0] = input[0].v.normal; - normal[1] = input[1].v.normal; - normal[2] = input[2].v.normal; + normal[0] = inpt[0].v.normal; + normal[1] = inpt[1].v.normal; + normal[2] = inpt[2].v.normal; #endif #if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE) vec4 edgeVerts[EDGE_VERTS]; - edgeVerts[0] = ProjectionMatrix * input[0].v.position; - edgeVerts[1] = ProjectionMatrix * input[1].v.position; - edgeVerts[2] = ProjectionMatrix * input[2].v.position; + edgeVerts[0] = ProjectionMatrix * inpt[0].v.position; + edgeVerts[1] = ProjectionMatrix * inpt[1].v.position; + edgeVerts[2] = ProjectionMatrix * inpt[2].v.position; edgeVerts[0].xy /= edgeVerts[0].w; edgeVerts[1].xy /= edgeVerts[1].w; @@ -346,7 +346,7 @@ void main() in block { OutputVertex v; -} input; +} inpt; out vec4 outColor; @@ -449,7 +449,7 @@ lighting(vec4 texColor, vec3 Peye, vec3 Neye) vec4 color = vec4(0); #ifdef USE_PTEX_OCCLUSION - float occ = PTexLookup(input.v.patchCoord, + float occ = PTexLookup(inpt.v.patchCoord, textureOcclusion_Data, textureOcclusion_Packing, textureOcclusion_Pages).x; @@ -487,12 +487,12 @@ edgeColor(vec4 Cfill, vec4 edgeDistance) #if defined(GEOMETRY_OUT_WIRE) || defined(GEOMETRY_OUT_LINE) #ifdef PRIM_TRI float d = - min(input.v.edgeDistance[0], min(input.v.edgeDistance[1], input.v.edgeDistance[2])); + min(inpt.v.edgeDistance[0], min(inpt.v.edgeDistance[1], inpt.v.edgeDistance[2])); #endif #ifdef PRIM_QUAD float d = - min(min(input.v.edgeDistance[0], input.v.edgeDistance[1]), - min(input.v.edgeDistance[2], input.v.edgeDistance[3])); + min(min(inpt.v.edgeDistance[0], inpt.v.edgeDistance[1]), + min(inpt.v.edgeDistance[2], inpt.v.edgeDistance[3])); #endif vec4 Cedge = vec4(1.0, 1.0, 0.0, 1.0); float p = exp2(-2 * d * d); @@ -510,7 +510,7 @@ void main() { #if USE_PTEX_COLOR - vec4 texColor = PTexLookup(input.v.patchCoord, + vec4 texColor = PTexLookup(inpt.v.patchCoord, textureImage_Data, textureImage_Packing, textureImage_Pages); @@ -520,23 +520,23 @@ main() #endif #if USE_PTEX_NORMAL - vec3 normal = perturbNormalFromDisplacement(input.v.position.xyz, - input.v.normal, - input.v.patchCoord); + vec3 normal = perturbNormalFromDisplacement(inpt.v.position.xyz, + inpt.v.normal, + inpt.v.patchCoord); #else - vec3 normal = input.v.normal; + vec3 normal = inpt.v.normal; #endif if (overrideColorEnable) { texColor = overrideColor; - vec4 Cf = lighting(texColor, input.v.position.xyz, normal); - outColor = edgeColor(Cf, input.v.edgeDistance); + vec4 Cf = lighting(texColor, inpt.v.position.xyz, normal); + outColor = edgeColor(Cf, inpt.v.edgeDistance); return; } #if USE_IBL #ifdef USE_PTEX_OCCLUSION - float occ = PTexLookup(input.v.patchCoord, + float occ = PTexLookup(inpt.v.patchCoord, textureOcclusion_Data, textureOcclusion_Packing, textureOcclusion_Pages).x; @@ -545,7 +545,7 @@ main() #endif #ifdef USE_PTEX_SPECULAR - float specular = PTexLookup(input.v.patchCoord, + float specular = PTexLookup(inpt.v.patchCoord, textureSpecular_Data, textureSpecular_Packing, textureSpecular_Pages).x; @@ -555,7 +555,7 @@ main() vec4 a = vec4(0, 0, 0, 1); //ambientColor; vec4 d = getEnvironmentHDR(diffuseEnvironmentMap, normal) * 1.4; - vec3 eye = normalize(input.v.position.xyz - vec3(0,0,0)); + vec3 eye = normalize(inpt.v.position.xyz - vec3(0,0,0)); vec3 reflect = reflect(eye, normal); vec4 s = getEnvironmentHDR(specularEnvironmentMap, reflect); const float fresnelBias = 0; @@ -569,10 +569,10 @@ main() vec4 Cf = (a + d) * texColor + s * 0.5; #else - vec4 Cf = lighting(texColor, input.v.position.xyz, normal); + vec4 Cf = lighting(texColor, inpt.v.position.xyz, normal); #endif - outColor = edgeColor(Cf, input.v.edgeDistance); + outColor = edgeColor(Cf, inpt.v.edgeDistance); } #endif diff --git a/examples/ptexViewer/shader_gl3.glsl b/examples/ptexViewer/shader_gl3.glsl index 248e4f3b..ae3126e1 100644 --- a/examples/ptexViewer/shader_gl3.glsl +++ b/examples/ptexViewer/shader_gl3.glsl @@ -86,11 +86,11 @@ vec4 PTexLookup(vec4 patchCoord, #ifdef USE_PTEX_DISPLACEMENT -#define OSD_DISPLACEMENT_CALLBACK \ - output.v.position = \ - displacement(output.v.position, \ - output.v.normal, \ - output.v.patchCoord); +#define OSD_DISPLACEMENT_CALLBACK \ + outpt.v.position = \ + displacement(outpt.v.position, \ + outpt.v.normal, \ + outpt.v.patchCoord); uniform sampler2DArray textureDisplace_Data; uniform samplerBuffer textureDisplace_Packing; diff --git a/opensubdiv/osd/glslPatchBoundary.glsl b/opensubdiv/osd/glslPatchBoundary.glsl index 3d280c07..0e28227a 100644 --- a/opensubdiv/osd/glslPatchBoundary.glsl +++ b/opensubdiv/osd/glslPatchBoundary.glsl @@ -64,15 +64,15 @@ layout (location=0) in vec4 position; out block { ControlVertex v; -} output; +} outpt; void main() { - output.v.position = ModelViewMatrix * position; + outpt.v.position = ModelViewMatrix * position; OSD_PATCH_CULL_COMPUTE_CLIPFLAGS(position); #if OSD_NUM_VARYINGS > 0 for (int i = 0; i < OSD_NUM_VARYINGS; ++i) - output.v.varyings[i] = varyings[i]; + outpt.v.varyings[i] = varyings[i]; #endif } @@ -87,11 +87,11 @@ layout(vertices = 16) out; in block { ControlVertex v; -} input[]; +} inpt[]; out block { ControlVertex v; -} output[]; +} outpt[]; #define ID gl_InvocationID @@ -107,7 +107,7 @@ void main() H[l] = vec3(0,0,0); for (int k=0; k<4; k++) { float c = Q[i][k]; - H[l] += c*input[l*4 + k].v.position.xyz; + H[l] += c*inpt[l*4 + k].v.position.xyz; } } @@ -116,13 +116,13 @@ void main() pos += B[j][k]*H[k]; } - output[ID].v.position = vec4(pos, 1.0); + outpt[ID].v.position = vec4(pos, 1.0); int patchLevel = GetPatchLevel(); // +0.5 to avoid interpolation error of integer value - output[ID].v.patchCoord = vec4(0, 0, - patchLevel+0.5, - gl_PrimitiveID+LevelBase+0.5); + outpt[ID].v.patchCoord = vec4(0, 0, + patchLevel+0.5, + gl_PrimitiveID+LevelBase+0.5); OSD_COMPUTE_PTEX_COORD_TESSCONTROL_SHADER; @@ -131,13 +131,13 @@ void main() #ifdef OSD_ENABLE_SCREENSPACE_TESSELLATION gl_TessLevelOuter[0] = - TessAdaptive(input[1].v.position.xyz, input[2].v.position.xyz, patchLevel); + TessAdaptive(inpt[1].v.position.xyz, inpt[2].v.position.xyz, patchLevel); gl_TessLevelOuter[1] = - TessAdaptive(input[2].v.position.xyz, input[6].v.position.xyz, patchLevel); + TessAdaptive(inpt[2].v.position.xyz, inpt[6].v.position.xyz, patchLevel); gl_TessLevelOuter[2] = - TessAdaptive(input[5].v.position.xyz, input[6].v.position.xyz, patchLevel); + TessAdaptive(inpt[5].v.position.xyz, inpt[6].v.position.xyz, patchLevel); gl_TessLevelOuter[3] = - TessAdaptive(input[1].v.position.xyz, input[5].v.position.xyz, patchLevel); + TessAdaptive(inpt[1].v.position.xyz, inpt[5].v.position.xyz, patchLevel); gl_TessLevelInner[0] = max(gl_TessLevelOuter[1], gl_TessLevelOuter[3]); gl_TessLevelInner[1] = @@ -166,11 +166,11 @@ layout(equal_spacing) in; in block { ControlVertex v; int clipFlag; -} input[]; +} inpt[]; out block { OutputVertex v; -} output; +} outpt; void main() { @@ -189,7 +189,7 @@ void main() DUCP[i] = vec3(0.0f, 0.0f, 0.0f); for (int j=0; j<4; ++j) { - vec3 A = input[4*i + j].v.position.xyz; + vec3 A = inpt[4*i + j].v.position.xyz; BUCP[i] += A * B[j]; DUCP[i] += A * D[j]; @@ -210,19 +210,19 @@ void main() */ vec3 WorldPos, Tangent, BiTangent; vec3 cp[16]; - for(int i = 0; i < 16; ++i) cp[i] = input[i].v.position.xyz; + for(int i = 0; i < 16; ++i) cp[i] = inpt[i].v.position.xyz; EvalBSpline(gl_TessCoord.xy, cp, WorldPos, Tangent, BiTangent); vec3 normal = normalize(cross(Tangent, BiTangent)); - output.v.position = vec4(WorldPos, 1.0f); - output.v.normal = normal; + outpt.v.position = vec4(WorldPos, 1.0f); + outpt.v.normal = normal; BiTangent = -BiTangent; // BiTangent will be used in following macro - output.v.tangent = BiTangent; + outpt.v.tangent = BiTangent; - output.v.patchCoord = input[0].v.patchCoord; - output.v.patchCoord.xy = vec2(1.0-v, u); + outpt.v.patchCoord = inpt[0].v.patchCoord; + outpt.v.patchCoord.xy = vec2(1.0-v, u); OSD_COMPUTE_PTEX_COORD_TESSEVAL_SHADER; @@ -246,11 +246,11 @@ layout (location=2) in vec4 color; out block { OutputVertex v; -} output; +} outpt; void main() { gl_Position = ModelViewProjectionMatrix * position; - output.v.color = color; + outpt.v.color = color; } #endif @@ -262,9 +262,9 @@ void main() { in block { OutputVertex v; -} input; +} inpt; void main() { - gl_FragColor = input.v.color; + gl_FragColor = inpt.v.color; } #endif diff --git a/opensubdiv/osd/glslPatchBoundaryGregory.glsl b/opensubdiv/osd/glslPatchBoundaryGregory.glsl index 9272501a..e7e29176 100644 --- a/opensubdiv/osd/glslPatchBoundaryGregory.glsl +++ b/opensubdiv/osd/glslPatchBoundaryGregory.glsl @@ -67,22 +67,22 @@ layout (location=0) in vec4 position; out block { GregControlVertex v; -} output; +} outpt; void main() { int vID = gl_VertexID; - output.v.hullPosition = (ModelViewMatrix * position).xyz; + outpt.v.hullPosition = (ModelViewMatrix * position).xyz; OSD_PATCH_CULL_COMPUTE_CLIPFLAGS(position); int valence = texelFetch(g_ValenceBuffer,int(vID * (2 * OSD_MAX_VALENCE + 1))).x; - output.v.valence = int(valence); + outpt.v.valence = int(valence); uint ivalence = uint(abs(valence)); vec3 f[OSD_MAX_VALENCE]; vec3 pos = position.xyz; - output.v.org = position.xyz; + outpt.v.org = position.xyz; vec3 opos = vec3(0,0,0); int boundaryEdgeNeighbors[2]; @@ -150,16 +150,16 @@ void main() f[i] = (pos * float(ivalence) + (neighbor_p + neighbor)*2.0f + diagonal) / (float(ivalence)+5.0f); opos += f[i]; - output.v.r[i] = (neighbor_p-neighbor_m)/3.0f + (diagonal - diagonal_m)/6.0f; + outpt.v.r[i] = (neighbor_p-neighbor_m)/3.0f + (diagonal - diagonal_m)/6.0f; } opos /= ivalence; - output.v.position = vec4(opos, 1.0f).xyz; - output.v.zerothNeighbor = zerothNeighbor; + outpt.v.position = vec4(opos, 1.0f).xyz; + outpt.v.zerothNeighbor = zerothNeighbor; #if OSD_NUM_VARYINGS > 0 for (int i = 0; i < OSD_NUM_VARYINGS; ++i) - output.v.varyings[i] = varyings[i]; + outpt.v.varyings[i] = varyings[i]; #endif @@ -168,21 +168,21 @@ void main() } vec3 e; - output.v.e0 = vec3(0,0,0); - output.v.e1 = vec3(0,0,0); + outpt.v.e0 = vec3(0,0,0); + outpt.v.e1 = vec3(0,0,0); for(uint i=0; i 2) { - output.v.position = ( + outpt.v.position = ( vec3(texelFetch(g_VertexBuffer, int(OSD_NUM_ELEMENTS*boundaryEdgeNeighbors[0])).x, texelFetch(g_VertexBuffer, int(OSD_NUM_ELEMENTS*boundaryEdgeNeighbors[0]+1)).x, texelFetch(g_VertexBuffer, int(OSD_NUM_ELEMENTS*boundaryEdgeNeighbors[0]+2)).x) + @@ -191,10 +191,10 @@ void main() texelFetch(g_VertexBuffer, int(OSD_NUM_ELEMENTS*boundaryEdgeNeighbors[1]+2)).x) + 4.0f * pos)/6.0f; } else { - output.v.position = pos; + outpt.v.position = pos; } - output.v.e0 = ( + outpt.v.e0 = ( vec3(texelFetch(g_VertexBuffer, int(OSD_NUM_ELEMENTS*boundaryEdgeNeighbors[0])).x, texelFetch(g_VertexBuffer, int(OSD_NUM_ELEMENTS*boundaryEdgeNeighbors[0]+1)).x, texelFetch(g_VertexBuffer, int(OSD_NUM_ELEMENTS*boundaryEdgeNeighbors[0]+2)).x) - @@ -218,7 +218,7 @@ void main() texelFetch(g_VertexBuffer, int(OSD_NUM_ELEMENTS*idx_diagonal+1)).x, texelFetch(g_VertexBuffer, int(OSD_NUM_ELEMENTS*idx_diagonal+2)).x); - output.v.e1 = gamma * pos + + outpt.v.e1 = gamma * pos + alpha_0k * vec3(texelFetch(g_VertexBuffer, int(OSD_NUM_ELEMENTS*boundaryEdgeNeighbors[0])).x, texelFetch(g_VertexBuffer, int(OSD_NUM_ELEMENTS*boundaryEdgeNeighbors[0]+1)).x, texelFetch(g_VertexBuffer, int(OSD_NUM_ELEMENTS*boundaryEdgeNeighbors[0]+2)).x) + @@ -247,10 +247,10 @@ void main() texelFetch(g_VertexBuffer, int(OSD_NUM_ELEMENTS*idx_diagonal+1)).x, texelFetch(g_VertexBuffer, int(OSD_NUM_ELEMENTS*idx_diagonal+2)).x); - output.v.e1 += alpha * neighbor + beta * diagonal; + outpt.v.e1 += alpha * neighbor + beta * diagonal; } - output.v.e1 /= 3.0f; + outpt.v.e1 /= 3.0f; } } #endif @@ -266,11 +266,11 @@ uniform isamplerBuffer g_QuadOffsetBuffer; in block { GregControlVertex v; -} input[]; +} inpt[]; out block { GregEvalVertex v; -} output[]; +} outpt[]; #define ID gl_InvocationID @@ -279,17 +279,17 @@ void main() uint i = gl_InvocationID; uint ip = (i+1)%4; uint im = (i+3)%4; - uint n = uint(abs(input[i].v.valence)); - uint ivalence = abs(input[i].v.valence); + uint n = uint(abs(inpt[i].v.valence)); + uint ivalence = abs(inpt[i].v.valence); int base = GregoryQuadOffsetBase; - output[ID].v.position = input[ID].v.position; + outpt[ID].v.position = inpt[ID].v.position; uint start = uint(texelFetch(g_QuadOffsetBuffer, int(4*gl_PrimitiveID+base + i)).x) & 0x00ffu; uint prev = uint(texelFetch(g_QuadOffsetBuffer, int(4*gl_PrimitiveID+base + i)).x) & 0xff00u; prev=uint(prev/256); - uint np = abs(input[ip].v.valence); - uint nm = abs(input[im].v.valence); + uint np = abs(inpt[ip].v.valence); + uint nm = abs(inpt[im].v.valence); // Control Vertices based on : // "Approximating Subdivision Surfaces with Gregory Patches for Hardware Tessellation" @@ -324,84 +324,84 @@ void main() prev_p=uint(prev_p/256); vec3 Em_ip; - if (input[ip].v.valence < -2) { - uint j = (np + prev_p - input[ip].v.zerothNeighbor) % np; - Em_ip = input[ip].v.position + cos((M_PI*j)/float(np-1))*input[ip].v.e0 + sin((M_PI*j)/float(np-1))*input[ip].v.e1; + if (inpt[ip].v.valence < -2) { + uint j = (np + prev_p - inpt[ip].v.zerothNeighbor) % np; + Em_ip = inpt[ip].v.position + cos((M_PI*j)/float(np-1))*inpt[ip].v.e0 + sin((M_PI*j)/float(np-1))*inpt[ip].v.e1; } else { - Em_ip = input[ip].v.position + input[ip].v.e0*csf(np-3,2*prev_p) + input[ip].v.e1*csf(np-3,2*prev_p+1); + Em_ip = inpt[ip].v.position + inpt[ip].v.e0*csf(np-3,2*prev_p) + inpt[ip].v.e1*csf(np-3,2*prev_p+1); } uint start_m = uint(texelFetch(g_QuadOffsetBuffer, int(4*gl_PrimitiveID+base + im)).x) & 0x00ffu; vec3 Ep_im; - if (input[im].v.valence < -2) { - uint j = (nm + start_m - input[im].v.zerothNeighbor) % nm; - Ep_im = input[im].v.position + cos((M_PI*j)/float(nm-1))*input[im].v.e0 + sin((M_PI*j)/float(nm-1))*input[im].v.e1; + if (inpt[im].v.valence < -2) { + uint j = (nm + start_m - inpt[im].v.zerothNeighbor) % nm; + Ep_im = inpt[im].v.position + cos((M_PI*j)/float(nm-1))*inpt[im].v.e0 + sin((M_PI*j)/float(nm-1))*inpt[im].v.e1; } else { - Ep_im = input[im].v.position + input[im].v.e0*csf(nm-3,2*start_m) + input[im].v.e1*csf(nm-3,2*start_m+1); + Ep_im = inpt[im].v.position + inpt[im].v.e0*csf(nm-3,2*start_m) + inpt[im].v.e1*csf(nm-3,2*start_m+1); } - if (input[i].v.valence < 0) { + if (inpt[i].v.valence < 0) { n = (n-1)*2; } - if (input[im].v.valence < 0) { + if (inpt[im].v.valence < 0) { nm = (nm-1)*2; } - if (input[ip].v.valence < 0) { + if (inpt[ip].v.valence < 0) { np = (np-1)*2; } - if (input[i].v.valence > 2) { - Ep = input[i].v.position + (input[i].v.e0*csf(n-3,2*start) + input[i].v.e1*csf(n-3,2*start+1)); - Em = input[i].v.position + (input[i].v.e0*csf(n-3,2*prev) + input[i].v.e1*csf(n-3,2*prev+1)); + if (inpt[i].v.valence > 2) { + Ep = inpt[i].v.position + (inpt[i].v.e0*csf(n-3,2*start) + inpt[i].v.e1*csf(n-3,2*start+1)); + Em = inpt[i].v.position + (inpt[i].v.e0*csf(n-3,2*prev) + inpt[i].v.e1*csf(n-3,2*prev+1)); float s1=3-2*csf(n-3,2)-csf(np-3,2); float s2=2*csf(n-3,2); - Fp = (csf(np-3,2)*input[i].v.position + s1*Ep + s2*Em_ip + input[i].v.r[start])/3.0f; + Fp = (csf(np-3,2)*inpt[i].v.position + s1*Ep + s2*Em_ip + inpt[i].v.r[start])/3.0f; s1 = 3.0f-2.0f*cos(2.0f*M_PI/n)-cos(2*M_PI/nm); - Fm = (csf(nm-3,2)*input[i].v.position + s1*Em + s2*Ep_im - input[i].v.r[prev])/3.0f; + Fm = (csf(nm-3,2)*inpt[i].v.position + s1*Em + s2*Ep_im - inpt[i].v.r[prev])/3.0f; - } else if (input[i].v.valence < -2) { - uint j = (ivalence + start - input[i].v.zerothNeighbor) % ivalence; + } else if (inpt[i].v.valence < -2) { + uint j = (ivalence + start - inpt[i].v.zerothNeighbor) % ivalence; - Ep = input[i].v.position + cos((M_PI*j)/float(ivalence-1))*input[i].v.e0 + sin((M_PI*j)/float(ivalence-1))*input[i].v.e1; - j = (ivalence + prev - input[i].v.zerothNeighbor) % ivalence; - Em = input[i].v.position + cos((M_PI*j)/float(ivalence-1))*input[i].v.e0 + sin((M_PI*j)/float(ivalence-1))*input[i].v.e1; + Ep = inpt[i].v.position + cos((M_PI*j)/float(ivalence-1))*inpt[i].v.e0 + sin((M_PI*j)/float(ivalence-1))*inpt[i].v.e1; + j = (ivalence + prev - inpt[i].v.zerothNeighbor) % ivalence; + Em = inpt[i].v.position + cos((M_PI*j)/float(ivalence-1))*inpt[i].v.e0 + sin((M_PI*j)/float(ivalence-1))*inpt[i].v.e1; - vec3 Rp = ((-2.0f * input[i].v.org - 1.0f * input[im].v.org) + (2.0f * input[ip].v.org + 1.0f * input[(i+2)%4].v.org))/3.0f; - vec3 Rm = ((-2.0f * input[i].v.org - 1.0f * input[ip].v.org) + (2.0f * input[im].v.org + 1.0f * input[(i+2)%4].v.org))/3.0f; + vec3 Rp = ((-2.0f * inpt[i].v.org - 1.0f * inpt[im].v.org) + (2.0f * inpt[ip].v.org + 1.0f * inpt[(i+2)%4].v.org))/3.0f; + vec3 Rm = ((-2.0f * inpt[i].v.org - 1.0f * inpt[ip].v.org) + (2.0f * inpt[im].v.org + 1.0f * inpt[(i+2)%4].v.org))/3.0f; float s1=3-2*csf(n-3,2)-csf(np-3,2); float s2=2*csf(n-3,2); - Fp = (csf(np-3,2)*input[i].v.position + s1*Ep + s2*Em_ip + input[i].v.r[start])/3.0f; + Fp = (csf(np-3,2)*inpt[i].v.position + s1*Ep + s2*Em_ip + inpt[i].v.r[start])/3.0f; s1 = 3.0f-2.0f*cos(2.0f*M_PI/n)-cos(2.0f*M_PI/nm); - Fm = (csf(nm-3,2)*input[i].v.position + s1*Em + s2*Ep_im - input[i].v.r[prev])/3.0f; + Fm = (csf(nm-3,2)*inpt[i].v.position + s1*Em + s2*Ep_im - inpt[i].v.r[prev])/3.0f; - if (input[im].v.valence < 0) { + if (inpt[im].v.valence < 0) { s1=3-2*csf(n-3,2)-csf(np-3,2); - Fp = Fm = (csf(np-3,2)*input[i].v.position + s1*Ep + s2*Em_ip + input[i].v.r[start])/3.0f; - } else if (input[ip].v.valence < 0) { + Fp = Fm = (csf(np-3,2)*inpt[i].v.position + s1*Ep + s2*Em_ip + inpt[i].v.r[start])/3.0f; + } else if (inpt[ip].v.valence < 0) { s1 = 3.0f-2.0f*cos(2.0f*M_PI/n)-cos(2.0f*M_PI/nm); - Fm = Fp = (csf(nm-3,2)*input[i].v.position + s1*Em + s2*Ep_im - input[i].v.r[prev])/3.0f; + Fm = Fp = (csf(nm-3,2)*inpt[i].v.position + s1*Em + s2*Ep_im - inpt[i].v.r[prev])/3.0f; } - } else if (input[i].v.valence == -2) { - Ep = (2.0f * input[i].v.org + input[ip].v.org)/3.0f; - Em = (2.0f * input[i].v.org + input[im].v.org)/3.0f; - Fp = Fm = (4.0f * input[i].v.org + input[(i+2)%n].v.org + 2.0f * input[ip].v.org + 2.0f * input[im].v.org)/9.0f; + } else if (inpt[i].v.valence == -2) { + Ep = (2.0f * inpt[i].v.org + inpt[ip].v.org)/3.0f; + Em = (2.0f * inpt[i].v.org + inpt[im].v.org)/3.0f; + Fp = Fm = (4.0f * inpt[i].v.org + inpt[(i+2)%n].v.org + 2.0f * inpt[ip].v.org + 2.0f * inpt[im].v.org)/9.0f; } - output[ID].v.Ep = Ep; - output[ID].v.Em = Em; - output[ID].v.Fp = Fp; - output[ID].v.Fm = Fm; + outpt[ID].v.Ep = Ep; + outpt[ID].v.Em = Em; + outpt[ID].v.Fp = Fp; + outpt[ID].v.Fm = Fm; int patchLevel = GetPatchLevel(); - output[ID].v.patchCoord = vec4(0, 0, - patchLevel+0.5f, - gl_PrimitiveID+LevelBase+0.5f); + outpt[ID].v.patchCoord = vec4(0, 0, + patchLevel+0.5f, + gl_PrimitiveID+LevelBase+0.5f); OSD_COMPUTE_PTEX_COORD_TESSCONTROL_SHADER; @@ -410,13 +410,13 @@ void main() #ifdef OSD_ENABLE_SCREENSPACE_TESSELLATION gl_TessLevelOuter[0] = - TessAdaptive(input[0].v.hullPosition.xyz, input[1].v.hullPosition.xyz, patchLevel); + TessAdaptive(inpt[0].v.hullPosition.xyz, inpt[1].v.hullPosition.xyz, patchLevel); gl_TessLevelOuter[1] = - TessAdaptive(input[0].v.hullPosition.xyz, input[3].v.hullPosition.xyz, patchLevel); + TessAdaptive(inpt[0].v.hullPosition.xyz, inpt[3].v.hullPosition.xyz, patchLevel); gl_TessLevelOuter[2] = - TessAdaptive(input[2].v.hullPosition.xyz, input[3].v.hullPosition.xyz, patchLevel); + TessAdaptive(inpt[2].v.hullPosition.xyz, inpt[3].v.hullPosition.xyz, patchLevel); gl_TessLevelOuter[3] = - TessAdaptive(input[1].v.hullPosition.xyz, input[2].v.hullPosition.xyz, patchLevel); + TessAdaptive(inpt[1].v.hullPosition.xyz, inpt[2].v.hullPosition.xyz, patchLevel); gl_TessLevelInner[0] = max(gl_TessLevelOuter[1], gl_TessLevelOuter[3]); gl_TessLevelInner[1] = @@ -443,11 +443,11 @@ layout(cw) in; in block { GregEvalVertex v; -} input[]; +} inpt[]; out block { OutputVertex v; -} output; +} outpt; void main() { @@ -456,29 +456,29 @@ void main() vec3 p[20]; - p[0] = input[0].v.position; - p[1] = input[0].v.Ep; - p[2] = input[0].v.Em; - p[3] = input[0].v.Fp; - p[4] = input[0].v.Fm; + p[0] = inpt[0].v.position; + p[1] = inpt[0].v.Ep; + p[2] = inpt[0].v.Em; + p[3] = inpt[0].v.Fp; + p[4] = inpt[0].v.Fm; - p[5] = input[1].v.position; - p[6] = input[1].v.Ep; - p[7] = input[1].v.Em; - p[8] = input[1].v.Fp; - p[9] = input[1].v.Fm; + p[5] = inpt[1].v.position; + p[6] = inpt[1].v.Ep; + p[7] = inpt[1].v.Em; + p[8] = inpt[1].v.Fp; + p[9] = inpt[1].v.Fm; - p[10] = input[2].v.position; - p[11] = input[2].v.Ep; - p[12] = input[2].v.Em; - p[13] = input[2].v.Fp; - p[14] = input[2].v.Fm; + p[10] = inpt[2].v.position; + p[11] = inpt[2].v.Ep; + p[12] = inpt[2].v.Em; + p[13] = inpt[2].v.Fp; + p[14] = inpt[2].v.Fm; - p[15] = input[3].v.position; - p[16] = input[3].v.Ep; - p[17] = input[3].v.Em; - p[18] = input[3].v.Fp; - p[19] = input[3].v.Fm; + p[15] = inpt[3].v.position; + p[16] = inpt[3].v.Ep; + p[17] = inpt[3].v.Em; + p[18] = inpt[3].v.Fp; + p[19] = inpt[3].v.Fm; vec3 q[16]; @@ -542,11 +542,11 @@ void main() vec3 normal = normalize(cross(BiTangent, Tangent)); - output.v.position = ModelViewMatrix * vec4(WorldPos, 1.0f); - output.v.normal = normal; - output.v.patchCoord = input[0].v.patchCoord; - output.v.patchCoord.xy = vec2(v, u); - output.v.tangent = normalize(BiTangent); + outpt.v.position = ModelViewMatrix * vec4(WorldPos, 1.0f); + outpt.v.normal = normal; + outpt.v.patchCoord = inpt[0].v.patchCoord; + outpt.v.patchCoord.xy = vec2(v, u); + outpt.v.tangent = normalize(BiTangent); OSD_COMPUTE_PTEX_COORD_TESSEVAL_SHADER; @@ -568,11 +568,11 @@ layout (location=2) in vec4 color; out block { OutputVertex v; -} output; +} outpt; void main() { gl_Position = ModelViewProjectionMatrix * position; - output.v.color = color; + outpt.v.color = color; } #endif @@ -584,9 +584,9 @@ void main() { in block { OutputVertex v; -} input; +} inpt; void main() { - gl_FragColor = input.v.color; + gl_FragColor = inpt.v.color; } #endif diff --git a/opensubdiv/osd/glslPatchCommon.glsl b/opensubdiv/osd/glslPatchCommon.glsl index 37cceb1c..fb201c3f 100644 --- a/opensubdiv/osd/glslPatchCommon.glsl +++ b/opensubdiv/osd/glslPatchCommon.glsl @@ -180,35 +180,35 @@ uniform isamplerBuffer g_ptexIndicesBuffer; int u = (ptexIndex.y >> 17) & 0x3ff; \ int v = (ptexIndex.y >> 7) & 0x3ff; \ int rotation = (ptexIndex.y >> 5) & 0x3; \ - output[ID].v.patchCoord.w = faceID+0.5; \ - output[ID].v.ptexInfo = ivec4(u, v, lv, rotation); \ + outpt[ID].v.patchCoord.w = faceID+0.5; \ + outpt[ID].v.ptexInfo = ivec4(u, v, lv, rotation); \ } #define OSD_COMPUTE_PTEX_COORD_TESSEVAL_SHADER \ { \ - vec2 uv = output.v.patchCoord.xy; \ - ivec2 p = input[0].v.ptexInfo.xy; \ - int lv = input[0].v.ptexInfo.z; \ - int rot = input[0].v.ptexInfo.w; \ - output.v.tessCoord.xy = uv; \ + vec2 uv = outpt.v.patchCoord.xy; \ + ivec2 p = inpt[0].v.ptexInfo.xy; \ + int lv = inpt[0].v.ptexInfo.z; \ + int rot = inpt[0].v.ptexInfo.w; \ + outpt.v.tessCoord.xy = uv; \ uv.xy = float(rot==0)*uv.xy \ + float(rot==1)*vec2(1.0-uv.y, uv.x) \ + float(rot==2)*vec2(1.0-uv.x, 1.0-uv.y) \ + float(rot==3)*vec2(uv.y, 1.0-uv.x); \ - output.v.patchCoord.xy = (uv * vec2(1.0)/lv) + vec2(p.x, p.y)/lv; \ + outpt.v.patchCoord.xy = (uv * vec2(1.0)/lv) + vec2(p.x, p.y)/lv; \ } #define OSD_COMPUTE_PTEX_COMPATIBLE_TANGENT(ROTATE) \ { \ - int rot = (input[0].v.ptexInfo.w + 4 - ROTATE)%4; \ + int rot = (inpt[0].v.ptexInfo.w + 4 - ROTATE)%4; \ if (rot == 1) { \ - output.v.tangent = -normalize(Tangent); \ + outpt.v.tangent = -normalize(Tangent); \ } else if (rot == 2) { \ - output.v.tangent = -normalize(BiTangent); \ + outpt.v.tangent = -normalize(BiTangent); \ } else if (rot == 3) { \ - output.v.tangent = normalize(Tangent); \ + outpt.v.tangent = normalize(Tangent); \ } else { \ - output.v.tangent = normalize(BiTangent); \ + outpt.v.tangent = normalize(BiTangent); \ } \ } @@ -218,12 +218,12 @@ uniform isamplerBuffer g_ptexIndicesBuffer; vec4 clipPos = ModelViewProjectionMatrix * P; \ bvec3 clip0 = lessThan(clipPos.xyz, vec3(clipPos.w)); \ bvec3 clip1 = greaterThan(clipPos.xyz, -vec3(clipPos.w)); \ - output.v.clipFlag = ivec3(clip0) + 2*ivec3(clip1); \ + outpt.v.clipFlag = ivec3(clip0) + 2*ivec3(clip1); \ #define OSD_PATCH_CULL(N) \ ivec3 clipFlag = ivec3(0); \ for(int i = 0; i < N; ++i) { \ - clipFlag |= input[i].v.clipFlag; \ + clipFlag |= inpt[i].v.clipFlag; \ } \ if (clipFlag != ivec3(3) ) { \ gl_TessLevelInner[0] = 0; \ diff --git a/opensubdiv/osd/glslPatchCorner.glsl b/opensubdiv/osd/glslPatchCorner.glsl index 13b9d490..185ffe02 100644 --- a/opensubdiv/osd/glslPatchCorner.glsl +++ b/opensubdiv/osd/glslPatchCorner.glsl @@ -64,15 +64,15 @@ layout (location=0) in vec4 position; out block { ControlVertex v; -} output; +} outpt; void main() { - output.v.position = ModelViewMatrix * position; + outpt.v.position = ModelViewMatrix * position; OSD_PATCH_CULL_COMPUTE_CLIPFLAGS(position); #if OSD_NUM_VARYINGS > 0 for (int i = 0; i < OSD_NUM_VARYINGS; ++i) - output.v.varyings[i] = varyings[i]; + outpt.v.varyings[i] = varyings[i]; #endif } @@ -87,11 +87,11 @@ layout(vertices = 16) out; in block { ControlVertex v; -} input[]; +} inpt[]; out block { ControlVertex v; -} output[]; +} outpt[]; #define ID gl_InvocationID @@ -105,7 +105,7 @@ void main() H[l] = vec3(0,0,0); for (int k=0; k<3; k++) { float c = B[i][2-k]; - H[l] += c*input[l*3 + k].v.position.xyz; + H[l] += c*inpt[l*3 + k].v.position.xyz; } } @@ -114,13 +114,13 @@ void main() pos += B[j][k]*H[k]; } - output[ID].v.position = vec4(pos, 1.0); + outpt[ID].v.position = vec4(pos, 1.0); int patchLevel = GetPatchLevel(); // +0.5 to avoid interpolation error of integer value - output[ID].v.patchCoord = vec4(0, 0, - patchLevel+0.5, - gl_PrimitiveID+LevelBase+0.5); + outpt[ID].v.patchCoord = vec4(0, 0, + patchLevel+0.5, + gl_PrimitiveID+LevelBase+0.5); OSD_COMPUTE_PTEX_COORD_TESSCONTROL_SHADER; @@ -129,16 +129,16 @@ void main() #ifdef OSD_ENABLE_SCREENSPACE_TESSELLATION gl_TessLevelOuter[0] = - TessAdaptive(input[2].v.position.xyz, input[5].v.position.xyz, patchLevel); + TessAdaptive(inpt[2].v.position.xyz, inpt[5].v.position.xyz, patchLevel); gl_TessLevelOuter[1] = - TessAdaptive(input[1].v.position.xyz, input[2].v.position.xyz, patchLevel); + TessAdaptive(inpt[1].v.position.xyz, inpt[2].v.position.xyz, patchLevel); gl_TessLevelOuter[2] = - TessAdaptive(input[4].v.position.xyz, input[5].v.position.xyz, patchLevel); + TessAdaptive(inpt[4].v.position.xyz, inpt[5].v.position.xyz, patchLevel); gl_TessLevelOuter[3] = - TessAdaptive(input[1].v.position.xyz, input[4].v.position.xyz, patchLevel); + TessAdaptive(inpt[1].v.position.xyz, inpt[4].v.position.xyz, patchLevel); gl_TessLevelInner[0] = max(gl_TessLevelOuter[1], gl_TessLevelOuter[3]); @@ -167,11 +167,11 @@ layout(equal_spacing) in; in block { ControlVertex v; -} input[]; +} inpt[]; out block { OutputVertex v; -} output; +} outpt; void main() { @@ -189,7 +189,7 @@ void main() DUCP[i] = vec3(0.0f, 0.0f, 0.0f); for (int j=0; j<4; ++j) { - vec3 A = input[4*i + j].v.position.xyz; + vec3 A = inpt[4*i + j].v.position.xyz; BUCP[i] += A * B[j]; DUCP[i] += A * D[j]; @@ -210,14 +210,14 @@ void main() vec3 normal = normalize(cross(Tangent, BiTangent)); - output.v.position = vec4(WorldPos, 1.0f); - output.v.normal = normal; + outpt.v.position = vec4(WorldPos, 1.0f); + outpt.v.normal = normal; BiTangent = -BiTangent; // BiTangent will be used in following macro - output.v.tangent = BiTangent; + outpt.v.tangent = BiTangent; - output.v.patchCoord = input[0].v.patchCoord; - output.v.patchCoord.xy = vec2(1.0-v, u); + outpt.v.patchCoord = inpt[0].v.patchCoord; + outpt.v.patchCoord.xy = vec2(1.0-v, u); OSD_COMPUTE_PTEX_COORD_TESSEVAL_SHADER; @@ -241,11 +241,11 @@ layout (location=2) in vec4 color; out block { OutputVertex v; -} output; +} outpt; void main() { gl_Position = ModelViewProjectionMatrix * position; - output.v.color = color; + outpt.v.color = color; } #endif @@ -257,9 +257,9 @@ void main() { in block { OutputVertex v; -} input; +} inpt; void main() { - gl_FragColor = input.v.color; + gl_FragColor = inpt.v.color; } #endif diff --git a/opensubdiv/osd/glslPatchGregory.glsl b/opensubdiv/osd/glslPatchGregory.glsl index 4cd68ad2..f5f7cdd7 100644 --- a/opensubdiv/osd/glslPatchGregory.glsl +++ b/opensubdiv/osd/glslPatchGregory.glsl @@ -67,17 +67,17 @@ layout (location=0) in vec4 position; out block { GregControlVertex v; -} output; +} outpt; void main() { int vID = gl_VertexID; - output.v.hullPosition = (ModelViewMatrix * position).xyz; + outpt.v.hullPosition = (ModelViewMatrix * position).xyz; OSD_PATCH_CULL_COMPUTE_CLIPFLAGS(position); uint valence = uint(texelFetch(g_ValenceBuffer,int(vID * (2 * OSD_MAX_VALENCE + 1))).x); - output.v.valence = int(valence); + outpt.v.valence = int(valence); vec3 f[OSD_MAX_VALENCE]; vec3 pos = position.xyz; @@ -125,28 +125,28 @@ void main() f[i] = (pos * float(valence) + (neighbor_p + neighbor)*2.0 + diagonal) / (float(valence)+5.0); opos += f[i]; - output.v.r[i] = (neighbor_p-neighbor_m)/3.0 + (diagonal - diagonal_m)/6.0; + outpt.v.r[i] = (neighbor_p-neighbor_m)/3.0 + (diagonal - diagonal_m)/6.0; } opos /= valence; - output.v.position = vec4(opos, 1.0f).xyz; + outpt.v.position = vec4(opos, 1.0f).xyz; #if OSD_NUM_VARYINGS > 0 for (int i = 0; i < OSD_NUM_VARYINGS; ++i) - output.v.varyings[i] = varyings[i]; + outpt.v.varyings[i] = varyings[i]; #endif vec3 e; - output.v.e0 = vec3(0,0,0); - output.v.e1 = vec3(0,0,0); + outpt.v.e0 = vec3(0,0,0); + outpt.v.e1 = vec3(0,0,0); for(uint i=0; i 0 for (int i = 0; i < OSD_NUM_VARYINGS; ++i) - output.v.varyings[i] = varyings[i]; + outpt.v.varyings[i] = varyings[i]; #endif } @@ -87,11 +87,11 @@ layout(vertices = 16) out; in block { ControlVertex v; -} input[]; +} inpt[]; out block { ControlVertex v; -} output[]; +} outpt[]; #define ID gl_InvocationID @@ -106,8 +106,8 @@ void main() for (int k=0; k<4; k++) { float c = Q[i][k]; // XXX: fix this in patchMeshFactory. -// H[l] += c*input[l*4 + k].v.position.xyz; - H[l] += c*input[l + k*4].v.position.xyz; +// H[l] += c*inpt[l*4 + k].v.position.xyz; + H[l] += c*inpt[l + k*4].v.position.xyz; } } @@ -116,14 +116,14 @@ void main() pos += Q[j][k]*H[k]; } - output[ID].v.position = vec4(pos, 1.0); + outpt[ID].v.position = vec4(pos, 1.0); int patchLevel = GetPatchLevel(); // +0.5 to avoid interpolation error of integer value - output[ID].v.patchCoord = vec4(0, 0, - patchLevel+0.5, - gl_PrimitiveID+LevelBase+0.5); + outpt[ID].v.patchCoord = vec4(0, 0, + patchLevel+0.5, + gl_PrimitiveID+LevelBase+0.5); OSD_COMPUTE_PTEX_COORD_TESSCONTROL_SHADER; @@ -132,13 +132,13 @@ void main() #ifdef OSD_ENABLE_SCREENSPACE_TESSELLATION gl_TessLevelOuter[0] = - TessAdaptive(input[5].v.position.xyz, input[9].v.position.xyz, patchLevel); + TessAdaptive(inpt[5].v.position.xyz, inpt[9].v.position.xyz, patchLevel); gl_TessLevelOuter[1] = - TessAdaptive(input[5].v.position.xyz, input[6].v.position.xyz, patchLevel); + TessAdaptive(inpt[5].v.position.xyz, inpt[6].v.position.xyz, patchLevel); gl_TessLevelOuter[2] = - TessAdaptive(input[6].v.position.xyz, input[10].v.position.xyz, patchLevel); + TessAdaptive(inpt[6].v.position.xyz, inpt[10].v.position.xyz, patchLevel); gl_TessLevelOuter[3] = - TessAdaptive(input[9].v.position.xyz, input[10].v.position.xyz, patchLevel); + TessAdaptive(inpt[9].v.position.xyz, inpt[10].v.position.xyz, patchLevel); gl_TessLevelInner[0] = max(gl_TessLevelOuter[1], gl_TessLevelOuter[3]); gl_TessLevelInner[1] = @@ -166,11 +166,11 @@ layout(equal_spacing) in; in block { ControlVertex v; -} input[]; +} inpt[]; out block { OutputVertex v; -} output; +} outpt; void main() { @@ -179,17 +179,17 @@ void main() vec3 WorldPos, Tangent, BiTangent; vec3 cp[16]; - for(int i = 0; i < 16; ++i) cp[i] = input[i].v.position.xyz; + for(int i = 0; i < 16; ++i) cp[i] = inpt[i].v.position.xyz; EvalBSpline(gl_TessCoord.xy, cp, WorldPos, Tangent, BiTangent); vec3 normal = normalize(cross(Tangent, BiTangent)); - output.v.position = vec4(WorldPos, 1.0f); - output.v.normal = normal; - output.v.tangent = Tangent; + outpt.v.position = vec4(WorldPos, 1.0f); + outpt.v.normal = normal; + outpt.v.tangent = Tangent; - output.v.patchCoord = input[0].v.patchCoord; - output.v.patchCoord.xy = vec2(u, v); + outpt.v.patchCoord = inpt[0].v.patchCoord; + outpt.v.patchCoord.xy = vec2(u, v); OSD_COMPUTE_PTEX_COORD_TESSEVAL_SHADER; @@ -211,11 +211,11 @@ layout (location=2) in vec4 color; out block { OutputVertex v; -} output; +} outpt; void main() { gl_Position = ModelViewProjectionMatrix * position; - output.v.color = color; + outpt.v.color = color; } #endif @@ -227,9 +227,9 @@ void main() { in block { OutputVertex v; -} input; +} inpt; void main() { - gl_FragColor = input.v.color; + gl_FragColor = inpt.v.color; } #endif diff --git a/opensubdiv/osd/glslPatchTransition.glsl b/opensubdiv/osd/glslPatchTransition.glsl index a51d3233..55af546d 100644 --- a/opensubdiv/osd/glslPatchTransition.glsl +++ b/opensubdiv/osd/glslPatchTransition.glsl @@ -78,15 +78,15 @@ layout (location=0) in vec4 position; out block { ControlVertex v; -} output; +} outpt; void main() { - output.v.position = ModelViewMatrix * position; + outpt.v.position = ModelViewMatrix * position; OSD_PATCH_CULL_COMPUTE_CLIPFLAGS(position); #if OSD_NUM_VARYINGS > 0 for (int i = 0; i < OSD_NUM_VARYINGS; ++i) - output.v.varyings[i] = varyings[i]; + outpt.v.varyings[i] = varyings[i]; #endif } @@ -101,11 +101,11 @@ layout(vertices = 16) out; in block { ControlVertex v; -} input[]; +} inpt[]; out block { ControlVertex v; -} output[]; +} outpt[]; #define ID gl_InvocationID @@ -125,7 +125,7 @@ void main() H[l] = vec3(0,0,0); for (int k=0; k<4; k++) { float c = Q[i][k]; - H[l] += c*input[l*4 + k].v.position.xyz; + H[l] += c*inpt[l*4 + k].v.position.xyz; } } @@ -143,7 +143,7 @@ void main() H[l] = vec3(0,0,0); for (int k=0; k<3; k++) { float c = B[i][2-k]; - H[l] += c*input[l*3 + k].v.position.xyz; + H[l] += c*inpt[l*3 + k].v.position.xyz; } } @@ -161,7 +161,7 @@ void main() H[l] = vec3(0,0,0); for (int k=0; k<4; k++) { float c = Q[i][k]; - H[l] += c*input[l*4 + k].v.position.xyz; + H[l] += c*inpt[l*4 + k].v.position.xyz; } } @@ -172,12 +172,12 @@ void main() #endif - output[ID].v.position = vec4(pos, 1.0); + outpt[ID].v.position = vec4(pos, 1.0); int patchLevel = GetPatchLevel(); - output[ID].v.patchCoord = vec4(0, 0, - patchLevel+0.5, - gl_PrimitiveID+LevelBase+0.5); + outpt[ID].v.patchCoord = vec4(0, 0, + patchLevel+0.5, + gl_PrimitiveID+LevelBase+0.5); OSD_COMPUTE_PTEX_COORD_TESSCONTROL_SHADER; @@ -185,7 +185,7 @@ void main() OSD_PATCH_CULL(16); #ifdef OSD_ENABLE_SCREENSPACE_TESSELLATION - // These tables map the 9, 12, or 16 input control points onto the + // These tables map the 9, 12, or 16 inpt control points onto the // canonical 16 control points for a regular patch. #if defined BOUNDARY const int p[16] = int[]( 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ); @@ -206,25 +206,25 @@ void main() #endif // Expand and rotate control points using remapping tables above - vec3 pv0 = input[p[r[0]]].v.position.xyz; - vec3 pv1 = input[p[r[1]]].v.position.xyz; - vec3 pv2 = input[p[r[2]]].v.position.xyz; - vec3 pv3 = input[p[r[3]]].v.position.xyz; + vec3 pv0 = inpt[p[r[0]]].v.position.xyz; + vec3 pv1 = inpt[p[r[1]]].v.position.xyz; + vec3 pv2 = inpt[p[r[2]]].v.position.xyz; + vec3 pv3 = inpt[p[r[3]]].v.position.xyz; - vec3 pv4 = input[p[r[4]]].v.position.xyz; - vec3 pv5 = input[p[r[5]]].v.position.xyz; - vec3 pv6 = input[p[r[6]]].v.position.xyz; - vec3 pv7 = input[p[r[7]]].v.position.xyz; + vec3 pv4 = inpt[p[r[4]]].v.position.xyz; + vec3 pv5 = inpt[p[r[5]]].v.position.xyz; + vec3 pv6 = inpt[p[r[6]]].v.position.xyz; + vec3 pv7 = inpt[p[r[7]]].v.position.xyz; - vec3 pv8 = input[p[r[8]]].v.position.xyz; - vec3 pv9 = input[p[r[9]]].v.position.xyz; - vec3 pv10 = input[p[r[10]]].v.position.xyz; - vec3 pv11 = input[p[r[11]]].v.position.xyz; + vec3 pv8 = inpt[p[r[8]]].v.position.xyz; + vec3 pv9 = inpt[p[r[9]]].v.position.xyz; + vec3 pv10 = inpt[p[r[10]]].v.position.xyz; + vec3 pv11 = inpt[p[r[11]]].v.position.xyz; - vec3 pv12 = input[p[r[12]]].v.position.xyz; - vec3 pv13 = input[p[r[13]]].v.position.xyz; - vec3 pv14 = input[p[r[14]]].v.position.xyz; - vec3 pv15 = input[p[r[15]]].v.position.xyz; + vec3 pv12 = inpt[p[r[12]]].v.position.xyz; + vec3 pv13 = inpt[p[r[13]]].v.position.xyz; + vec3 pv14 = inpt[p[r[14]]].v.position.xyz; + vec3 pv15 = inpt[p[r[15]]].v.position.xyz; // Each edge of a transition patch is adjacent to one or two // patches at the next refined level of subdivision. @@ -600,11 +600,11 @@ void main() in block { ControlVertex v; -} input[]; +} inpt[]; out block { OutputVertex v; -} output; +} outpt; void main() { @@ -734,25 +734,25 @@ void main() vec3 WorldPos, Tangent, BiTangent; vec3 cp[16]; - for(int i = 0; i < 16; ++i) cp[i] = input[i].v.position.xyz; + for(int i = 0; i < 16; ++i) cp[i] = inpt[i].v.position.xyz; EvalBSpline(UV, cp, WorldPos, Tangent, BiTangent); vec3 normal = normalize(cross(BiTangent, Tangent)); - output.v.position = vec4(WorldPos, 1.0f); - output.v.normal = normal; - output.v.tangent = BiTangent; + outpt.v.position = vec4(WorldPos, 1.0f); + outpt.v.normal = normal; + outpt.v.tangent = BiTangent; - output.v.patchCoord = input[0].v.patchCoord; + outpt.v.patchCoord = inpt[0].v.patchCoord; #if ROTATE == 1 - output.v.patchCoord.xy = vec2(UV.x, 1.0-UV.y); + outpt.v.patchCoord.xy = vec2(UV.x, 1.0-UV.y); #elif ROTATE == 2 - output.v.patchCoord.xy = vec2(1.0-UV.y, 1.0-UV.x); + outpt.v.patchCoord.xy = vec2(1.0-UV.y, 1.0-UV.x); #elif ROTATE == 3 - output.v.patchCoord.xy = vec2(1.0-UV.x, UV.y); + outpt.v.patchCoord.xy = vec2(1.0-UV.x, UV.y); #else - output.v.patchCoord.xy = vec2(UV.y, UV.x); + outpt.v.patchCoord.xy = vec2(UV.y, UV.x); #endif OSD_COMPUTE_PTEX_COORD_TESSEVAL_SHADER; @@ -777,11 +777,11 @@ layout (location=2) in vec4 color; out block { OutputVertex v; -} output; +} outpt; void main() { gl_Position = ModelViewProjectionMatrix * position; - output.v.color = color; + outpt.v.color = color; } #endif @@ -793,9 +793,9 @@ void main() { in block { OutputVertex v; -} input; +} inpt; void main() { - gl_FragColor = input.v.color; + gl_FragColor = inpt.v.color; } #endif