Skip to content

Commit

Permalink
changing opRepeat
Browse files Browse the repository at this point in the history
  • Loading branch information
patriciogonzalezvivo committed Jul 4, 2023
1 parent 6586740 commit df2db43
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 35 deletions.
14 changes: 14 additions & 0 deletions math/scale2d.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
original_author: Patricio Gonzalez Vivo
description: returns a 2x2 scale matrix
use: scale2d(<float> radians)
*/

#ifndef FNC_SCALE4D
mat2 scale2d(float _scale) {
return mat2(
_scale, 0.0,
0.0, _scale,
);
}
#endif
15 changes: 15 additions & 0 deletions math/scale3d.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
original_author: Patricio Gonzalez Vivo
description: returns a 3x3 scale matrix
use: scale3d(<float> radians)
*/

#ifndef FNC_SCALE4D
mat3 scale3d(float _scale) {
return mat3(
_scale, 0.0, 0.0,
0.0, _scale, 0.0,
0.0, 0.0, _scale,
);
}
#endif
2 changes: 1 addition & 1 deletion sdf.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

// Operations
#include "sdf/opOnion.glsl"
#include "sdf/opRepite.glsl"
#include "sdf/opRepeat.glsl"
#include "sdf/opRevolve.glsl"
#include "sdf/opRound.glsl"
#include "sdf/opSubtraction.glsl"
Expand Down
2 changes: 1 addition & 1 deletion sdf.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

// Operations
#include "sdf/opOnion.hlsl"
#include "sdf/opRepite.hlsl"
#include "sdf/opRepeat.hlsl"
#include "sdf/opRevolve.hlsl"
#include "sdf/opRound.hlsl"
#include "sdf/opSubtraction.hlsl"
Expand Down
27 changes: 27 additions & 0 deletions sdf/opRepeat.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
original_author: Inigo Quiles
description: repeat operation for 2D/3D SDFs
use: <vec4> opElongate( in <vec3> p, in <vec3> h )
*/

#ifndef FNC_OPREPEAT
#define FNC_OPREPEAT

vec2 opRepeat( in vec2 p, in float s ) {
return mod(p+s*0.5,s)-s*0.5;
}

vec3 opRepeat( in vec3 p, in vec3 c ) {
return mod(p+0.5*c,c)-0.5*c;
}

vec2 opRepeat( in vec2 p, in vec2 lima, in vec2 limb, in float s ) {
return p-s*clamp(floor(p/s),lima,limb);
}

vec3 opRepeat( in vec3 p, in vec3 lima, in vec3 limb, in float s ) {
return p-s*clamp(floor(p/s),lima,limb);
}

#endif

12 changes: 6 additions & 6 deletions sdf/opRepite.hlsl → sdf/opRepeat.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ description: repite operation of one 2D SDFs
use: <vec4> opElongate( in <float3> p, in <float3> h )
*/

#ifndef FNC_OPREPITE
#define FNC_OPREPITE
#ifndef FNC_OPREPEAT
#define FNC_OPREPEAT

float2 opRepite( in float2 p, in float s ) {
float2 opRepeat( in float2 p, in float s ) {
return mod(p+s*0.5,s)-s*0.5;
}

float3 opRepite( in float3 p, in float3 c ) {
float3 opRepeat( in float3 p, in float3 c ) {
return mod(p+0.5*c,c)-0.5*c;
}

float2 opRepite( in float2 p, in float2 lima, in float2 limb, in float s ) {
float2 opRepeat( in float2 p, in float2 lima, in float2 limb, in float s ) {
return p-s*clamp(floor(p/s), lima, limb);
}

float3 opRepite( in float3 p, in float3 lima, in float3 limb, in float s ) {
float3 opRepeat( in float3 p, in float3 lima, in float3 limb, in float s ) {
return p-s*clamp(floor(p/s), lima, limb);
}

Expand Down
27 changes: 0 additions & 27 deletions sdf/opRepite.glsl

This file was deleted.

0 comments on commit df2db43

Please sign in to comment.