Skip to content

Support native GLSL fragment and vertex builtins - #40

Merged
treeform merged 3 commits into
masterfrom
polyworld-fragment-builtins
Nov 25, 2026
Merged

treeform merged 3 commits into
masterfrom
polyworld-fragment-builtins

Conversation

@treeform

Copy link
Copy Markdown
Owner

Fullscreen and depth-aware shaders cannot currently use GLSL builtins consistently: entry parameters can redeclare reserved inputs, fragment-depth outputs become user varyings, and desktop fragment coordinates are forced to an upper-left origin.

Keep GLSL builtin declarations native, including gl_FragCoord, gl_FragDepth, and gl_VertexID. Add highp integer precision to WebGL output and expose asin(float32) for spherical shader mapping. Regression tests cover entry parameters, globals, both GLSL targets, and mixed integer/fragment interfaces.

Desktop gl_FragCoord now retains OpenGL's lower-left origin, matching WebGL. Callers that relied on the previous forced upper-left origin must flip coordinates explicitly.

Validation:

  • Nim checks, backend regressions, golden-source tests, and Metal resource tests passed.
  • glslangValidator compiled and linked desktop GLSL 410 and ES 300 coordinate/depth/integer/asin fixtures.
  • Polyworld desktop OpenGL and Chrome WebGL2 rendering tests passed with this commit. Converted courtyard shaders matched the original GLSL across 216 pixel-comparison cases; night-sky and post-processing comparisons also matched exactly.

@treeform
treeform merged commit 556159d into master Nov 25, 2026
1 check passed
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.

1 participant