uniform int mn;highp float Nx;highp float Ny; highp float Nz;highp float invXTMax;highp float invYTMax;int m; int n; highp vec4 func(in highp vec3 texCoords3D){ // tile index int Ti = int(texCoords3D.z * Nz); // (r,c) position of tile withn texture unit int r = Ti / n; // integer division int c = Ti - r * n; // x/y offsets in pixels of tile origin with the texture unit highp float xOff = float(c) * Nx; highp float yOff = float(r) * Ny; // 2D texture coordinates highp vec2 texCoords2D; texCoords2D.x = (Nx * texCoords3D.x + xOff)*invXTMax; texCoords2D.y = (Ny * texCoords3D.y + yOff)*invYTMax; return texture2D(uSamplerTex0,texCoords2D); }
编辑:
为了给出一些上下文,func()用作光线投射设置的一部分.它被召集起来
每个片段从main()300次.
highp vec3 N;highp vec2 invTMax;highp vec4 func(in highp vec3 texCoords3D){ // tile index int Ti = int(texCoords3D.z * N.z); // (r,c) position of tile within texture unit int r = Ti / n; int c = Ti - r * n; // x/y offsets in pixels of tile origin with the texture unit highp vec2 Off = vec2( float(c),float(r) ) * N; // 2D texture coordinates highp vec2 texCoords2D = ( N * texCoords3D.xy + Off ) * invTMax; return texture2D(uSamplerTex0,texCoords2D); }
确保类似的计算并行运行.
总结以上是内存溢出为你收集整理的优化片段着色器中的GLSL代码(iOS 5 OpenGL ES 2.0)全部内容,希望文章能够帮你解决优化片段着色器中的GLSL代码(iOS 5 OpenGL ES 2.0)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)