8000 Finalize shader properties and upload image · chr-wei/tinyrenderer_python@aba0675 · GitHub
[go: up one dir, main page]

Skip to content

Commit aba0675

Browse files
author
Christian Weihsbach
committed
Finalize shader properties and upload image
1 parent aa0dd01 commit aba0675

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ After finishing the fork I am going to be working on course material and structu
2424
## Here are some examples generated by the renderer
2525

2626
### Rendered image with shadows and specular lighting (current optimum)
27-
<img src="https://github.com/rap1ide/tinyrenderer_python/blob/master/docs/images/shadow_shade.png" alt="Rendered image with shadows and specular lighting" width="400">
27+
<img src="https://github.com/rap1ide/tinyrenderer_python/blob/master/docs/images/tiny_shader.png" alt="Rendered image with shadows and specular lighting" width="400">
2828

2929
### Rendered wire mesh
3030
& 8000 lt;img src="https://github.com/rap1ide/tinyrenderer_python/blob/master/docs/images/e04_autumn_mesh.png" alt="Rendered wire mesh" width="400">

docs/images/tiny_shader.png

452 KB
Loading

tiny_shaders.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def fragment(self, bary: Barycentric):
8282
p_shadow = transform_vertex_to_screen(v_bary, self.uniform_M_sb)
8383
z_lit = self.shadow_buffer[p_shadow.x][p_shadow.y]
8484

85-
shadowed_intensity = .3 if p_shadow.z + .02 * 255 < z_lit else 1.0
85+
shadowed_intensity = .7 if p_shadow.z + .02 * 255 < z_lit else 1.0
8686

8787
n_global = self.mdl.get_normal_from_map(p_uv)
8888
n_local = transform_3D4D3D(n_global, Vector4DType.DIRECTION, \
@@ -103,11 +103,10 @@ def fragment(self, bary: Barycentric):
103103
# Get diffuse color and apply ambient occlusion intensity
104104
ao_intensity = self.mdl.get_ao_intensity_from_map(p_uv)
105105
color = self.mdl.get_diffuse_color(p_uv)
106-
color *= ao_intensity
107106

108107
# Combine base, diffuse and specular intensity
109-
color = 20 * Vector3D(1,1,1) + \
110-
color * shadowed_intensity * (1.8 * diffuse_intensity + .6 * specular_intensity)
108+
color = 10 * Vector3D(1,1,1) + \
109+
color * shadowed_intensity * (2.8 * (.7 * diffuse_intensity + .3 * ao_intensity) + .6 * specular_intensity)
111110
color = comp_min(Vector3D(255, 255, 255), color) // 1
112111

113112
# Do not discard pixel and return color

0 commit comments

Comments
 (0)
0