Textures have sharper edges
Description
The texture we provided only has 4 pixels (2x2). The rendered cubes will likely have more than 4 pixels per face, so OpenGL will interpolate between values to create a color gradient.
This isn't what we want for our game aesthetic, so we can instruct OpenGL to not interpolate but choose the nearest color to the point. This will result in a sharper, blockier texture which is what we're looking for.
Screenshot
Commands
git clone git@github.com:atsheehan/iridium
cd iridium
git checkout c37ccecca1bbf8c2b8c073f2ffc79cfee6fafe56
cargo run --release
Code Changes
Modified src/render.rsGitHub
@@ -111,6 +111,13 @@111111 gl::UNSIGNED_BYTE,
112112 data.as_ptr() as *const c_void,
113113 );
114+ gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MAG_FILTER, gl::NEAREST as GLint);
115+ gl::TexParameteri(
116+ gl::TEXTURE_2D,
117+ gl::TEXTURE_MIN_FILTER,
118+ gl::NEAREST_MIPMAP_NEAREST as GLint,
119+ );
120+
114121 gl::GenerateMipmap(gl::TEXTURE_2D);
115122 cube_texture_id
116123 };
@@ -111,6 +111,13 @@111 gl::UNSIGNED_BYTE,
112 data.as_ptr() as *const c_void,
113 );
114 gl::GenerateMipmap(gl::TEXTURE_2D);
115 cube_texture_id
116 };
@@ -111,6 +111,13 @@111 gl::UNSIGNED_BYTE,
112 data.as_ptr() as *const c_void,
113 );
114+ gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MAG_FILTER, gl::NEAREST as GLint);
115+ gl::TexParameteri(
116+ gl::TEXTURE_2D,
117+ gl::TEXTURE_MIN_FILTER,
118+ gl::NEAREST_MIPMAP_NEAREST as GLint,
119+ );
120+
121 gl::GenerateMipmap(gl::TEXTURE_2D);
122 cube_texture_id
123 };