Skip to content

Commit

Permalink
next try to get shaders working with opengl
Browse files Browse the repository at this point in the history
  • Loading branch information
exeldro committed Nov 10, 2023
1 parent 030180c commit 354a8a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions data/examples/embers.effect
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ uniform string notes<
> = "luma is applied with Apply to Alpha Layer. Movement Speed and Direction can be negatives";

#ifndef OPENGL
#define mat2 float2x2
#define fract frac
#define mix lerp
#endif
Expand Down Expand Up @@ -124,7 +125,8 @@ float hash1_2(float2 x)

float2 hash2_2(float2 x)
{
float2 y = mul(x, float2x2(20.52, 24.1994, 70.291, 80.171));
mat2 m = mat2(20.52, 24.1994, 70.291, 80.171);
float2 y = mul(x, m);
return fract(sin(y) * 492.194);
}

Expand Down Expand Up @@ -197,7 +199,8 @@ float2 rotate(float2 vpoint, float deg)
{
float s = sin(deg);
float c = cos(deg);
return mul(vpoint, float2x2(s, c, -c, s));
mat2 m = mat2(s, c, -c, s);
return mul(vpoint, m);
}

//Cell center from point on the grid
Expand All @@ -206,7 +209,8 @@ float2 voronoiPointFromRoot(float2 root, float deg)
float2 vpoint = hash2_2(root) - 0.5;
float s = sin(deg);
float c = cos(deg);
vpoint = mul(vpoint, float2x2(s, c, -c, s)) * 0.66;
mat2 m = mat2(s, c, -c, s);
vpoint = mul(vpoint, m) * 0.66;
vpoint += root + 0.5;
return vpoint;
}
Expand Down
8 changes: 6 additions & 2 deletions data/examples/twist.shader
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ uniform float rotation<
float step = 0.001;
> = 2.0;

float2x2 rotate(float angle){
return float2x2(float2(cos(angle), -sin(angle)), float2(sin(angle), cos(angle)));
#ifndef OPENGL
#define mat2 float2x2
#endif

mat2 rotate(float angle){
return mat2(float2(cos(angle), -sin(angle)), float2(sin(angle), cos(angle)));
}

float4 mainImage(VertData v_in) : TARGET
Expand Down

0 comments on commit 354a8a2

Please sign in to comment.