61 lines
1.6 KiB
HLSL
61 lines
1.6 KiB
HLSL
#include "sh/common.hlsl"
|
|
|
|
/* ========================== *
|
|
* Root signature
|
|
* ========================== */
|
|
|
|
#define ROOTSIG \
|
|
"RootConstants(num32BitConstants=16, b0), " \
|
|
"SRV(t0), " \
|
|
"SRV(t1), " \
|
|
"DescriptorTable(SRV(t2, numDescriptors = unbounded, flags = DESCRIPTORS_VOLATILE)), " \
|
|
"StaticSampler(s0, " \
|
|
"filter = FILTER_MIN_MAG_MIP_POINT, " \
|
|
"addressU = TEXTURE_ADDRESS_CLAMP, " \
|
|
"addressV = TEXTURE_ADDRESS_CLAMP, " \
|
|
"addressW = TEXTURE_ADDRESS_CLAMP, " \
|
|
"maxAnisotropy = 1)"
|
|
|
|
ConstantBuffer<struct sh_material_constants> g_constants : register(b0);
|
|
StructuredBuffer<struct sh_material_instance> g_instances : register(t0);
|
|
StructuredBuffer<struct sh_material_grid> g_grids : register(t1);
|
|
Texture2D g_textures[] : register(t2);
|
|
|
|
SamplerState g_sampler : register(s0);
|
|
|
|
/* ========================== *
|
|
* Vertex shader
|
|
* ========================== */
|
|
|
|
struct vs_output {
|
|
DECLS(float4, SV_Position);
|
|
DECLS(float4, color_lin);
|
|
};
|
|
|
|
SH_ENTRY(ROOTSIG) struct vs_output vs(struct sh_shape_vert input)
|
|
{
|
|
struct vs_output output;
|
|
output.SV_Position = mul(g_constants.projection, float4(input.pos, 0, 1));
|
|
output.color_lin = linear_from_srgb32(input.color_srgb);
|
|
return output;
|
|
}
|
|
|
|
/* ========================== *
|
|
* Pixel shader
|
|
* ========================== */
|
|
|
|
struct ps_input {
|
|
struct vs_output vs;
|
|
};
|
|
|
|
struct ps_output {
|
|
DECLS(float4, SV_Target);
|
|
};
|
|
|
|
SH_ENTRY(ROOTSIG) struct ps_output ps(struct ps_input input)
|
|
{
|
|
struct ps_output output;
|
|
output.SV_Target = input.vs.color_lin;
|
|
return output;
|
|
}
|