Apply inverse-square law for fragment lighting
This commit is contained in:
parent
7cc4ffb114
commit
fa1e885d26
|
@ -31,7 +31,8 @@ TANGO = {'Butter': ('fce94f', 'edd400', 'c4a000'),
|
|||
'Plum': ('ad7fa8', '75507b', '5c3566'),
|
||||
'Scarlet Red': ('ef2929', 'cc0000', 'a40000'),
|
||||
'Aluminium': ('eeeeec', 'd3d7cf', 'babdb6',
|
||||
'888a85', '555753', '2e3436')}
|
||||
'888a85', '555753', '2e3436'),
|
||||
'Background': ('000000',)}
|
||||
COLOR_NAMES = ['Butter', 'Orange', 'Chocolate', 'Chameleon',
|
||||
'Sky Blue', 'Plum', 'Scarlet Red']
|
||||
NEIGHBORS = set(chain.from_iterable(
|
||||
|
@ -47,8 +48,7 @@ def abspath(resource_name):
|
|||
|
||||
def color(name, idx=0):
|
||||
"""Return NumPy float32 array of RGB colors from color name."""
|
||||
col = TANGO['Aluminium'][-1] if name == 'Background' else TANGO[name][idx]
|
||||
return numpy.float32([i / 255 for i in bytes.fromhex(col)])
|
||||
return numpy.float32([i / 255 for i in bytes.fromhex(TANGO[name][idx])])
|
||||
|
||||
|
||||
def mapidgen(replacement=False):
|
||||
|
|
|
@ -3,13 +3,9 @@
|
|||
uniform vec3 bg;
|
||||
uniform vec3 color;
|
||||
|
||||
in float depth;
|
||||
in float intensity;
|
||||
out vec4 f_color;
|
||||
|
||||
void main() {
|
||||
if (depth < 1) {
|
||||
f_color = vec4(bg * depth + color * (1 - depth), 1.0);
|
||||
} else {
|
||||
f_color = vec4(bg, 1.0);
|
||||
}
|
||||
f_color = vec4(bg * (1 - intensity) + color * intensity, 1.0);
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ uniform vec3 camera;
|
|||
uniform float visibility;
|
||||
|
||||
in vec3 in_vert;
|
||||
out float depth;
|
||||
out float intensity;
|
||||
|
||||
void main() {
|
||||
gl_Position = mvp * vec4(in_vert, 1.0);
|
||||
depth = distance(camera, in_vert) / visibility;
|
||||
intensity = 1 / (1 + pow(distance(camera, in_vert), 2) / visibility);
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
uniform vec3 color;
|
||||
|
||||
in float depth;
|
||||
in float intensity;
|
||||
out vec4 f_color;
|
||||
|
||||
void main() {
|
||||
f_color = vec4(color, 1 - depth);
|
||||
f_color = vec4(color, intensity);
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@ uniform vec3 camera;
|
|||
uniform float visibility;
|
||||
|
||||
in vec3 in_vert;
|
||||
out float depth;
|
||||
out float intensity;
|
||||
|
||||
void main() {
|
||||
vec4 vert = model * vec4(in_vert, 1.0);
|
||||
gl_Position = vp * vert;
|
||||
depth = distance(camera, vec3(vert)) / visibility;
|
||||
intensity = 1 / (1 + pow(distance(camera, vec3(vert)), 2) / visibility);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue