zesterer / euc

A software rendering crate that lets you write shaders with Rust
Apache License 2.0
294 stars 18 forks source link

Use perspective correct interpolation #5

Closed MartinSandfuchs closed 4 years ago

MartinSandfuchs commented 5 years ago

At the moment the vertex attributes are interpolated linearly in screen space which produces an incorrect result. This is especially visible when using interpolated texture coordinates (see image below). image Fixing this issue probably requires the vertex shader to output a 4d vector in homogeneous coordinates. The w component of the vector can then be used by the rasterizer to perform perspective correct interpolation (this is how I believe OpenGL does it).

zesterer commented 5 years ago

I'll look into adding this in the near future. Is this something you're needing to have working soon?

MartinSandfuchs commented 5 years ago

I don't need to have it working any time soon. Just thought it would be a neat feature to have.