Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a cursor to make placing/breaking blocks easier #349

Merged
merged 1 commit into from
Jan 27, 2024

Conversation

patowen
Copy link
Collaborator

@patowen patowen commented Jan 27, 2024

This PR hijacks the fog shader to also add a cursor in the center of the viewport to allow players to target where they place and break blocks.

This introduces an if statement to the fragment shader, and branching in shaders is generally bad for performance in my understanding, but given its simplicity, I believe that the shader compiler should be smart enough to optimize this in a way that acts as though such branching basically does not exist.

@patowen patowen force-pushed the temporary-cursor branch 2 times, most recently from f3f9a7b to cb02d90 Compare January 27, 2024 18:34
@Ralith
Copy link
Owner

Ralith commented Jan 27, 2024

branching in shaders is generally bad for performance in my understanding

This hasn't really been true for a while. So long as register allocation costs aren't wildly unbalanced between branches, you can be pretty free with them.

client/shaders/fog.frag Outdated Show resolved Hide resolved
@Ralith Ralith merged commit 31c0e2a into Ralith:master Jan 27, 2024
6 checks passed
@patowen patowen deleted the temporary-cursor branch January 27, 2024 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants