magicshader icon indicating copy to clipboard operation
magicshader copied to clipboard

Apply to all threejs shaders?

Open luruke opened this issue 6 years ago • 2 comments

Just an idea, we could plug and use the magic comments everywhere on three.js without even using the MagicShader class...

luruke avatar Apr 04 '19 14:04 luruke

i think my issue belongs here: i've been using usual ShaderMaterial, and just noticed it only works for RawShaderMaterial right now. It actually works perfectly if u just replace this dep in your code. But i guess there should be some more clever way for that. And thank you again for implementing this idea! =)

akella avatar Apr 05 '19 22:04 akella

Yeah, a solution could be:

import MagicShader from 'magicshader';

const material = new MagicShader(Material)({
  fragmentShader:'...'
});

where Material can be anything that inherits from THREE.Material. But I guess it would be just useful for RawShaderMaterial and ShaderMaterial...

Or a syntax like:

import { MagicShader, RawMagicShader} from 'magicshader';

where MagicShader uses ShaderMaterial and RawMagicShader uses RawShaderMaterial

luruke avatar Apr 07 '19 09:04 luruke