elm-3d-scene icon indicating copy to clipboard operation
elm-3d-scene copied to clipboard

Support 'precision mediump float' in fragment shaders

Open ianmackenzie opened this issue 4 years ago • 1 comments

Currently all elm-3d-scene shaders use precision highp float. It should be possible to use precision mediump float in at least the fragment shaders, by doing things like carefully clamping color values (specular lighting can result in very high color values).

If not possible in general, it may be possible to have a compromise like only use precision highp float in the PBR shaders and precision mediump float (or even precision lowp float) in shaders like those for Lambertian, emissive or constant-color materials where calculations should not result in particularly large values.

ianmackenzie avatar Apr 20 '20 00:04 ianmackenzie

Specific improvements to make:

  • [ ] Replace sceneProperties in constantPointFragment with single lowp supersampling uniform
  • [ ] Replace sceneProperties in emissiveFragment and emissiveTextureFragment with separate mediump reference white and lowp dynamic range uniforms
  • [ ] Replace sceneProperties in emissivePointFragment with lowp supersampling, mediump reference white and lowp dynamic range uniforms

Looks like it will be difficult to avoid highp in Lambertian fragment shaders, though.

ianmackenzie avatar Apr 20 '20 02:04 ianmackenzie