project-aster/samples/03_model_render/shader/graphics_structs.hlsli

66 lines
1.6 KiB
HLSL

#include "bindless_structs.hlsli"
struct CameraData
{
float4x4 View; // 64
float4x4 Projection; // 128
float4x4 InvView; // 192
float4x4 InvProjection; // 256
float4 Position; // 272
};
struct Lighting
{
uint EnvCubeHandle; // 4
uint DiffuseIrradianceHandle; // 8
uint PrefilterHandle; // 12
uint BrdfLutHandle; // 16
uint LightHandle; // 20
uint PointLightIndexer; // 24
uint DirectionalLightIndexer; // 28
};
struct ModelHandles
{
uint VertexBufferHandle; // 4
uint VertexDataHandle; // 8
uint MaterialBufferHandle; // 12
uint NodeBufferHandle; // 16
};
struct Block
{
uint VertexBufferHandle; // 4
uint VertexDataHandle; // 8
uint MaterialBufferHandle; // 12
uint NodeBufferHandle; // 16
uint DebugFlags; // 20
int MaterialIdx; // 24
uint NodeIdx; // 28
};
static const uint USE_DIFFUSE_BIT = 1;
static const uint USE_SPECULAR_BIT = 2;
static const uint SHOW_DIFFUSE_BIT = 4;
static const uint SHOW_PREFILTER_BIT = 8;
[[vk::binding(0, 1)]] ConstantBuffer<CameraData> Camera;
[[vk::binding(1, 1)]] ConstantBuffer<Lighting> Lights;
[[vk::binding(2, 1)]] ConstantBuffer<ModelHandles> Model;
[[vk::push_constant]]
Block PushConstant;
float3 Uncharted2Tonemap(float3 color)
{
float A = 0.15f;
float B = 0.50f;
float C = 0.10f;
float D = 0.20f;
float E = 0.02f;
float F = 0.30f;
float W = 11.2f;
return ((color * (A * color + C * B) + D * E) / (color * (A * color + B) + D * F)) - E / F;
}