大佬教程收集整理的这篇文章主要介绍了优化片段着色器中的GLSL代码(iOS 5 OpenGL ES 2.0),大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
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)所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。