FarazzShaikh / THREE-CustomShaderMaterial

🧩 Extend Three.js standard materials with your own shaders!
https://farazzshaikh.github.io/THREE-CustomShaderMaterial/
MIT License
890 stars 56 forks source link

added csm_Bump with psrdnoise example for procedural bump #34

Closed chasedavis closed 1 year ago

chasedavis commented 1 year ago

Added csm_Bump per suggestion in https://github.com/FarazzShaikh/THREE-CustomShaderMaterial/issues/33

A couple of notes:

While I think it works, I do wonder if it would be better if these lines in the example were somehow moved to patchMaps.ts so that users don't have to worry about projection and normal calculation, though doing that would also tradeoff against flexibility.

                // N_ is orthogonal to N.
                vec3 N_ = g - (dot(g, csm_vNormal) * csm_vNormal);

                // need to do projection, and multiply by bumpStrength
                csm_Bump = mat3(csm_vModelViewMatrix) * (bumpStrength * N_);

I'd also be remiss not to mention that the technique used in the example is from @stegu and the tutorial here

Screen Shot 2023-02-22 at 2 49 37 AM
Allakazan commented 4 months ago

Can you provide this example used on the image above ? i'm trying to make csm_Bump work and i'm not having any luck with it lol