pex-gl / pex-renderer

Physically based renderer (PBR) and scene graph for PEX.
https://pex-gl.github.io/pex-renderer/examples/index.html
MIT License
237 stars 16 forks source link

Adding hook to material breaks shadows of instanced geometry #369

Closed vorg closed 4 months ago

vorg commented 5 months ago

Without hook vs with hook (all hook glsl commented out, just empty stage declarations) Screenshot 2024-04-09 at 21 30 10

vorg commented 5 months ago

False alarm: I was using saturate (defined here https://github.com/pex-gl/pex-shaders/blob/cb6db08184414ed8a17ff22864d53b424528e35a/shaders/chunks/math.glsl.js#L8) function in hook that is defined when rendering to screen but not included with depth only rendering for shadowmapping.

Makes me wonder about using HSLS function in GLSL code (should be just clamp(f, 0, 1)) as similar problems might occur again in the future when porting code.

dmnsgn commented 4 months ago

Agree we should avoid HLSL naming but I'd argue for keeping it as it is part of WGSL naming (and is quite useful, judging by the 24 occurences of it in pex-shaders and the few more clamp(x, 0.0, 1.0) there).

vorg commented 4 months ago

Well ok but then it should be proper function not define as below as it's crashing if i pass vec2 or vec3

#define saturate(x) clamp(x, 0.0, 1.0)