|
@@ -1,5 +1,5 @@
|
|
|
Technique
|
|
Technique
|
|
|
-#if USE_BLEND_SHAPES
|
|
|
|
|
|
|
+#ifdef USE_BLEND_SHAPES
|
|
|
: base("MorphVertexInput") =
|
|
: base("MorphVertexInput") =
|
|
|
#else
|
|
#else
|
|
|
: base("NormalVertexInput") =
|
|
: base("NormalVertexInput") =
|
|
@@ -18,11 +18,6 @@ Technique
|
|
|
|
|
|
|
|
float3 tangentToWorldZ : NORMAL; // Note: Half-precision could be used
|
|
float3 tangentToWorldZ : NORMAL; // Note: Half-precision could be used
|
|
|
float4 tangentToWorldX : TANGENT; // Note: Half-precision could be used
|
|
float4 tangentToWorldX : TANGENT; // Note: Half-precision could be used
|
|
|
-
|
|
|
|
|
- #if USE_BLEND_SHAPES
|
|
|
|
|
- float3 deltaPosition : POSITION1;
|
|
|
|
|
- float4 deltaNormal : NORMAL1;
|
|
|
|
|
- #endif
|
|
|
|
|
};
|
|
};
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -34,6 +29,11 @@ Technique
|
|
|
float3 normal : NORMAL; // Note: Half-precision could be used
|
|
float3 normal : NORMAL; // Note: Half-precision could be used
|
|
|
float4 tangent : TANGENT; // Note: Half-precision could be used
|
|
float4 tangent : TANGENT; // Note: Half-precision could be used
|
|
|
float2 uv0 : TEXCOORD0;
|
|
float2 uv0 : TEXCOORD0;
|
|
|
|
|
+
|
|
|
|
|
+ #ifdef USE_BLEND_SHAPES
|
|
|
|
|
+ float3 deltaPosition : POSITION1;
|
|
|
|
|
+ float4 deltaNormal : NORMAL1;
|
|
|
|
|
+ #endif
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
struct VertexIntermediate
|
|
struct VertexIntermediate
|
|
@@ -47,19 +47,19 @@ Technique
|
|
|
float3x3 getTangentToLocal(VertexInput input, out float tangentSign)
|
|
float3x3 getTangentToLocal(VertexInput input, out float tangentSign)
|
|
|
{
|
|
{
|
|
|
float3 normal = input.normal * 2.0f - 1.0f;
|
|
float3 normal = input.normal * 2.0f - 1.0f;
|
|
|
- float4 tangent = input.tangent * 2.0f - 1.0f;
|
|
|
|
|
|
|
+ float3 tangent = input.tangent.xyz * 2.0f - 1.0f;
|
|
|
|
|
|
|
|
- #if USE_BLEND_SHAPES
|
|
|
|
|
- float3 deltaNormal = input.deltaNormal.xyz * 2.0f - 1.0f;
|
|
|
|
|
|
|
+ #ifdef USE_BLEND_SHAPES
|
|
|
|
|
+ float3 deltaNormal = (input.deltaNormal.xyz * 2.0f - 1.0f) * 2.0f;
|
|
|
normal = normalize(normal + deltaNormal * input.deltaNormal.w);
|
|
normal = normalize(normal + deltaNormal * input.deltaNormal.w);
|
|
|
tangent = normalize(tangent - dot(tangent, normal) * normal);
|
|
tangent = normalize(tangent - dot(tangent, normal) * normal);
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
- float3 bitangent = cross(normal, tangent.xyz) * tangent.w;
|
|
|
|
|
- tangentSign = tangent.w * gWorldDeterminantSign;
|
|
|
|
|
|
|
+ float3 bitangent = cross(normal, tangent) * input.tangent.w;
|
|
|
|
|
+ tangentSign = input.tangent.w * gWorldDeterminantSign;
|
|
|
|
|
|
|
|
// Note: Maybe it's better to store everything in row vector format?
|
|
// Note: Maybe it's better to store everything in row vector format?
|
|
|
- float3x3 result = float3x3(tangent.xyz, bitangent, normal);
|
|
|
|
|
|
|
+ float3x3 result = float3x3(tangent, bitangent, normal);
|
|
|
result = transpose(result);
|
|
result = transpose(result);
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
@@ -81,7 +81,7 @@ Technique
|
|
|
|
|
|
|
|
float4 getVertexWorldPosition(VertexInput input, VertexIntermediate intermediate)
|
|
float4 getVertexWorldPosition(VertexInput input, VertexIntermediate intermediate)
|
|
|
{
|
|
{
|
|
|
- #if USE_BLEND_SHAPES
|
|
|
|
|
|
|
+ #ifdef USE_BLEND_SHAPES
|
|
|
float4 position = float4(input.position + input.deltaPosition, 1.0f);
|
|
float4 position = float4(input.position + input.deltaPosition, 1.0f);
|
|
|
#else
|
|
#else
|
|
|
float4 position = float4(input.position, 1.0f);
|
|
float4 position = float4(input.position, 1.0f);
|
|
@@ -102,7 +102,7 @@ Technique
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
Technique
|
|
Technique
|
|
|
-#if USE_BLEND_SHAPES
|
|
|
|
|
|
|
+#ifdef USE_BLEND_SHAPES
|
|
|
: base("MorphVertexInput") =
|
|
: base("MorphVertexInput") =
|
|
|
#else
|
|
#else
|
|
|
: base("NormalVertexInput") =
|
|
: base("NormalVertexInput") =
|
|
@@ -126,7 +126,7 @@ Technique
|
|
|
in vec4 bs_tangent;
|
|
in vec4 bs_tangent;
|
|
|
in vec2 bs_texcoord0;
|
|
in vec2 bs_texcoord0;
|
|
|
|
|
|
|
|
- #if USE_BLEND_SHAPES
|
|
|
|
|
|
|
+ #ifdef USE_BLEND_SHAPES
|
|
|
in vec3 bs_position1;
|
|
in vec3 bs_position1;
|
|
|
in vec4 bs_normal1;
|
|
in vec4 bs_normal1;
|
|
|
#endif
|
|
#endif
|
|
@@ -142,12 +142,11 @@ Technique
|
|
|
vec4 gl_Position;
|
|
vec4 gl_Position;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- void getTangentToLocal(vec3 normal, vec4 tangent, out float tangentSign, out mat3 tangentToLocal)
|
|
|
|
|
|
|
+ void getTangentToLocal(vec3 normal, vec3 tangent, float tangentSign, out mat3 tangentToLocal)
|
|
|
{
|
|
{
|
|
|
- vec3 bitangent = cross(normal, tangent.xyz) * tangent.w;
|
|
|
|
|
- tangentSign = tangent.w * gWorldDeterminantSign;
|
|
|
|
|
-
|
|
|
|
|
- tangentToLocal[0] = tangent.xyz;
|
|
|
|
|
|
|
+ vec3 bitangent = cross(normal, tangent) * tangentSign;
|
|
|
|
|
+
|
|
|
|
|
+ tangentToLocal[0] = tangent;
|
|
|
tangentToLocal[1] = bitangent;
|
|
tangentToLocal[1] = bitangent;
|
|
|
tangentToLocal[2] = normal;
|
|
tangentToLocal[2] = normal;
|
|
|
}
|
|
}
|
|
@@ -155,17 +154,18 @@ Technique
|
|
|
void getVertexWorldPosition(VertexIntermediate intermediate, out vec4 result)
|
|
void getVertexWorldPosition(VertexIntermediate intermediate, out vec4 result)
|
|
|
{
|
|
{
|
|
|
vec3 normal = bs_normal * 2.0f - 1.0f;
|
|
vec3 normal = bs_normal * 2.0f - 1.0f;
|
|
|
- vec4 tangent = bs_tangent * 2.0f - 1.0f;
|
|
|
|
|
|
|
+ vec3 tangent = bs_tangent.xyz * 2.0f - 1.0f;
|
|
|
|
|
|
|
|
- #if USE_BLEND_SHAPES
|
|
|
|
|
- vec3 deltaNormal = bs_normal1.xyz * 2.0f - 1.0f;
|
|
|
|
|
|
|
+ #ifdef USE_BLEND_SHAPES
|
|
|
|
|
+ vec3 deltaNormal = (bs_normal1.xyz * 2.0f - 1.0f) * 2.0f;
|
|
|
normal = normalize(normal + deltaNormal * bs_normal1.w);
|
|
normal = normalize(normal + deltaNormal * bs_normal1.w);
|
|
|
tangent = normalize(tangent - dot(tangent, normal) * normal);
|
|
tangent = normalize(tangent - dot(tangent, normal) * normal);
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
- float tangentSign;
|
|
|
|
|
|
|
+ float tangentSign = bs_tangent.w;
|
|
|
mat3 tangentToLocal;
|
|
mat3 tangentToLocal;
|
|
|
getTangentToLocal(normal, tangent, tangentSign, tangentToLocal);
|
|
getTangentToLocal(normal, tangent, tangentSign, tangentToLocal);
|
|
|
|
|
+ tangentSign *= gWorldDeterminantSign;
|
|
|
|
|
|
|
|
mat3 tangentToWorld = mat3(gMatWorldNoScale) * tangentToLocal;
|
|
mat3 tangentToWorld = mat3(gMatWorldNoScale) * tangentToLocal;
|
|
|
result.worldNormal = tangentToWorld[2]; // Normal basis vector
|
|
result.worldNormal = tangentToWorld[2]; // Normal basis vector
|
|
@@ -174,7 +174,7 @@ Technique
|
|
|
|
|
|
|
|
void getVertexWorldPosition(out vec4 result)
|
|
void getVertexWorldPosition(out vec4 result)
|
|
|
{
|
|
{
|
|
|
- #if USE_BLEND_SHAPES
|
|
|
|
|
|
|
+ #ifdef USE_BLEND_SHAPES
|
|
|
vec4 position = vec4(bs_position + bs_position1, 1.0f);
|
|
vec4 position = vec4(bs_position + bs_position1, 1.0f);
|
|
|
#else
|
|
#else
|
|
|
vec4 position = vec4(bs_position, 1.0f);
|
|
vec4 position = vec4(bs_position, 1.0f);
|