2010-12-22 68 views

回答

1

我假设你可以计算点积。所以只需乘以另一个包含(0,0,0,1)的vec4即可。

编辑:但是,你确定你不能简单地使用.w?我发现的所有文档和示例都说可以。

4

我认为你可能误读了规范 - 阅读单个组件完全有效。 GLSL甚至允许隐式排列和原始组件的组合,例如,

lowp vec4 someVector; 

// someVector.xy is a lowp vec2 containing the first two scalars from someVector 
// someVector.zwx is a lowp vec3 containing the third, fourth and first scalars in that order 
// someVector.w is a lowp float containing the fourth scalar 

例如,我使用的片段着色器:

void main() 
{ 
    lowp vec4 srcPixel = texture2D(tex2D, texCoordVarying); 
    lowp vec4 yuvPixel = rgbToYuv * srcPixel; 

    yuvPixel.r *= 3.0; 

    gl_FragColor = yuvToRgb * yuvPixel; 
} 

与合适的基质和varyings提高纹理三倍的亮度。