Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
depressed-pho committed Dec 26, 2018
1 parent db846b2 commit 1536c44
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/shaders/glsl/natural-mystic-hacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@

/* Detect leaves based on the color of material. */
bool isLeaf(vec4 color) {
/* FIXME: This function currently fails to detect leaves whose
* color is affected by seasons. */
vec4 norm = normalize(color);
return norm.g >= 0.65 && norm.g <= 0.9;
}

/* Detect grasses based on the color of material. This function also
* returns true for grass blocks and leaves because it's impossible to
* tell them from plants. [Currently unused]
*/
bool isGrass(vec4 color) {
/* Grass colors are affected by seasons and can turn red. */
vec4 hsv = rgb2hsv(color);
return hsv.x >= 149.0 && hsv.x <= 270.0;
}

/* Detect water based on the color of material. */
bool isWater(vec4 color) {
/* Yikes. The color of water greatly changes in swampland so we
Expand Down

0 comments on commit 1536c44

Please sign in to comment.