Asperger
Asperger

Reputation: 3222

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?

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.

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.

Upvotes: 0

Views: 200

Answers (1)

BDL
BDL

Reputation: 22168

This are so-called swizzle operators and return the corresponding component of a vector, where r corresponds to x and so on.

Upvotes: 2

Related Questions