mirror of
https://github.com/antopilo/Nuake.git
synced 2025-12-30 21:49:06 +03:00
115 lines
2.1 KiB
GLSL
115 lines
2.1 KiB
GLSL
// Transforms
|
|
struct ModelData
|
|
{
|
|
float4x4 model;
|
|
};
|
|
[[vk::binding(0, 0)]]
|
|
StructuredBuffer<ModelData> model : register(t1);
|
|
|
|
// Vertex
|
|
struct Vertex
|
|
{
|
|
float3 position;
|
|
float uv_x;
|
|
float3 normal;
|
|
float uv_y;
|
|
float3 tangent;
|
|
float3 bitangent;
|
|
};
|
|
|
|
[[vk::binding(0, 1)]]
|
|
StructuredBuffer<Vertex> vertexBuffer : register(t2);
|
|
|
|
// Samplers
|
|
[[vk::binding(0, 2)]]
|
|
SamplerState mySampler : register(s0);
|
|
|
|
// Materials
|
|
struct Material
|
|
{
|
|
bool hasAlbedo;
|
|
float3 albedo;
|
|
bool hasNormal;
|
|
bool hasMetalness;
|
|
bool hasRoughness;
|
|
bool hasAO;
|
|
float metalnessValue;
|
|
float roughnessValue;
|
|
float aoValue;
|
|
int albedoTextureId;
|
|
int normalTextureId;
|
|
int metalnessTextureId;
|
|
int roughnessTextureId;
|
|
int aoTextureId;
|
|
};
|
|
[[vk::binding(0, 3)]]
|
|
StructuredBuffer<Material> material;
|
|
|
|
// Textures
|
|
[[vk::binding(0, 4)]]
|
|
Texture2D textures[];
|
|
|
|
// Lights
|
|
struct Light
|
|
{
|
|
float3 position;
|
|
int type;
|
|
float4 color;
|
|
float3 direction;
|
|
float outerConeAngle;
|
|
float innerConeAngle;
|
|
bool castShadow;
|
|
int shadowMapTextureId[4];
|
|
int transformId[4];
|
|
};
|
|
|
|
[[vk::binding(0, 5)]]
|
|
StructuredBuffer<Light> lights;
|
|
|
|
// Cameras
|
|
struct CameraView {
|
|
float4x4 View;
|
|
float4x4 Projection;
|
|
float4x4 ViewProjection;
|
|
float4x4 InverseView;
|
|
float4x4 InverseProjection;
|
|
float3 Position;
|
|
float Near;
|
|
float Far;
|
|
};
|
|
[[vk::binding(0, 6)]]
|
|
StructuredBuffer<CameraView> cameras;
|
|
|
|
struct ShadingPushConstant
|
|
{
|
|
int AlbedoInputTextureId;
|
|
int DepthInputTextureId;
|
|
int NormalInputTextureId;
|
|
int MaterialInputTextureId;
|
|
int LightCount;
|
|
int CameraID;
|
|
float cascadeDepth[4];
|
|
float AmbientTerm;
|
|
};
|
|
|
|
[[vk::push_constant]]
|
|
ShadingPushConstant pushConstants;
|
|
|
|
// Outputs
|
|
struct VSOutput {
|
|
float4 Position : SV_Position;
|
|
float2 UV : TEXCOORD0;
|
|
};
|
|
|
|
|
|
// Main vertex shader
|
|
VSOutput main(uint vertexIndex : SV_VertexID)
|
|
{
|
|
VSOutput output;
|
|
|
|
Vertex v = vertexBuffer[vertexIndex];
|
|
output.UV = float2(v.uv_x, v.uv_y);
|
|
output.Position = float4(v.position, 1.0f);
|
|
|
|
return output;
|
|
} |