diff --git a/addons/ShaderLib/Artistic/Adjustment/ContrastNode.gd b/addons/ShaderLib/Artistic/Adjustment/ContrastNode.gd new file mode 100644 index 0000000..e10694d --- /dev/null +++ b/addons/ShaderLib/Artistic/Adjustment/ContrastNode.gd @@ -0,0 +1,60 @@ +@tool +class_name VisualShaderNodeAdjustmentContrastNode extends VisualShaderNodeCustom + +func _get_name() -> String: + return "ContrastNode" + +func _get_category() -> String: + return "Artistic/Adjustment" + +func _get_description() -> String: + return "Adjusts the contrast of input in by the amount of input contrast." + +func _get_return_icon_type() -> PortType: + return PORT_TYPE_VECTOR_3D + +func _get_input_port_count() -> int: + return 2 + +func _get_input_port_name(port: int) -> String: + match port: + 0: + return "in" + _: + return "contrast" + +func _get_input_port_type(port: int) -> PortType: + match port: + 0: + return PORT_TYPE_VECTOR_3D + _: + return PORT_TYPE_SCALAR + +func _get_input_port_default_value(port: int) -> Variant: + match port: + 1: + return 1.0 + _: + return null + +func _get_output_port_count() -> int: + return 1 + +func _get_output_port_name(port: int) -> String: + return "out" + +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("ContrastNode.gdshaderinc").code + return code + +func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String: + var input: String = "vec3(1.0)" + + if input_vars[0]: + input = input_vars[0] + + var contrast: String = input_vars[1] + return output_vars[0] + " = contrast(%s, %s);" % [input, contrast] diff --git a/addons/ShaderLib/Artistic/Adjustment/ContrastNode.gdshaderinc b/addons/ShaderLib/Artistic/Adjustment/ContrastNode.gdshaderinc new file mode 100644 index 0000000..54fae12 --- /dev/null +++ b/addons/ShaderLib/Artistic/Adjustment/ContrastNode.gdshaderinc @@ -0,0 +1,5 @@ +vec3 contrast(vec3 input, float contrast) +{ + float midpoint = pow(0.5, 2.2); + return (input - midpoint) * contrast + midpoint; +} \ No newline at end of file diff --git a/documentation/Documentation.md b/documentation/Documentation.md index f61b3db..6cc2785 100644 --- a/documentation/Documentation.md +++ b/documentation/Documentation.md @@ -10,6 +10,7 @@ Delete the contents of **_addons/ShaderLib_** folder from your project. Make sur