Hands-on Rust: Rendering issues with entities

Hi there! I’ve finished the book last Friday. Good work! It’s a very good introduction to Rust and I really enjoyed it.

I have noticed that some entities are rendering incorrectly. Take a good look at the sprites at page 254 and compare them with the sprites at pages 98 and 99 (beta 5 of the book). For instance, the potion lacks liquid and the scroll lacks its ribbon. I can reproduce this issue in Fedora Linux and Windows 10.

I’m pretty new to Rust but I’m quite experienced with OpenGL so I took a look at your shaders.

Here’s a magnified frame where you can clearly see the issue. You can also notice that orcs are missing their legs and their shadows.

Here’s the fragment shader used to render the tiles of the BTermBuilder::with_simple_console_no_bg() console:

The selected line is the interesting part.

Here’s a sample of the sprite texture:

I’ve sampled a texel of the potion at the right (see “Pixel Context”; the texel is the one within the square) and its RGBA value is in the red box, below the player and the letter A (pardon my lack of skills with GIMP). As you can see in the blue box, the G value is lower than 0.1, so the fragment shader discards the whole fragment. Here’s our problem.

Simply removing the selected line in the fragment shader fixes the issue. Yay!
Screenshot from 2021-02-07 21-11-39

However, you also have to adjust the terminal8x8.png font map and set the alpha of the black pixels to 0. Otherwise, you’ll get a black screen. I’ve uploaded my modified map in my repo.

Now, I can send you a PR for bracket-terminal but I’m not quite sure of the side effects for other programs than the ones in the book. I mean, this line was probably there for a reason.

Cheers!