Hi all,
I want to create a Sprite2D and it's image can make some effect like grayscale.
So I consider using CustomProceduralTexture to implement it.
My pseudo code is like below (the shader is just basic one not grayscale):
let sampleTexture = new BABYLON.Texture("img/sample.png", scene, true, false, BABYLON.Texture.NEAREST_SAMPLINGMODE);
BABYLON.Effect.ShadersStore["TestPixelShader"]
= "precision highp float;\n"
+ "varying vec2 vUV;\n"
+ "uniform sampler2D sampleTexture;\n"
+ "void main(void) {\n"
+ "gl_FragColor = texture2D(sampleTexture, vUV);\n"
+ "}\n";
let procedualTexture = new BABYLON.CustomProceduralTexture("custom", "Test", 1024, scene);
procedualTexture.setTexture("sampleTexture", sampleTexture);
let sprite2d = new BABYLON.Sprite2D(procedualTexture, { options... });
Is my idea workable? Or do I need using another ways to implement it?
Thanks!