tabvaranjr

tabvaranjr

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!

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!

Where Next?

Popular Pragmatic Bookshelf topics Top

iPaul
page 37 ANTLRInputStream input = new ANTLRInputStream(is); as of ANTLR 4 .8 should be: CharStream stream = CharStreams.fromStream(i...
New
johnp
Hi Brian, Looks like the api for tinydb has changed a little. Noticed while working on chapter 7 that the .purge() call to the db throws...
New
ianwillie
Hello Brian, I have some problems with running the code in your book. I like the style of the book very much and I have learnt a lot as...
New
yulkin
your book suggests to use Image.toByteData() to convert image to bytes, however I get the following error: "the getter ‘toByteData’ isn’t...
New
jamis
The following is cross-posted from the original Ray Tracer Challenge forum, from a post by garfieldnate. I’m cross-posting it so that the...
New
cro
I am working on the “Your Turn” for chapter one and building out the restart button talked about on page 27. It recommends looking into ...
New
rainforest
Hi, I’ve got a question about the implementation of PubSub when using a Phoenix.Socket.Transport behaviour rather than channels. Before ...
New
Henrai
Hi, I’m working on the Chapter 8 of the book. After I add add the point_offset, I’m still able to see acne: In the image above, I re...
New
a.zampa
@mfazio23 I’m following the indications of the book and arriver ad chapter 10, but the app cannot be compiled due to an error in the Bas...
New
redconfetti
Docker-Machine became part of the Docker Toolbox, which was deprecated in 2020, long after Docker Desktop supported Docker Engine nativel...
New

Other popular topics Top

Exadra37
I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
New
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New
AstonJ
Biggest jackpot ever apparently! :upside_down_face: I don’t (usually) gamble/play the lottery, but working on a program to predict the...
New
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New

Sub Categories: