mirror of
https://github.com/DigvijaysinhGohil/Godot-Shader-Lib.git
synced 2025-01-07 01:43:35 +08:00
Saturation node added
This commit is contained in:
parent
6b62f15a7d
commit
578a78df0b
61
addons/ShaderLib/Artistic/Adjustment/Saturation.gd
Normal file
61
addons/ShaderLib/Artistic/Adjustment/Saturation.gd
Normal file
@ -0,0 +1,61 @@
|
||||
@tool
|
||||
class_name VisualShaderNodeAdjustmentSaturation extends VisualShaderNodeCustom
|
||||
|
||||
|
||||
func _get_name() -> String:
|
||||
return "Saturation"
|
||||
|
||||
func _get_category() -> String:
|
||||
return "Artistic/Adjustment"
|
||||
|
||||
func _get_description() -> String:
|
||||
return "Adjusts the saturation of input \"in\" by the amount of input \"saturation\"."
|
||||
|
||||
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 "saturation"
|
||||
|
||||
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:
|
||||
0:
|
||||
return null
|
||||
_:
|
||||
return 1.0
|
||||
|
||||
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("Saturation.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 saturation = input_vars[1]
|
||||
return output_vars[0] + " = saturation(%s, %s);" % [input, saturation]
|
@ -0,0 +1,4 @@
|
||||
vec3 saturation(vec3 input, float saturation){
|
||||
float luma = dot(input, vec3(0.2126729, 0.7151522, 0.0721750));
|
||||
return luma + saturation * (input - vec3(luma));
|
||||
}
|
@ -12,6 +12,7 @@ Delete the contents of **_addons/ShaderLib_** folder from your project. Make sur
|
||||
<h4><a href="/documentation/Nodes/Artistic/Adjustment/ContrastNode.md">  Contrast node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Artistic/Adjustment/HueNode.md">  Hue node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Artistic/Adjustment/ReplaceColorNode.md">  Replace Color node</a></h4>
|
||||
<h4><a href="/documentation/Nodes/Artistic/Adjustment/SaturationNode.md">  Saturation node</a></h4>
|
||||
|
||||
<h2>Geometry nodes</h2>
|
||||
|
||||
|
15
documentation/Nodes/Artistic/Adjustment/SaturationNode.md
Normal file
15
documentation/Nodes/Artistic/Adjustment/SaturationNode.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Saturation node
|
||||
Adjusts the saturation of input <b><i>in</i></b> by the amount of input <b><i>saturation</i></b>. A Saturation value of 1 will return the input unaltered. A Saturation value of 0 will return the input completely desaturated.
|
||||
<hr>
|
||||
|
||||
**Inputs**
|
||||
|Name|Type|Binding|Description|
|
||||
|---|---|---|---|
|
||||
|in|vec3|none|Input value|
|
||||
|saturation|float|none|Saturation value|
|
||||
|
||||
**Outputs**
|
||||
|Name|Type|Binding|Description|
|
||||
|---|---|---|---|
|
||||
|out|vec3|None|Output value|
|
||||
___
|
Loading…
x
Reference in New Issue
Block a user