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

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
Alexandr
Hi everyone! There is an error on the page 71 in the book “Programming machine learning from coding to depp learning” P. Perrotta. You c...
New
mikecargal
Title: Hands-On Rust (Chap 8 (Adding a Heads Up Display) It looks like ​.with_simple_console_no_bg​(SCREEN_WIDTH*2, SCREEN_HEIGHT*2...
New
mikecargal
Title: Hands-On Rust (Chapter 11: prefab) Just played a couple of amulet-less games. With a bit of debugging, I believe that your can_p...
New
JohnS
I can’t setup the Rails source code. This happens in a working directory containing multiple (postgres) Rails apps. With: ruby-3.0.0 s...
New
patoncrispy
I’m new to Rust and am using this book to learn more as well as to feed my interest in game dev. I’ve just finished the flappy dragon exa...
New
AndyDavis3416
@noelrappin Running the webpack dev server, I receive the following warning: ERROR in tsconfig.json TS18003: No inputs were found in c...
New
brunogirin
When trying to run tox in parallel as explained on page 151, I got the following error: tox: error: argument -p/–parallel: expected one...
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

Other popular topics Top

AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
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
Build highly interactive applications without ever leaving Elixir, the way the experts do. Let LiveView take care of performance, scalabi...
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
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New

Sub Categories: