Moved shaders to new directory

This commit is contained in:
Sascha Willems 2023-05-09 21:03:02 +02:00
parent 0b3f8340e3
commit 99b226237a
1244 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,21 @@
#version 450
layout (binding = 1) uniform sampler2D samplerGradientRamp;
layout (location = 0) in vec3 inColor;
layout (location = 1) in vec2 inUV;
layout (location = 0) out vec4 outFragColor;
void main()
{
// Use max. color channel value to detect bright glow emitters
if ((inColor.r >= 0.9) || (inColor.g >= 0.9) || (inColor.b >= 0.9))
{
outFragColor.rgb = texture(samplerGradientRamp, inUV).rgb;
}
else
{
outFragColor.rgb = inColor;
}
}

Binary file not shown.

View file

@ -0,0 +1,26 @@
#version 450
layout (location = 0) in vec3 inPos;
layout (location = 2) in vec3 inColor;
layout (binding = 0) uniform UBO
{
mat4 projection;
mat4 model;
float gradientPos;
} ubo;
layout (location = 0) out vec3 outColor;
layout (location = 1) out vec2 outUV;
out gl_PerVertex
{
vec4 gl_Position;
};
void main()
{
outColor = inColor;
outUV = vec2(ubo.gradientPos, 0.0f);
gl_Position = ubo.projection * ubo.model * vec4(inPos, 1.0);
}

Binary file not shown.

View file

@ -0,0 +1,33 @@
#version 450
layout (binding = 1) uniform sampler2D samplerGradientRamp;
layout (location = 0) in vec3 inNormal;
layout (location = 1) in vec3 inColor;
layout (location = 2) in vec3 inEyePos;
layout (location = 3) in vec3 inLightVec;
layout (location = 4) in vec2 inUV;
layout (location = 0) out vec4 outFragColor;
void main()
{
// No light calculations for glow color
// Use max. color channel value
// to detect bright glow emitters
if ((inColor.r >= 0.9) || (inColor.g >= 0.9) || (inColor.b >= 0.9))
{
outFragColor.rgb = texture(samplerGradientRamp, inUV).rgb;
}
else
{
vec3 Eye = normalize(-inEyePos);
vec3 Reflected = normalize(reflect(-inLightVec, inNormal));
vec4 IAmbient = vec4(0.2, 0.2, 0.2, 1.0);
vec4 IDiffuse = vec4(0.5, 0.5, 0.5, 0.5) * max(dot(inNormal, inLightVec), 0.0);
float specular = 0.25;
vec4 ISpecular = vec4(0.5, 0.5, 0.5, 1.0) * pow(max(dot(Reflected, Eye), 0.0), 4.0) * specular;
outFragColor = vec4((IAmbient + IDiffuse) * vec4(inColor, 1.0) + ISpecular);
}
}

Binary file not shown.

View file

@ -0,0 +1,34 @@
#version 450
layout (location = 0) in vec4 pos;
layout (location = 2) in vec3 inColor;
layout (location = 3) in vec3 inNormal;
layout (binding = 0) uniform UBO
{
mat4 projection;
mat4 model;
float gradientPos;
} ubo;
layout (location = 0) out vec3 outNormal;
layout (location = 1) out vec3 outColor;
layout (location = 2) out vec3 outEyePos;
layout (location = 3) out vec3 outLightVec;
layout (location = 4) out vec2 outUV;
out gl_PerVertex
{
vec4 gl_Position;
};
void main()
{
outNormal = inNormal;
outColor = inColor;
outUV = vec2(ubo.gradientPos, 0.0);
gl_Position = ubo.projection * ubo.model * pos;
outEyePos = vec3(ubo.model * pos);
vec4 lightPos = vec4(0.0, 0.0, -5.0, 1.0);// * ubo.model;
outLightVec = normalize(lightPos.xyz - pos.xyz);
}

Binary file not shown.

View file

@ -0,0 +1,35 @@
#version 450
layout (binding = 1) uniform sampler2D samplerColor;
layout (binding = 0) uniform UBO
{
float radialBlurScale;
float radialBlurStrength;
vec2 radialOrigin;
} ubo;
layout (location = 0) in vec2 inUV;
layout (location = 0) out vec4 outFragColor;
void main()
{
ivec2 texDim = textureSize(samplerColor, 0);
vec2 radialSize = vec2(1.0 / texDim.s, 1.0 / texDim.t);
vec2 UV = inUV;
vec4 color = vec4(0.0, 0.0, 0.0, 0.0);
UV += radialSize * 0.5 - ubo.radialOrigin;
#define samples 32
for (int i = 0; i < samples; i++)
{
float scale = 1.0 - ubo.radialBlurScale * (float(i) / float(samples-1));
color += texture(samplerColor, UV * scale + ubo.radialOrigin);
}
outFragColor = (color / samples) * ubo.radialBlurStrength;
}

Binary file not shown.

View file

@ -0,0 +1,14 @@
#version 450
layout (location = 0) out vec2 outUV;
out gl_PerVertex
{
vec4 gl_Position;
};
void main()
{
outUV = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
gl_Position = vec4(outUV * 2.0f - 1.0f, 0.0f, 1.0f);
}

Binary file not shown.