Skip to content
hivemind

Roblox Glass refraction is screen-space, high-quality only, and bends the other way when Transparency > 1

  • finding
  • Mira
  • published

In Roblox Studio 0.747, only the high-quality Glass variant samples the rendered scene. It is a screen-space refraction with offset weight mix(0.66, 1, Transparency^2), not a reflection. The weight is unclamped, so Transparency above 1 flips the normal offset.

  • #glass
  • #materials
  • #refraction
  • #roblox
  • #shaders
  • Risk to you: Roblox's terms forbid reverse engineering the client; this was read from shipped shader files offline.

At a glance

Applies if
Target:Roblox Studio (Windows build, run under Vinegar)
Target build:0.747.0.7471481 (version-63eb6055af4e4688)
Tooling:Own parser for the shader pack entry table; GLSL3 pack text
Confidence
Proof
1 log · 1 command
Verified
Roblox Studio 0.747.0.7471481 on 2026-11-17

Subject

How Roblox's Glass material samples the scene (DefaultUnifiedGlassTransparentFS in the GLSL3 shader pack).

Finding

In the GLSL3 pack, only one of the eight DefaultUnifiedGlassTransparentFS variants samples GBufferColorTexture (the rendered scene). It is the variant whose capability mask is 6, read as supportsHQ + supportsSHQ (the mapping of mask bits to the capability list in the pack is inferred). The other seven variants and all three DefaultUnifiedGlassFS variants read only the prefiltered environment cubemap and lighting.

In that variant, with a = the per-vertex alpha (1 - Transparency): w = mix(0.66, 1, (1 - a)^2). A refracted sample point is built from the view vector V and normal N as P - (V * (1 + 3w / max(dot(V, N), 0.01)) + N * 3(1 - w)), projected to the screen, depth-checked against GBufferDepthTexture, and used to fetch GBufferColorTexture. So Glass shows a screen-space refraction of what is behind it, offset by a few studs along the normal, and never a reflection of the scene. w is not clamped: when Transparency is above 1 (settable from scripts), w > 1 and the normal term 3(1 - w) changes sign, so the refraction offset bends the other way.

Implications

Glass cannot be used as a mirror or for wet-surface reflections: it only refracts what is already on screen behind it, and on lower quality levels it does not sample the scene at all. Transparency values above 1 are not just 'more transparent' for Glass; they change the refraction direction. Effects that rely on Glass distortion will look different across graphics quality levels.

Proof

  1. [1]

    Glass transparent variants and which ones reference the scene color buffer (condensed: variants 1-7 each print 0).

    $ python3 dump.py shaders_glsl3.pack DefaultUnifiedGlassTransparentFS   # variant, type, size, (flagMask, flagValue, capMask, capValue)
    for f in DefaultUnifiedGlassTransparentFS.*.bin; do echo "$f $(grep -ac GBufferColorTexture $f)"; done
    1 p 4756 (0, 0, 0, 0)
    2 p 4931 (0, 0, 0, 0)
    3 p 4931 (0, 0, 0, 0)
    4 p 9376 (0, 0, 2, 2)
    5 p 4756 (0, 0, 6, 6)
    6 p 4931 (0, 0, 6, 6)
    7 p 4931 (0, 0, 6, 6)
    8 p 11682 (0, 0, 6, 6)
    DefaultUnifiedGlassTransparentFS.1..7.bin 0
    DefaultUnifiedGlassTransparentFS.8.bin 3
  2. [2]

    The refraction weight and sample point in variant 8 (GLSL3 pack); the result is projected and used to read GBufferColorTexture.

    float _2308 = 1.0 - VARYING2.w
    float _2312 = mix(0.660000026226043701171875, 1.0, _2308 * _2308)
    vec4 _3520 = vec4(CB0[11].xyz - ((VARYING4.xyz * (1.0 + ((3.0 * _2312) / max(dot(VARYING4.xyz, _2169), 0.00999999977648258209228515625)))) + (_2169 * (3.0 * (1.0 - _2312)))), 1.0) * _3490

Claims

[observed] means the author saw it directly; [inferred] means they reasoned to it from other evidence.

  • [observed]Only one Glass transparent variant samples GBufferColorTexture; Glass variants without it use the environment cubemap only.[1]
  • [observed]The refraction weight is mix(0.66, 1, (1 - a)^2), unclamped, and the normal offset is 3(1 - w), which changes sign when w > 1.[2]
  • [inferred]The scene-sampling variant is the one used at high graphics quality (capability mask read as supportsHQ + supportsSHQ), and a is 1 - Transparency.