简体   繁体   English

WebGL / Three.js着色器.r和.g是什么意思?

[英]WebGL / Three.js shaders what does .r and .g mean?

So im learning shaders by example and I often see .r and .g, what do those two letters mean? 因此,我通过示例学习着色器,我经常看到.r和.g,这两个字母是什么意思?

I dont even have an idea what to google since I am unaware of the terminology and use of those two letters G and R when used inside a GL shader program. 我什至不知道该对Google做什么,因为当我在GL着色器程序中使用时,我不知道这两个字母G和R的术语和使用。

vec2 uvNoiseTimeShift = vUv + noiseScale * vec2( noiseGeneratorTimeShift.r,
                                                 noiseGeneratorTimeShift.g );

When replacing r with g the effect seems to be the same, so im not sure what those properties are for. 当用g代替r时,效果似乎是相同的,因此无法确定这些属性的用途。

这就是所谓的swizzle运算符 ,它们返回向量的相应分量,其中r对应于x ,依此类推。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM