Files
Seele/res/shaders/lib/StaticMeshVertexData.slang
T

30 lines
1.2 KiB
Plaintext
Raw Normal View History

2023-10-07 19:29:53 +02:00
import Common;
2023-11-08 23:27:21 +01:00
import VertexData;
import MaterialParameter;
2023-10-07 19:29:53 +02:00
2023-11-08 23:27:21 +01:00
struct StaticMeshVertexData : IVertexData
2023-10-07 19:29:53 +02:00
{
2023-11-09 22:15:51 +01:00
VertexAttributes getAttributes(uint index, float4x4 transform)
2023-10-07 19:29:53 +02:00
{
2023-11-09 22:15:51 +01:00
VertexAttributes attributes;
MaterialParameter params;
2023-11-10 19:18:09 +01:00
float4 localPos = float4(positions[3 * index + 0], positions[3 * index + 1], positions[3 * index + 2], 1);
2023-10-24 15:01:09 +02:00
float4 worldPos = mul(transform, localPos);
2023-11-08 23:27:21 +01:00
float4 viewPos = mul(pViewParams.viewMatrix, worldPos);
float4 clipPos = mul(pViewParams.projectionMatrix, viewPos);
2023-11-09 22:15:51 +01:00
params.worldPosition = worldPos.xyz;
2023-11-10 19:18:09 +01:00
params.texCoords = float2(texCoords[2 * index + 0], texCoords[2 * index + 1]);
params.normal = float3(normals[3 * index + 0], normals[3 * index + 1], normals[3 * index + 2]);
params.tangent = float3(tangents[3 * index + 0], tangents[3 * index + 1], tangents[3 * index + 2]);
params.biTangent = float3(biTangents[3 * index + 0], biTangents[3 * index + 1], biTangents[3 * index + 2]);
2023-11-09 22:15:51 +01:00
attributes.parameter = params;
attributes.clipPosition = clipPos;
return attributes;
2023-10-07 19:29:53 +02:00
}
2023-11-10 19:18:09 +01:00
StructuredBuffer<float> positions;
StructuredBuffer<float> texCoords;
StructuredBuffer<float> normals;
StructuredBuffer<float> tangents;
StructuredBuffer<float> biTangents;
2023-11-08 23:27:21 +01:00
};