Skip to content

Commit f62e9ee

Browse files
committed
fix: Wrong calculation of normalized device coordinates
1 parent 1952705 commit f62e9ee

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/tinyrenderer/shaders.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ impl Shader for MyShader<'_> {
4343
*gl_position =
4444
Point4::from(self.uniform_projection * self.uniform_model_view * gl_position.coords);
4545
*gl_position /= gl_position.w;
46+
self.varying_ndc_tri
47+
.set_column(nthvert, &gl_position.xyz().coords);
4648
// Clip out of frame points
4749
gl_position.x = clamp(gl_position.x, -1.0, 1.0);
4850
gl_position.y = clamp(gl_position.y, -1.0, 1.0);
4951
*gl_position = Point4::from(self.uniform_viewport * gl_position.coords);
50-
self.varying_ndc_tri
51-
.set_column(nthvert, &(*gl_position / gl_position.z).xyz().coords);
5252
}
5353
fn fragment_shader(&self, bar_coords: Vector3<f32>) -> Option<Rgba<u8>> {
5454
// Texture coords

0 commit comments

Comments
 (0)