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

30 lines
915 B
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-10-09 17:20:30 +02:00
float4 localPos = float4(positions[index], 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;
params.texCoords = texCoords[index];
params.normal = normals[index];
params.tangent = tangents[index];
params.biTangent = biTangents[index];
attributes.parameter = params;
attributes.clipPosition = clipPos;
return attributes;
2023-10-07 19:29:53 +02:00
}
2023-10-09 17:20:30 +02:00
StructuredBuffer<float3> positions;
2023-10-07 19:29:53 +02:00
StructuredBuffer<float2> texCoords;
StructuredBuffer<float3> normals;
2023-10-09 17:20:30 +02:00
StructuredBuffer<float3> tangents;
StructuredBuffer<float3> biTangents;
2023-11-08 23:27:21 +01:00
};