diff options
author | Sven Gothel <[email protected]> | 2023-09-30 01:28:59 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-09-30 01:28:59 +0200 |
commit | 297c48f4fefd1ab59800524ea5f0dd56684d6786 (patch) | |
tree | 02c1b8f65de349c9af3bc2a5b94e04e90d75c684 /src/jogl/classes/jogamp/graph/curve/opengl/shader/functions.glsl | |
parent | 2e46eb1bf06ef07801062122716aa99a6c871646 (diff) |
Bug 1465 - Graph / GraphUI: Render a Region's ColorTexture in proper aspect-ratio, letter-boxed or zoomed (config) + Bug 1466 Fix color mixing
Bug 1465: Region currently simply bloats a given texture to its region AABBox,
which renders textures with the wrong aspect ratio.
Add facility to program the texture-coordinates to either letter-box
or scaled-up (and cut) true aspect-ratio.
Default shall be zoom (scale-up and cut),
but user shall be able to set a flag in the Region for letter-box.
Have the shader clip texture coordinates properly,
best w/o branching to soothe performance.
See functions.glsl
+++
Bug 1466: Current color mix: texture * color_channel * color_static
is useless in GraphUI.
color_static shall modulate the texture, which works.
But in case of color_channel (attribute/varying)
we want it to be mixed so it can become the more dominant color
for e.g. a border.
Desired is:
color = vec4( mix( tex.rgb * gcu_ColorStatic.rgb, gcv_Color.rgb, gcv_Color.a ),
mix( tex.a * gcu_ColorStatic.a, 1, gcv_Color.a) );
Diffstat (limited to 'src/jogl/classes/jogamp/graph/curve/opengl/shader/functions.glsl')
-rw-r--r-- | src/jogl/classes/jogamp/graph/curve/opengl/shader/functions.glsl | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/functions.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/functions.glsl new file mode 100644 index 000000000..eeab54ebf --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/functions.glsl @@ -0,0 +1,42 @@ +// Copyright 2023 JogAmp Community. All rights reserved. + +#ifndef functions_glsl +#define functions_glsl + +/** Returns product of components. */ +float v_mul( vec2 v ) { + return v.x * v.y; +} +/** Returns component wise logical 'or' as float '0' or '1' using the components product and clamp. */ +float v_or( vec2 v ) { + return clamp(v.x * v.y, 0, 1); +} + +/** Returns sum of components. */ +float v_sum( vec2 v ) { + return v.x + v.y; +} +/** Returns component wise logical 'and' as float '0' or '1' using the components sum and clamp. */ +float v_and( vec2 v ) { + return clamp(v.x + v.y, 0, 1); +} + +/** + * Branch-less clipping function. + * <p> + * Returns either 'col_in' if the 'coord' is within ['low'..'high'] range, + * otherwise 'col_ex'. + * </p> + * <p> + * This is achieved via the build-in 'step' and 'mix' function + * as well as our own 'v_mul' and v_and' function, + * which flattens a 'vec2' to one float suitable to be used as the 'mix' criteria. + * </p> + */ +vec4 clip_coord(vec4 col_in, vec4 col_ex, vec2 coord, vec2 low, vec2 high) { + vec4 c = mix( col_ex, col_in, v_mul( step(low, coord) )); + return mix( c, col_ex, v_and( step(high, coord) )); +} + +#endif // functions_glsl + |