Opengl es 在OpenGL ES着色语言中从vec4获取alpha浮点值

Opengl es 在OpenGL ES着色语言中从vec4获取alpha浮点值,opengl-es,Opengl Es,这听起来可能很愚蠢,但我不太确定如何从输入的vec4中获取“W”组件本身。我在说明书中读到,你无法获得单个组件,因此,甚至询问可能都是错误的 谢谢 我想你可以计算点积。所以只需乘以另一个包含(0,0,0,1)的向量4 编辑:但是,你确定不能简单地使用.w吗?我找到的所有文档和示例都说您可以。我假设您可以计算点积。所以只需乘以另一个包含(0,0,0,1)的向量4 编辑:但是,你确定不能简单地使用.w吗?我找到的所有文档和示例都表明您可以。我认为您可能误读了规范-阅读单个组件是完全正确的。GLSL甚

这听起来可能很愚蠢,但我不太确定如何从输入的vec4中获取“W”组件本身。我在说明书中读到,你无法获得单个组件,因此,甚至询问可能都是错误的


谢谢

我想你可以计算点积。所以只需乘以另一个包含(0,0,0,1)的向量4


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

我假设您可以计算点积。所以只需乘以另一个包含(0,0,0,1)的向量4


编辑:但是,你确定不能简单地使用.w吗?我找到的所有文档和示例都表明您可以。

我认为您可能误读了规范-阅读单个组件是完全正确的。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;
}

使用合适的矩阵和变量将纹理亮度提高三倍。

我认为您可能误读了规范-读取单个组件是完全有效的。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;
}
使用合适的矩阵和变量将纹理的亮度提高三倍