Skip to content

Commit 2e32e99

Browse files
committed
Fixed issue where expressions with negations would be evaluated incorrectly
1 parent 2e10128 commit 2e32e99

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/shaders/embedded_shaders.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,10 @@ vec3 hsl2rgb(vec3 hsl) {
660660
return hsl.z + hsl.y * (rgb - 0.5) * (1.0 - abs(2.0 * hsl.z - 1.0));
661661
}
662662
663-
vec3 domain_color(in vec2 z){
663+
vec3 domain_color(in vec2 z, float k){
664664
float angle = atan(z.y,z.x);
665665
float hue = (angle/(2.0 * PI));
666-
float light = (TWO_OVER_PI) * atan(length(z));
666+
float light = TWO_OVER_PI * atan(pow(length(z),k));
667667
return vec3(hue,1.0f,light);
668668
}
669669
@@ -682,12 +682,12 @@ void main(){
682682
683683
#define INTERPRETER_ASSIGNEMENT HERE
684684
vec2 func_value = run_stack(operator_stack,constant_stack,z);
685-
func_value = clamp(func_value, -1e38,)shdr" R"shdr( 1e38);
685+
func_value = clamp(func)shdr" R"shdr(_value, -1e38, 1e38);
686686
#define END_INTERPRETER_ASSIGNEMENT HERE
687687
688688
#define INJECTION_POINT HERE
689689
690-
vec3 hsl = domain_color(func_value);
690+
vec3 hsl = domain_color(func_value,0.5);
691691
692692
if(show_grid){
693693
vec2 target = z;

src/shaders/plotter.frag

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,10 @@ vec3 hsl2rgb(vec3 hsl) {
344344
return hsl.z + hsl.y * (rgb - 0.5) * (1.0 - abs(2.0 * hsl.z - 1.0));
345345
}
346346

347-
vec3 domain_color(in vec2 z){
347+
vec3 domain_color(in vec2 z, float k){
348348
float angle = atan(z.y,z.x);
349349
float hue = (angle/(2.0 * PI));
350-
float light = (TWO_OVER_PI) * atan(length(z));
350+
float light = TWO_OVER_PI * atan(pow(length(z),k));
351351
return vec3(hue,1.0f,light);
352352
}
353353

@@ -371,7 +371,7 @@ void main(){
371371

372372
#define INJECTION_POINT HERE
373373

374-
vec3 hsl = domain_color(func_value);
374+
vec3 hsl = domain_color(func_value,0.5);
375375

376376
if(show_grid){
377377
vec2 target = z;

src/types/types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ inline const std::vector<TokenOperator> operators = []() {
201201

202202
inline const std::vector<AmbiguousOperator> amb_operators = {
203203
{
204-
{Arity::UNARY, Associativity::RIGHT, Operator::NEG, "~", 1},
205-
{Arity::BINARY, Associativity::LEFT, Operator::SUB, "-", 0},
204+
{Arity::UNARY, Associativity::RIGHT, Operator::NEG, "~", 4},
205+
{Arity::BINARY, Associativity::LEFT, Operator::SUB, "-", 1},
206206
Operator::SUB
207207
}
208208
};

0 commit comments

Comments
 (0)