Hi I have the below shadermaterial with the fs and vs as below, I am using a plane to display the output of the below shader material. so far it is working properly. After doing so I have added refraction on a 3D glb object which is refracting the plane.
When I set the plane to visibility to 0, it still shows on the refraction, is there a way to not show it on the refraction as well? Any help would be appreciated
image with visibility
image without visibility
BABYLON.Effect.ShadersStore["customVertexShader"] = `
precision highp float;
attribute vec3 position;
attribute vec2 uv;
uniform mat4 worldViewProjection;
varying vec2 vUv;
void main(void) {
vUv = uv;
gl_Position = worldViewProjection * vec4( position, 1.0 );
}`;
BABYLON.Effect.ShadersStore["customFragmentShader"] = `
uniform float time;
uniform float progress;
uniform float intensity;
uniform float width;
uniform float scaleX;
uniform float scaleY;
uniform float transition;
uniform float radius;
uniform float swipe;
uniform sampler2D texture1;
uniform sampler2D texture2;
uniform sampler2D displacement;
uniform float opacity;
uniform vec4 resolution;
varying vec2 vUv;
mat2 getRotM(float angle) {
float s = sin(angle);
float c = cos(angle);
return mat2(c, -s, s, c);
}
const float PI = 3.1415;
const float angle1 = PI *0.25;
const float angle2 = -PI *0.75;
void main() {
vec2 newUV = (vUv - vec2(0.5))*resolution.zw + vec2(0.5);
vec4 disp = texture2D(displacement, newUV);
vec2 dispVec = vec2(disp.r, disp.g);
vec2 distortedPosition1 = newUV + getRotM(angle1) * dispVec * intensity * progress;
vec4 t1 = texture2D(texture1, distortedPosition1);
vec2 distortedPosition2 = newUV + getRotM(angle2) * dispVec * intensity * (1.0 - progress);
vec4 t2 = texture2D(texture2, distortedPosition2);
gl_FragColor = mix(t1, t2, progress);
}`;
material = new BABYLON.ShaderMaterial('', scene, {
vertex: 'custom',
fragment: 'custom',
}, {
needAlphaBlending: true,
needAlphaTesting: true,
attributes: ["position", "uv"],
uniforms: [
"worldViewProjection",
"time",
"progress",
"border",
"intensity",
"scaleX",
"scaleY",
"transition",
"swipe",
"width",
"radius",
"texture1",
"texture2",
"displacement",
"resolution"
],
define: [
"time",
"progress",
"border",
"intensity",
"scaleX",
"scaleY",
"transition",
"swipe",
"width",
"radius",
"texture1",
"texture2",
"displacement",
"resolution",
"opacity"
]
});
material.setFloat("time", 0);
material.setFloat("progress", 0);
material.setFloat("border", 0);
material.setFloat("intensity", 0.1);
material.setFloat("scaleX", 40);
material.setFloat("scaleY", 40);
material.setFloat("transition", 40);
material.setFloat("swipe", 0);
material.setFloat("width", 0);
material.setFloat("radius", 0);
var texture1 = new BABYLON.Texture(textures[0].url, scene);
material.setTexture("texture1", texture1);
var texture2 = new BABYLON.Texture(textures[1].url, scene);
material.setTexture("texture2", texture2);
var displacement = new BABYLON.Texture('./img/disp1.jpg', scene);
material.setTexture("displacement", displacement);
material.setVector4("resolution", new BABYLON.Vector4());
imagePlane = BABYLON.MeshBuilder.CreatePlane("imagePlane", {
width: 100,
height: 100
}, scene);
imagePlane.material = material;
imagePlane.position.y = 0;
imagePlane.position.z = 0;