- Fix honeycomb type conversion error

This commit is contained in:
Tanasart 2024-09-10 09:50:48 +07:00
parent 6581ae8e58
commit 1410549965
6 changed files with 63 additions and 50 deletions

View file

@ -51,6 +51,8 @@
globalvar CURRENT_COLOR;
CURRENT_COLOR = c_white;
#macro MAC (OS == os_macosx)
#endregion
#region input

View file

@ -339,7 +339,17 @@
if(PREFERENCES.use_legacy_exception) resetException();
else setException();
if(OS != os_macosx && !LOADING) {
if(OS == os_macosx) {
var ww = PREFERENCES.window_width;
var hh = PREFERENCES.window_height;
window_minimize_size = [ ww, hh ];
window_set_rectangle(display_get_width() / 2 - ww / 2, display_get_height() / 2 - hh / 2, ww, hh);
if(PREFERENCES.window_maximize)
winMan_Maximize();
} else if(!LOADING) {
var _monitors = display_measure_all();
var _monitor = noone;

View file

@ -248,22 +248,22 @@ function winManDraw() { #region
}
if(l && u) {
CURSOR = cr_size_nwse;
CURSOR = MAC? cr_size_all : cr_size_nwse;
hv = 0b0110;
}
if(r && d) {
CURSOR = cr_size_nwse;
CURSOR = MAC? cr_size_all : cr_size_nwse;
hv = 0b1001;
}
if(l && d) {
CURSOR = cr_size_nesw;
CURSOR = MAC? cr_size_all : cr_size_nesw;
hv = 0b1100;
}
if(r && u) {
CURSOR = cr_size_nesw;
CURSOR = MAC? cr_size_all : cr_size_nesw;
hv = 0b0011;
}

View file

@ -1,22 +1,21 @@
//
// Simple passthrough fragment shader
//
#define CURVE_MAX 512
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float w_curve[512];
uniform float w_curve[CURVE_MAX];
uniform int w_amount;
uniform float r_curve[512];
uniform float r_curve[CURVE_MAX];
uniform int r_amount;
uniform float g_curve[512];
uniform float g_curve[CURVE_MAX];
uniform int g_amount;
uniform float b_curve[512];
uniform float b_curve[CURVE_MAX];
uniform int b_amount;
uniform float a_curve[512];
uniform float a_curve[CURVE_MAX];
uniform int a_amount;
float eval_curve_segment_t(in float _y0, in float ax0, in float ay0, in float bx1, in float by1, in float _y1, in float prog) {
@ -73,7 +72,7 @@ float eval_curve_segment_x(in float _y0, in float ax0, in float ay0, in float bx
return eval_curve_segment_t(_y0, ax0, ay0, bx1, by1, _y1, _xt);
}
float curveEval(in float[512] curve, in int amo, in float _x) {
float curveEval(in float[CURVE_MAX] curve, in int amo, in float _x) {
int _shf = amo - int(floor(float(amo) / 6.) * 6.);
int _segs = (amo - _shf) / 6 - 1;

View file

@ -1,4 +1,8 @@
#extension GL_OES_standard_derivatives : enable
#define MACOS 1
#ifndef MACOS
#extension GL_OES_standard_derivatives : enable
#endif
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
@ -12,19 +16,26 @@ uniform vec2 shift;
uniform float axisBlend;
vec4 grid(vec2 pos, float scale) {
vec2 coord = pos * scale; // use the scale variable to set the distance between the lines
vec2 derivative = fwidth(coord);
vec2 grid = abs(fract(coord - 0.5) - 0.5) / derivative;
float line = min(grid.x, grid.y);
float minimumy = min(derivative.y, 1.);
float minimumx = min(derivative.x, 1.);
vec4 color = vec4(.3, .3, .3, 1. - min(line, 1.));
// y axis
if(pos.x > -1. * minimumx / scale && pos.x < 1. * minimumx / scale)
color.y = 0.3 + axisBlend * 0.7;
// x axis
if(pos.y > -1. * minimumy / scale && pos.y < 1. * minimumy / scale)
color.x = 0.3 + axisBlend * 0.7;
#ifdef MACOS
vec4 color = vec4(0.);
#else
vec2 coord = pos * scale; // use the scale variable to set the distance between the lines
vec2 derivative = fwidth(coord);
vec2 grid = abs(fract(coord - 0.5) - 0.5) / derivative;
float line = min(grid.x, grid.y);
float minimumy = min(derivative.y, 1.);
float minimumx = min(derivative.x, 1.);
vec4 color = vec4(.3, .3, .3, 1. - min(line, 1.));
// y axis
if(pos.x > -1. * minimumx / scale && pos.x < 1. * minimumx / scale)
color.y = 0.3 + axisBlend * 0.7;
// x axis
if(pos.y > -1. * minimumy / scale && pos.y < 1. * minimumy / scale)
color.x = 0.3 + axisBlend * 0.7;
#endif
return color;
}

View file

@ -23,17 +23,6 @@ vec3 hash3x2(vec2 x1,vec2 x2,vec2 x3) { return hash(vec3(dot(mod(x1, 100.0), ve
vec4 hash4( vec4 n ) { return fract(sin(n) * (753.5453123 + seed / 100000.)); }
float noise2( vec2 x ) {
vec3 p = floor(vec3(x, x.y + 0.5));
vec3 f = fract(vec3(x, x.y + 0.5));
float n = p.x + p.y * 157.0;
vec4 s1 = hash4(vec4(n) + vec4(0.0, 1.0, 157.0, 158.0));
s1.xy = mix(s1.xz, s1.yw, vec2(f.x));
return mix(s1.x, s1.y, f.y);
}
float noiseHoneycomb(vec2 i) {
vec2 c3;
i.x *= 1.15470053837925;
@ -55,8 +44,9 @@ float noiseHoneycomb(vec2 i) {
vec2 d = fract(c3 * 0.5) * 2.0;
s = fract(vec4(dot(m1, w1), dot(m2, w2), dot(m3, w2), dot(m4, w1)));
return fract(mix(mix(s.z, s.w, d.x), mix(s.x, s.y, d.x), d.y));
float f = fract(mix(mix(s.z, s.w, d.x), mix(s.x, s.y, d.x), d.y));
return f;
}
float noiseHoneycombStar(vec2 i) {
@ -68,9 +58,9 @@ float noiseHoneycombStar(vec2 i) {
vec3 o = fract(vec3(i.x, b.xy));
vec4 s;
vec3 m1 = vec3(hash2(c3 + vec2(1.0, 0.0)), hash2(c3 + vec2(-1.0, -1.0)), hash2(c3 + vec2(-1.0, 1.0)));
vec3 m2 = vec3(hash2(c3), hash2(c3 + vec2(0.0, 1.0)), hash2(c3 + vec2(0.0, -1.0)));
vec3 m3 = vec3(hash2(c3 + vec2(-1.0, 0.0)), hash2(c3 + vec2(1.0, 1.0)), hash2(c3 + vec2(1.0, -1.0)));
vec3 m1 = vec3(hash2(c3 + vec2( 1.0, 0.0)), hash2(c3 + vec2(-1.0, -1.0)), hash2(c3 + vec2(-1.0, 1.0)));
vec3 m2 = vec3(hash2(c3), hash2(c3 + vec2( 0.0, 1.0)), hash2(c3 + vec2( 0.0, -1.0)));
vec3 m3 = vec3(hash2(c3 + vec2(-1.0, 0.0)), hash2(c3 + vec2( 1.0, 1.0)), hash2(c3 + vec2( 1.0, -1.0)));
vec3 m4 = vec3(m2.x, m2.z, m2.y);
vec3 w1 = vec3(o.x, (1.0 - o.y), o.z);
@ -82,28 +72,29 @@ float noiseHoneycombStar(vec2 i) {
s = fract(vec4(dot(m1, w1), dot(m2, w2), dot(m3, w2), dot(m4, w1)));
return fract(mix(mix(s.z, s.w, d.x), mix(s.x, s.y, d.x), d.y));
float f = fract(mix(mix(s.z, s.w, d.x), mix(s.x, s.y, d.x), d.y));
return f;
}
float iterateNoise ( vec2 pos, int iteration ) {
vec3 iterateNoise ( vec2 pos, int iteration ) {
float amp = pow(2., float(iteration) - 1.) / (pow(2., float(iteration)) - 1.);
float n = 0.;
for(int i = 0; i < iteration; i++) {
if(mode == 0) n += vec3(noiseHoneycomb(pos)) * amp;
else if(mode == 1) n += vec3(noiseHoneycombStar(pos)) * amp;
if(mode == 0) n += noiseHoneycomb(pos) * amp;
else if(mode == 1) n += noiseHoneycombStar(pos) * amp;
amp *= .5;
pos *= 2.;
}
return n;
return vec3(n, n, n);
}
void main() {
float ang = radians(rotation);
vec2 pos = (v_vTexcoord - position / u_resolution) * mat2(cos(ang), -sin(ang), sin(ang), cos(ang)) * scale * 4.;
vec3 col = vec3(iterateNoise(pos, iteration));
vec3 col = iterateNoise(pos, iteration);
// if(mode == 0) col = vec3(noiseHoneycomb(pos));
// else if(mode == 1) col = vec3(noiseHoneycombStar(pos));