本文介绍了向量在着色器语言中如何相乘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

gl_FragColor = v1 * v2一样,我无法真正得知它是如何相乘的,似乎该参考文献给出了矢量乘法矩阵的解释.
ps:v1v2的类型均为vec4.

Such as gl_FragColor = v1 * v2, i can't really get how does it multiplies and it seems that the reference give the explanation of vector multiply matrix.
ps: The type of v1 and v2 are both vec4.

推荐答案

*运算符在逐个组件上有效表示vec4之类的向量.

The * operator works component-wise for vectors like vec4.

vec4 a = vec4(1.0, 2.0, 3.0, 4.0);
vec4 b = vec4(0.1, 0.2, 0.3, 0.4);
vec4 c = a * b; // vec4(0.1, 0.4, 0.9, 1.6)

GLSL语言规范 5.10矢量和矩阵运算部分中说:

这篇关于向量在着色器语言中如何相乘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 03:03