Merge pull request #501 from davidgyu/irregularRotate

Fixed handedness flip in Gregory{Basis} shaders
This commit is contained in:
Takahito Tejima 2015-05-20 15:54:07 -07:00
commit 1e89b93e7d
4 changed files with 30 additions and 48 deletions

View File

@ -430,7 +430,6 @@ void main()
#ifdef OSD_PATCH_TESS_EVAL_GREGORY_SHADER
layout(quads) in;
layout(cw) in;
#if defined OSD_FRACTIONAL_ODD_SPACING
layout(fractional_odd_spacing) in;
@ -523,9 +522,7 @@ void main()
for (int i=0; i<4; ++i) {
for (uint j=0; j<4; ++j) {
// reverse face front
vec3 A = q[i + 4*j];
vec3 A = q[4*i + j];
BUCP[i] += A * B[j];
DUCP[i] += A * D[j];
CUCP[i] += A * C[j];
@ -569,7 +566,7 @@ void main()
BiTangent = (OsdModelViewMatrix() * vec4(BiTangent, 0)).xyz;
Tangent = (OsdModelViewMatrix() * vec4(Tangent, 0)).xyz;
normal = normalize(cross(BiTangent, Tangent));
normal = normalize(cross(Tangent, BiTangent));
outpt.v.Nu = Nu;
outpt.v.Nv = Nv;
@ -583,9 +580,7 @@ void main()
for (int i=0; i<4; ++i) {
for (uint j=0; j<4; ++j) {
// reverse face front
vec3 A = q[i + 4*j];
vec3 A = q[4*i + j];
BUCP[i] += A * B[j];
DUCP[i] += A * D[j];
}
@ -605,16 +600,16 @@ void main()
BiTangent = (OsdModelViewMatrix() * vec4(BiTangent, 0)).xyz;
Tangent = (OsdModelViewMatrix() * vec4(Tangent, 0)).xyz;
vec3 normal = normalize(cross(BiTangent, Tangent));
vec3 normal = normalize(cross(Tangent, BiTangent));
#endif
outpt.v.position = OsdModelViewMatrix() * vec4(WorldPos, 1.0f);
outpt.v.normal = normal;
outpt.v.tangent = BiTangent;
outpt.v.bitangent = Tangent;
outpt.v.tangent = 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);

View File

@ -101,7 +101,6 @@ void main()
#ifdef OSD_PATCH_TESS_EVAL_GREGORY_BASIS_SHADER
layout(quads) in;
layout(cw) in;
#if defined OSD_FRACTIONAL_ODD_SPACING
layout(fractional_odd_spacing) in;
@ -180,9 +179,7 @@ void main()
for (int i=0; i<4; ++i) {
for (uint j=0; j<4; ++j) {
// reverse face front
vec3 A = q[i + 4*j];
vec3 A = q[4*i + j];
BUCP[i] += A * B[j];
DUCP[i] += A * D[j];
CUCP[i] += A * C[j];
@ -207,7 +204,7 @@ void main()
dVV *= 6 * level;
dUV *= 9 * level;
vec3 n = cross(BiTangent, Tangent);
vec3 n = cross(Tangent, BiTangent);
vec3 normal = normalize(n);
float E = dot(Tangent, Tangent);
@ -235,9 +232,7 @@ void main()
for (int i=0; i<4; ++i) {
for (uint j=0; j<4; ++j) {
// reverse face front
vec3 A = q[i + 4*j];
vec3 A = q[4*i + j];
BUCP[i] += A * B[j];
DUCP[i] += A * D[j];
}
@ -254,15 +249,15 @@ void main()
BiTangent *= 3 * level;
Tangent *= 3 * level;
vec3 normal = normalize(cross(BiTangent, Tangent));
vec3 normal = normalize(cross(Tangent, BiTangent));
#endif
outpt.v.position = vec4(WorldPos, 1.0f);
outpt.v.normal = normal;
outpt.v.tangent = BiTangent;
outpt.v.bitangent = Tangent;
outpt.v.tangent = 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);

View File

@ -295,7 +295,7 @@ HS_CONSTANT_FUNC_OUT HSConstFunc(
[domain("quad")]
[partitioning(HS_PARTITION)]
[outputtopology("triangle_ccw")]
[outputtopology("triangle_cw")]
[outputcontrolpoints(4)]
[patchconstantfunc("HSConstFunc")]
GregDomainVertex hs_main_patches(
@ -537,9 +537,7 @@ void ds_main_patches(
for (int i=0; i<4; ++i) {
for (uint j=0; j<4; ++j) {
// reverse face front
float3 A = q[i + 4*j];
float3 A = q[4*i + j];
BUCP[i] += A * B[j];
DUCP[i] += A * D[j];
CUCP[i] += A * C[j];
@ -583,7 +581,7 @@ void ds_main_patches(
BiTangent = mul(OsdModelViewMatrix(), float4(BiTangent, 0)).xyz;
Tangent = mul(OsdModelViewMatrix(), float4(Tangent, 0)).xyz;
normal = normalize(cross(BiTangent, Tangent));
normal = normalize(cross(Tangent, BiTangent));
output.Nu = Nu;
output.Nv = Nv;
@ -597,9 +595,7 @@ void ds_main_patches(
for (int i=0; i<4; ++i) {
for (uint j=0; j<4; ++j) {
// reverse face front
float3 A = q[i + 4*j];
float3 A = q[4*i + j];
BUCP[i] += A * B[j];
DUCP[i] += A * D[j];
}
@ -619,18 +615,18 @@ void ds_main_patches(
BiTangent = mul(OsdModelViewMatrix(), float4(BiTangent, 0)).xyz;
Tangent = mul(OsdModelViewMatrix(), float4(Tangent, 0)).xyz;
float3 normal = normalize(cross(BiTangent, Tangent));
float3 normal = normalize(cross(Tangent, BiTangent));
#endif
output.position = mul(OsdModelViewMatrix(), float4(WorldPos, 1.0f));
output.normal = normal;
output.tangent = BiTangent;
output.bitangent = Tangent;
output.tangent = Tangent;
output.bitangent = BiTangent;
output.edgeDistance = 0;
float2 UV = float2(v, u);
float2 UV = float2(u, v);
output.patchCoord = OsdInterpolatePatchCoord(UV, patch[0].patchCoord);
OSD_DISPLACEMENT_CALLBACK;

View File

@ -78,7 +78,7 @@ HSConstFunc(
[domain("quad")]
[partitioning(HS_PARTITION)]
[outputtopology("triangle_ccw")]
[outputtopology("triangle_cw")]
[outputcontrolpoints(20)]
[patchconstantfunc("HSConstFunc")]
HullVertex hs_main_patches(
@ -159,9 +159,7 @@ void ds_main_patches(
for (int i=0; i<4; ++i) {
for (uint j=0; j<4; ++j) {
// reverse face front
float3 A = q[i + 4*j];
float3 A = q[4*i + j];
BUCP[i] += A * B[j];
DUCP[i] += A * D[j];
CUCP[i] += A * C[j];
@ -186,7 +184,7 @@ void ds_main_patches(
dVV *= 6 * level;
dUV *= 9 * level;
float3 n = cross(BiTangent, Tangent);
float3 n = cross(Tangent, BiTangent);
float3 normal = normalize(n);
float E = dot(Tangent, Tangent);
@ -214,9 +212,7 @@ void ds_main_patches(
for (int i=0; i<4; ++i) {
for (uint j=0; j<4; ++j) {
// reverse face front
float3 A = q[i + 4*j];
float3 A = q[4*i + j];
BUCP[i] += A * B[j];
DUCP[i] += A * D[j];
}
@ -233,18 +229,18 @@ void ds_main_patches(
BiTangent *= 3 * level;
Tangent *= 3 * level;
float3 normal = normalize(cross(BiTangent, Tangent));
float3 normal = normalize(cross(Tangent, BiTangent));
#endif
output.position = float4(WorldPos, 1.0f);
output.normal = normal;
output.tangent = BiTangent;
output.bitangent = Tangent;
output.tangent = Tangent;
output.bitangent = BiTangent;
output.edgeDistance = 0;
float2 UV = float2(v, u);
float2 UV = float2(u, v);
output.patchCoord = OsdInterpolatePatchCoord(UV, patch[0].patchCoord);
OSD_DISPLACEMENT_CALLBACK;