1
0
mirror of https://github.com/DigvijaysinhGohil/Godot-Shader-Lib.git synced 2025-01-09 02:43:25 +08:00

Pseudo random noise node added

This commit is contained in:
Digvijaysinh Gohil 2023-12-24 20:47:18 +05:30
parent 8b1f8d246e
commit db2384c5df
5 changed files with 63 additions and 8 deletions

View File

@ -10,7 +10,7 @@ If you don't immediatly see new nodes under **_Addons_** category, simply reload
Delete the contents of **_addons/ShaderLib_** folder from your project. Make sure to delete it using the Godot editor instead of your default file system program. Delete the contents of **_addons/ShaderLib_** folder from your project. Make sure to delete it using the Godot editor instead of your default file system program.
# Nodes documentation # Nodes documentation
<details open> <details open>
<summary><h1>Input nodes</h1></summary> <summary><h1>Geometry nodes</h1></summary>
<details> <details>
<summary><h3>Node Scale World node</h3></summary> <summary><h3>Node Scale World node</h3></summary>
Provides accees to node scale in world space. Provides accees to node scale in world space.
@ -130,6 +130,22 @@ Generates a gradient, or Perlin noise based on input UV. The resulting <b><i>out
|uv|vec2|UV|Input UV value| |uv|vec2|UV|Input UV value|
|scale|float|none|Noise scale| |scale|float|none|Noise scale|
**Outputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|output|float|None|Output noise value|
___
</details>
<details>
<summary><h3>Pseudo Random Noise node</h3></summary>
Generates a pseudo random noise based on input seed. The resulting <b><i>output</i></b> values will be between 0 and 1.
<hr>
**Inputs**
|Name|Type|Binding|Description|
|---|---|---|---|
|seed|float|none|Input seed|
**Outputs** **Outputs**
|Name|Type|Binding|Description| |Name|Type|Binding|Description|
|---|---|---|---| |---|---|---|---|

View File

@ -1,11 +1,11 @@
@tool @tool
class_name VisualShaderNodeInputNodeScaleWorld extends VisualShaderNodeCustom class_name VisualShaderNodeGeometryNodeScaleWorld extends VisualShaderNodeCustom
func _get_name() -> String: func _get_name() -> String:
return "NodeScaleWorld" return "NodeScaleWorld"
func _get_category() -> String: func _get_category() -> String:
return "Input" return "Geometry"
func _get_description() -> String: func _get_description() -> String:
return "Provides accees to node scale in world space." return "Provides accees to node scale in world space."
@ -42,4 +42,4 @@ func _get_global_code(mode: Shader.Mode) -> String:
return code return code
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String: func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
return output_vars[0] + " = node_scale_world(MODEL_MATRIX);" return output_vars[0] + " = geometry_node_scale_world(MODEL_MATRIX);"

View File

@ -1,4 +1,4 @@
vec3 node_scale_world(mat4 model_matrix){ vec3 geometry_node_scale_world(mat4 model_matrix){
vec3 _axis_x = model_matrix[0].xyz; vec3 _axis_x = model_matrix[0].xyz;
vec3 _axis_y = model_matrix[1].xyz; vec3 _axis_y = model_matrix[1].xyz;
vec3 _axis_z = model_matrix[2].xyz; vec3 _axis_z = model_matrix[2].xyz;

View File

@ -0,0 +1,39 @@
@tool
class_name VisualShaderNodePseudoRandomNoise extends VisualShaderNodeCustom
func _init() -> void:
set_input_port_default_value(0, 0.0)
output_port_for_preview = 0
func _get_name() -> String:
return "PseudoRandomNoise"
func _get_category() -> String:
return "Procedural/Noise"
func _get_description() -> String:
return "Generates a pseudo random noise based on input seed."
func _get_return_icon_type() -> PortType:
return PORT_TYPE_SCALAR
func _get_input_port_count() -> int:
return 1
func _get_input_port_name(port: int) -> String:
return "seed"
func _get_input_port_type(port: int) -> PortType:
return PORT_TYPE_SCALAR
func _get_output_port_count() -> int:
return 1
func _get_output_port_name(port: int) -> String:
return "output"
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]