Color gradient ramp for glowing parts of the mesh
This commit is contained in:
parent
cb5bd093ec
commit
e74e37cc16
11 changed files with 64 additions and 24 deletions
|
|
@ -3,11 +3,22 @@
|
|||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
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()
|
||||
{
|
||||
outFragColor.rgb = inColor;
|
||||
// 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.
|
|
@ -3,16 +3,18 @@
|
|||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (location = 0) in vec4 inPos;
|
||||
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
|
||||
{
|
||||
|
|
@ -22,5 +24,6 @@ out gl_PerVertex
|
|||
void main()
|
||||
{
|
||||
outColor = inColor;
|
||||
gl_Position = ubo.projection * ubo.model * inPos;
|
||||
outUV = vec2(ubo.gradientPos, 0.0f);
|
||||
gl_Position = ubo.projection * ubo.model * vec4(inPos, 1.0);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -3,10 +3,13 @@
|
|||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
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;
|
||||
|
||||
|
|
@ -17,7 +20,7 @@ void main()
|
|||
// to detect bright glow emitters
|
||||
if ((inColor.r >= 0.9) || (inColor.g >= 0.9) || (inColor.b >= 0.9))
|
||||
{
|
||||
outFragColor.rgb = inColor;
|
||||
outFragColor.rgb = texture(samplerGradientRamp, inUV).rgb;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -11,12 +11,14 @@ 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
|
||||
{
|
||||
|
|
@ -27,6 +29,7 @@ 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;
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -26,7 +26,7 @@ void main()
|
|||
vec4 color = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
UV += radialSize * 0.5 - ubo.radialOrigin;
|
||||
|
||||
#define samples 16
|
||||
#define samples 32
|
||||
|
||||
for (int i = 0; i < samples; i++)
|
||||
{
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue