Add shading for shapes and the floor
This commit is contained in:
@@ -1,17 +1,24 @@
|
||||
#version 450 core
|
||||
uniform vec3 lightPos;
|
||||
uniform vec4 lumRad;
|
||||
uniform sampler2D screenTexture;
|
||||
layout (binding = 0) uniform sampler2D screenTexture;
|
||||
layout (binding = 1) uniform sampler2D normals;
|
||||
in vec2 vTexPos;
|
||||
out vec4 fColor;
|
||||
float rad = lumRad.a;
|
||||
void main() {
|
||||
vec3 distVec = texture(screenTexture, vTexPos).xyz - lightPos;
|
||||
vec3 pos = texture(screenTexture, vTexPos).xyz;
|
||||
vec3 distVec = pos - lightPos;
|
||||
vec4 normbit = texture(normals, vTexPos);
|
||||
vec3 norm = normbit.xyz - pos;
|
||||
float y1 = float(normbit.w == 0 ? 1 : dot(normalize(norm), normalize(distVec)));
|
||||
float y = float(y1 > 0 ? 1 : 0);
|
||||
// float y = float(normbit.w == 1 ? 1 : 0);
|
||||
float dist = dot(distVec, distVec);
|
||||
if (dist > rad) {
|
||||
discard;
|
||||
}
|
||||
float x = 1 - dist / rad;
|
||||
vec3 c = (x * x * x) * lumRad.rgb;
|
||||
vec3 c = y* (x * x * x) * lumRad.rgb;
|
||||
fColor = vec4(c, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user