86 lines
1.8 KiB
HLSL
86 lines
1.8 KiB
HLSL
|
|
struct VertexData
|
|
{
|
|
float4 Normal;
|
|
float2 TexCoord0;
|
|
float2 TexCoord1;
|
|
float4 Color0;
|
|
};
|
|
|
|
struct TransformData
|
|
{
|
|
float4x4 Transform;
|
|
float4x4 NormalTransform;
|
|
};
|
|
|
|
struct MaterialData
|
|
{
|
|
float AlbedoFactor[4];
|
|
float EmissionFactor[3];
|
|
float MetalFactor;
|
|
float RoughFactor;
|
|
uint AlbedoTex;
|
|
uint NormalTex;
|
|
uint MetalRoughTex;
|
|
uint OcclusionTex;
|
|
uint EmissionTex;
|
|
};
|
|
|
|
struct Block
|
|
{
|
|
uint VertexBufferHandle;
|
|
uint VertexDataHandle;
|
|
uint MaterialBufferHandle;
|
|
uint NodeBufferHandle;
|
|
uint LightHandle;
|
|
uint PointLightIndexer;
|
|
uint DirectionLightIndexer;
|
|
int MaterialIdx;
|
|
uint NodeIdx;
|
|
};
|
|
|
|
struct PointLight
|
|
{
|
|
float Position[3];
|
|
float Range;
|
|
uint Color;
|
|
float Intensity;
|
|
};
|
|
|
|
struct DirectionalLight
|
|
{
|
|
float Direction[3];
|
|
float Validity_;
|
|
uint Color;
|
|
float Intensity;
|
|
};
|
|
|
|
struct CameraData
|
|
{
|
|
float4x4 View;
|
|
float4x4 Projection;
|
|
float4 Position;
|
|
};
|
|
|
|
// Little Endian storage. First short is least significant.
|
|
#define IndexerCount(Indexer) (Indexer & 0xFFFF)
|
|
#define IndexerOffset(Indexer) ((Indexer & 0xFFFF0000) >> 16);
|
|
|
|
#define INVALID_HANDLE 0xFFFFFFFF
|
|
|
|
static const float PI = 3.14159265f;
|
|
|
|
[[vk::binding(0, 0)]] StructuredBuffer<float4> VertexBuffer[];
|
|
[[vk::binding(0, 0)]] StructuredBuffer<VertexData> VertexDataBuffer[];
|
|
[[vk::binding(0, 0)]] StructuredBuffer<MaterialData> MaterialsBuffer[];
|
|
[[vk::binding(0, 0)]] StructuredBuffer<TransformData> NodeBuffer[];
|
|
[[vk::binding(0, 0)]] StructuredBuffer<PointLight> PointLightBuffer[];
|
|
[[vk::binding(0, 0)]] StructuredBuffer<DirectionalLight> DirectionalLightBuffer[];
|
|
|
|
[[vk::binding(1, 0)]] Texture2D<float4> Textures[];
|
|
[[vk::binding(1, 0)]] SamplerState ImmutableSamplers[];
|
|
|
|
[[vk::binding(0, 1)]] ConstantBuffer<CameraData> Camera;
|
|
|
|
[[vk::push_constant]]
|
|
Block PushConstant; |