Files
Seele/res/shaders/lib/StaticMeshVertexData.slang
T
2023-10-09 17:20:30 +02:00

58 lines
1.3 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, InstanceData inst)
{
StaticMeshVertexAttributes attr;
float4 localPos = float4(positions[index], 1);
float4 worldPos = mul(inst.transformMatrix, 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;
}
ParameterBlock<StaticMeshVertexData> vertexData;