mirror of
https://github.com/DigvijaysinhGohil/Godot-Shader-Lib.git
synced 2025-01-05 00:53:36 +08:00
Merge branch 'godot-4.2'
This commit is contained in:
commit
1b66431979
@ -47,8 +47,7 @@ func _get_output_port_type(port: int) -> PortType:
|
||||
return PORT_TYPE_VECTOR_3D
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("Contrast.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String = "vec3(1.0)"
|
||||
|
@ -1,4 +0,0 @@
|
||||
vec3 contrast(vec3 input, float contrast){
|
||||
float midpoint = pow(0.5, 2.2);
|
||||
return (input - midpoint) * contrast + midpoint;
|
||||
}
|
@ -59,8 +59,7 @@ func _get_property_options(index: int) -> PackedStringArray:
|
||||
return ["Degrees", "Normalize"]
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("Hue.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var range_index: int = get_option_index(0)
|
||||
|
@ -1,27 +0,0 @@
|
||||
vec3 hue(vec3 input, float offset, int range_index){
|
||||
// RGB to HSV
|
||||
vec4 k = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(input.bg, k.wz), vec4(input.gb, k.xy), step(input.b, input.g));
|
||||
vec4 q = mix(vec4(p.xyw, input.r), vec4(input.r, p.yzx), step(p.x, input.r));
|
||||
float d = q.x - min(q.w, q.y);
|
||||
float e = 1.0e-10;
|
||||
vec3 hsv = vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
|
||||
offset = (range_index == 0) ? offset / 360.0 : offset;
|
||||
float hue = hsv.x + offset;
|
||||
if(hue < 0.0){
|
||||
hsv.x = hue + 1.;
|
||||
}
|
||||
else if(hue > 1.){
|
||||
hsv.x = hue - 1.;
|
||||
}
|
||||
else{
|
||||
hsv.x = hue;
|
||||
}
|
||||
|
||||
// HSV to RGB
|
||||
vec4 k2 = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p2 = abs(fract(hsv.xxx + k2.xyz) * 6.0 - k2.www);
|
||||
vec3 rgb = hsv.z * mix(k2.xxx, clamp(p2 - k2.xxx, 0.0, 1.0), hsv.y);
|
||||
return rgb;
|
||||
}
|
@ -55,8 +55,7 @@ func _get_output_port_type(port: int) -> PortType:
|
||||
return PORT_TYPE_VECTOR_3D
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("ReplaceColor.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String = "vec3(1.0)"
|
||||
|
@ -1,4 +0,0 @@
|
||||
vec3 replace_color(vec3 input, vec3 from, vec3 to, float range, float fuzziness){
|
||||
float dist = distance(from, input);
|
||||
return mix(to, input, clamp((dist - range) / max(fuzziness, 1.0e-5), 0.0, 1.0));
|
||||
}
|
@ -48,8 +48,7 @@ func _get_output_port_type(port: int) -> PortType:
|
||||
return PORT_TYPE_VECTOR_3D
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("Saturation.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String = "vec3(1.0)"
|
||||
|
@ -1,4 +0,0 @@
|
||||
vec3 saturation(vec3 input, float saturation){
|
||||
float luma = dot(input, vec3(0.2126729, 0.7151522, 0.0721750));
|
||||
return luma + saturation * (input - vec3(luma));
|
||||
}
|
@ -49,8 +49,7 @@ func _get_output_port_type(port: int) -> PortType:
|
||||
return PORT_TYPE_VECTOR_3D
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("WhiteBalance.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String = "vec3(1.0)"
|
||||
|
@ -1,36 +0,0 @@
|
||||
vec3 white_balance(vec3 input, float temperature, float tint){
|
||||
float t1 = temperature * 10.0 / 6.0;
|
||||
float t2 = tint * 10.0 / 6.0;
|
||||
|
||||
float x = 0.31271 - t1 * (t1 < 0.0 ? 0.1 : 0.05);
|
||||
float standard_illuminant_y = 2.87 * x - 3.0 * x * x - 0.27509507;
|
||||
float y = standard_illuminant_y + t2 * 0.05;
|
||||
|
||||
vec3 w1 = vec3(0.949237, 1.03542, 1.08728);
|
||||
|
||||
float Y = 1.;
|
||||
float X = Y * x / y;
|
||||
float Z = Y * (1. - x - y) / y;
|
||||
float L = 0.7328 * X + 0.4296 * Y - 0.1624 * Z;
|
||||
float M = -0.7036 * X + 1.6975 * Y + 0.0061 * Z;
|
||||
float S = 0.0030 * X + 0.0136 * Y + 0.9834 * Z;
|
||||
vec3 w2 = vec3(L, M, S);
|
||||
|
||||
vec3 balance = vec3(w1.x / w2.x, w1.y / w2.y, w1.z / w2.z);
|
||||
|
||||
mat3 LIN_2_LMS_MAT = mat3(
|
||||
vec3(3.90405e-1, 5.49941e-1, 8.92632e-3),
|
||||
vec3(7.08416e-2, 9.63172e-1, 1.35775e-3),
|
||||
vec3(2.31082e-2, 1.28021e-1, 9.36245e-1)
|
||||
);
|
||||
|
||||
mat3 LMS_2_LIN_MAT = mat3(
|
||||
vec3(2.85847, -1.62879, -2.48910),
|
||||
vec3(-2.10182e-1, 1.15820e+0, 3.24281e-4),
|
||||
vec3(-4.18120e-2, -1.18169e-1, 1.06867e+0)
|
||||
);
|
||||
|
||||
vec3 lms = LIN_2_LMS_MAT * input;
|
||||
lms *= balance;
|
||||
return LMS_2_LIN_MAT * lms;
|
||||
}
|
84
addons/ShaderLib/Artistic/Artistic.gdshaderinc
Normal file
84
addons/ShaderLib/Artistic/Artistic.gdshaderinc
Normal file
@ -0,0 +1,84 @@
|
||||
vec3 contrast(vec3 input, float contrast){
|
||||
float midpoint = pow(0.5, 2.2);
|
||||
return (input - midpoint) * contrast + midpoint;
|
||||
}
|
||||
|
||||
vec3 hue(vec3 input, float offset, int range_index){
|
||||
// RGB to HSV
|
||||
vec4 k = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(input.bg, k.wz), vec4(input.gb, k.xy), step(input.b, input.g));
|
||||
vec4 q = mix(vec4(p.xyw, input.r), vec4(input.r, p.yzx), step(p.x, input.r));
|
||||
float d = q.x - min(q.w, q.y);
|
||||
float e = 1.0e-10;
|
||||
vec3 hsv = vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
|
||||
offset = (range_index == 0) ? offset / 360.0 : offset;
|
||||
float hue = hsv.x + offset;
|
||||
if(hue < 0.0){
|
||||
hsv.x = hue + 1.;
|
||||
}
|
||||
else if(hue > 1.){
|
||||
hsv.x = hue - 1.;
|
||||
}
|
||||
else{
|
||||
hsv.x = hue;
|
||||
}
|
||||
|
||||
// HSV to RGB
|
||||
vec4 k2 = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
vec3 p2 = abs(fract(hsv.xxx + k2.xyz) * 6.0 - k2.www);
|
||||
vec3 rgb = hsv.z * mix(k2.xxx, clamp(p2 - k2.xxx, 0.0, 1.0), hsv.y);
|
||||
return rgb;
|
||||
}
|
||||
|
||||
vec3 replace_color(vec3 input, vec3 from, vec3 to, float range, float fuzziness){
|
||||
float dist = distance(from, input);
|
||||
return mix(to, input, clamp((dist - range) / max(fuzziness, 1.0e-5), 0.0, 1.0));
|
||||
}
|
||||
|
||||
vec3 saturation(vec3 input, float saturation){
|
||||
float luma = dot(input, vec3(0.2126729, 0.7151522, 0.0721750));
|
||||
return luma + saturation * (input - vec3(luma));
|
||||
}
|
||||
|
||||
vec3 white_balance(vec3 input, float temperature, float tint){
|
||||
float t1 = temperature * 10.0 / 6.0;
|
||||
float t2 = tint * 10.0 / 6.0;
|
||||
|
||||
float x = 0.31271 - t1 * (t1 < 0.0 ? 0.1 : 0.05);
|
||||
float standard_illuminant_y = 2.87 * x - 3.0 * x * x - 0.27509507;
|
||||
float y = standard_illuminant_y + t2 * 0.05;
|
||||
|
||||
vec3 w1 = vec3(0.949237, 1.03542, 1.08728);
|
||||
|
||||
float Y = 1.;
|
||||
float X = Y * x / y;
|
||||
float Z = Y * (1. - x - y) / y;
|
||||
float L = 0.7328 * X + 0.4296 * Y - 0.1624 * Z;
|
||||
float M = -0.7036 * X + 1.6975 * Y + 0.0061 * Z;
|
||||
float S = 0.0030 * X + 0.0136 * Y + 0.9834 * Z;
|
||||
vec3 w2 = vec3(L, M, S);
|
||||
|
||||
vec3 balance = vec3(w1.x / w2.x, w1.y / w2.y, w1.z / w2.z);
|
||||
|
||||
mat3 LIN_2_LMS_MAT = mat3(
|
||||
vec3(3.90405e-1, 5.49941e-1, 8.92632e-3),
|
||||
vec3(7.08416e-2, 9.63172e-1, 1.35775e-3),
|
||||
vec3(2.31082e-2, 1.28021e-1, 9.36245e-1)
|
||||
);
|
||||
|
||||
mat3 LMS_2_LIN_MAT = mat3(
|
||||
vec3(2.85847, -1.62879, -2.48910),
|
||||
vec3(-2.10182e-1, 1.15820e+0, 3.24281e-4),
|
||||
vec3(-4.18120e-2, -1.18169e-1, 1.06867e+0)
|
||||
);
|
||||
|
||||
vec3 lms = LIN_2_LMS_MAT * input;
|
||||
lms *= balance;
|
||||
return LMS_2_LIN_MAT * lms;
|
||||
}
|
||||
|
||||
vec4 color_mask(vec3 input, vec3 mask_color, float range, float fuzziness){
|
||||
float dist = distance(mask_color, input);
|
||||
return vec4(clamp(1. - (dist - range) / max(fuzziness, 1e-5), 0., 1.));
|
||||
}
|
@ -53,8 +53,7 @@ func _get_output_port_type(port: int) -> PortType:
|
||||
return PORT_TYPE_VECTOR_4D
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("ColorMask.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Artistic/Artistic.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String = "vec3(0.0)"
|
||||
|
@ -1,4 +0,0 @@
|
||||
vec4 color_mask(vec3 input, vec3 mask_color, float range, float fuzziness){
|
||||
float dist = distance(mask_color, input);
|
||||
return vec4(clamp(1. - (dist - range) / max(fuzziness, 1e-5), 0., 1.));
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
vec3 geometry_node_scale_world(mat4 model_matrix){
|
||||
vec3 node_scale_world(mat4 model_matrix){
|
||||
vec3 _axis_x = model_matrix[0].xyz;
|
||||
vec3 _axis_y = model_matrix[1].xyz;
|
||||
vec3 _axis_z = model_matrix[2].xyz;
|
@ -42,11 +42,10 @@ func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool:
|
||||
return false
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("MeshNode.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Geometry/Geometry.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var code: String
|
||||
code = "%s = NODE_POSITION_WORLD;" % output_vars[0]
|
||||
code += "\n%s = geometry_node_scale_world(MODEL_MATRIX);" % output_vars[1]
|
||||
code += "\n%s = node_scale_world(MODEL_MATRIX);" % output_vars[1]
|
||||
return code
|
||||
|
@ -1,3 +1,45 @@
|
||||
float chebyshev_distance_2d(vec2 point1, vec2 point2, float power) {
|
||||
vec2 p = abs(point1 - point2);
|
||||
return pow(pow(p.x, power) + pow(p.y, power), 1. / power);
|
||||
}
|
||||
|
||||
float chebyshev_distance_3d(vec3 point1, vec3 point2, float power) {
|
||||
vec3 p = abs(point1 - point2);
|
||||
return pow(pow(p.x, power) + pow(p.y, power) + pow(p.z, power), 1. / power);
|
||||
}
|
||||
|
||||
float manhattan_distance_2d(vec2 point1, vec2 point2) {
|
||||
vec2 d = point1 - point2;
|
||||
return abs(d.x) + abs(d.y);
|
||||
}
|
||||
|
||||
float manhattan_distance_3d(vec3 point1, vec3 point2) {
|
||||
vec3 d = point1 - point2;
|
||||
return abs(d.x) + abs(d.y) + abs(d.z);
|
||||
}
|
||||
|
||||
vec2 project_2d(vec2 a, vec2 b) {
|
||||
return b * (dot(a, b) / dot(b, b));
|
||||
}
|
||||
|
||||
vec3 project_3d(vec3 a, vec3 b) {
|
||||
return b * (dot(a, b) / dot(b, b));
|
||||
}
|
||||
|
||||
vec3 project_on_plane(vec3 vector, vec3 plane_normal) {
|
||||
return vector - (plane_normal * (dot(vector, plane_normal) / dot(plane_normal, plane_normal)));
|
||||
}
|
||||
|
||||
float smoothmin(float a, float b, float t) {
|
||||
float h = clamp(.5 + .5 * (b - a) / t, 0, 1);
|
||||
return mix(b, a, h) - t * h * (1. - h);
|
||||
}
|
||||
|
||||
float smoothmax(float a, float b, float t) {
|
||||
float h = clamp(.5 + .5 * (b - a) / -t, 0, 1);
|
||||
return mix(b, a, h) + t * h * (1. - h);
|
||||
}
|
||||
|
||||
vec3 vector_transform_world_to_local(mat4 model_matrix, vec3 vector){
|
||||
return (inverse(model_matrix) * vec4(vector, 1.0)).xyz;
|
||||
}
|
||||
@ -97,3 +139,23 @@ vec3 vector_transform_tangent_to_screen(mat4 model_matrix, mat4 view_matrix, mat
|
||||
vec3 vector_local = tangent_to_local_matrix * vector;
|
||||
return vector_transform_local_to_screen(model_matrix, view_matrix, projection_matrix, vector_local);
|
||||
}
|
||||
|
||||
vec4 noise_sine_wave(vec4 input, vec2 min_max) {
|
||||
vec4 _sin_in = sin(input);
|
||||
vec4 _sin_in_offset = sin(input + 1.0);
|
||||
vec4 _random_number = fract(sin((_sin_in - _sin_in_offset) * (12.9898 + 78.233))*43758.5453);
|
||||
float _noise = mix(min_max.x, min_max.y, _random_number.x);
|
||||
return _sin_in + vec4(_noise);
|
||||
}
|
||||
|
||||
vec4 sawtooth_wave(vec4 input) {
|
||||
return 2. * (input - floor(.5 + input));
|
||||
}
|
||||
|
||||
vec4 square_wave(vec4 input) {
|
||||
return 1. - 2. * round(fract(input));
|
||||
}
|
||||
|
||||
vec4 triangle_wave(vec4 input) {
|
||||
return 2. * abs(2. * (input - floor(.5 + input))) - 1.;
|
||||
}
|
@ -45,8 +45,7 @@ func _get_output_port_type(port: int) -> PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("SmoothMax.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var a: String = input_vars[0]
|
||||
|
@ -1,4 +0,0 @@
|
||||
float smoothmax(float a, float b, float t) {
|
||||
float h = clamp(.5 + .5 * (b - a) / -t, 0, 1);
|
||||
return mix(b, a, h) + t * h * (1. - h);
|
||||
}
|
@ -45,8 +45,7 @@ func _get_output_port_type(port: int) -> PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("SmoothMin.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var a: String = input_vars[0]
|
||||
|
@ -1,4 +0,0 @@
|
||||
float smoothmin(float a, float b, float t) {
|
||||
float h = clamp(.5 + .5 * (b - a) / t, 0, 1);
|
||||
return mix(b, a, h) - t * h * (1. - h);
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
float chebyshev_distance_2d(vec2 point1, vec2 point2, float power) {
|
||||
vec2 p = abs(point1 - point2);
|
||||
return pow(pow(p.x, power) + pow(p.y, power), 1. / power);
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
float chebyshev_distance_3d(vec3 point1, vec3 point2, float power) {
|
||||
vec3 p = abs(point1 - point2);
|
||||
return pow(pow(p.x, power) + pow(p.y, power) + pow(p.z, power), 1. / power);
|
||||
}
|
@ -66,14 +66,7 @@ func _get_property_options(index: int) -> PackedStringArray:
|
||||
return ["Vector2", "Vector3"]
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String
|
||||
var vector_index: int = get_option_index(0)
|
||||
match vector_index:
|
||||
0:
|
||||
code = preload("Chebyshev2D.gdshaderinc").code
|
||||
_:
|
||||
code = preload("Chebyshev3D.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var point_a: String
|
||||
|
@ -1,4 +0,0 @@
|
||||
float manhattan_distance_2d(vec2 point1, vec2 point2) {
|
||||
vec2 d = point1 - point2;
|
||||
return abs(d.x) + abs(d.y);
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
float manhattan_distance_3d(vec3 point1, vec3 point2) {
|
||||
vec3 d = point1 - point2;
|
||||
return abs(d.x) + abs(d.y) + abs(d.z);
|
||||
}
|
@ -53,14 +53,7 @@ func _get_property_options(index: int) -> PackedStringArray:
|
||||
return ["Vector2", "Vector3"]
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String
|
||||
var vector_index: int = get_option_index(0)
|
||||
match vector_index:
|
||||
0:
|
||||
code = preload("Manhattan2D.gdshaderinc").code
|
||||
_:
|
||||
code = preload("Manhattan3D.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var point_a: String
|
||||
|
@ -63,8 +63,7 @@ func _get_property_options(index: int) -> PackedStringArray:
|
||||
return ["Vector2", "Vector3"]
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("Project.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var vector_a: String = input_vars[0]
|
||||
|
@ -1,7 +0,0 @@
|
||||
vec2 project_2d(vec2 a, vec2 b) {
|
||||
return b * (dot(a, b) / dot(b, b));
|
||||
}
|
||||
|
||||
vec3 project_3d(vec3 a, vec3 b) {
|
||||
return b * (dot(a, b) / dot(b, b));
|
||||
}
|
@ -36,8 +36,7 @@ func _get_output_port_type(port: int) -> PortType:
|
||||
return PORT_TYPE_VECTOR_3D
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("ProjectOnPlane.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var vector_a: String = input_vars[0]
|
||||
|
@ -1,3 +0,0 @@
|
||||
vec3 project_on_plane(vec3 vector, vec3 plane_normal) {
|
||||
return vector - (plane_normal * (dot(vector, plane_normal) / dot(plane_normal, plane_normal)));
|
||||
}
|
@ -55,8 +55,7 @@ func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool:
|
||||
return mode == Shader.MODE_SPATIAL
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("VectorTransform.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var code: String
|
||||
|
@ -87,8 +87,7 @@ func _get_property_options(index: int) -> PackedStringArray:
|
||||
return ["Vector1", "Vector2", "Vector3", "Vector4"]
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("NoiseSineWave.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String
|
||||
|
@ -1,8 +0,0 @@
|
||||
vec4 noise_sine_wave(vec4 input, vec2 min_max)
|
||||
{
|
||||
vec4 _sin_in = sin(input);
|
||||
vec4 _sin_in_offset = sin(input + 1.0);
|
||||
vec4 _random_number = fract(sin((_sin_in - _sin_in_offset) * (12.9898 + 78.233))*43758.5453);
|
||||
float _noise = mix(min_max.x, min_max.y, _random_number.x);
|
||||
return _sin_in + vec4(_noise);
|
||||
}
|
@ -71,8 +71,7 @@ func _get_property_options(index: int) -> PackedStringArray:
|
||||
return ["Vector1", "Vector2", "Vector3", "Vector4"]
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("SawtoothWave.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String
|
||||
|
@ -1,3 +0,0 @@
|
||||
vec4 sawtooth_wave(vec4 input) {
|
||||
return 2. * (input - floor(.5 + input));
|
||||
}
|
@ -72,8 +72,7 @@ func _get_property_options(index: int) -> PackedStringArray:
|
||||
return ["Vector1", "Vector2", "Vector3", "Vector4"]
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("SquareWave.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String
|
||||
|
@ -1,3 +0,0 @@
|
||||
vec4 square_wave(vec4 input) {
|
||||
return 1. - 2. * round(fract(input));
|
||||
}
|
@ -70,8 +70,7 @@ func _get_property_options(index: int) -> PackedStringArray:
|
||||
return ["Vector1", "Vector2", "Vector3", "Vector4"]
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("TriangleWave.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Maths/Maths.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var input: String
|
||||
|
@ -1,3 +0,0 @@
|
||||
vec4 triangle_wave(vec4 input) {
|
||||
return 2. * abs(2. * (input - floor(.5 + input))) - 1.;
|
||||
}
|
@ -60,8 +60,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_3D
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("CheckerBoard.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -1,12 +0,0 @@
|
||||
vec3 checker_board(vec2 uv, vec3 color_a, vec3 color_b, vec2 frequency){
|
||||
uv = (uv.xy + 0.5) * frequency;
|
||||
vec4 _derivatives = vec4(dFdx(uv), dFdy(uv));
|
||||
vec2 _duv_length = sqrt(vec2(dot(_derivatives.xz, _derivatives.xz), dot(_derivatives.yw, _derivatives.yw)));
|
||||
float _width = 1.0;
|
||||
vec2 _distance3 = 4.0 * abs(fract(uv + 0.25) - 0.5) - _width;
|
||||
vec2 _scale = 0.35 / _duv_length.xy;
|
||||
float _frequency_limiter = sqrt(clamp(1.1f - max(_duv_length.x, _duv_length.y), 0.0, 1.0));
|
||||
vec2 _vector_alpha = clamp(_distance3 * _scale.xy, -1.0, 1.0);
|
||||
float _alpha = clamp(0.5f + 0.5f * _vector_alpha.x * _vector_alpha.y * _frequency_limiter, 0.0, 1.0);
|
||||
return mix(color_b, color_a, _alpha);
|
||||
}
|
@ -68,8 +68,7 @@ func _get_output_port_type(port: int) -> PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("KochFractal.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -1,36 +0,0 @@
|
||||
vec2 koch_fractal_direction(float angle){
|
||||
return vec2(sin(angle), cos(angle));
|
||||
}
|
||||
|
||||
float koch_fractal(vec2 uv, float outline, int iteration, float shape_width, float shape_height, out vec2 koch_uv) {
|
||||
float tiling = 3.0;
|
||||
vec2 center = uv - vec2(.5);
|
||||
shape_width = .85 * (shape_width / 1.);
|
||||
shape_height = .85 * (shape_height / 1.);
|
||||
center.x /= shape_width;
|
||||
center.y /= shape_height;
|
||||
|
||||
center.x = abs(center.x);
|
||||
center.y += tan(.833 * PI) * .5;
|
||||
vec2 dir = koch_fractal_direction(.833 * PI);
|
||||
float dist = dot(center - vec2(tiling / (2. * tiling), 0), dir);
|
||||
center -= dir * max(0, dist) * 2.0;
|
||||
|
||||
dir = koch_fractal_direction(.6667 * PI);
|
||||
float scale = 1.0;
|
||||
center.x += .5;
|
||||
for(int i = 0; i < iteration; i++){
|
||||
center *= tiling;
|
||||
scale *= tiling;
|
||||
center.x -= .5 * tiling;
|
||||
|
||||
center.x = abs(center.x);
|
||||
center.x -= .5;
|
||||
center -= dir * min(0.0, dot(center, dir)) * 2.0;
|
||||
}
|
||||
|
||||
dist = length(center - vec2(clamp(center.x, -1.0, 1.0), 0));
|
||||
dist += step(outline / 100.0, dist / scale);
|
||||
koch_uv = abs(center);
|
||||
return 1.0 - dist;
|
||||
}
|
@ -52,8 +52,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("GradientNoise.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -1,28 +0,0 @@
|
||||
vec2 gradient_modulo(vec2 divident, vec2 divisor){
|
||||
vec2 _positive_divident = mod(divident, divisor) + divisor;
|
||||
return mod(_positive_divident, divisor);
|
||||
}
|
||||
|
||||
vec2 gradient_random(vec2 uv){
|
||||
uv = vec2(dot(uv, vec2(127.1,311.7)), dot(uv, vec2(269.5,183.3)));
|
||||
return -1.0 + 2.0 * fract(sin(uv) * 43758.5453123);
|
||||
}
|
||||
|
||||
float gradient_noise(vec2 uv, float scale) {
|
||||
uv = uv * float(scale);
|
||||
vec2 _period = vec2(30.0, 60.0);
|
||||
vec2 _cells_minimum = floor(uv);
|
||||
vec2 _cells_maximum = ceil(uv);
|
||||
vec2 _uv_fract = fract(uv);
|
||||
_cells_minimum = gradient_modulo(_cells_minimum, _period);
|
||||
_cells_maximum = gradient_modulo(_cells_maximum, _period);
|
||||
vec2 _blur = smoothstep(0.0, 1.0, _uv_fract);
|
||||
vec2 _lowerLeftDirection = gradient_random(vec2(_cells_minimum.x, _cells_minimum.y));
|
||||
vec2 _lowerRightDirection = gradient_random(vec2(_cells_maximum.x, _cells_minimum.y));
|
||||
vec2 _upperLeftDirection = gradient_random(vec2(_cells_minimum.x, _cells_maximum.y));
|
||||
vec2 _upperRightDirection = gradient_random(vec2(_cells_maximum.x, _cells_maximum.y));
|
||||
vec2 _fraction = fract(uv);
|
||||
float _mix_one = mix(dot(_lowerLeftDirection, _fraction - vec2(0, 0)), dot(_lowerRightDirection, _fraction - vec2(1, 0)), _blur.x);
|
||||
float _mix_two = mix(dot(_upperLeftDirection, _fraction - vec2(0, 1)), dot(_upperRightDirection, _fraction - vec2(1, 1)), _blur.x);
|
||||
return mix(_mix_one, _mix_two, _blur.y) * 0.8 + 0.5;
|
||||
}
|
@ -62,8 +62,7 @@ func _get_output_port_type(port: int) -> PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("GyroidNoise.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -1,7 +0,0 @@
|
||||
float gyroid_noise(vec2 uv, float scale, vec2 ratio, float height, float thickness) {
|
||||
scale *= 10.;
|
||||
thickness = clamp(thickness, 0., 1.);
|
||||
vec3 vector = vec3(uv, height);
|
||||
vector *= scale;
|
||||
return abs(dot(sin(vector * ratio.x), cos(vector.zxy * ratio.y))) - thickness;
|
||||
}
|
@ -42,4 +42,4 @@ func _get_output_port_type(port: int) -> PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
return output_vars[0] + " = fract(sin(dot(UV.xy + vec2(%s), vec2(12.9898,78.233))) * 43758.5453123);" % input_vars[0]
|
||||
return output_vars[0] + " = pseudo_random_noise(UV, %s);" % input_vars[0]
|
||||
|
@ -56,8 +56,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("SimpleNoise.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -1,33 +0,0 @@
|
||||
float simple_noise_random(vec2 point) {
|
||||
return fract(sin(point.x * 100. + point.y * 654.125) * 55647.8745);
|
||||
}
|
||||
|
||||
float value_noise(vec2 uv) {
|
||||
vec2 grid_uv = fract(uv);
|
||||
vec2 grid_id = floor(uv);
|
||||
grid_uv = grid_uv * grid_uv * (3. - 2. * grid_uv);
|
||||
|
||||
float bottom_left = simple_noise_random(grid_id);
|
||||
float bottom_right = simple_noise_random(grid_id + vec2(1, 0));
|
||||
float bottom = mix(bottom_left, bottom_right, grid_uv.x);
|
||||
|
||||
float top_left = simple_noise_random(grid_id + vec2(0, 1));
|
||||
float top_right = simple_noise_random(grid_id + vec2(1, 1));
|
||||
float top = mix(top_left, top_right, grid_uv.x);
|
||||
|
||||
return mix(bottom, top, grid_uv.y);
|
||||
}
|
||||
|
||||
float simple_noise(vec2 uv, float scale, int octaves) {
|
||||
octaves = clamp(octaves, 1, 6);
|
||||
float noise = value_noise(uv * scale);
|
||||
float amplitude = 1.;
|
||||
|
||||
for(int i = 1; i < octaves; i++) {
|
||||
scale *= 2.;
|
||||
amplitude /= 2.;
|
||||
noise += value_noise(uv * scale) * amplitude;
|
||||
}
|
||||
|
||||
return noise / 2.;
|
||||
}
|
@ -101,8 +101,7 @@ func _get_property_options(index: int) -> PackedStringArray:
|
||||
return ["Euclidean", "Manhattan", "Chebyshev"]
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("Voronoi.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -1,43 +0,0 @@
|
||||
#include "res://addons/ShaderLib/Maths/Vector/Distance/Manhattan2D.gdshaderinc"
|
||||
#include "res://addons/ShaderLib/Maths/Vector/Distance/Chebyshev2D.gdshaderinc"
|
||||
|
||||
vec2 voronoi_random_vector(vec2 p) {
|
||||
mat2 matrix = mat2(vec2(15.27, 47.63), vec2(99.41, 89.98));
|
||||
return fract(sin(p * matrix) * 46839.32);
|
||||
}
|
||||
|
||||
void voronoi_noise(vec2 uv, float cell_density, float angle_offset, int distance_index, float chebyshev_power, out float output, out float cells){
|
||||
vec2 grid_uv = fract(uv * cell_density);
|
||||
vec2 grid_id = floor(uv * cell_density);
|
||||
vec2 cell_id = vec2(0);
|
||||
float min_dist = 100.;
|
||||
|
||||
for(float y = -1.; y <= 1.; y++) {
|
||||
for(float x = -1.; x <= 1.; x++) {
|
||||
vec2 offset = vec2(x, y);
|
||||
vec2 n = voronoi_random_vector(grid_id + offset);
|
||||
vec2 p = offset + vec2(sin(n.x + angle_offset) * .5 + .5, cos(n.y + angle_offset) * .5 + .5);
|
||||
float d = min_dist;
|
||||
|
||||
switch(distance_index){
|
||||
case 1:
|
||||
d = manhattan_distance_2d(grid_uv, p);
|
||||
break;
|
||||
case 2:
|
||||
d = chebyshev_distance_2d(grid_uv, p, chebyshev_power);
|
||||
break;
|
||||
default:
|
||||
d = distance(grid_uv, p);
|
||||
break;
|
||||
}
|
||||
|
||||
if(d < min_dist) {
|
||||
min_dist = d;
|
||||
cell_id = voronoi_random_vector(grid_id + offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output = min_dist;
|
||||
cells = cell_id.y;
|
||||
}
|
232
addons/ShaderLib/Procedural/Procedural.gdshaderinc
Normal file
232
addons/ShaderLib/Procedural/Procedural.gdshaderinc
Normal file
@ -0,0 +1,232 @@
|
||||
#include "res://addons/ShaderLib/Maths/Maths.gdshaderinc"
|
||||
|
||||
vec3 checker_board(vec2 uv, vec3 color_a, vec3 color_b, vec2 frequency){
|
||||
uv = (uv.xy + 0.5) * frequency;
|
||||
vec4 _derivatives = vec4(dFdx(uv), dFdy(uv));
|
||||
vec2 _duv_length = sqrt(vec2(dot(_derivatives.xz, _derivatives.xz), dot(_derivatives.yw, _derivatives.yw)));
|
||||
float _width = 1.0;
|
||||
vec2 _distance3 = 4.0 * abs(fract(uv + 0.25) - 0.5) - _width;
|
||||
vec2 _scale = 0.35 / _duv_length.xy;
|
||||
float _frequency_limiter = sqrt(clamp(1.1f - max(_duv_length.x, _duv_length.y), 0.0, 1.0));
|
||||
vec2 _vector_alpha = clamp(_distance3 * _scale.xy, -1.0, 1.0);
|
||||
float _alpha = clamp(0.5f + 0.5f * _vector_alpha.x * _vector_alpha.y * _frequency_limiter, 0.0, 1.0);
|
||||
return mix(color_b, color_a, _alpha);
|
||||
}
|
||||
|
||||
vec2 koch_fractal_direction(float angle){
|
||||
return vec2(sin(angle), cos(angle));
|
||||
}
|
||||
|
||||
float koch_fractal(vec2 uv, float outline, int iteration, float shape_width, float shape_height, out vec2 koch_uv) {
|
||||
float tiling = 3.0;
|
||||
vec2 center = uv - vec2(.5);
|
||||
shape_width = .85 * (shape_width / 1.);
|
||||
shape_height = .85 * (shape_height / 1.);
|
||||
center.x /= shape_width;
|
||||
center.y /= shape_height;
|
||||
|
||||
center.x = abs(center.x);
|
||||
center.y += tan(.833 * PI) * .5;
|
||||
vec2 dir = koch_fractal_direction(.833 * PI);
|
||||
float dist = dot(center - vec2(tiling / (2. * tiling), 0), dir);
|
||||
center -= dir * max(0, dist) * 2.0;
|
||||
|
||||
dir = koch_fractal_direction(.6667 * PI);
|
||||
float scale = 1.0;
|
||||
center.x += .5;
|
||||
for(int i = 0; i < iteration; i++){
|
||||
center *= tiling;
|
||||
scale *= tiling;
|
||||
center.x -= .5 * tiling;
|
||||
|
||||
center.x = abs(center.x);
|
||||
center.x -= .5;
|
||||
center -= dir * min(0.0, dot(center, dir)) * 2.0;
|
||||
}
|
||||
|
||||
dist = length(center - vec2(clamp(center.x, -1.0, 1.0), 0));
|
||||
dist += step(outline / 100.0, dist / scale);
|
||||
koch_uv = abs(center);
|
||||
return 1.0 - dist;
|
||||
}
|
||||
|
||||
vec2 gradient_modulo(vec2 divident, vec2 divisor){
|
||||
vec2 _positive_divident = mod(divident, divisor) + divisor;
|
||||
return mod(_positive_divident, divisor);
|
||||
}
|
||||
|
||||
vec2 gradient_random(vec2 uv){
|
||||
uv = vec2(dot(uv, vec2(127.1,311.7)), dot(uv, vec2(269.5,183.3)));
|
||||
return -1.0 + 2.0 * fract(sin(uv) * 43758.5453123);
|
||||
}
|
||||
|
||||
float gradient_noise(vec2 uv, float scale) {
|
||||
uv = uv * float(scale);
|
||||
vec2 _period = vec2(30.0, 60.0);
|
||||
vec2 _cells_minimum = floor(uv);
|
||||
vec2 _cells_maximum = ceil(uv);
|
||||
vec2 _uv_fract = fract(uv);
|
||||
_cells_minimum = gradient_modulo(_cells_minimum, _period);
|
||||
_cells_maximum = gradient_modulo(_cells_maximum, _period);
|
||||
vec2 _blur = smoothstep(0.0, 1.0, _uv_fract);
|
||||
vec2 _lowerLeftDirection = gradient_random(vec2(_cells_minimum.x, _cells_minimum.y));
|
||||
vec2 _lowerRightDirection = gradient_random(vec2(_cells_maximum.x, _cells_minimum.y));
|
||||
vec2 _upperLeftDirection = gradient_random(vec2(_cells_minimum.x, _cells_maximum.y));
|
||||
vec2 _upperRightDirection = gradient_random(vec2(_cells_maximum.x, _cells_maximum.y));
|
||||
vec2 _fraction = fract(uv);
|
||||
float _mix_one = mix(dot(_lowerLeftDirection, _fraction - vec2(0, 0)), dot(_lowerRightDirection, _fraction - vec2(1, 0)), _blur.x);
|
||||
float _mix_two = mix(dot(_upperLeftDirection, _fraction - vec2(0, 1)), dot(_upperRightDirection, _fraction - vec2(1, 1)), _blur.x);
|
||||
return mix(_mix_one, _mix_two, _blur.y) * 0.8 + 0.5;
|
||||
}
|
||||
|
||||
float gyroid_noise(vec2 uv, float scale, vec2 ratio, float height, float thickness) {
|
||||
scale *= 10.;
|
||||
thickness = clamp(thickness, 0., 1.);
|
||||
vec3 vector = vec3(uv, height);
|
||||
vector *= scale;
|
||||
return abs(dot(sin(vector * ratio.x), cos(vector.zxy * ratio.y))) - thickness;
|
||||
}
|
||||
|
||||
float pseudo_random_noise(vec2 uv, float seed) {
|
||||
return fract(sin(dot(uv.xy + seed, vec2(12.9898,78.233))) * 43758.5453123);
|
||||
}
|
||||
|
||||
float simple_noise_random(vec2 point) {
|
||||
return fract(sin(point.x * 100. + point.y * 654.125) * 55647.8745);
|
||||
}
|
||||
|
||||
float value_noise(vec2 uv) {
|
||||
vec2 grid_uv = fract(uv);
|
||||
vec2 grid_id = floor(uv);
|
||||
grid_uv = grid_uv * grid_uv * (3. - 2. * grid_uv);
|
||||
|
||||
float bottom_left = simple_noise_random(grid_id);
|
||||
float bottom_right = simple_noise_random(grid_id + vec2(1, 0));
|
||||
float bottom = mix(bottom_left, bottom_right, grid_uv.x);
|
||||
|
||||
float top_left = simple_noise_random(grid_id + vec2(0, 1));
|
||||
float top_right = simple_noise_random(grid_id + vec2(1, 1));
|
||||
float top = mix(top_left, top_right, grid_uv.x);
|
||||
|
||||
return mix(bottom, top, grid_uv.y);
|
||||
}
|
||||
|
||||
float simple_noise(vec2 uv, float scale, int octaves) {
|
||||
octaves = clamp(octaves, 1, 6);
|
||||
float noise = value_noise(uv * scale);
|
||||
float amplitude = 1.;
|
||||
|
||||
for(int i = 1; i < octaves; i++) {
|
||||
scale *= 2.;
|
||||
amplitude /= 2.;
|
||||
noise += value_noise(uv * scale) * amplitude;
|
||||
}
|
||||
|
||||
return noise / 2.;
|
||||
}
|
||||
|
||||
vec2 voronoi_random_vector(vec2 p) {
|
||||
mat2 matrix = mat2(vec2(15.27, 47.63), vec2(99.41, 89.98));
|
||||
return fract(sin(p * matrix) * 46839.32);
|
||||
}
|
||||
|
||||
void voronoi_noise(vec2 uv, float cell_density, float angle_offset, int distance_index, float chebyshev_power, out float output, out float cells){
|
||||
vec2 grid_uv = fract(uv * cell_density);
|
||||
vec2 grid_id = floor(uv * cell_density);
|
||||
vec2 cell_id = vec2(0);
|
||||
float min_dist = 100.;
|
||||
|
||||
for(float y = -1.; y <= 1.; y++) {
|
||||
for(float x = -1.; x <= 1.; x++) {
|
||||
vec2 offset = vec2(x, y);
|
||||
vec2 n = voronoi_random_vector(grid_id + offset);
|
||||
vec2 p = offset + vec2(sin(n.x + angle_offset) * .5 + .5, cos(n.y + angle_offset) * .5 + .5);
|
||||
float d = min_dist;
|
||||
|
||||
switch(distance_index){
|
||||
case 1:
|
||||
d = manhattan_distance_2d(grid_uv, p);
|
||||
break;
|
||||
case 2:
|
||||
d = chebyshev_distance_2d(grid_uv, p, chebyshev_power);
|
||||
break;
|
||||
default:
|
||||
d = distance(grid_uv, p);
|
||||
break;
|
||||
}
|
||||
|
||||
if(d < min_dist) {
|
||||
min_dist = d;
|
||||
cell_id = voronoi_random_vector(grid_id + offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output = min_dist;
|
||||
cells = cell_id.y;
|
||||
}
|
||||
|
||||
float ellipse_shape(vec2 uv, float width, float height){
|
||||
float _distance = length((uv * 2.0 - 1.0) / vec2(width, height));
|
||||
return clamp((1.0 - _distance) / fwidth(_distance), 0.0, 1.0);
|
||||
}
|
||||
|
||||
float polygon_shape(vec2 uv, int sides, float width, float height){
|
||||
float _a_width = width * cos(PI / float(sides));
|
||||
float _a_height = height * cos(PI / float(sides));
|
||||
uv = (uv * 2.0 - 1.0) / vec2(_a_width, _a_height);
|
||||
uv.y *= -1.0;
|
||||
float _polar_coords = atan(uv.x, uv.y);
|
||||
float _radius = 2.0 * PI / float(sides);
|
||||
float _distance = cos(floor(0.5 + _polar_coords / _radius) * _radius - _polar_coords) * length(uv);
|
||||
return clamp((1.0 - _distance) / fwidth(_distance), 0.0, 1.0);
|
||||
}
|
||||
|
||||
float rectangle_shape(vec2 uv, float width, float height){
|
||||
vec2 _distance = abs(uv * 2.0 - 1.0) - vec2(width, height);
|
||||
_distance = 1.0 - _distance / fwidth(_distance);
|
||||
return clamp(min(_distance.x, _distance.y), 0.0, 1.0);
|
||||
}
|
||||
|
||||
float rounded_polygon_shape(vec2 uv, float width, float height, float sides, float roundness){
|
||||
uv = uv * 2.0 + vec2(-1.0);
|
||||
roundness /= 10.0;
|
||||
float _epsilon = 1e-6;
|
||||
uv.x = uv.x / ( width + ((width>-_epsilon && width<_epsilon) ? 1.0 : 0.0 * _epsilon));
|
||||
uv.y = uv.y / ( height + ((height>-_epsilon && height<_epsilon) ? 1.0 : 0.0 * _epsilon));
|
||||
roundness = clamp(roundness, 1e-6, 1.0);
|
||||
float _i_sides = floor( abs( sides ) );
|
||||
float _full_angle = 2.0 * PI / _i_sides;
|
||||
float _half_angle = _full_angle / 2.;
|
||||
float _diagonal = 1.0 / cos( _half_angle );
|
||||
float _chamfer_angle = roundness * _half_angle;
|
||||
float _remaining_angle = _half_angle - _chamfer_angle;
|
||||
float _ratio = tan(_remaining_angle) / tan(_half_angle);
|
||||
vec2 _chamfer_center = vec2(cos(_half_angle) , sin(_half_angle))* _ratio * _diagonal;
|
||||
|
||||
float _dist_a = length(_chamfer_center);
|
||||
float _dist_b = 1.0 - _chamfer_center.x;
|
||||
float _uv_scale = _diagonal;
|
||||
uv *= _uv_scale;
|
||||
vec2 _polar_uv = vec2(atan(uv.y, uv.x), length(uv));
|
||||
|
||||
_polar_uv.x += PI / 2.0 + TAU;
|
||||
_polar_uv.x = mod(_polar_uv.x + _half_angle, _full_angle );
|
||||
_polar_uv.x = abs(_polar_uv.x - _half_angle);
|
||||
uv = vec2(cos(_polar_uv.x), sin(_polar_uv.x)) * _polar_uv.y;
|
||||
float _angle_ratio = 1.0 - (_polar_uv.x-_remaining_angle) / _chamfer_angle;
|
||||
float _dist_c = sqrt(_dist_a * _dist_a + _dist_b * _dist_b - 2.0 * _dist_a *_dist_b * cos(PI - _half_angle * _angle_ratio));
|
||||
float output = uv.x;
|
||||
float _chamfer_zone = (_half_angle - _polar_uv.x) < _chamfer_angle ? 1.0 : 0.0;
|
||||
output = mix(uv.x, _polar_uv.y / _dist_c, _chamfer_zone);
|
||||
output = clamp((1.0 - output) / fwidth(output), 0.0, 1.0);
|
||||
return output;
|
||||
}
|
||||
|
||||
float rounded_rectangle_shape(vec2 uv, float width, float height, float radius){
|
||||
radius /= 10.0;
|
||||
radius = max(min(min(abs(radius * 2.0), abs(width)), abs(height)), 1e-5);
|
||||
uv = abs(uv * 2.0 - 1.0) - vec2(width, height) + radius;
|
||||
float _distance = length(max(vec2(0.0), uv)) / radius;
|
||||
return clamp((1.0 - _distance) / fwidth(_distance), 0.0, 1.0);
|
||||
}
|
@ -54,8 +54,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("Ellipse.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -1,4 +0,0 @@
|
||||
float ellipse_shape(vec2 uv, float width, float height){
|
||||
float _distance = length((uv * 2.0 - 1.0) / vec2(width, height));
|
||||
return clamp((1.0 - _distance) / fwidth(_distance), 0.0, 1.0);
|
||||
}
|
@ -60,8 +60,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("Polygon.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -1,10 +0,0 @@
|
||||
float polygon_shape(vec2 uv, int sides, float width, float height){
|
||||
float _a_width = width * cos(PI / float(sides));
|
||||
float _a_height = height * cos(PI / float(sides));
|
||||
uv = (uv * 2.0 - 1.0) / vec2(_a_width, _a_height);
|
||||
uv.y *= -1.0;
|
||||
float _polar_coords = atan(uv.x, uv.y);
|
||||
float _radius = 2.0 * PI / float(sides);
|
||||
float _distance = cos(floor(0.5 + _polar_coords / _radius) * _radius - _polar_coords) * length(uv);
|
||||
return clamp((1.0 - _distance) / fwidth(_distance), 0.0, 1.0);
|
||||
}
|
@ -54,8 +54,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("Rectangle.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -1,5 +0,0 @@
|
||||
float rectangle_shape(vec2 uv, float width, float height){
|
||||
vec2 _distance = abs(uv * 2.0 - 1.0) - vec2(width, height);
|
||||
_distance = 1.0 - _distance / fwidth(_distance);
|
||||
return clamp(min(_distance.x, _distance.y), 0.0, 1.0);
|
||||
}
|
@ -61,8 +61,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("RoundedPolygon.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -1,34 +0,0 @@
|
||||
float rounded_polygon_shape(vec2 uv, float width, float height, float sides, float roundness){
|
||||
uv = uv * 2.0 + vec2(-1.0);
|
||||
roundness /= 10.0;
|
||||
float _epsilon = 1e-6;
|
||||
uv.x = uv.x / ( width + ((width>-_epsilon && width<_epsilon) ? 1.0 : 0.0 * _epsilon));
|
||||
uv.y = uv.y / ( height + ((height>-_epsilon && height<_epsilon) ? 1.0 : 0.0 * _epsilon));
|
||||
roundness = clamp(roundness, 1e-6, 1.0);
|
||||
float _i_sides = floor( abs( sides ) );
|
||||
float _full_angle = 2.0 * PI / _i_sides;
|
||||
float _half_angle = _full_angle / 2.;
|
||||
float _diagonal = 1.0 / cos( _half_angle );
|
||||
float _chamfer_angle = roundness * _half_angle;
|
||||
float _remaining_angle = _half_angle - _chamfer_angle;
|
||||
float _ratio = tan(_remaining_angle) / tan(_half_angle);
|
||||
vec2 _chamfer_center = vec2(cos(_half_angle) , sin(_half_angle))* _ratio * _diagonal;
|
||||
|
||||
float _dist_a = length(_chamfer_center);
|
||||
float _dist_b = 1.0 - _chamfer_center.x;
|
||||
float _uv_scale = _diagonal;
|
||||
uv *= _uv_scale;
|
||||
vec2 _polar_uv = vec2(atan(uv.y, uv.x), length(uv));
|
||||
|
||||
_polar_uv.x += PI / 2.0 + TAU;
|
||||
_polar_uv.x = mod(_polar_uv.x + _half_angle, _full_angle );
|
||||
_polar_uv.x = abs(_polar_uv.x - _half_angle);
|
||||
uv = vec2(cos(_polar_uv.x), sin(_polar_uv.x)) * _polar_uv.y;
|
||||
float _angle_ratio = 1.0 - (_polar_uv.x-_remaining_angle) / _chamfer_angle;
|
||||
float _dist_c = sqrt(_dist_a * _dist_a + _dist_b * _dist_b - 2.0 * _dist_a *_dist_b * cos(PI - _half_angle * _angle_ratio));
|
||||
float output = uv.x;
|
||||
float _chamfer_zone = (_half_angle - _polar_uv.x) < _chamfer_angle ? 1.0 : 0.0;
|
||||
output = mix(uv.x, _polar_uv.y / _dist_c, _chamfer_zone);
|
||||
output = clamp((1.0 - output) / fwidth(output), 0.0, 1.0);
|
||||
return output;
|
||||
}
|
@ -58,8 +58,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("RoundedRectangle.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/Procedural/Procedural.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String = "UV"
|
||||
|
@ -1,7 +0,0 @@
|
||||
float rounded_rectangle_shape(vec2 uv, float width, float height, float radius){
|
||||
radius /= 10.0;
|
||||
radius = max(min(min(abs(radius * 2.0), abs(width)), abs(height)), 1e-5);
|
||||
uv = abs(uv * 2.0 - 1.0) - vec2(width, height) + radius;
|
||||
float _distance = length(max(vec2(0.0), uv)) / radius;
|
||||
return clamp((1.0 - _distance) / fwidth(_distance), 0.0, 1.0);
|
||||
}
|
@ -183,21 +183,7 @@ func _get_output_port_type(port: int) -> PortType:
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String
|
||||
var sdf_index: int = get_option_index(0)
|
||||
code = preload("RayMarchRotation.gdshaderinc").code
|
||||
match sdf_index:
|
||||
0:
|
||||
code += preload("SDBox.gdshaderinc").code
|
||||
1:
|
||||
code += preload("SDSphere.gdshaderinc").code
|
||||
2:
|
||||
code += preload("SDCapsule.gdshaderinc").code
|
||||
3:
|
||||
code += preload("SDCylinder.gdshaderinc").code
|
||||
_:
|
||||
code += preload("SDTorus.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/RayMarching/SignedDistanceFunctions.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var sdf_index: int = get_option_index(0)
|
||||
|
@ -1,3 +1,6 @@
|
||||
// For in depth ray marching or sphere tracing info check out the playlist
|
||||
// https://www.youtube.com/watch?v=68G3V5Yr8FY&list=PLaE0_uENxXqvzte-A0Ux2pav0zrUrTJ1V
|
||||
|
||||
float sdf_custom(vec3 p) {
|
||||
// Basic example of Sphere SDF with radius of .3
|
||||
// Put your custom logic here
|
@ -1,7 +0,0 @@
|
||||
mat2 rm_rotation(float angle) {
|
||||
angle = -angle * (3.1415926 / 180.);
|
||||
return mat2(
|
||||
vec2(cos(angle), -sin(angle)),
|
||||
vec2(sin(angle), cos(angle))
|
||||
);
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
float sd_box(vec3 point, vec3 size, vec3 eulers) {
|
||||
point.yz *= rm_rotation(eulers.x);
|
||||
point.xy *= rm_rotation(eulers.z);
|
||||
point.xz *= rm_rotation(-eulers.y);
|
||||
return length(max(abs(point) - size, vec3(0)));
|
||||
}
|
||||
|
||||
float ray_march_sd_box(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 cube_pos, vec3 eulers, vec3 size) {
|
||||
ray_dir = normalize(ray_dir);
|
||||
dist_threshold = abs(dist_threshold);
|
||||
float dist_from_origin = 0.;
|
||||
float dist_to_surface;
|
||||
for(int i = 0; i < max_steps; i++) {
|
||||
vec3 point = ray_origin + dist_from_origin * ray_dir;
|
||||
dist_to_surface = sd_box(point - cube_pos, size, eulers);
|
||||
dist_from_origin += dist_to_surface;
|
||||
if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
|
||||
break;
|
||||
}
|
||||
return dist_from_origin;
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
float sd_capsule(vec3 point, vec3 capsule_pos, float height, float radius, vec3 eulers) {
|
||||
vec3 orientation = vec3(0, 1, 0);
|
||||
orientation.yz *= rm_rotation(eulers.x);
|
||||
orientation.xy *= rm_rotation(eulers.z);
|
||||
orientation.xz *= rm_rotation(-eulers.y);
|
||||
|
||||
vec3 top_point = point + orientation * (height * .5);
|
||||
vec3 bottom_point = point - orientation * (height * .5);
|
||||
|
||||
vec3 height_vector = bottom_point - top_point;
|
||||
vec3 top_distance = capsule_pos - top_point;
|
||||
|
||||
float t = dot(height_vector, top_distance) / dot(height_vector, height_vector);
|
||||
t = clamp(t, 0., 1.);
|
||||
vec3 hit_point = top_point + t * height_vector;
|
||||
|
||||
return length(capsule_pos - hit_point) - radius;
|
||||
}
|
||||
|
||||
float ray_march_sd_capsule(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 capsule_pos, float capsule_height, float capsule_radius, vec3 eulers) {
|
||||
ray_dir = normalize(ray_dir);
|
||||
dist_threshold = abs(dist_threshold);
|
||||
float dist_from_origin = 0.;
|
||||
float dist_to_surface;
|
||||
for(int i = 0; i < max_steps; i++) {
|
||||
vec3 point = ray_origin + dist_from_origin * ray_dir;
|
||||
dist_to_surface = sd_capsule(point, capsule_pos, capsule_height, capsule_radius, eulers);
|
||||
dist_from_origin += dist_to_surface;
|
||||
if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
|
||||
break;
|
||||
}
|
||||
return dist_from_origin;
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
float sd_cylinder(vec3 point, vec3 cylinder_pos, float height, float radius, vec3 eulers) {
|
||||
vec3 orientation = vec3(0, 1, 0);
|
||||
orientation.yz *= rm_rotation(eulers.x);
|
||||
orientation.xy *= rm_rotation(eulers.z);
|
||||
orientation.xz *= rm_rotation(-eulers.y);
|
||||
|
||||
vec3 top_point = point + orientation * (height * .5);
|
||||
vec3 bottom_point = point - orientation * (height * .5);
|
||||
|
||||
vec3 height_vector = bottom_point - top_point;
|
||||
vec3 top_distance = cylinder_pos - top_point;
|
||||
|
||||
float t = dot(height_vector, top_distance) / dot(height_vector, height_vector);
|
||||
vec3 hit_point = top_point + t * height_vector;
|
||||
|
||||
float x = length(cylinder_pos - hit_point) - radius;
|
||||
float y = (abs(t - .5) - .5) * length(height_vector);
|
||||
float e = length(max(vec2(x, y), 0));
|
||||
float i = min(max(x, y), 0.);
|
||||
|
||||
return e + i;
|
||||
}
|
||||
|
||||
float ray_march_sd_cylinder(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 cylinder_pos, float cylinder_height, float cylinder_radius, vec3 eulers) {
|
||||
ray_dir = normalize(ray_dir);
|
||||
dist_threshold = abs(dist_threshold);
|
||||
float dist_from_origin = 0.;
|
||||
float dist_to_surface;
|
||||
for(int i = 0; i < max_steps; i++) {
|
||||
vec3 point = ray_origin + dist_from_origin * ray_dir;
|
||||
dist_to_surface = sd_cylinder(point, cylinder_pos, cylinder_height, cylinder_radius, eulers);
|
||||
dist_from_origin += dist_to_surface;
|
||||
if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
|
||||
break;
|
||||
}
|
||||
return dist_from_origin;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
float sd_sphere(vec3 point, vec3 eulers, vec3 scale) {
|
||||
float radius = 1.;
|
||||
point.yz *= rm_rotation(eulers.x);
|
||||
point.xy *= rm_rotation(eulers.z);
|
||||
point.xz *= rm_rotation(-eulers.y);
|
||||
point /= scale;
|
||||
return (length(point) - radius) * min(scale.x, min(scale.y, scale.z));
|
||||
}
|
||||
|
||||
float ray_march_sd_sphere(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 sphere_pos, vec3 eulers, vec3 scale) {
|
||||
ray_dir = normalize(ray_dir);
|
||||
dist_threshold = abs(dist_threshold);
|
||||
float dist_from_origin = 0.;
|
||||
float dist_to_surface;
|
||||
for(int i = 0; i < max_steps; i++) {
|
||||
vec3 point = ray_origin + dist_from_origin * ray_dir;
|
||||
dist_to_surface = sd_sphere(point - sphere_pos, eulers, scale);
|
||||
dist_from_origin += dist_to_surface;
|
||||
if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
|
||||
break;
|
||||
}
|
||||
return dist_from_origin;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
float sd_torus(vec3 point, float small_radius, float big_radius, vec3 eulers) {
|
||||
point.yz *= rm_rotation(eulers.x);
|
||||
point.xy *= rm_rotation(eulers.z);
|
||||
point.xz *= rm_rotation(-eulers.y);
|
||||
return length(vec2(length(point.xz) - big_radius, point.y)) - small_radius;
|
||||
}
|
||||
|
||||
float ray_march_sd_torus(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 torus_pos, vec3 eulers, float small_radius, float big_radius) {
|
||||
ray_dir = normalize(ray_dir);
|
||||
dist_threshold = abs(dist_threshold);
|
||||
float dist_from_origin = 0.;
|
||||
float dist_to_surface;
|
||||
for(int i = 0; i < max_steps; i++) {
|
||||
vec3 point = ray_origin + dist_from_origin * ray_dir;
|
||||
dist_to_surface = sd_torus(point - torus_pos, small_radius, big_radius, eulers);
|
||||
dist_from_origin += dist_to_surface;
|
||||
if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
|
||||
break;
|
||||
}
|
||||
return dist_from_origin;
|
||||
}
|
150
addons/ShaderLib/RayMarching/SignedDistanceFunctions.gdshaderinc
Normal file
150
addons/ShaderLib/RayMarching/SignedDistanceFunctions.gdshaderinc
Normal file
@ -0,0 +1,150 @@
|
||||
mat2 rm_rotation(float angle) {
|
||||
angle = -angle * (3.1415926 / 180.);
|
||||
return mat2(
|
||||
vec2(cos(angle), -sin(angle)),
|
||||
vec2(sin(angle), cos(angle))
|
||||
);
|
||||
}
|
||||
|
||||
float sd_box(vec3 point, vec3 size, vec3 eulers) {
|
||||
point.yz *= rm_rotation(eulers.x);
|
||||
point.xy *= rm_rotation(eulers.z);
|
||||
point.xz *= rm_rotation(-eulers.y);
|
||||
vec3 box_distances = abs(point) - size;
|
||||
float external_dist = length(max(box_distances, 0));
|
||||
float internal_dist = min(max(box_distances.x, max(box_distances.y, box_distances.z)), 0);
|
||||
return external_dist + internal_dist;
|
||||
}
|
||||
|
||||
float ray_march_sd_box(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 cube_pos, vec3 eulers, vec3 size) {
|
||||
ray_dir = normalize(ray_dir);
|
||||
dist_threshold = abs(dist_threshold);
|
||||
float dist_from_origin = 0.;
|
||||
float dist_to_surface;
|
||||
for(int i = 0; i < max_steps; i++) {
|
||||
vec3 point = ray_origin + dist_from_origin * ray_dir;
|
||||
dist_to_surface = sd_box(point - cube_pos, size, eulers);
|
||||
dist_from_origin += dist_to_surface;
|
||||
if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
|
||||
break;
|
||||
}
|
||||
return dist_from_origin;
|
||||
}
|
||||
|
||||
float sd_capsule(vec3 point, vec3 capsule_pos, float height, float radius, vec3 eulers) {
|
||||
vec3 orientation = vec3(0, 1, 0);
|
||||
orientation.yz *= rm_rotation(eulers.x);
|
||||
orientation.xy *= rm_rotation(eulers.z);
|
||||
orientation.xz *= rm_rotation(-eulers.y);
|
||||
|
||||
vec3 top_point = point + orientation * (height * .5);
|
||||
vec3 bottom_point = point - orientation * (height * .5);
|
||||
|
||||
vec3 height_vector = bottom_point - top_point;
|
||||
vec3 top_distance = capsule_pos - top_point;
|
||||
|
||||
float t = dot(height_vector, top_distance) / dot(height_vector, height_vector);
|
||||
t = clamp(t, 0., 1.);
|
||||
vec3 hit_point = top_point + t * height_vector;
|
||||
|
||||
return length(capsule_pos - hit_point) - radius;
|
||||
}
|
||||
|
||||
float ray_march_sd_capsule(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 capsule_pos, float capsule_height, float capsule_radius, vec3 eulers) {
|
||||
ray_dir = normalize(ray_dir);
|
||||
dist_threshold = abs(dist_threshold);
|
||||
float dist_from_origin = 0.;
|
||||
float dist_to_surface;
|
||||
for(int i = 0; i < max_steps; i++) {
|
||||
vec3 point = ray_origin + dist_from_origin * ray_dir;
|
||||
dist_to_surface = sd_capsule(point, capsule_pos, capsule_height, capsule_radius, eulers);
|
||||
dist_from_origin += dist_to_surface;
|
||||
if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
|
||||
break;
|
||||
}
|
||||
return dist_from_origin;
|
||||
}
|
||||
|
||||
float sd_cylinder(vec3 point, vec3 cylinder_pos, float height, float radius, vec3 eulers) {
|
||||
vec3 orientation = vec3(0, 1, 0);
|
||||
orientation.yz *= rm_rotation(eulers.x);
|
||||
orientation.xy *= rm_rotation(eulers.z);
|
||||
orientation.xz *= rm_rotation(-eulers.y);
|
||||
|
||||
vec3 top_point = point + orientation * (height * .5);
|
||||
vec3 bottom_point = point - orientation * (height * .5);
|
||||
|
||||
vec3 height_vector = bottom_point - top_point;
|
||||
vec3 top_distance = cylinder_pos - top_point;
|
||||
|
||||
float t = dot(height_vector, top_distance) / dot(height_vector, height_vector);
|
||||
vec3 hit_point = top_point + t * height_vector;
|
||||
|
||||
float x = length(cylinder_pos - hit_point) - radius;
|
||||
float y = (abs(t - .5) - .5) * length(height_vector);
|
||||
float e = length(max(vec2(x, y), 0));
|
||||
float i = min(max(x, y), 0.);
|
||||
|
||||
return e + i;
|
||||
}
|
||||
|
||||
float ray_march_sd_cylinder(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 cylinder_pos, float cylinder_height, float cylinder_radius, vec3 eulers) {
|
||||
ray_dir = normalize(ray_dir);
|
||||
dist_threshold = abs(dist_threshold);
|
||||
float dist_from_origin = 0.;
|
||||
float dist_to_surface;
|
||||
for(int i = 0; i < max_steps; i++) {
|
||||
vec3 point = ray_origin + dist_from_origin * ray_dir;
|
||||
dist_to_surface = sd_cylinder(point, cylinder_pos, cylinder_height, cylinder_radius, eulers);
|
||||
dist_from_origin += dist_to_surface;
|
||||
if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
|
||||
break;
|
||||
}
|
||||
return dist_from_origin;
|
||||
}
|
||||
|
||||
float sd_sphere(vec3 point, vec3 eulers, vec3 scale) {
|
||||
float radius = 1.;
|
||||
point.yz *= rm_rotation(eulers.x);
|
||||
point.xy *= rm_rotation(eulers.z);
|
||||
point.xz *= rm_rotation(-eulers.y);
|
||||
point /= scale;
|
||||
return (length(point) - radius) * min(scale.x, min(scale.y, scale.z));
|
||||
}
|
||||
|
||||
float ray_march_sd_sphere(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 sphere_pos, vec3 eulers, vec3 scale) {
|
||||
ray_dir = normalize(ray_dir);
|
||||
dist_threshold = abs(dist_threshold);
|
||||
float dist_from_origin = 0.;
|
||||
float dist_to_surface;
|
||||
for(int i = 0; i < max_steps; i++) {
|
||||
vec3 point = ray_origin + dist_from_origin * ray_dir;
|
||||
dist_to_surface = sd_sphere(point - sphere_pos, eulers, scale);
|
||||
dist_from_origin += dist_to_surface;
|
||||
if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
|
||||
break;
|
||||
}
|
||||
return dist_from_origin;
|
||||
}
|
||||
|
||||
float sd_torus(vec3 point, float small_radius, float big_radius, vec3 eulers) {
|
||||
point.yz *= rm_rotation(eulers.x);
|
||||
point.xy *= rm_rotation(eulers.z);
|
||||
point.xz *= rm_rotation(-eulers.y);
|
||||
return length(vec2(length(point.xz) - big_radius, point.y)) - small_radius;
|
||||
}
|
||||
|
||||
float ray_march_sd_torus(vec3 ray_origin, vec3 ray_dir, int max_steps, float max_dist, float dist_threshold, vec3 torus_pos, vec3 eulers, float small_radius, float big_radius) {
|
||||
ray_dir = normalize(ray_dir);
|
||||
dist_threshold = abs(dist_threshold);
|
||||
float dist_from_origin = 0.;
|
||||
float dist_to_surface;
|
||||
for(int i = 0; i < max_steps; i++) {
|
||||
vec3 point = ray_origin + dist_from_origin * ray_dir;
|
||||
dist_to_surface = sd_torus(point - torus_pos, small_radius, big_radius, eulers);
|
||||
dist_from_origin += dist_to_surface;
|
||||
if(dist_to_surface < dist_threshold || dist_to_surface > max_dist)
|
||||
break;
|
||||
}
|
||||
return dist_from_origin;
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeUVFlipbook extends VisualShaderNodeCustom
|
||||
|
||||
func _init() -> void:
|
||||
set_output_port_for_preview(0)
|
||||
|
||||
func _get_name() -> String:
|
||||
return "Flipbook"
|
||||
|
||||
@ -60,8 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_2D
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("FlipbookUV.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\""
|
||||
|
||||
func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool:
|
||||
match mode:
|
||||
|
@ -1,16 +0,0 @@
|
||||
vec2 flipbook_uv(vec2 uv, int rows, int columns, float anim_speed){
|
||||
int start_frame = 1;
|
||||
int end_frame = rows * columns;
|
||||
start_frame += int(fract(TIME * anim_speed) * float(end_frame));
|
||||
float _frame = float(clamp(start_frame, 0, end_frame));
|
||||
vec2 _off_per_frame = vec2((1.0 / float(columns)), (1.0 / float(rows)));
|
||||
vec2 _sprite_size = vec2(uv.x / float(columns), uv.y / float(rows));
|
||||
vec2 _current_sprite = vec2(0.0, 1.0 - _off_per_frame.y);
|
||||
_current_sprite.x += _frame * _off_per_frame.x;
|
||||
float _row_index;
|
||||
float _mod = modf(_frame / float(columns), _row_index);
|
||||
_current_sprite.y -= 1.0 - (_row_index * _off_per_frame.y);
|
||||
_current_sprite.x -= _row_index * float(columns) * _off_per_frame.x;
|
||||
vec2 _sprite_uv = (_sprite_size + _current_sprite);
|
||||
return _sprite_uv;
|
||||
}
|
@ -55,8 +55,7 @@ func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool:
|
||||
return false
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("ParallaxMappingUV.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var height_map: String = input_vars[0]
|
||||
|
@ -1,17 +0,0 @@
|
||||
vec2 parallax_mapping_uv_offset_1_step(float height, float amplitude, vec3 view_dir_tangent)
|
||||
{
|
||||
height = height * amplitude - amplitude / 2.0;
|
||||
vec3 _vector = view_dir_tangent;
|
||||
_vector.y += 0.42;
|
||||
return height * (_vector.xz / _vector.y);
|
||||
}
|
||||
|
||||
vec2 parallax_mapping_uv(sampler2D height, float amplitude, vec2 uv, vec3 tangent, vec3 normal, vec3 binormal, vec3 view)
|
||||
{
|
||||
float depth = amplitude / 10.0;
|
||||
mat3 _tangent_matrix = mat3(tangent, normal, -binormal); // VIEW TO TANGENT SPACE
|
||||
vec3 _view_tangent = transpose(_tangent_matrix) * view;
|
||||
float _parallaxHeight = texture(height, uv).r;
|
||||
vec2 _parallaxOffset = parallax_mapping_uv_offset_1_step(_parallaxHeight, depth, _view_tangent);
|
||||
return _parallaxOffset + uv;
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeUVRadialShear extends VisualShaderNodeCustom
|
||||
|
||||
func _init() -> void:
|
||||
set_output_port_for_preview(0)
|
||||
|
||||
func _get_name() -> String:
|
||||
return "RadialShear"
|
||||
|
||||
@ -60,8 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_2D
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("RadialShearUV.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String
|
||||
|
@ -1,6 +0,0 @@
|
||||
vec2 radial_shear_uv(vec2 uv, vec2 center, float strength, vec2 offset){
|
||||
vec2 _delta = uv - center;
|
||||
float _delta2 = dot(_delta.xy, _delta.xy);
|
||||
vec2 _delta_offset = vec2(_delta2 * strength);
|
||||
return uv + vec2(_delta.y, -_delta.x) * _delta_offset + offset;
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeUVRotate extends VisualShaderNodeCustom
|
||||
|
||||
func _init() -> void:
|
||||
set_output_port_for_preview(0)
|
||||
|
||||
func _get_name() -> String:
|
||||
return "Rotate"
|
||||
|
||||
@ -68,8 +65,7 @@ func _get_property_options(index: int) -> PackedStringArray:
|
||||
return ["Degrees", "Radians"]
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("RotateUV.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String
|
||||
|
@ -1,13 +0,0 @@
|
||||
vec2 rotate_uv(vec2 uv, vec2 center, float rotation, bool use_degrees){
|
||||
float _angle = rotation;
|
||||
if(use_degrees){
|
||||
_angle = rotation * (3.1415926/180.0);
|
||||
}
|
||||
mat2 _rotation = mat2(
|
||||
vec2(cos(_angle), -sin(_angle)),
|
||||
vec2(sin(_angle), cos(_angle))
|
||||
);
|
||||
vec2 _delta = uv - center;
|
||||
_delta = _rotation * _delta;
|
||||
return _delta + center;
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeUVSpherize extends VisualShaderNodeCustom
|
||||
|
||||
func _init() -> void:
|
||||
set_output_port_for_preview(0)
|
||||
|
||||
func _get_name() -> String:
|
||||
return "Spherize"
|
||||
|
||||
@ -60,8 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_2D
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("SpherizeUV.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String
|
||||
|
@ -1,7 +0,0 @@
|
||||
vec2 spherize_uv(vec2 uv, vec2 center, float strength, vec2 offset){
|
||||
vec2 _delta = uv - center;
|
||||
float _delta2 = dot(_delta.xy, _delta.xy);
|
||||
float _delta4 = _delta2 * _delta2;
|
||||
vec2 _delta_offset = vec2(_delta4 * strength);
|
||||
return uv + _delta * _delta_offset + offset;
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeUVSwirl extends VisualShaderNodeCustom
|
||||
|
||||
func _init() -> void:
|
||||
output_port_for_preview = 0
|
||||
|
||||
func _get_name() -> String:
|
||||
return "Swirl"
|
||||
|
||||
@ -60,8 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_2D
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("SwirlUV.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String
|
||||
|
@ -1,10 +0,0 @@
|
||||
vec2 swirl_uv(vec2 uv, vec2 center, float strength, vec2 offset){
|
||||
vec2 _delta = uv - center;
|
||||
float _angle = strength * max(pow(1. - length(_delta), 3), 0);
|
||||
mat2 _rotation = mat2(
|
||||
vec2(cos(_angle), -sin(_angle)),
|
||||
vec2(sin(_angle), cos(_angle))
|
||||
);
|
||||
_delta = _rotation * _delta;
|
||||
return _delta + center;
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeUVTilingAndOffset extends VisualShaderNodeCustom
|
||||
|
||||
func _init() -> void:
|
||||
output_port_for_preview = 0
|
||||
|
||||
func _get_name() -> String:
|
||||
return "TilingAndOffset"
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeUVTwirl extends VisualShaderNodeCustom
|
||||
|
||||
func _init() -> void:
|
||||
output_port_for_preview = 0
|
||||
|
||||
func _get_name() -> String:
|
||||
return "Twirl"
|
||||
|
||||
@ -60,8 +57,7 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_2D
|
||||
|
||||
func _get_global_code(mode: Shader.Mode) -> String:
|
||||
var code: String = preload("TwirlUV.gdshaderinc").code
|
||||
return code
|
||||
return "#include \"res://addons/ShaderLib/UV/UV.gdshaderinc\""
|
||||
|
||||
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
|
||||
var uv: String
|
||||
|
@ -1,10 +0,0 @@
|
||||
vec2 twirl_uv(vec2 uv, vec2 center, float strength, vec2 offset){
|
||||
vec2 _delta = uv - center;
|
||||
float _angle = strength * length(_delta);
|
||||
mat2 _rotation = mat2(
|
||||
vec2(cos(_angle), -sin(_angle)),
|
||||
vec2(sin(_angle), cos(_angle))
|
||||
);
|
||||
_delta = _rotation * _delta;
|
||||
return _delta + center;
|
||||
}
|
85
addons/ShaderLib/UV/UV.gdshaderinc
Normal file
85
addons/ShaderLib/UV/UV.gdshaderinc
Normal file
@ -0,0 +1,85 @@
|
||||
vec2 flipbook_uv(vec2 uv, int rows, int columns, float anim_speed){
|
||||
int start_frame = 1;
|
||||
int end_frame = rows * columns;
|
||||
start_frame += int(fract(TIME * anim_speed) * float(end_frame));
|
||||
float _frame = float(clamp(start_frame, 0, end_frame));
|
||||
vec2 _off_per_frame = vec2((1.0 / float(columns)), (1.0 / float(rows)));
|
||||
vec2 _sprite_size = vec2(uv.x / float(columns), uv.y / float(rows));
|
||||
vec2 _current_sprite = vec2(0.0, 1.0 - _off_per_frame.y);
|
||||
_current_sprite.x += _frame * _off_per_frame.x;
|
||||
float _row_index;
|
||||
float _mod = modf(_frame / float(columns), _row_index);
|
||||
_current_sprite.y -= 1.0 - (_row_index * _off_per_frame.y);
|
||||
_current_sprite.x -= _row_index * float(columns) * _off_per_frame.x;
|
||||
vec2 _sprite_uv = (_sprite_size + _current_sprite);
|
||||
return _sprite_uv;
|
||||
}
|
||||
|
||||
vec2 parallax_mapping_uv_offset_1_step(float height, float amplitude, vec3 view_dir_tangent)
|
||||
{
|
||||
height = height * amplitude - amplitude / 2.0;
|
||||
vec3 _vector = view_dir_tangent;
|
||||
_vector.y += 0.42;
|
||||
return height * (_vector.xz / _vector.y);
|
||||
}
|
||||
|
||||
vec2 parallax_mapping_uv(sampler2D height, float amplitude, vec2 uv, vec3 tangent, vec3 normal, vec3 binormal, vec3 view)
|
||||
{
|
||||
float depth = amplitude / 10.0;
|
||||
mat3 _tangent_matrix = mat3(tangent, normal, -binormal); // VIEW TO TANGENT SPACE
|
||||
vec3 _view_tangent = transpose(_tangent_matrix) * view;
|
||||
float _parallaxHeight = texture(height, uv).r;
|
||||
vec2 _parallaxOffset = parallax_mapping_uv_offset_1_step(_parallaxHeight, depth, _view_tangent);
|
||||
return _parallaxOffset + uv;
|
||||
}
|
||||
|
||||
vec2 radial_shear_uv(vec2 uv, vec2 center, float strength, vec2 offset){
|
||||
vec2 _delta = uv - center;
|
||||
float _delta2 = dot(_delta.xy, _delta.xy);
|
||||
vec2 _delta_offset = vec2(_delta2 * strength);
|
||||
return uv + vec2(_delta.y, -_delta.x) * _delta_offset + offset;
|
||||
}
|
||||
|
||||
vec2 rotate_uv(vec2 uv, vec2 center, float rotation, bool use_degrees){
|
||||
float _angle = rotation;
|
||||
if(use_degrees){
|
||||
_angle = rotation * (3.1415926/180.0);
|
||||
}
|
||||
mat2 _rotation = mat2(
|
||||
vec2(cos(_angle), -sin(_angle)),
|
||||
vec2(sin(_angle), cos(_angle))
|
||||
);
|
||||
vec2 _delta = uv - center;
|
||||
_delta = _rotation * _delta;
|
||||
return _delta + center;
|
||||
}
|
||||
|
||||
vec2 spherize_uv(vec2 uv, vec2 center, float strength, vec2 offset){
|
||||
vec2 _delta = uv - center;
|
||||
float _delta2 = dot(_delta.xy, _delta.xy);
|
||||
float _delta4 = _delta2 * _delta2;
|
||||
vec2 _delta_offset = vec2(_delta4 * strength);
|
||||
return uv + _delta * _delta_offset + offset;
|
||||
}
|
||||
|
||||
vec2 swirl_uv(vec2 uv, vec2 center, float strength, vec2 offset){
|
||||
vec2 _delta = uv - center;
|
||||
float _angle = strength * max(pow(1. - length(_delta), 3), 0);
|
||||
mat2 _rotation = mat2(
|
||||
vec2(cos(_angle), -sin(_angle)),
|
||||
vec2(sin(_angle), cos(_angle))
|
||||
);
|
||||
_delta = _rotation * _delta;
|
||||
return _delta + center;
|
||||
}
|
||||
|
||||
vec2 twirl_uv(vec2 uv, vec2 center, float strength, vec2 offset){
|
||||
vec2 _delta = uv - center;
|
||||
float _angle = strength * length(_delta);
|
||||
mat2 _rotation = mat2(
|
||||
vec2(cos(_angle), -sin(_angle)),
|
||||
vec2(sin(_angle), cos(_angle))
|
||||
);
|
||||
_delta = _rotation * _delta;
|
||||
return _delta + center;
|
||||
}
|
@ -14,7 +14,7 @@ Adjusts the contrast of input <b><i>in</i></b> by the amount of input <b><i>cont
|
||||
|out|vec3|None|Output value|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Artistic/Adjustment/Contrast.gdshaderinc`
|
||||
<br>`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`vec3 contrast(input, contrast)`
|
||||
|
@ -19,7 +19,7 @@ Offsets the hue of input <b><i>in</i></b> by the amount of input <b><i>offset</i
|
||||
|out|vec3|None|Output value|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Artistic/Adjustment/Hue.gdshaderinc`
|
||||
<br>`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`vec3 hue(input, offset, range_index)`
|
||||
|
@ -17,7 +17,7 @@ Replaces values in input <b><i>in</i></b> equal to input <b><i>from</i></b> to t
|
||||
|out|vec3|None|Output value|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Artistic/Adjustment/ReplaceColor.gdshaderinc`
|
||||
<br>`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`vec3 replace_color(input, from, to, range, fuzziness)`
|
||||
|
@ -14,7 +14,7 @@ Adjusts the saturation of input <b><i>in</i></b> by the amount of input <b><i>sa
|
||||
|out|vec3|None|Output value|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Artistic/Adjustment/Saturation.gdshaderinc`
|
||||
<br>`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`vec3 saturation(input, saturation)`
|
||||
|
@ -15,7 +15,7 @@ Adjusts the temperature and tint of input <b><i>in</i></b> by the amount of inpu
|
||||
|out|vec3|None|Output value|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Artistic/Adjustment/WhiteBalance.gdshaderinc`
|
||||
<br>`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`vec3 white_balance(input, temperature, tint)`
|
||||
|
@ -16,7 +16,7 @@ Creates a mask from values in input <b><i>in</i></b> equal to input <b><i>mask c
|
||||
|out|vec3|None|Output mask value|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Artistic/Mask/ColorMask.gdshaderinc`
|
||||
<br>`res://addons/ShaderLib/Artistic/Artistic.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`vec4 color_mask(input, mask_color, range, fuzziness)`
|
||||
|
@ -9,7 +9,7 @@ Provides accees to node's position and scale in world space.
|
||||
|scale|vec3|None|Node/object scale in world space|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Geometry/MeshNode.gdshaderinc`
|
||||
<br>`res://addons/ShaderLib/Geometry/Geometry.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`vec3 geometry_node_scale_world(mat4 model_matrix)`
|
||||
|
@ -15,7 +15,7 @@ Returns the maximum value between A and B, but smooths out the intersections of
|
||||
|op|float|None|Smooth maximum between A and B|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Maths/Scalar/SmoothMax.gdshaderinc`
|
||||
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`float smoothmax(float a, float b, float t)`
|
||||
|
@ -15,7 +15,7 @@ Returns the minimum value between A and B, but smooths out the intersections of
|
||||
|op|float|None|Smooth minimum between A and B|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Maths/Scalar/SmoothMin.gdshaderinc`
|
||||
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`float smoothmin(float a, float b, float t)`
|
||||
|
@ -20,8 +20,7 @@ Returns the distance between two points using Chebyshev distance matrix.
|
||||
|distance|float|None|Distance between 2 points|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>For 2D - `res://addons/ShaderLib/Maths/Vector/Distance/Chebyshev2D.gdshaderinc`
|
||||
<br>For 3D - `res://addons/ShaderLib/Maths/Vector/Distance/Chebyshev3D.gdshaderinc`
|
||||
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>For 2D - `float chebyshev_distance_2d(vec2 point1, vec2 point2, float power)`
|
||||
|
@ -19,8 +19,7 @@ Returns the distance between two points using Manhattan distance matrix.
|
||||
|distance|float|None|Distance between 2 points|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>For 2D - `res://addons/ShaderLib/Maths/Vector/Distance/Manhattan2D.gdshaderinc`
|
||||
<br>For 3D - `res://addons/ShaderLib/Maths/Vector/Distance/Manhattan3D.gdshaderinc`
|
||||
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>For 2D - `float manhattan_distance_2d(vec2 point1, vec2 point2)`
|
||||
|
@ -19,7 +19,7 @@ Projects <i><b>vector A</b></i> onto <i><b>vector B</b></i>.
|
||||
|vector|vector3|None|Output vector|
|
||||
|
||||
**ShaderInc location**
|
||||
<br>`res://addons/ShaderLib/Maths/Vector/Project.gdshaderinc`
|
||||
<br>`res://addons/ShaderLib/Maths/Maths.gdshaderinc`
|
||||
|
||||
**Method signature**
|
||||
<br>`vec2 project_2d(vec2 a, vec2 b)`
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user