Skip to content

Commit 10e904a

Browse files
committed
Deferred tweaks
1 parent 6b4ccb7 commit 10e904a

File tree

5 files changed

+48
-6
lines changed

5 files changed

+48
-6
lines changed

demosys/deferred/renderer.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,18 @@
99
class PointLight:
1010
"""A point light and its properties"""
1111
def __init__(self, position, radius):
12-
self.position = position
12+
self._position = position
1313
self.radius = radius
14-
self.matrix = matrix44.create_from_translation(position)
14+
self.matrix = None
15+
16+
@property
17+
def position(self):
18+
return self._position
19+
20+
@position.setter
21+
def position(self, pos):
22+
self._position = pos
23+
self.matrix = matrix44.create_from_translation(pos)
1524

1625

1726
class DeferredRenderer:

demosys/deferred/shaders/deferred/combine.glsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ uniform sampler2D light_buffer;
2020
in vec2 uv;
2121

2222
void main() {
23-
out_color = texture(diffuse_buffer, uv) * (texture(light_buffer, uv) * 0.75 + 0.25);
23+
out_color = texture(diffuse_buffer, uv) * (texture(light_buffer, uv));
2424
}
2525

2626
#endif
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#version 410
2+
3+
#if defined VERTEX_SHADER
4+
5+
in vec3 in_position;
6+
in vec3 in_normal;
7+
in vec2 in_uv;
8+
9+
uniform mat4 m_mv;
10+
uniform mat4 m_proj;
11+
uniform mat3 m_normal;
12+
13+
out vec3 normal;
14+
15+
void main() {
16+
normal = m_normal * in_normal;
17+
gl_Position = m_proj * m_mv * vec4(in_position, 1.0);
18+
}
19+
20+
#elif defined FRAGMENT_SHADER
21+
22+
layout(location=0) out vec4 out_color;
23+
layout(location=1) out vec3 out_normal;
24+
25+
uniform vec4 color;
26+
27+
in vec3 normal;
28+
29+
void main() {
30+
out_normal = normalize(normal);
31+
out_color = color;
32+
}
33+
34+
#endif

demosys/deferred/shaders/deferred/geometry.glsl renamed to demosys/deferred/shaders/deferred/geometry_texture.glsl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ in vec2 uv;
3232
void main() {
3333
out_normal = normalize(normal);
3434
out_color = texture(texture0, uv);
35-
// out_color = vec4(1.0);
3635
}
3736

3837
#endif

demosys/deferred/shaders/deferred/light_point.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ void main() {
5454
vec3 reflectDir = reflect(-lightDir, normal);
5555

5656
float diffuse = max(dot(normal, lightDir), 0.0);
57-
// float spec = pow(max(dot(normal, halfwayDir), 0.0), 32.8);
58-
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 4.0);
57+
// float spec = pow(max(dot(normal, halfwayDir), 0.0), 32.0);
58+
float spec = pow(max(dot(viewDir, reflectDir), 0.0), 8.0);
5959

6060
float l = diffuse * 0.5 + spec;
6161
// l *= (1.0 - dist / radius);

0 commit comments

Comments
 (0)