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

30 lines
1.3 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;
2023-11-13 09:07:23 +01:00
float4 modelPos = float4(positions[3 * index + 0], positions[3 * index + 1], positions[3 * index + 2], 1);
float4 worldPos = mul(transform, modelPos);
2023-11-08 23:27:21 +01:00
float4 viewPos = mul(pViewParams.viewMatrix, worldPos);
float4 clipPos = mul(pViewParams.projectionMatrix, viewPos);
2023-11-13 09:07:23 +01:00
attributes.normal_MS = float3(normals[3 * index + 0], normals[3 * index + 1], normals[3 * index + 2]);
attributes.tangent_MS = float3(tangents[3 * index + 0], tangents[3 * index + 1], tangents[3 * index + 2]);
attributes.biTangent_MS = float3(biTangents[3 * index + 0], biTangents[3 * index + 1], biTangents[3 * index + 2]);
attributes.position_WS = worldPos.xyz;
attributes.position_CS = clipPos;
attributes.texCoords = float2(texCoords[2 * index + 0], texCoords[2 * index + 1]);
attributes.vertexColor = float3(color[3 * index + 0], color[3 * index + 1], color[3 * index + 2]);
2023-11-09 22:15:51 +01:00
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-11 22:39:17 +01:00
StructuredBuffer<float> color;
2023-11-08 23:27:21 +01:00
};