我这里有一些 glsl,它就像一个魅力。仅编译需要 3 分钟或其他时间。我知道这是由于角度问题,Angle 是一个软件,可以将 opengl es 2.0 代码转换为用于 windows 系统上的 webgl 的 directX 9。如果我禁用角度,它会在一秒钟内编译。有谁知道为什么嵌套循环的角度太慢了。如果有解决办法?我的意思是我不能让每个着色器的每个人都等待超过一分钟。
for ( int b = 0; b < numberOfSplitpoints; b++ ) {
if ( cameraDepth > splitPoints[b] && cameraDepth < splitPoints[b+1] ) {
const float numberOfSplitpoints = float( NUMBER_OF_SPLIT_POINTS - 1 );
vec4 projCoords = v_projTextureCoords[b];
projCoords /= projCoords.w;
projCoords = 0.5 * projCoords + 0.5;
float shadowDepth = projCoords.z;
projCoords.x /= numberOfSplitpoints;
projCoords.x += float(b) / numberOfSplitpoints;
for( int x = 0; x < fullkernelSize; x++ ) {
for( int y = 0; y < fullkernelSize; y++ ) {
vec2 pointer = vec2( float(x-kernelsize) / 3072.0, float(y-kernelsize) / 1024.0 );
float convolution = kernel[x] * kernel[y];
vec4 color = texture2D(shadowMapSampler, projCoords.xy+pointer);
if(encodeDepth( color ) + shadowBias > shadowDepth) {
light += convolution;
} else {
light += convolution * 0.6;
}
}
}
}
}
vec2 random = normalize(texture2D(randomSampler, screenSize * uv / 64.0).xy * 2.0 - 1.0);
float ambiantAmount = 0.0;
const int kernel = 4;
float offset = ssoasampleRad / depth;
for(int x = 0; x<kernel; x++) {
vec2 a = reflect(directions[x], random) * offset;
vec2 b = vec2( a.x *0.707 - a.y*0.707,
a.x*0.707 + a.y*0.707 );
ambiantAmount += abientOcclusion(uv, a*0.25, position, normal);
ambiantAmount += abientOcclusion(uv, b*0.50, position, normal);
ambiantAmount += abientOcclusion(uv, a*0.75, position, normal);
ambiantAmount += abientOcclusion(uv, b, position, normal);
}