Skip to content

Discrepancy in water caustic rendering between VSCode shader-toy and shadertoy.com #189

@meisei4

Description

@meisei4

Description:
When running identical GLSL shader code on the VSCode shader-toy extension and the shadertoy website, this water caustic effect behaves differently. The original code (as used on Shadertoy.com) produces the intended look, while the VSCode preview renders the water layers incorrectly (resulting in blown‐out white areas).

Expected Behavior:
The shader should produce an identical water caustic effect on both the VSCode shader-toy extension and theshadertoy.com website since they are using the same GLSL code.

Actual Behavior:

  • Shadertoy.com:
    The original code renders water layers and highlights correctly.
  • VSCode Extension:
    The original code results in a white or blown-out image, where adjusting the thresholds/inequalities (as shown below) is necessary to match the intended visual output.

Steps to Reproduce:

  1. Original shader (Shadertoy.com):

  2. Original shader in VSCode Extension Preview:

Original shader in VSCode preview:
Image

  1. Refactored Version in VSCode:
    In order to correct for the blown-out output and achieve a similar visual effect in the VSCode GLSL preview, I adjusted lines 44~50 to invert the inequalities and the threshold values as follows:

Original:

if(avg(water1 + water2) > 0.3) {
    alpha = 0.0;
}
if(avg(water1 + water2 + highlights1 + highlights2) > 0.75) {
    alpha = 5.0 * opacity;
}

Refactored version:

if(avg(water1 + water2) < 1.7) {
    alpha = 0.0;
}
if(avg(water1 + water2 + highlights1 + highlights2) < 1.25) {
    alpha = 0.5 * opacity;
}

Refactored Version in VSCode preview:
Image

  1. Refactored shader in shadertoy website view:
  • For comprehensiveness, conversely when i run the refactored version on the shadertoy website it eliminates much of the caustic highlights from the original

Refactored Version in shadertoy website preview:
Image

Textures used:
source: https://shadertoyunofficial.wordpress.com/2019/07/23/shadertoy-media-files/

Abstract 1 texture 1024x1024

Gray Noise Small texture 64x64

Pebbles texture 512x512

Environment:

  • Shader Toy Extension Version: 0.11.2 (Last Updated 2025-02-01, 12:40:24)
  • VSCode Version: 1.97.2 (Commit: e54c774e0add60467559eb0d1e229c6452cf8447)
  • VSCode Architecture: x64
  • OS: macOS 12.7.6 (Build: 21H1320)
  • Kernel: Darwin 21.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions