我正在尝试制作一个过滤器来替换图像中的颜色 颜色替换很好这里是一个例子
private _createColorFilter(shaderTexture, materialTexture) {
const uniforms = {
uTextureOne: {
type: 'f',
value: 0.1
},
uTextureTwo: {
type: 'sampler2D',
value : shaderTexture
}
};
const shaderCode = `
varying vec2 vTextureCoord;
varying vec4 vColor;
uniform sampler2D uTextureOne;
uniform float customUniform;
void main(){
vec4 one = texture2D(uTextureOne, vTextureCoord);
float percent = (one.r-one.g)/255.0;
one.r = one.r + (254.0 - 255.0)*percent;
one.g = one.g + 255.0 * percent;
one.b = one.b + 47.0 * percent;
gl_FragColor = one;
}`;
return new PIXI.Filter('', shaderCode, uniforms);
}
我想实现相同的效果,但现在使用纹理颜色 从逻辑上讲,我需要从纹理中获取颜色,并根据我的算法,将其更改为适合色调
但是,不去((
private _createColorFilter(shaderTexture, materialTexture) {
const uniforms = {
uTextureOne: {
type: 'f',
value: 0.1
},
uTextureTwo: {
type: 'sampler2D',
value : shaderTexture
}
};
const shaderCode = `
varying vec2 vTextureCoord;
varying vec4 vColor;
uniform sampler2D uTextureOne;
uniform sampler2D uTextureTwo;
uniform float customUniform;
void main(){
vec4 one = texture2D(uTextureOne, vTextureCoord);
var4 two = texture2D(uTextureTwo, vTextureCoord);
float percent = (one.r-one.g)/255.0;
one.r = one.r + (two.r - 255.0)*percent;
one.g = one.g + two.g * percent;
one.b = one.b + two.b * percent;
gl_FragColor = one;
}`;
return new PIXI.Filter('', shaderCode, uniforms);
颜色变黑
请帮帮我