MeshStandardMaterial & MeshPhysicalMaterial Lighting problem on Adreno GPU

Description of the problem

MeshStandardMaterial & MeshPhysicalMaterial Lighting problem on Adreno GPU.

Not Adreno GPU
image

Adreno GPU
image

live example:

Three.js version
  • r98
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • Android
Hardware Requirements (graphics card, VR Device, …)
  • Adreno GPU

Author: Fantashit

1 thought on “MeshStandardMaterial & MeshPhysicalMaterial Lighting problem on Adreno GPU

  1. @Mugen87
    After a week of exploring, I think I should have solved the problem.
    Before the change:
    before
    modified:
    after

    Links to the original author

    According to the developer’s code, I modified the relevant code of three.js

    float D_GGX( const in float alpha, const in float dotNH,const vec3 normal, const vec3 halfDir ) {
        vec3 NxH = cross(normal, halfDir);
        float oneMinusNoHSquared = dot(NxH, NxH);
        float a = dotNH * alpha;
        float k = alpha / (oneMinusNoHSquared + a * a);
        float d = k * k * (1.0 / PI);
        return saturateMediump(d);
    }
    

    and

    float D = D_GGX( alpha, dotNH ,geometry.normal,halfDir);

    And then add code:

    #define MEDIUMP_FLT_MAX 65504.0
    #define saturateMediump(x) min(x, MEDIUMP_FLT_MAX)
    

Comments are closed.