forked from patriciogonzalezvivo/lygia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing dilation/erosion tweaking random and adding AABB
- Loading branch information
1 parent
6f0ea4e
commit ccedcae
Showing
14 changed files
with
188 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef STR_AABB | ||
#define STR_AABB | ||
|
||
struct AABB { | ||
vec3 min; | ||
vec3 max; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
#include "../aabb.glsl" | ||
|
||
/* | ||
original_author: P | ||
description: Compute if point is inside AABB | ||
use: <bool> AABBinside(<AABB> box, <vec3> point ) | ||
*/ | ||
|
||
#ifndef FNC_AABB_INSIDE | ||
#define FNC_AABB_INSIDE | ||
|
||
bool AABBinside(const in AABB box, const in vec3 point ) { | ||
return all( lessThanEqual(point, box.max) ) && | ||
all( lessThan(box.min, point) ); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "../aabb.glsl" | ||
|
||
/* | ||
original_author: Dominik Schmid | ||
description: compute the near and far intersections of the cube (stored in the x and y components) using the slab method | ||
// no intersection means vec.x > vec.y (really tNear > tFar) https://gist.github.com/DomNomNom/46bb1ce47f68d255fd5d | ||
use: <vec2> AABBintersect(<AABB> box, <vec3> rayOrigin, <vec3> rayDir) | ||
*/ | ||
|
||
#ifndef FNC_AABB_INTERSECT | ||
#define FNC_AABB_INTERSECT | ||
|
||
vec2 AABBintersect(const in AABB box, const in vec3 rayOrigin, const in vec3 rayDir) { | ||
vec3 tMin = (box.min - rayOrigin) / rayDir; | ||
vec3 tMax = (box.max - rayOrigin) / rayDir; | ||
vec3 t1 = min(tMin, tMax); | ||
vec3 t2 = max(tMin, tMax); | ||
float tNear = max(max(t1.x, t1.y), t1.z); | ||
float tFar = min(min(t2.x, t2.y), t2.z); | ||
return vec2(tNear, tFar); | ||
} | ||
|
||
#endif |