Updated bloom shaders (better lighting with specular)
This commit is contained in:
parent
997898032c
commit
4807931164
12 changed files with 22 additions and 21 deletions
|
|
@ -80,7 +80,7 @@ public:
|
|||
int32_t texWidth = TEX_DIM;
|
||||
int32_t texHeight = TEX_DIM;
|
||||
float blurScale = 1.0f;
|
||||
float blurStrength = 1.0f;
|
||||
float blurStrength = 1.5f;
|
||||
uint32_t horizontal;
|
||||
};
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -8,28 +8,26 @@ layout (binding = 1) uniform sampler2D colorMap;
|
|||
layout (location = 0) in vec3 inNormal;
|
||||
layout (location = 1) in vec2 inUV;
|
||||
layout (location = 2) in vec3 inColor;
|
||||
layout (location = 3) in vec3 inEyePos;
|
||||
layout (location = 3) in vec3 inViewVec;
|
||||
layout (location = 4) in vec3 inLightVec;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
// No light calculations for glow color
|
||||
// Use max. color channel value
|
||||
// to detect bright glow emitters
|
||||
vec3 ambient = vec3(0.0f);
|
||||
|
||||
// Adjust light calculations for glow color
|
||||
if ((inColor.r >= 0.9) || (inColor.g >= 0.9) || (inColor.b >= 0.9))
|
||||
{
|
||||
outFragColor.rgb = inColor;
|
||||
ambient = inColor * 0.25;
|
||||
}
|
||||
else
|
||||
{
|
||||
vec3 Eye = normalize(-inEyePos);
|
||||
vec3 Reflected = normalize(reflect(-inLightVec, inNormal));
|
||||
|
||||
vec4 IDiffuse = vec4(inColor, 1.0) * 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), 16.0) * specular;
|
||||
outFragColor = IDiffuse + ISpecular;
|
||||
}
|
||||
vec3 N = normalize(inNormal);
|
||||
vec3 L = normalize(inLightVec);
|
||||
vec3 V = normalize(inViewVec);
|
||||
vec3 R = reflect(-L, N);
|
||||
vec3 diffuse = max(dot(N, L), 0.0) * inColor;
|
||||
vec3 specular = pow(max(dot(R, V), 0.0), 8.0) * vec3(0.75);
|
||||
outFragColor = vec4(ambient + diffuse + specular, 1.0);
|
||||
}
|
||||
Binary file not shown.
|
|
@ -11,13 +11,13 @@ layout (location = 3) in vec3 inNormal;
|
|||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 model;
|
||||
mat4 modelview;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec3 outNormal;
|
||||
layout (location = 1) out vec2 outUV;
|
||||
layout (location = 2) out vec3 outColor;
|
||||
layout (location = 3) out vec3 outEyePos;
|
||||
layout (location = 3) out vec3 outViewVec;
|
||||
layout (location = 4) out vec3 outLightVec;
|
||||
|
||||
void main()
|
||||
|
|
@ -25,8 +25,11 @@ void main()
|
|||
outNormal = inNormal;
|
||||
outColor = inColor;
|
||||
outUV = inUV;
|
||||
gl_Position = ubo.projection * ubo.model * inPos;
|
||||
outEyePos = vec3(ubo.model * inPos);
|
||||
vec4 lightPos = vec4(-5.0, -5.0, 0.0, 1.0);
|
||||
outLightVec = normalize(lightPos.xyz - inPos.xyz);
|
||||
gl_Position = ubo.projection * ubo.modelview * inPos;
|
||||
|
||||
vec3 lightPos = vec3(-5.0, -5.0, 0.0);
|
||||
vec4 pos = ubo.modelview * inPos;
|
||||
outNormal = mat3(ubo.modelview) * inNormal;
|
||||
outLightVec = lightPos - pos.xyz;
|
||||
outViewVec = -pos.xyz;
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 483 KiB After Width: | Height: | Size: 476 KiB |
Loading…
Add table
Add a link
Reference in a new issue