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

Format shader compilation errors with line numbers and listing of info log entries #500

Merged
merged 2 commits into from
Nov 11, 2024

Conversation

BonsaiDen
Copy link
Contributor

At the moment shader compilation failures just print out the debug representation of the error as a giant wall of unformatted text, making it rather hard to debug custom shaders.

This PR changes it so that shader compilation failures now result in an output like the one below:

thread 'main' panicked at /home/ivo/dev/23/three-d/src/renderer.rs:404:25:
failed compiling fragment shader

source:
001: #version 330 core
002: in float cascadeDepth;
003:
004: layout (location = 0) out vec2 outColor;
005:
006: void main() {
007:     // Emulate GL_DEPTH_CLAMP
008:     float depth = clamp(cascadeDepth, 0.0, 1.0);
009:     gl_FragDepth = depth;
010:
011:     // bias second moment based on viewing angle
012:     // See https://www.youtube.com/watch?v=F5QAkUloGOs
013:     float dx = dFdx(depth);
014:     float dy = dFdy(depth);
015:     vec2 moments = vec2(depth, depth * depth);
016:     moments.y += 0.25 * (dx * dx + dy * dy);
017:
018:     // Optimization for 2 moments proposed in
019:     // http://momentsingraphics.de/Media/I3D2015/MomentShadowMapping.pdf
020:     moments.y = 4.0 * (moments.x - moments.y);
021:     outColor = ;
022: }
023:
024:

log:
0(21) : error C0000: syntax error, unexpected ';', expecting "::" at token ";"

@asny asny merged commit 7d61b56 into asny:master Nov 11, 2024
5 checks passed
@asny
Copy link
Owner

asny commented Nov 11, 2024

Super nice 🥳 Thanks for the contribution 🙏

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