无法让这个 shadertoy 着色器在 GLSL 和 OpenGL 2.0 中工作

问题描述

我在下面转换的着色器在使用 Opengl 2.0 的 LibGDX 中引发以下错误

ERROR: 0:08: '<<' does not operate on 'int' and 'int'
ERROR: 0:23: No matching function for call to mod(int,int)
ERROR: 0:24: Invalid call of undeclared identifier 'textureLod'

显然我注释掉并替换了某些部分以进一步查看错误,但错误应该是它存在的所有问题。

varying vec4 v_color;
varying vec2 v_texCoords;

uniform sampler2D u_texture;

uniform vec2 resolution;

const int samples = 35,LOD = 2,sLOD = 1 << LOD;//error here
const float sigma = float(samples) * .25;

float gaussian(vec2 i) {
    return exp( -.5* dot(i/=sigma,i) ) / ( 6.28 * sigma*sigma );
}

void main() {
    vec2 u = gl_FragCoord.xy/resolution.xy;

    vec4 o = vec4(0);  
    int s = samples/sLOD;
    vec2 scale = vec2(1,1);

    for ( int i = 0; i < s*s; i++ ) {
        vec2 d = vec2(mod(i,s),i/s)*float(sLOD) - float(samples)/2.;//error here
        o += gaussian(d) * textureLod( u_texture,u + scale * d,float(LOD) );//error here
    }

    gl_FragColor = v_color * texture2D(u_texture,v_texCoords);//simply outputs default image at the moment since the above has errors
}

在 LibGDX 中使用高于 opengl 2.0 的任何东西真的没有任何简单或好的方法,但我想知道是否有任何这些命令的解决方法或替代方法。不确定为什么 mod 不起作用 - 它仅适用于 float

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)