blender/intern/cycles/kernel/osl/shaders/node_mix_vector.osl
Raiko f14783d511 Nodes: Optimize Four Color Mix Modes
The geo nodes implementations of the `mix`, `addition`, `multiplication`
and `subtraction` color mix modes are both faster and have better
numerical properties than the ones we use in Cycles, OSL and EEVEE.

This PR ports the geo nodes implementations of those color mix modes
to Cycles, OSL and EEVEE.

Additionally, the SVM mix function implementation is templatized and
a new function called "endvalue_preserving_mix" is added for the
alternative variant of linear interpolation.

Pull Request: https://projects.blender.org/blender/blender/pulls/158022
2026-06-05 11:54:48 +02:00

15 lines
449 B
Text

/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
*
* SPDX-License-Identifier: Apache-2.0 */
#include "node_math.h"
shader node_mix_vector(int use_clamp = 0,
float Factor = 0.5,
vector A = 0.0,
vector B = 0.0,
output vector Result = 0.0)
{
float t = (use_clamp) ? clamp(Factor, 0.0, 1.0) : Factor;
Result = endvalue_preserving_mix(A, B, t);
}