SHADE_Y3/Assets/Shaders/Silhouette_FS.glsl

67 lines
1.5 KiB
Plaintext
Raw Normal View History

#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
#extension GL_EXT_nonuniform_qualifier : require
struct MatPropData
{
vec4 color;
};
struct GenericData
{
//! Delta time
float dt;
//! Elapsed time of the application
float elapsedTime;
//! Viewport width of the scene (excluding imgui, that means smaller than window)
uint viewportWidth;
//! Ditto but for height
uint viewportHeight;
};
layout(location = 0) in struct
{
vec4 vertPos; // location 0
vec2 uv; // location = 1
vec4 normal; // location = 2
vec4 worldPos; // location = 3
} In;
// material stuff
layout(location = 4) flat in struct
{
int materialIndex;
uint eid;
uint lightLayerIndex;
} In2;
layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global)
layout (std430, set = 2, binding = 0) buffer MaterialProperties // For materials
{
MatPropData data[];
} MatProp;
layout (set = 0, binding = 0) uniform GenericDataBuffer
{
GenericData data;
} genericDataBuffer;
layout(location = 0) out vec4 objectVFX;
layout(input_attachment_index = 0, set = 3, binding = 0) uniform subpassInput depthBuffer;
void main()
{
// Sample depth buffer using UV and save it
float currentDepth = subpassLoad (depthBuffer).r;
// Use depth buffer to check against current fragment's depth. If fragment is behind depth buffer, render fragment.
if (currentDepth > gl_FragCoord.z)
discard;
objectVFX = MatProp.data[In2.materialIndex].color;
}