mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-12-11 11:50:04 +00:00
Merge pull request #501 from davidgyu/irregularRotate
Fixed handedness flip in Gregory{Basis} shaders
This commit is contained in:
commit
1e89b93e7d
@ -430,7 +430,6 @@ void main()
|
|||||||
#ifdef OSD_PATCH_TESS_EVAL_GREGORY_SHADER
|
#ifdef OSD_PATCH_TESS_EVAL_GREGORY_SHADER
|
||||||
|
|
||||||
layout(quads) in;
|
layout(quads) in;
|
||||||
layout(cw) in;
|
|
||||||
|
|
||||||
#if defined OSD_FRACTIONAL_ODD_SPACING
|
#if defined OSD_FRACTIONAL_ODD_SPACING
|
||||||
layout(fractional_odd_spacing) in;
|
layout(fractional_odd_spacing) in;
|
||||||
@ -523,9 +522,7 @@ void main()
|
|||||||
|
|
||||||
for (int i=0; i<4; ++i) {
|
for (int i=0; i<4; ++i) {
|
||||||
for (uint j=0; j<4; ++j) {
|
for (uint j=0; j<4; ++j) {
|
||||||
// reverse face front
|
vec3 A = q[4*i + j];
|
||||||
vec3 A = q[i + 4*j];
|
|
||||||
|
|
||||||
BUCP[i] += A * B[j];
|
BUCP[i] += A * B[j];
|
||||||
DUCP[i] += A * D[j];
|
DUCP[i] += A * D[j];
|
||||||
CUCP[i] += A * C[j];
|
CUCP[i] += A * C[j];
|
||||||
@ -569,7 +566,7 @@ void main()
|
|||||||
BiTangent = (OsdModelViewMatrix() * vec4(BiTangent, 0)).xyz;
|
BiTangent = (OsdModelViewMatrix() * vec4(BiTangent, 0)).xyz;
|
||||||
Tangent = (OsdModelViewMatrix() * vec4(Tangent, 0)).xyz;
|
Tangent = (OsdModelViewMatrix() * vec4(Tangent, 0)).xyz;
|
||||||
|
|
||||||
normal = normalize(cross(BiTangent, Tangent));
|
normal = normalize(cross(Tangent, BiTangent));
|
||||||
|
|
||||||
outpt.v.Nu = Nu;
|
outpt.v.Nu = Nu;
|
||||||
outpt.v.Nv = Nv;
|
outpt.v.Nv = Nv;
|
||||||
@ -583,9 +580,7 @@ void main()
|
|||||||
|
|
||||||
for (int i=0; i<4; ++i) {
|
for (int i=0; i<4; ++i) {
|
||||||
for (uint j=0; j<4; ++j) {
|
for (uint j=0; j<4; ++j) {
|
||||||
// reverse face front
|
vec3 A = q[4*i + j];
|
||||||
vec3 A = q[i + 4*j];
|
|
||||||
|
|
||||||
BUCP[i] += A * B[j];
|
BUCP[i] += A * B[j];
|
||||||
DUCP[i] += A * D[j];
|
DUCP[i] += A * D[j];
|
||||||
}
|
}
|
||||||
@ -605,16 +600,16 @@ void main()
|
|||||||
BiTangent = (OsdModelViewMatrix() * vec4(BiTangent, 0)).xyz;
|
BiTangent = (OsdModelViewMatrix() * vec4(BiTangent, 0)).xyz;
|
||||||
Tangent = (OsdModelViewMatrix() * vec4(Tangent, 0)).xyz;
|
Tangent = (OsdModelViewMatrix() * vec4(Tangent, 0)).xyz;
|
||||||
|
|
||||||
vec3 normal = normalize(cross(BiTangent, Tangent));
|
vec3 normal = normalize(cross(Tangent, BiTangent));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
outpt.v.position = OsdModelViewMatrix() * vec4(WorldPos, 1.0f);
|
outpt.v.position = OsdModelViewMatrix() * vec4(WorldPos, 1.0f);
|
||||||
outpt.v.normal = normal;
|
outpt.v.normal = normal;
|
||||||
outpt.v.tangent = BiTangent;
|
outpt.v.tangent = Tangent;
|
||||||
outpt.v.bitangent = Tangent;
|
outpt.v.bitangent = BiTangent;
|
||||||
|
|
||||||
vec2 UV = vec2(v, u);
|
vec2 UV = vec2(u, v);
|
||||||
|
|
||||||
OSD_USER_VARYING_PER_EVAL_POINT(UV, 0, 1, 3, 2);
|
OSD_USER_VARYING_PER_EVAL_POINT(UV, 0, 1, 3, 2);
|
||||||
|
|
||||||
|
@ -101,7 +101,6 @@ void main()
|
|||||||
#ifdef OSD_PATCH_TESS_EVAL_GREGORY_BASIS_SHADER
|
#ifdef OSD_PATCH_TESS_EVAL_GREGORY_BASIS_SHADER
|
||||||
|
|
||||||
layout(quads) in;
|
layout(quads) in;
|
||||||
layout(cw) in;
|
|
||||||
|
|
||||||
#if defined OSD_FRACTIONAL_ODD_SPACING
|
#if defined OSD_FRACTIONAL_ODD_SPACING
|
||||||
layout(fractional_odd_spacing) in;
|
layout(fractional_odd_spacing) in;
|
||||||
@ -180,9 +179,7 @@ void main()
|
|||||||
|
|
||||||
for (int i=0; i<4; ++i) {
|
for (int i=0; i<4; ++i) {
|
||||||
for (uint j=0; j<4; ++j) {
|
for (uint j=0; j<4; ++j) {
|
||||||
// reverse face front
|
vec3 A = q[4*i + j];
|
||||||
vec3 A = q[i + 4*j];
|
|
||||||
|
|
||||||
BUCP[i] += A * B[j];
|
BUCP[i] += A * B[j];
|
||||||
DUCP[i] += A * D[j];
|
DUCP[i] += A * D[j];
|
||||||
CUCP[i] += A * C[j];
|
CUCP[i] += A * C[j];
|
||||||
@ -207,7 +204,7 @@ void main()
|
|||||||
dVV *= 6 * level;
|
dVV *= 6 * level;
|
||||||
dUV *= 9 * level;
|
dUV *= 9 * level;
|
||||||
|
|
||||||
vec3 n = cross(BiTangent, Tangent);
|
vec3 n = cross(Tangent, BiTangent);
|
||||||
vec3 normal = normalize(n);
|
vec3 normal = normalize(n);
|
||||||
|
|
||||||
float E = dot(Tangent, Tangent);
|
float E = dot(Tangent, Tangent);
|
||||||
@ -235,9 +232,7 @@ void main()
|
|||||||
|
|
||||||
for (int i=0; i<4; ++i) {
|
for (int i=0; i<4; ++i) {
|
||||||
for (uint j=0; j<4; ++j) {
|
for (uint j=0; j<4; ++j) {
|
||||||
// reverse face front
|
vec3 A = q[4*i + j];
|
||||||
vec3 A = q[i + 4*j];
|
|
||||||
|
|
||||||
BUCP[i] += A * B[j];
|
BUCP[i] += A * B[j];
|
||||||
DUCP[i] += A * D[j];
|
DUCP[i] += A * D[j];
|
||||||
}
|
}
|
||||||
@ -254,15 +249,15 @@ void main()
|
|||||||
BiTangent *= 3 * level;
|
BiTangent *= 3 * level;
|
||||||
Tangent *= 3 * level;
|
Tangent *= 3 * level;
|
||||||
|
|
||||||
vec3 normal = normalize(cross(BiTangent, Tangent));
|
vec3 normal = normalize(cross(Tangent, BiTangent));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
outpt.v.position = vec4(WorldPos, 1.0f);
|
outpt.v.position = vec4(WorldPos, 1.0f);
|
||||||
outpt.v.normal = normal;
|
outpt.v.normal = normal;
|
||||||
outpt.v.tangent = BiTangent;
|
outpt.v.tangent = Tangent;
|
||||||
outpt.v.bitangent = Tangent;
|
outpt.v.bitangent = BiTangent;
|
||||||
|
|
||||||
vec2 UV = vec2(v, u);
|
vec2 UV = vec2(u, v);
|
||||||
|
|
||||||
OSD_USER_VARYING_PER_EVAL_POINT(UV, 0, 5, 15, 10);
|
OSD_USER_VARYING_PER_EVAL_POINT(UV, 0, 5, 15, 10);
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ HS_CONSTANT_FUNC_OUT HSConstFunc(
|
|||||||
|
|
||||||
[domain("quad")]
|
[domain("quad")]
|
||||||
[partitioning(HS_PARTITION)]
|
[partitioning(HS_PARTITION)]
|
||||||
[outputtopology("triangle_ccw")]
|
[outputtopology("triangle_cw")]
|
||||||
[outputcontrolpoints(4)]
|
[outputcontrolpoints(4)]
|
||||||
[patchconstantfunc("HSConstFunc")]
|
[patchconstantfunc("HSConstFunc")]
|
||||||
GregDomainVertex hs_main_patches(
|
GregDomainVertex hs_main_patches(
|
||||||
@ -537,9 +537,7 @@ void ds_main_patches(
|
|||||||
|
|
||||||
for (int i=0; i<4; ++i) {
|
for (int i=0; i<4; ++i) {
|
||||||
for (uint j=0; j<4; ++j) {
|
for (uint j=0; j<4; ++j) {
|
||||||
// reverse face front
|
float3 A = q[4*i + j];
|
||||||
float3 A = q[i + 4*j];
|
|
||||||
|
|
||||||
BUCP[i] += A * B[j];
|
BUCP[i] += A * B[j];
|
||||||
DUCP[i] += A * D[j];
|
DUCP[i] += A * D[j];
|
||||||
CUCP[i] += A * C[j];
|
CUCP[i] += A * C[j];
|
||||||
@ -583,7 +581,7 @@ void ds_main_patches(
|
|||||||
BiTangent = mul(OsdModelViewMatrix(), float4(BiTangent, 0)).xyz;
|
BiTangent = mul(OsdModelViewMatrix(), float4(BiTangent, 0)).xyz;
|
||||||
Tangent = mul(OsdModelViewMatrix(), float4(Tangent, 0)).xyz;
|
Tangent = mul(OsdModelViewMatrix(), float4(Tangent, 0)).xyz;
|
||||||
|
|
||||||
normal = normalize(cross(BiTangent, Tangent));
|
normal = normalize(cross(Tangent, BiTangent));
|
||||||
|
|
||||||
output.Nu = Nu;
|
output.Nu = Nu;
|
||||||
output.Nv = Nv;
|
output.Nv = Nv;
|
||||||
@ -597,9 +595,7 @@ void ds_main_patches(
|
|||||||
|
|
||||||
for (int i=0; i<4; ++i) {
|
for (int i=0; i<4; ++i) {
|
||||||
for (uint j=0; j<4; ++j) {
|
for (uint j=0; j<4; ++j) {
|
||||||
// reverse face front
|
float3 A = q[4*i + j];
|
||||||
float3 A = q[i + 4*j];
|
|
||||||
|
|
||||||
BUCP[i] += A * B[j];
|
BUCP[i] += A * B[j];
|
||||||
DUCP[i] += A * D[j];
|
DUCP[i] += A * D[j];
|
||||||
}
|
}
|
||||||
@ -619,18 +615,18 @@ void ds_main_patches(
|
|||||||
BiTangent = mul(OsdModelViewMatrix(), float4(BiTangent, 0)).xyz;
|
BiTangent = mul(OsdModelViewMatrix(), float4(BiTangent, 0)).xyz;
|
||||||
Tangent = mul(OsdModelViewMatrix(), float4(Tangent, 0)).xyz;
|
Tangent = mul(OsdModelViewMatrix(), float4(Tangent, 0)).xyz;
|
||||||
|
|
||||||
float3 normal = normalize(cross(BiTangent, Tangent));
|
float3 normal = normalize(cross(Tangent, BiTangent));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
output.position = mul(OsdModelViewMatrix(), float4(WorldPos, 1.0f));
|
output.position = mul(OsdModelViewMatrix(), float4(WorldPos, 1.0f));
|
||||||
output.normal = normal;
|
output.normal = normal;
|
||||||
output.tangent = BiTangent;
|
output.tangent = Tangent;
|
||||||
output.bitangent = Tangent;
|
output.bitangent = BiTangent;
|
||||||
|
|
||||||
output.edgeDistance = 0;
|
output.edgeDistance = 0;
|
||||||
|
|
||||||
float2 UV = float2(v, u);
|
float2 UV = float2(u, v);
|
||||||
output.patchCoord = OsdInterpolatePatchCoord(UV, patch[0].patchCoord);
|
output.patchCoord = OsdInterpolatePatchCoord(UV, patch[0].patchCoord);
|
||||||
|
|
||||||
OSD_DISPLACEMENT_CALLBACK;
|
OSD_DISPLACEMENT_CALLBACK;
|
||||||
|
@ -78,7 +78,7 @@ HSConstFunc(
|
|||||||
|
|
||||||
[domain("quad")]
|
[domain("quad")]
|
||||||
[partitioning(HS_PARTITION)]
|
[partitioning(HS_PARTITION)]
|
||||||
[outputtopology("triangle_ccw")]
|
[outputtopology("triangle_cw")]
|
||||||
[outputcontrolpoints(20)]
|
[outputcontrolpoints(20)]
|
||||||
[patchconstantfunc("HSConstFunc")]
|
[patchconstantfunc("HSConstFunc")]
|
||||||
HullVertex hs_main_patches(
|
HullVertex hs_main_patches(
|
||||||
@ -159,9 +159,7 @@ void ds_main_patches(
|
|||||||
|
|
||||||
for (int i=0; i<4; ++i) {
|
for (int i=0; i<4; ++i) {
|
||||||
for (uint j=0; j<4; ++j) {
|
for (uint j=0; j<4; ++j) {
|
||||||
// reverse face front
|
float3 A = q[4*i + j];
|
||||||
float3 A = q[i + 4*j];
|
|
||||||
|
|
||||||
BUCP[i] += A * B[j];
|
BUCP[i] += A * B[j];
|
||||||
DUCP[i] += A * D[j];
|
DUCP[i] += A * D[j];
|
||||||
CUCP[i] += A * C[j];
|
CUCP[i] += A * C[j];
|
||||||
@ -186,7 +184,7 @@ void ds_main_patches(
|
|||||||
dVV *= 6 * level;
|
dVV *= 6 * level;
|
||||||
dUV *= 9 * level;
|
dUV *= 9 * level;
|
||||||
|
|
||||||
float3 n = cross(BiTangent, Tangent);
|
float3 n = cross(Tangent, BiTangent);
|
||||||
float3 normal = normalize(n);
|
float3 normal = normalize(n);
|
||||||
|
|
||||||
float E = dot(Tangent, Tangent);
|
float E = dot(Tangent, Tangent);
|
||||||
@ -214,9 +212,7 @@ void ds_main_patches(
|
|||||||
|
|
||||||
for (int i=0; i<4; ++i) {
|
for (int i=0; i<4; ++i) {
|
||||||
for (uint j=0; j<4; ++j) {
|
for (uint j=0; j<4; ++j) {
|
||||||
// reverse face front
|
float3 A = q[4*i + j];
|
||||||
float3 A = q[i + 4*j];
|
|
||||||
|
|
||||||
BUCP[i] += A * B[j];
|
BUCP[i] += A * B[j];
|
||||||
DUCP[i] += A * D[j];
|
DUCP[i] += A * D[j];
|
||||||
}
|
}
|
||||||
@ -233,18 +229,18 @@ void ds_main_patches(
|
|||||||
BiTangent *= 3 * level;
|
BiTangent *= 3 * level;
|
||||||
Tangent *= 3 * level;
|
Tangent *= 3 * level;
|
||||||
|
|
||||||
float3 normal = normalize(cross(BiTangent, Tangent));
|
float3 normal = normalize(cross(Tangent, BiTangent));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
output.position = float4(WorldPos, 1.0f);
|
output.position = float4(WorldPos, 1.0f);
|
||||||
output.normal = normal;
|
output.normal = normal;
|
||||||
output.tangent = BiTangent;
|
output.tangent = Tangent;
|
||||||
output.bitangent = Tangent;
|
output.bitangent = BiTangent;
|
||||||
|
|
||||||
output.edgeDistance = 0;
|
output.edgeDistance = 0;
|
||||||
|
|
||||||
float2 UV = float2(v, u);
|
float2 UV = float2(u, v);
|
||||||
output.patchCoord = OsdInterpolatePatchCoord(UV, patch[0].patchCoord);
|
output.patchCoord = OsdInterpolatePatchCoord(UV, patch[0].patchCoord);
|
||||||
|
|
||||||
OSD_DISPLACEMENT_CALLBACK;
|
OSD_DISPLACEMENT_CALLBACK;
|
||||||
|
Loading…
Reference in New Issue
Block a user