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

UV nodes refactored

- Set the default value for uv input as 0, 0 to avoid errors when using with shader modes PARTICLES, SKY and FOG
- FlipbookUV node is now only available in shader modes SPATIAL and CANVAS_ITEM
This commit is contained in:
Digvijaysinh Gohil 2023-11-21 20:49:41 +05:30
parent 05dfe4c1fd
commit ecd09b5246
8 changed files with 52 additions and 8 deletions

View File

@ -2,10 +2,10 @@ 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;
float _scale_x = length(_axis_x);
float _scale_y = length(_axis_y);
float _scale_z = length(_axis_z);
return vec3(_scale_x, _scale_y, _scale_z);
}

View File

@ -64,8 +64,21 @@ func _get_global_code(mode: Shader.Mode) -> String:
var code: String = preload("FlipbookUV.gdshaderinc").code
return code
func _is_available(mode: Shader.Mode, type: VisualShader.Type) -> bool:
match mode:
0, 1:
return true
_:
return false
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
var uv: String
match mode:
0, 1:
uv = "UV"
_:
uv = "vec2(0.0)"
if input_vars[0]:
uv = input_vars[0]

View File

@ -57,7 +57,13 @@ func _get_global_code(mode: Shader.Mode) -> String:
return code
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
var uv: String
match mode:
0, 1:
uv = "UV"
_:
uv = "vec2(0.0)"
if input_vars[0]:
uv = input_vars[0]

View File

@ -59,7 +59,13 @@ func _get_global_code(mode: Shader.Mode) -> String:
return code
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
var uv: String
match mode:
0, 1:
uv = "UV"
_:
uv = "vec2(0.0)"
if input_vars[0]:
uv = input_vars[0]

View File

@ -57,7 +57,13 @@ func _get_global_code(mode: Shader.Mode) -> String:
return code
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
var uv: String
match mode:
0, 1:
uv = "UV"
_:
uv = "vec2(0.0)"
if input_vars[0]:
uv = input_vars[0]

View File

@ -48,7 +48,13 @@ func _get_output_port_type(port: int) -> VisualShaderNode.PortType:
return PORT_TYPE_VECTOR_2D
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
var uv: String
match mode:
0, 1:
uv = "UV"
_:
uv = "vec2(0.0)"
if input_vars[0]:
uv = input_vars[0]

View File

@ -57,7 +57,13 @@ func _get_global_code(mode: Shader.Mode) -> String:
return code
func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shader.Mode, type: VisualShader.Type) -> String:
var uv: String = "UV"
var uv: String
match mode:
0, 1:
uv = "UV"
_:
uv = "vec2(0.0)"
if input_vars[0]:
uv = input_vars[0]

View File

@ -11,5 +11,6 @@ config_version=5
[application]
config/name="Godot-shader-lib"
config/tags=PackedStringArray("addons")
config/features=PackedStringArray("4.1", "Forward Plus")
config/icon="res://icons/icon.png"