compressing normal space to qtangents
This commit is contained in:
@@ -12,7 +12,6 @@ struct LightingParameter
|
||||
float3x3 tangentToWorld;
|
||||
float3 viewDir_WS;
|
||||
float3 position_WS;
|
||||
float3 normal_WS;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +91,6 @@ struct FragmentParameter
|
||||
result.tangentToWorld = getTangentToWorld();
|
||||
result.viewDir_WS = normalize(pViewParams.cameraPosition_WS.xyz - position_WS);
|
||||
result.position_WS = position_WS;
|
||||
result.normal_WS = normalize(normal_WS);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -127,9 +125,7 @@ struct VertexAttributes
|
||||
{
|
||||
float3 position_MS;
|
||||
#ifndef POS_ONLY
|
||||
float3 normal_MS;
|
||||
float3 tangent_MS;
|
||||
float3 biTangent_MS;
|
||||
float4 qTangent;
|
||||
float3 vertexColor;
|
||||
float2 texCoords[MAX_TEXCOORDS];
|
||||
#endif
|
||||
@@ -142,9 +138,10 @@ struct VertexAttributes
|
||||
FragmentParameter result;
|
||||
result.position_CS = clipPos;
|
||||
#ifndef POS_ONLY
|
||||
result.tangent_WS = normalize(mul(transformMatrix, float4(tangent_MS, 0)).xyz);
|
||||
result.biTangent_WS = normalize(mul(transformMatrix, float4(biTangent_MS, 0)).xyz);
|
||||
result.normal_WS = normalize(mul(transformMatrix, float4(normal_MS, 0)).xyz);
|
||||
float3x3 tbn = qTangentToMatrix(qTangent);
|
||||
result.tangent_WS = normalize(mul(transformMatrix, float4(tbn[0], 0)).xyz);
|
||||
result.biTangent_WS = normalize(mul(transformMatrix, float4(tbn[1], 0)).xyz);
|
||||
result.normal_WS = normalize(mul(transformMatrix, float4(tbn[2], 0)).xyz);
|
||||
result.vertexColor = vertexColor;
|
||||
result.position_WS = worldPos.xyz;
|
||||
result.texCoords0 = float4(texCoords[0], texCoords[1]);
|
||||
|
||||
@@ -14,9 +14,9 @@ struct StaticMeshVertexData
|
||||
VertexAttributes attributes;
|
||||
attributes.position_MS = float3(positions[index * 3 + 0], positions[index * 3 + 1], positions[index * 3 + 2]);
|
||||
#ifndef POS_ONLY
|
||||
attributes.normal_MS = float3(normals[index * 3 + 0], normals[index * 3 + 1], normals[index * 3 + 2]);
|
||||
attributes.tangent_MS = float3(tangents[index * 3 + 0], tangents[index * 3 + 1], tangents[index * 3 + 2]);
|
||||
attributes.biTangent_MS = float3(biTangents[index * 3 + 0], biTangents[index * 3 + 1], biTangents[index * 3 + 2]);
|
||||
attributes.qTangent = qTangent[index];
|
||||
//attributes.tangent_MS = float3(tangents[index * 3 + 0], tangents[index * 3 + 1], tangents[index * 3 + 2]);
|
||||
//attributes.biTangent_MS = float3(biTangents[index * 3 + 0], biTangents[index * 3 + 1], biTangents[index * 3 + 2]);
|
||||
for(uint i = 0; i < MAX_TEXCOORDS; ++i)
|
||||
{
|
||||
attributes.texCoords[i] = float2(uint16ToFloat(texCoords[i][index * 2 + 0]), uint16ToFloat(texCoords[i][index * 2 + 1]));
|
||||
@@ -26,9 +26,9 @@ struct StaticMeshVertexData
|
||||
return attributes;
|
||||
}
|
||||
StructuredBuffer<float> positions;
|
||||
StructuredBuffer<float> normals;
|
||||
StructuredBuffer<float> tangents;
|
||||
StructuredBuffer<float> biTangents;
|
||||
StructuredBuffer<float4> qTangent;
|
||||
//StructuredBuffer<float> tangents;
|
||||
//StructuredBuffer<float> biTangents;
|
||||
StructuredBuffer<uint16_t> color;
|
||||
StructuredBuffer<uint16_t> texCoords[MAX_TEXCOORDS];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user