Average out the Product of 2 Vectors

lighting
(Adrian) #1

Hey everyone,

When I multiply 2 Vectors together, and then convert them to a factor of the envoirement texture, this gives me some light and some dark Areas in my envoirement texture.
Do you know any way to average those out, so the entire envoirement has the same color?

Thanks for any tips
Adrian

0 Likes

(Secrop) #2

1st- Which vectors?
2nd- What exactly do you mean by ‘multiplication’? (dot product, cross product, or simple component product?)
3rd- How are you converting that multiplication into a factor?

0 Likes

(Adrian) #3

Ähm… I hope this helps you

0 Likes

(Secrop) #4

Nopes… it doesn’t help much, as I still don’t have any clue about the object you’re using, and what are you trying to accomplish…

But here’s the explanation:
The Object coordinates have a range that depends on the object’s mesh! Each point being sampled will have, as possible coordinates, something between the lower-front-left corner and the top-back-right corner of the object’s bounding box, using the object’s position/orientation/scale as origin.
This means that whatever comes out from the Object coordinate system is merelly a vector from the objects origin to the point being sampled (in object space). The Dot Product of that vector with itself is merelly the distance of the point to the origin squared:

Dot(A,A)=Ax * Ax + Ay * Ay + Az * Az

and this is the same as the Pythagoras theorem in three dimentions… Dist(Orig, A) = sqrt(Dot(A,A))

So, the distance from the origin to each sampled point will vary. And distances bigger than 1 will grow exponentially (since you don’t squarerooted the dot product result).
But your color ramp makes a different interpretation of that result:
If the square of the distance is between 0 and 0.632, then the output color is pure white. If it’s between 0.632 and 1 it decays to black, and it keeps as black for distances above 1.

Since you now have something in a range of:

dist^2 | 0.0 | 0.1 | ... | 0.632 | ... | 1.0 | >1.0 ...
          v     v     v      v      v     v      v
color  |  1  |  1  |  1  |   1   | 0.5 | 0.0 |  0.0 ...

you can scale it to whatever you want (either by re-scaling the distance, or re-scaling the output of that ramp)!

For example, making the last ramp stop a grey color instead of black, might «average» your output gradient (thought the term here has nothing to do with averaging)

0 Likes