@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.
86 lines • 3.11 kB
JavaScript
// Do not edit.
import { ShaderStore } from "../Engines/shaderStore.js";
const name = "textureMergerPixelShader";
const shader = `
var inputTexture0Sampler: sampler;var inputTexture0: texture_2d<f32>;
var inputTexture1Sampler: sampler;var inputTexture1: texture_2d<f32>;
var inputTexture2Sampler: sampler;var inputTexture2: texture_2d<f32>;
var inputTexture3Sampler: sampler;var inputTexture3: texture_2d<f32>;
uniform redTextureIndex: i32;uniform redSourceChannel: i32;
uniform redConstantValue: f32;
uniform greenTextureIndex: i32;uniform greenSourceChannel: i32;
uniform greenConstantValue: f32;
uniform blueTextureIndex: i32;uniform blueSourceChannel: i32;
uniform blueConstantValue: f32;
uniform alphaTextureIndex: i32;uniform alphaSourceChannel: i32;
uniform alphaConstantValue: f32;
varying vUV: vec2f;
fn sampleTexture(textureIndex: i32,uv: vec2f)->vec4f {switch (textureIndex) {
case 0: {return textureSample(inputTexture0,inputTexture0Sampler,uv);}
case 1: {return textureSample(inputTexture1,inputTexture1Sampler,uv);}
case 2: {return textureSample(inputTexture2,inputTexture2Sampler,uv);}
case 3: {return textureSample(inputTexture3,inputTexture3Sampler,uv);}
default: {return vec4f(0.0,0.0,0.0,1.0); }}}
fn extractChannel(color: vec4f,channelIndex: i32)->f32 {switch (channelIndex) {case 0: {return color.r; }
case 1: {return color.g; }
case 2: {return color.b; }
default: {return color.a; }}}
@fragment
fn main(input: FragmentInputs)->FragmentOutputs {let uv: vec2f=input.vUV;
let redSample: vec4f=sampleTexture(uniforms.redTextureIndex,uv);let r: f32=extractChannel(redSample,uniforms.redSourceChannel);
let r: f32=uniforms.redConstantValue;
let greenSample: vec4f=sampleTexture(uniforms.greenTextureIndex,uv);let g: f32=extractChannel(greenSample,uniforms.greenSourceChannel);
let g: f32=uniforms.greenConstantValue;
let blueSample: vec4f=sampleTexture(uniforms.blueTextureIndex,uv);let b: f32=extractChannel(blueSample,uniforms.blueSourceChannel);
let b: f32=uniforms.blueConstantValue;
let alphaSample: vec4f=sampleTexture(uniforms.alphaTextureIndex,uv);let a: f32=extractChannel(alphaSample,uniforms.alphaSourceChannel);
let a: f32=uniforms.alphaConstantValue;
fragmentOutputs.color=vec4f(r,g,b,a);}`;
// Sideeffect
if (!ShaderStore.ShadersStoreWGSL[name]) {
ShaderStore.ShadersStoreWGSL[name] = shader;
}
/** @internal */
export const textureMergerPixelShaderWGSL = { name, shader };
//# sourceMappingURL=textureMerger.fragment.js.map