Skip to content

[Bug]: DirectBRDFSpecular FP16 overflow clamp missing for Linux (Vulkan/OpenGL Core) #92

Description

@decentraland-bot

Bug Report

Description

The DirectBRDFSpecular function in Runtime/Shaders/Scene/URP/Lighting.hlsl has an FP16 overflow protection guard that only covers mobile and Switch platforms:

#if defined (SHADER_API_MOBILE) || defined (SHADER_API_SWITCH)
    specularTerm = specularTerm - HALF_MIN;
    specularTerm = clamp(specularTerm, 0.0, 100.0); // Prevent FP16 overflow on mobiles
#endif

This condition is incomplete — Linux using Vulkan (SHADER_API_VULKAN) or OpenGL Core (SHADER_API_GLCORE) is not covered, yet those backends also use true 16-bit half-precision types and are susceptible to the same FP16 overflow.

Steps to Reproduce

  1. Run Decentraland on Linux (Vulkan or OpenGL Core)
  2. Observe broken specular highlights / rendering artifacts in scenes

Expected Behavior

Specular term is clamped to [0, 100] on all platforms where half is a true 16-bit type, including Linux.

Actual Behavior

On Linux, the clamp is skipped, causing FP16 overflow and visual artifacts in the specular BRDF.

Fix

Expand the #if guard to include SHADER_API_VULKAN and SHADER_API_GLCORE, or remove the guard entirely and apply the clamp unconditionally (safe, since it's a no-op on 32-bit float platforms).


Reported via Slack by Esteban Ordano

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions