Files
Seele/res/shaders/lib/StaticMeshVertexData.slang
T
2023-10-24 15:01:09 +02:00

59 lines
1.4 KiB
Plaintext

import VertexData;
import Common;
import Scene;
struct StaticMeshVertexAttributes : VertexAttributes
{
float4 clipPosition: SV_Position;
float3 worldPosition: POSITION0;
float2 texCoords: TEXCOORD0;
float3 normal: NORMAL0;
float3 tangent: TANGENT0;
float3 biTangent: BITANGENT0;
float3 getWorldPosition()
{
return worldPosition;
}
float2 getTexCoords()
{
return texCoords;
}
float3 getNormal()
{
return normal;
}
float3 getTangent()
{
return tangent;
}
float3 getBiTangent()
{
return biTangent;
}
}
struct StaticMeshVertexData : VertexData
{
StaticMeshVertexAttributes getAttributes(uint index, float4x4 transform)
{
StaticMeshVertexAttributes attr;
float4 localPos = float4(positions[index], 1);
float4 worldPos = mul(transform, localPos);
float4 viewPos = mul(viewParams.viewMatrix, worldPos);
float4 clipPos = mul(viewParams.projectionMatrix, viewPos);
attr.clipPosition = clipPos;
attr.worldPosition = worldPos.xyz;
attr.texCoords = texCoords[index];
attr.normal = normals[index];
attr.tangent = tangents[index];
attr.biTangent = biTangents[index];
return attr;
}
StructuredBuffer<float3> positions;
StructuredBuffer<float2> texCoords;
StructuredBuffer<float3> normals;
StructuredBuffer<float3> tangents;
StructuredBuffer<float3> biTangents;
}
layout(set = INDEX_VERTEX_DATA)
ParameterBlock<StaticMeshVertexData> vertexData;