glsl矢量加标量 [英] glsl vector plus scalar

查看:86
本文介绍了glsl矢量加标量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我进行了很多搜索,但找不到以下语句在#version 330顶点着色器中是否合法:

I searched a lot but could not find if the following statements are legal in a #version 330 vertex shader:

#define note_the_following_whitespaces            0x01

(layout location = 7) vec3 out ov;
(layout location = 8) vec3 out rv;
void main() {
    rv = vec3(1.0,2.0,3.0);
    ov = (1.0+rv)/2.0;
    gl_Position = [whatever]...
}

我特别指的是(1.0+rv)-着色器可以在每张nVidia卡上正常编译,但是拒绝在ATI卡上编译.不幸的是,我没有确切的编译结果,我只知道编译不成功.

I'm referring particularly to the (1.0+rv) - the shader compiles fine on every nVidia card, but refuses to compile on ATI cards. Unfortunately I don't have the exact compilation result, I just know that the compilation was unsuccessful.

推荐答案

http://www .opengl.org/registry/doc/GLSLangSpec.3.30.6.pdf

来自5.9

算术二进制运算符加(+),减(-),乘(*)和除(/)对整数和 浮点标量,向量和矩阵.

The arithmetic binary operators add (+), subtract (-), multiply (*), and divide (/) operate on integer and floating-point scalars, vectors, and matrices.

(...)

一个操作数是标量,另一个是向量或矩阵.在这种情况下,标量运算为 独立应用于向量或矩阵的每个分量,从而得到相同大小的向量 或矩阵.

One operand is a scalar, and the other is a vector or matrix. In this case, the scalar operation is applied independently to each component of the vector or matrix, resulting in the same size vector or matrix.

因此,如果它不能在ATI上编译,则仅表示其驱动程序在这方面是不正确的.

So if it doesn't compile on ATI, it just means its driver is incorrect in that regard.

这篇关于glsl矢量加标量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆