Opengl es 查找着色器的概念
以下是着色器的示例:Opengl es 查找着色器的概念,opengl-es,glsl,Opengl Es,Glsl,以下是着色器的示例: varying highp vec2 textureCoordinate; varying highp vec2 textureCoordinate2; // TODO: This is not used uniform sampler2D inputImageTexture; uniform sampler2D inputImageTexture2; // lookup texture void main() { lowp vec4 textur
varying highp vec2 textureCoordinate;
varying highp vec2 textureCoordinate2; // TODO: This is not used
uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2; // lookup texture
void main()
{
lowp vec4 textureColor = texture2D(inputImageTexture, textureCoordinate);
mediump float blueColor = textureColor.b * 63.0;
mediump vec2 quad1;
quad1.y = floor(floor(blueColor) / 8.0);
quad1.x = floor(blueColor) - (quad1.y * 8.0);
mediump vec2 quad2;
quad2.y = floor(ceil(blueColor) / 8.0);
quad2.x = ceil(blueColor) - (quad2.y * 8.0);
highp vec2 texPos1;
texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.r);
texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.g);
highp vec2 texPos2;
texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.r);
texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.g);
lowp vec4 newColor1 = texture2D(inputImageTexture2, texPos1);
lowp vec4 newColor2 = texture2D(inputImageTexture2, texPos2);
lowp vec4 newColor = mix(newColor1, newColor2, fract(blueColor));
gl_FragColor = vec4(newColor.rgb, textureColor.w);
}
此着色器在图像周围添加蓝色边的效果。它使用附加纹理进行计算。以下是纹理:
有人能解释一下这种质地的用途吗。在代码中,此纹理存储在inputImageTexture2变量中。什么是想法和算法?
例如,如果想要获得红色边而不是蓝色边,我需要如何修改输入纹理
谢谢。这个特殊的过滤器是由Lev Zelensky编写的,他在上描述了它的配置 基本上,从基本RGB查找表开始,将其放入Photoshop并应用要复制的颜色效果,然后获取结果图像并将其用作此过滤器的查找表。对于图像中的每个RGB值,将找到并使用该表中最接近的匹配项,而不是原始颜色
至于为什么您在图像外部看到蓝色,请确保您正确生成并保存了查找表,并且将其添加到过滤器的正确输入槽中。您是否尝试将蓝色添加到红色通道中?