Skip to content

Instantly share code, notes, and snippets.

@Quackdoc
Last active May 17, 2023 07:33
Show Gist options
  • Save Quackdoc/fab716e36f592d5765dc0b4d49cdb181 to your computer and use it in GitHub Desktop.
Save Quackdoc/fab716e36f592d5765dc0b4d49cdb181 to your computer and use it in GitHub Desktop.
olive glsl PR
<?xml version="1.0"?>
<olive version="230220">
<nodes version="1">
<node version="1" id="org.olivevideoeditor.Olive.shader" ptr="94848584989760">
<label>bloom</label>
<input id="enabled_in">
<primary>
<keyframing>0</keyframing>
<standard>
<track>true</track>
</standard>
</primary>
</input>
<input id="source">
<primary>
<standard>
<track>//OVE shader_name: bloom
//OVE shader_description:
//OVE main_input_name: Input
uniform sampler2D tex_in;
//OVE name: BlurSize
//OVE type: FLOAT
//OVE flag: CONNECTABLE
//OVE min: -64.0
//OVE max: 64.0
//OVE default: 8.0
//OVE description:
uniform float BlurSize;
//OVE name: Threshold
//OVE type: FLOAT
//OVE flag: CONNECTABLE
//OVE min: -99.0
//OVE max: 99.0
//OVE default: 5.0
//OVE description:
uniform float Threshold;
//OVE name: Intensity
//OVE type: FLOAT
//OVE flag: CONNECTABLE
//OVE min: -20.0
//OVE max: 20.0
//OVE default: 10.0
//OVE description:
uniform float Intensity;
//OVE end
// pixel coordinates in range [0..1]x[0..1]
in vec2 ove_texcoord;
// output color
out vec4 frag_color;
vec2 resolution = vec2(1920.0, 1080.0);
vec4 BlurColor (in vec2 Coord, in sampler2D Tex, in float MipBias)
{
vec2 TexelSize = MipBias/resolution.xy;
vec4 Color = texture2D(Tex, Coord, MipBias);
Color += texture2D(Tex, Coord + vec2(TexelSize.x,0.0), MipBias);
Color += texture2D(Tex, Coord + vec2(-TexelSize.x,0.0), MipBias);
Color += texture2D(Tex, Coord + vec2(0.0,TexelSize.y), MipBias);
Color += texture2D(Tex, Coord + vec2(0.0,-TexelSize.y), MipBias);
Color += texture2D(Tex, Coord + vec2(TexelSize.x,TexelSize.y), MipBias);
Color += texture2D(Tex, Coord + vec2(-TexelSize.x,TexelSize.y), MipBias);
Color += texture2D(Tex, Coord + vec2(TexelSize.x,-TexelSize.y), MipBias);
Color += texture2D(Tex, Coord + vec2(-TexelSize.x,-TexelSize.y), MipBias);
return Color/9.0;
}
void main(void) {
vec2 uv = ove_texcoord.xy;
vec4 Color = texture2D(tex_in, uv);
vec4 Highlight = clamp(BlurColor(uv, tex_in, log2(BlurSize))-(Threshold*0.1),0.0,1.0)*1.0/(1.0-(Threshold*0.1));
frag_color = 1.0-(1.0-Color)*(1.0-Highlight*(Intensity*0.1));
}
</track>
</standard>
</primary>
</input>
<input id="issues">
<primary>
<standard>
<track>None</track>
</standard>
</primary>
</input>
<input id="tex_in">
<primary>
<standard>
<track></track>
</standard>
</primary>
</input>
<input id="BlurSize">
<primary>
<keyframing>0</keyframing>
<standard>
<track>8</track>
</standard>
</primary>
</input>
<input id="Threshold">
<primary>
<keyframing>0</keyframing>
<standard>
<track>5</track>
</standard>
</primary>
</input>
<input id="Intensity">
<primary>
<keyframing>0</keyframing>
<standard>
<track>10</track>
</standard>
</primary>
</input>
<connections>
<connection input="tex_in" element="-1">
<output>94848620339744</output>
</connection>
</connections>
<hints>
<hint input="enabled_in" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="issues" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="source" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="tex_in" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
</hints>
<caches>
<audio>{eb07c07d-1a6e-4a13-888d-a6ebc723129d}</audio>
<video>{dbfb1cb0-c4f0-4336-ac83-5c376383706b}</video>
<thumb>{2084aba5-66ca-422c-be90-f61e3f00cd8d}</thumb>
<waveform>{fd42e402-74f5-4ff0-88ae-62b2bfd20296}</waveform>
</caches>
<custom/>
</node>
<properties>
<node ptr="94848584989760">
<expanded>1</expanded>
<x>-1.44127</x>
<y>0.788931</y>
</node>
</properties>
</nodes>
</olive>
<?xml version="1.0"?>
<olive version="230220">
<nodes version="1">
<node version="1" id="org.olivevideoeditor.Olive.shader" ptr="139685696727232">
<label>Color Temp</label>
<input id="enabled_in">
<primary>
<keyframing>0</keyframing>
<standard>
<track>true</track>
</standard>
</primary>
</input>
<input id="source">
<primary>
<standard>
<track>//OVE shader_name: Color Temp
//OVE shader_description:
//OVE main_input_name: Input
uniform sampler2D tex_in;
//OVE end
#define WithQuickAndDirtyLuminancePreservation
//OVE name: Luminance pres
//OVE type: FLOAT
//OVE flag: CONNECTABLE
//OVE min: 0.0
//OVE max: 3.0
//OVE default: 1.0
//OVE description:
uniform float LuminancePreservationFactor = 1.0;
//OVE name: Temp Factor
//OVE type: FLOAT
//OVE flag: CONNECTABLE
//OVE min: 0.0
//OVE max: 3.0
//OVE default: 1.0
//OVE description:
uniform float temperatureFactor = 1.0; //
//OVE name: Temperature Strength
//OVE type: FLOAT
//OVE flag: CONNECTABLE
//OVE min: 0.0
//OVE max: 3.0
//OVE default: 1.0
//OVE description:
uniform float temperatureStrength = 0.40;
const float PI2 = 6.2831853071;
// pixel coordinates in range [0..1]x[0..1]
in vec2 ove_texcoord;
// output color
out vec4 frag_color;
vec3 colorTemperatureToRGB(const in float temperature){
// Values from: http://blenderartists.org/forum/showthread.php?270332-OSL-Goodness&amp;p=2268693&amp;viewfull=1#post2268693
mat3 m = (temperature &lt;= 6500.0) ? mat3(vec3(0.0, -2902.1955373783176, -8257.7997278925690),
vec3(0.0, 1669.5803561666639, 2575.2827530017594),
vec3(1.0, 1.3302673723350029, 1.8993753891711275)) :
mat3(vec3(1745.0425298314172, 1216.6168361476490, -8257.7997278925690),
vec3(-2666.3474220535695, -2173.1012343082230, 2575.2827530017594),
vec3(0.55995389139931482, 0.70381203140554553, 1.8993753891711275));
return mix(clamp(vec3(m[0] / (vec3(clamp(temperature, 1000.0, 40000.0)) + m[1]) + m[2]), vec3(0.0), vec3(1.0)), vec3(1.0), smoothstep(1000.0, 0.0, temperature));
}
void main(void) {
//vec4 textureColor = texture2D(tex_in, ove_texcoord);
//frag_color= textureColor.rgba;
vec2 uv = ove_texcoord;
float temperature = mix(1000.0, 40000.0, temperatureFactor);
vec3 inColor = texture(tex_in, uv).xyz;
vec3 outColor = mix(inColor, inColor * colorTemperatureToRGB(temperature), temperatureStrength);
#ifdef WithQuickAndDirtyLuminancePreservation
outColor *= mix(1.0, dot(inColor, vec3(0.2126, 0.7152, 0.0722)) / max(dot(outColor, vec3(0.2126, 0.7152, 0.0722)), 1e-5), LuminancePreservationFactor);
#endif
frag_color = vec4(outColor, 1.0);
}
// Valid from 1000 to 40000 K (and additionally 0 for pure full white)
//void mainImage( out vec4 fragColor, in vec2 fragCoord )
//{
//
//}</track>
</standard>
</primary>
</input>
<input id="issues">
<primary>
<standard>
<track>None</track>
</standard>
</primary>
</input>
<input id="tex_in">
<primary>
<standard>
<track></track>
</standard>
</primary>
</input>
<connections>
<connection input="tex_in" element="-1">
<output>139683677938768</output>
</connection>
</connections>
<hints>
<hint input="enabled_in" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="issues" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="source" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="tex_in" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
</hints>
<caches>
<audio>{f0f70d70-27b1-45cc-8d28-cfdfcb5bb8bd}</audio>
<video>{996c6ddc-6700-4563-b4b0-2ea1ad44c45f}</video>
<thumb>{924aa407-3e2a-4497-abdb-0f45f050b6ab}</thumb>
<waveform>{5290f939-4bf8-4c2c-9847-28decbfdf8df}</waveform>
</caches>
<custom/>
</node>
<properties>
<node ptr="139685696727232">
<expanded>0</expanded>
<x>-0.830986</x>
<y>0.293333</y>
</node>
</properties>
</nodes>
</olive>
<?xml version="1.0"?>
<olive version="230220">
<nodes version="1">
<node version="1" id="org.olivevideoeditor.Olive.shader" ptr="93898224926768">
<label>Rudimentary Levels</label>
<input id="enabled_in">
<primary>
<keyframing>0</keyframing>
<standard>
<track>true</track>
</standard>
</primary>
</input>
<input id="source">
<primary>
<standard>
<track>//OVE shader_name: Rudimentary Levels
//OVE shader_description:
//OVE main_input_name: Input
uniform sampler2D tex_in;
//OVE name: inputWhite
//OVE type: FLOAT
//OVE flag: NOT_CONNECTABLE
//OVE min: 0.0
//OVE max: 255.0
//OVE default: 255.0
//OVE description:
uniform float inputWhite;
//OVE name: outputWhite
//OVE type: FLOAT
//OVE flag: NOT_CONNECTABLE
//OVE min: 0.0
//OVE max: 255.0
//OVE default: 255.0
//OVE description:
uniform float outputWhite;
//OVE name: outputBlack
//OVE type: FLOAT
//OVE flag: NOT_CONNECTABLE
//OVE min: 0.0
//OVE max: 255.0
//OVE default: 0.0
//OVE description:
uniform float outputBlack;
//OVE name: inputBlack
//OVE type: FLOAT
//OVE flag: CONNECTABLE
//OVE min: 0.0
//OVE max: 255.0
//OVE default: 0.0
//OVE description:
uniform float inputBlack;
//OVE name: gamma
//OVE type: FLOAT
//OVE flag: CONNECTABLE
//OVE min: 0.0
//OVE max: 5.0
//OVE default: 1.0
//OVE description:
uniform float gamma;
//OVE end
// pixel coordinates in range [0..1]x[0..1]
in vec2 ove_texcoord;
// output color
out vec4 frag_color;
const float minInputBlack = 0.0;
const float maxInputBlack = 255.0;
const float minInputWhite = 0.0;
const float maxInputWhite = 255.0;
const float minGamma = 0.0;
const float maxGamma = 5.0;
const float minOutputBlack = 0.0;
const float maxOutputBlack = 255.0;
const float minOutputWhite = 0.0;
const float maxOutputWhite = 255.0;
vec3 gammaControl(vec3 color, float gamma) {
float r = pow(color.r, 1.0 / gamma);
float g = pow(color.g, 1.0 / gamma);
float b = pow(color.b, 1.0 / gamma);
return vec3(r, g, b);
}
vec3 inputControl(vec3 color, float minInput, float maxInput) {
return (color - minInput) / (maxInput - minInput);
}
vec3 outputControl(vec3 color, float minOutput, float maxOutput) {
float r = mix(minOutput, maxOutput, color.r);
float g = mix(minOutput, maxOutput, color.g);
float b = mix(minOutput, maxOutput, color.b);
return vec3(r, g, b);
}
void main(void) {
vec2 uv = ove_texcoord;
vec4 outColor = texture(tex_in, uv);
//float value = gamm;
// Generating only inputBlack for demonstration.
//float inputBlack = mix(minInputBlack + 50.0, maxInputBlack - 50.0, value);
outColor.rgb = outputControl(gammaControl(inputControl(outColor.rgb, inputBlack/255.0, inputWhite/255.0), gamma), outputBlack/255.0, outputWhite/255.0);
frag_color = outColor;
}
</track>
</standard>
</primary>
</input>
<input id="issues">
<primary>
<standard>
<track>None</track>
</standard>
</primary>
</input>
<input id="tex_in">
<primary>
<standard>
<track></track>
</standard>
</primary>
</input>
<input id="inputWhite">
<primary>
<keyframing>0</keyframing>
<standard>
<track>255</track>
</standard>
</primary>
</input>
<input id="outputWhite">
<primary>
<keyframing>0</keyframing>
<standard>
<track>255</track>
</standard>
</primary>
</input>
<input id="outputBlack">
<primary>
<keyframing>0</keyframing>
<standard>
<track>0</track>
</standard>
</primary>
</input>
<input id="inputBlack">
<primary>
<keyframing>0</keyframing>
<standard>
<track>0</track>
</standard>
</primary>
</input>
<input id="gamma">
<primary>
<keyframing>0</keyframing>
<standard>
<track>1</track>
</standard>
</primary>
</input>
<connections>
<connection input="tex_in" element="-1">
<output>140397850902112</output>
</connection>
</connections>
<hints>
<hint input="enabled_in" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="issues" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="source" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="tex_in" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
</hints>
<caches>
<audio>{f69b7c85-00b0-4569-8bea-12340d5f78d8}</audio>
<video>{f097e733-f356-4f95-946b-1089f0e6bfa7}</video>
<thumb>{e4097f05-705b-4398-8773-11c612d1ed31}</thumb>
<waveform>{dfa3333d-e004-488f-b9ce-8e495eff1b94}</waveform>
</caches>
<custom/>
</node>
<properties>
<node ptr="93898224926768">
<expanded>0</expanded>
<x>-0.821596</x>
<y>0.666667</y>
</node>
</properties>
</nodes>
</olive>
<?xml version="1.0"?>
<olive version="230220">
<nodes version="1">
<node version="1" id="org.olivevideoeditor.Olive.shader" ptr="93903583639072">
<label>rain</label>
<input id="enabled_in">
<primary>
<keyframing>0</keyframing>
<standard>
<track>true</track>
</standard>
</primary>
</input>
<input id="source">
<primary>
<standard>
<track>//OVE shader_name: rain
//OVE shader_description:
//OVE main_input_name: Input
uniform sampler2D tex_in;
//OVE name: time
//OVE type: FLOAT
//OVE flag: CONNECTABLE
//OVE min: 0.0
//OVE max: 3000000.0
//OVE default: 1.0
//OVE description:
uniform float time;
//OVE end
// based on
// https://www.shadertoy.com/view/MlfBWr
// pixel coordinates in range [0..1]x[0..1]
in vec2 ove_texcoord;
// output color
out vec4 frag_color;
vec2 res = vec2(1920.0,1080.0);
vec2 rand(vec2 c){
mat2 m = mat2(12.9898,.16180,78.233,.31415);
return fract(sin(m * c) * vec2(43758.5453, 14142.1));
}
vec2 noise(vec2 p){
vec2 co = floor(p);
vec2 mu = fract(p);
mu = 3.*mu*mu-2.*mu*mu*mu;
vec2 a = rand((co+vec2(0.,0.)));
vec2 b = rand((co+vec2(1.,0.)));
vec2 c = rand((co+vec2(0.,1.)));
vec2 d = rand((co+vec2(1.,1.)));
return mix(mix(a, b, mu.x), mix(c, d, mu.x), mu.y);
}
void main(void) {
vec2 u = ove_texcoord;
vec2 v = ove_texcoord*.1;
vec2 n = noise(v * 200.0);
frag_color = textureLod(tex_in, u, 0.5);
for (float r = 4. ; r &gt; 0. ; r--) {
vec2 x = res.xy * r * .015, // Number of potential drops (in a grid)
p = 6.28 * u * x + (n - .5) * 2.,
s = sin(p);
// Current drop properties. Coordinates are rounded to ensure a
// consistent value among the fragment of a given drop.
//vec4 d = texture(iChannel1, round(u * x - 0.25) / x);
vec2 v = round(u * x - 0.25) / x;
vec4 d = vec4(noise(v*200.), noise(v));
// Drop shape and fading
float t = (s.x+s.y) * max(0., 1. - fract(time * (d.b + .1) + d.g) * 2.);;
// d.r -&gt; only x% of drops are kept on, with x depending on the size of drops
if (d.r &lt; (5.-r)*.08 &amp;&amp; t &gt; .5) {
// Drop normal
vec3 v = normalize(-vec3(cos(p), mix(.2, 2., t-.5)));
// fragColor = vec4(v * 0.5 + 0.5, 1.0); // show normals
// Poor man's refraction (no visual need to do more)
frag_color = texture(tex_in, u * .3);
}
}
//frag_color = vec4(n, 0.0, 1.0);
}
</track>
</standard>
</primary>
</input>
<input id="issues">
<primary>
<standard>
<track>None</track>
</standard>
</primary>
</input>
<input id="tex_in">
<primary>
<standard>
<track></track>
</standard>
</primary>
</input>
<input id="time">
<primary>
<keyframing>1</keyframing>
<standard>
<track>0</track>
</standard>
<keyframes>
<track>
<key input="time" time="0/1" type="0" inhandlex="0" inhandley="0" outhandlex="0" outhandley="0">0</key>
<key input="time" time="33/10" type="0" inhandlex="0" inhandley="0" outhandlex="0" outhandley="0">0</key>
<key input="time" time="156/5" type="0" inhandlex="0" inhandley="0" outhandlex="0" outhandley="0">0</key>
<key input="time" time="5773/30" type="0" inhandlex="0" inhandley="0" outhandlex="0" outhandley="0">30000</key>
</track>
</keyframes>
</primary>
</input>
<connections>
<connection input="tex_in" element="-1">
<output>93903578742784</output>
</connection>
</connections>
<hints>
<hint input="enabled_in" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="issues" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="source" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="tex_in" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
</hints>
<caches>
<audio>{4292da8f-c075-4a0e-a1bc-73c223f3e52e}</audio>
<video>{5c7c2ff5-2a97-4e9f-9d63-cc1200cc0075}</video>
<thumb>{3880e751-0cbc-4dd1-ba00-bb5fe034d71a}</thumb>
<waveform>{2d286319-b23a-4186-9524-167257728f57}</waveform>
</caches>
<custom/>
</node>
<properties>
<node ptr="93903583639072">
<expanded>1</expanded>
<x>-2.03973</x>
<y>0.123873</y>
</node>
</properties>
</nodes>
</olive>
<?xml version="1.0"?>
<olive version="230220">
<nodes version="1">
<node version="1" id="org.olivevideoeditor.Olive.shader" ptr="94848620339744">
<label>sharpen</label>
<input id="enabled_in">
<primary>
<keyframing>0</keyframing>
<standard>
<track>true</track>
</standard>
</primary>
</input>
<input id="source">
<primary>
<standard>
<track>//OVE shader_name: sharpen
//OVE shader_description:
//OVE main_input_name: Texture
uniform sampler2D tex_in;
//OVE name: Sharpness
//OVE type: FLOAT
//OVE flag: CONNECTABLE
//OVE min: -10.0
//OVE max: 20.0
//OVE default: 2.0
//OVE description:
uniform float sharpness;
//OVE end
// pixel coordinates in range [0..1]x[0..1]
in vec2 ove_texcoord;
// output color
out vec4 frag_color;
//const vec2 renderScale = vec2(1.,1.);
vec2 resolution = vec2(1920.0, 1080.0);
void main(void) {
//vec2 resolution = textureSize(tex_in,0);
vec2 uv = ove_texcoord.xy;
vec2 step = 1.0 / resolution.xy;
vec3 texA = texture2D( tex_in, uv + vec2(-step.x, -step.y) * 1.5 ).rgb;
vec3 texB = texture2D( tex_in, uv + vec2( step.x, -step.y) * 1.5 ).rgb;
vec3 texC = texture2D( tex_in, uv + vec2(-step.x, step.y) * 1.5 ).rgb;
vec3 texD = texture2D( tex_in, uv + vec2( step.x, step.y) * 1.5 ).rgb;
vec3 around = 0.25 * (texA + texB + texC + texD);
vec3 center = texture2D( tex_in, uv ).rgb;
vec3 col = center + (center - around) * sharpness;
frag_color = vec4(col,texture2D( tex_in, uv ).rgba);
//vec4 textureColor = texture2D(tex_in, ove_texcoord);
//frag_color= textureColor.yzxt;
}
</track>
</standard>
</primary>
</input>
<input id="issues">
<primary>
<standard>
<track>None</track>
</standard>
</primary>
</input>
<input id="tex_in">
<primary>
<standard>
<track></track>
</standard>
</primary>
</input>
<input id="sharpness">
<primary>
<keyframing>0</keyframing>
<standard>
<track>-10</track>
</standard>
</primary>
</input>
<connections>
<connection input="tex_in" element="-1">
<output>94848583715968</output>
</connection>
</connections>
<hints>
<hint input="enabled_in" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="issues" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="source" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
<hint input="tex_in" element="-1" version="1">
<types/>
<index>-1</index>
<tag></tag>
</hint>
</hints>
<caches>
<audio>{7979adca-fbfa-40a9-b927-00684f362de0}</audio>
<video>{93bd8e4e-94fa-4a06-8744-6908d301b057}</video>
<thumb>{fb0b28c7-d2e7-4ef2-bd8d-0dc9fe4fe6e6}</thumb>
<waveform>{a5fc4c51-63e8-4316-996e-e4b3d51fdda4}</waveform>
</caches>
<custom/>
</node>
<properties>
<node ptr="94848620339744">
<expanded>1</expanded>
<x>-1.88334</x>
<y>-0.679522</y>
</node>
</properties>
</nodes>
</olive>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment