@babylonjs/core
Version:
Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.
94 lines • 2.59 kB
JavaScript
// Do not edit.
import { ShaderStore } from "../Engines/shaderStore.js";
const name = "textureMergerPixelShader";
const shader = `
uniform sampler2D inputTexture0;
uniform sampler2D inputTexture1;
uniform sampler2D inputTexture2;
uniform sampler2D inputTexture3;
uniform int redTextureIndex;uniform int redSourceChannel;
uniform float redConstantValue;
uniform int greenTextureIndex;uniform int greenSourceChannel;
uniform float greenConstantValue;
uniform int blueTextureIndex;uniform int blueSourceChannel;
uniform float blueConstantValue;
uniform int alphaTextureIndex;uniform int alphaSourceChannel;
uniform float alphaConstantValue;
varying vec2 vUV;
vec4 sampleTexture(int textureIndex,vec2 uv) {switch (textureIndex) {
case 0:
return texture2D(inputTexture0,uv);
case 1:
return texture2D(inputTexture1,uv);
case 2:
return texture2D(inputTexture2,uv);
case 3:
return texture2D(inputTexture3,uv);
default:
return vec4(0.0,0.0,0.0,1.0); }}
float extractChannel(vec4 color,int channelIndex) {switch (channelIndex) {case 0:
return color.r;
case 1:
return color.g;
case 2:
return color.b;
default:
return color.a; }}
void main() {vec2 uv=vUV;
vec4 redSample=sampleTexture(redTextureIndex,uv);float r=extractChannel(redSample,redSourceChannel);
float r=redConstantValue;
vec4 greenSample=sampleTexture(greenTextureIndex,uv);float g=extractChannel(greenSample,greenSourceChannel);
float g=greenConstantValue;
vec4 blueSample=sampleTexture(blueTextureIndex,uv);float b=extractChannel(blueSample,blueSourceChannel);
float b=blueConstantValue;
vec4 alphaSample=sampleTexture(alphaTextureIndex,uv);float a=extractChannel(alphaSample,alphaSourceChannel);
float a=alphaConstantValue;
gl_FragColor=vec4(r,g,b,a);}`;
// Sideeffect
if (!ShaderStore.ShadersStore[name]) {
ShaderStore.ShadersStore[name] = shader;
}
/** @internal */
export const textureMergerPixelShader = { name, shader };
//# sourceMappingURL=textureMerger.fragment.js.map