LYGIA Shader Library

mixRYB (lygia/color/mixRYB)

Mix colors in RYB space.

Dependencies:

Use:

<vec3|vec4> mixRYB(<vec3|vec4> colA, <vec3|vec4> colB, <float> p)
<vec4> mixRYB(<vec4> colA, <vec4> colB, <vec4> colC)
<vec3> mixRYB(<vec3> colA, <vec3> colB, <vec3> colC, <vec3> p)
<vec4> mixRYB(<vec4> colA, <vec4> colB, <vec4> colC, <vec4> colD)
<vec3> mixRYB(<vec3> colA, <vec3> colB, <vec3> colC, <vec3> colD, <vec4> p)

Check it on Github




#ifndef FNC_MIXRYB
#define FNC_MIXRYB

vec3 mixRYB(vec3 A, vec3 B, float p) { return ryb2rgb(mix(rgb2ryb(A),rgb2ryb(B), p)); }
vec4 mixRYB(vec4 A, vec4 B, float p) { return ryb2rgb(mix(rgb2ryb(A),rgb2ryb(B), p)); }

vec4 mixRYB(vec4 A, vec4 B, vec4 C) { return vec4(ryb2rgb(rgb2ryb(A.rgb) * A.a + rgb2ryb(B.rgb) * B.a + rgb2ryb(C.rgb) * C.a), sum(vec3(A.a, B.a, C.a))); }
vec3 mixRYB(vec3 A, vec3 B, vec3 C, vec3 p) { return ryb2rgb(rgb2ryb(A) * p.x + rgb2ryb(B) * p.y + rgb2ryb(C) * p.z ); }

vec4 mixRYB(vec4 A, vec4 B, vec4 C, vec4 D) { return vec4(ryb2rgb(rgb2ryb(A.rgb) * A.a + rgb2ryb(B.rgb) * B.a + rgb2ryb(C.rgb) * C.a + rgb2ryb(D.rgb) * D.a), sum(vec4(A.a, B.a, C.a, D.a))); }
vec3 mixRYB(vec3 A, vec3 B, vec3 C, vec3 D, vec4 p) { return ryb2rgb(rgb2ryb(A) * p.x + rgb2ryb(B) * p.y + rgb2ryb(C) * p.z + rgb2ryb(D) * p.w); }

#endif

Dependencies:

Use:

<float3|float4> mixRYB(<float3|float4> colA, <float3|float4> colB, <float> p)
<float4> mixRYB(<float4> colA, <float4> colB, <float4> colC)
<float3> mixRYB(<float3> colA, <float3> colB, <float3> colC, <float3> p)
<float4> mixRYB(<float4> colA, <float4> colB, <float4> colC, <float4> colD)
<float3> mixRYB(<float3> colA, <float3> colB, <float3> colC, <float3> colD, <float4> p)

Check it on Github




#ifndef FNC_MIXRYB
#define FNC_MIXRYB

float3 mixRYB(float3 A, float3 B, float p) { return ryb2rgb(lerp(rgb2ryb(A),rgb2ryb(B), p)); }
float4 mixRYB(float4 A, float4 B, float p) { return ryb2rgb(lerp(rgb2ryb(A),rgb2ryb(B), p)); }

float4 mixRYB(float4 A, float4 B, float4 C) { return float4(ryb2rgb(rgb2ryb(A.rgb) * A.a + rgb2ryb(B.rgb) * B.a + rgb2ryb(C.rgb) * C.a), sum(float3(A.a, B.a, C.a))); }
float3 mixRYB(float3 A, float3 B, float3 C, float3 p) { return ryb2rgb(rgb2ryb(A) * p.x + rgb2ryb(B) * p.y + rgb2ryb(C) * p.z ); }

float4 mixRYB(float4 A, float4 B, float4 C, float4 D) { return float4(ryb2rgb(rgb2ryb(A.rgb) * A.a + rgb2ryb(B.rgb) * B.a + rgb2ryb(C.rgb) * C.a + rgb2ryb(D.rgb) * D.a), sum(float4(A.a, B.a, C.a, D.a))); }
float3 mixRYB(float3 A, float3 B, float3 C, float3 D, float4 p) { return ryb2rgb(rgb2ryb(A) * p.x + rgb2ryb(B) * p.y + rgb2ryb(C) * p.z + rgb2ryb(D) * p.w); }

#endif

Dependencies:

Use:

<float3|float4> mixRYB(<float3|float4> colA, <float3|float4> colB, <float> p)
<float4> mixRYB(<float4> colA, <float4> colB, <float4> colC)
<float3> mixRYB(<float3> colA, <float3> colB, <float3> colC, <float3> p)
<float4> mixRYB(<float4> colA, <float4> colB, <float4> colC, <float4> colD)
<float3> mixRYB(<float3> colA, <float3> colB, <float3> colC, <float3> colD, <float4> p)

Check it on Github




#ifndef FNC_MIXRYB
#define FNC_MIXRYB

float3 mixRYB(float3 A, float3 B, float p) { return ryb2rgb(mix(rgb2ryb(A),rgb2ryb(B), p)); }
float4 mixRYB(float4 A, float4 B, float p) { return ryb2rgb(mix(rgb2ryb(A),rgb2ryb(B), p)); }

float4 mixRYB(float4 A, float4 B, float4 C) { return float4(ryb2rgb(rgb2ryb(A.rgb) * A.a + rgb2ryb(B.rgb) * B.a + rgb2ryb(C.rgb) * C.a), sum(float3(A.a, B.a, C.a))); }
float3 mixRYB(float3 A, float3 B, float3 C, float3 p) { return ryb2rgb(rgb2ryb(A) * p.x + rgb2ryb(B) * p.y + rgb2ryb(C) * p.z ); }

float4 mixRYB(float4 A, float4 B, float4 C, float4 D) { return float4(ryb2rgb(rgb2ryb(A.rgb) * A.a + rgb2ryb(B.rgb) * B.a + rgb2ryb(C.rgb) * C.a + rgb2ryb(D.rgb) * D.a), sum(float4(A.a, B.a, C.a, D.a))); }
float3 mixRYB(float3 A, float3 B, float3 C, float3 D, float4 p) { return ryb2rgb(rgb2ryb(A) * p.x + rgb2ryb(B) * p.y + rgb2ryb(C) * p.z + rgb2ryb(D) * p.w); }

#endif

Examples

Licenses

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository