WebGL shaders: maximum number of varying variables

后端 未结 1 1344
傲寒
傲寒 2020-12-16 04:32

From the OpenGL ES spec section 2.10.4 (Shader Variables: Varying Variables):

The number of interpolators available for processing varying variables i

1条回答
  •  囚心锁ツ
    2020-12-16 05:06

    From the WebGL spec

    6.24 Packing Restrictions for Uniforms and Varyings

    The OpenGL ES Shading Language, Version 1.00 [GLES20GLSL], Appendix A, Section 7 "Counting of Varyings and Uniforms" defines a conservative algorithm for computing the storage required for all of the uniform and varying variables in a shader. The GLSL ES specification requires that if the packing algorithm defined in Appendix A succeeds, then the shader must succeed compilation on the target platform. The WebGL API further requires that if the packing algorithm fails either for the uniform variables of a shader or for the varying variables of a program, compilation or linking must fail.

    So yes, if you read the algorithm if MAX_VARYING_VECTORS is 8 you can use 16 vec2s. You can not however use 10 vec3s. You could only use 8 vec3s

    There are also array restrictions. For example you couldn't have an array of floats larger than 8 nor an array of vec2 larger than 8 if MAX_VARYING_VECTORS is 8.

    0 讨论(0)
提交回复
热议问题