Skip to content

Commit

Permalink
improve converting shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro committed Jan 15, 2025
1 parent 6010b14 commit 650f90e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 2 additions & 7 deletions data/examples/clock_digital_nixie.shader
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ uniform float3 anodehighlightscolor = {1.0,0.5,0.0};

#ifndef OPENGL
#define mod(x,y) (x - y * floor(x / y))
bool2 greaterThan(float2 a, float2 b){
return bool2(a.x > b.x, a.y > b.y);
}

bool2 lessThan(float2 a, float2 b){
return bool2(a.x < b.x, a.y < b.y);
}
#define lessThan(a,b) (a < b)
#define greaterThan(a,b) (a > b)
#endif

// psrdnoise (c) Stefan Gustavson and Ian McEwan,
Expand Down
6 changes: 5 additions & 1 deletion obs-shaderfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,7 @@ static bool shader_filter_convert(obs_properties_t *props, obs_property_t *prope
dstr_replace(&effect_text, "mix(", "lerp(");
dstr_replace(&effect_text, "fract(", "frac(");
dstr_replace(&effect_text, "inversesqrt(", "rsqrt(");

dstr_replace(&effect_text, "extern bool", "uniform bool");
dstr_replace(&effect_text, "extern uint", "uniform uint");
dstr_replace(&effect_text, "extern int", "uniform int");
Expand Down Expand Up @@ -1878,6 +1878,10 @@ static bool shader_filter_convert(obs_properties_t *props, obs_property_t *prope

if (dstr_find(&effect_text, "mod("))
dstr_cat(&insert_text, "#define mod(x,y) (x - y * floor(x / y))\n");
if (dstr_find(&effect_text, "lessThan("))
dstr_cat(&insert_text, "#define lessThan(a,b) (a < b)\n");
if (dstr_find(&effect_text, "greaterThan("))
dstr_cat(&insert_text, "#define greaterThan(a,b) (a > b)\n");
dstr_cat(&insert_text, "#endif\n");

if (dstr_find(&effect_text, "iMouse") && !dstr_find(&effect_text, "float2 iMouse"))
Expand Down

0 comments on commit 650f90e

Please sign in to comment.