-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from Mikeysax/main
Added shapes, uv_grid, uv_rotate, fresnel, and fresnel_glow functions
- Loading branch information
Showing
5 changed files
with
117 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# License Information | ||
|
||
## shapes.gdshaderinc | ||
```md | ||
/**************************************************************************/ | ||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | ||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ | ||
/* */ | ||
/* Permission is hereby granted, free of charge, to any person obtaining */ | ||
/* a copy of this software and associated documentation files (the */ | ||
/* "Software"), to deal in the Software without restriction, including */ | ||
/* without limitation the rights to use, copy, modify, merge, publish, */ | ||
/* distribute, sublicense, and/or sell copies of the Software, and to */ | ||
/* permit persons to whom the Software is furnished to do so, subject to */ | ||
/* the following conditions: */ | ||
/* */ | ||
/* The above copyright notice and this permission notice shall be */ | ||
/* included in all copies or substantial portions of the Software. */ | ||
/* */ | ||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ | ||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ | ||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | ||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ | ||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ | ||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ | ||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
/**************************************************************************/ | ||
``` |
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,51 @@ | ||
float polygon(vec2 uv, float width, int sides) { | ||
uv = uv * 2.0 - 1.0; | ||
float angle = atan(uv.x, uv.y); | ||
float radius = 6.28318530718 / float(sides); | ||
float dist = cos(floor(0.5 + angle / radius) * radius - angle) * length(uv); | ||
return step(width, dist); | ||
} | ||
|
||
float circle(vec2 uv, float radius, float feather) { | ||
return smoothstep(radius, radius + feather, dot(position, position) * 4.0); | ||
} | ||
|
||
float square(vec2 uv, float width) { | ||
uv = uv * 2.0 - 1.0; | ||
vec2 abs_uv = abs(uv.xy); | ||
return step(width, max(abs_uv.x, abs_uv.y)); | ||
} | ||
|
||
float square_stroke(vec2 uv, float width, float stroke_width) { | ||
uv = uv * 2.0 - 1.0; | ||
vec2 abs_uv = abs(uv.xy); | ||
float dist = max(abs_uv.x, abs_uv.y); | ||
return 1.0 - (step(width, dist) - step(width + stroke_width, dist)); | ||
} | ||
|
||
float square_rounded(vec2 uv, float width, float radius) { | ||
uv = uv * 2.0 - 1.0; | ||
radius *= width; | ||
vec2 abs_uv = abs(uv.xy) - radius; | ||
vec2 dist = vec2(max(abs_uv.xy, 0.0)); | ||
return step(width - radius, length(dist)); | ||
} | ||
|
||
float swirl(vec2 uv, float size, int arms) { | ||
float angle = atan(-uv.y + 0.5, uv.x - 0.5); | ||
float len = length(uv - vec2(0.5, 0.5)); | ||
return sin(len * size + angle * float(arms)); | ||
} | ||
|
||
float line(vec2 uv, vec2 p1, vec2 p2, float width) { | ||
float dist = distance(p1, p2); | ||
float dist_uv = distance(p1, uv); | ||
return 1.0 - floor(1.0 - (0.001 * width) + distance (mix(p1, p2, clamp(dist_uv / dist, 0.0, 1.0)), uv)); | ||
} | ||
|
||
float border(vec2 uv, float border_width) { | ||
vec2 bottom_left = step(vec2(border_width), uv); | ||
vec2 top_right = step(vec2(border_width), 1.0 - uv); | ||
return bottom_left.x * bottom_left.y * top_right.x * top_right.y; | ||
} | ||
|
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