mirror of
https://github.com/DigvijaysinhGohil/Godot-Shader-Lib.git
synced 2025-09-20 04:15:58 +08:00
Compare commits
14 Commits
a98305fa5f
...
godot-4.1
Author | SHA1 | Date | |
---|---|---|---|
6cff1d40bb | |||
5fe35becbf | |||
152f2049b3 | |||
4e095dfe00 | |||
a3943b722b | |||
df7cf1aee2 | |||
fae913cea6 | |||
9d7c679c5b | |||
67ec588347 | |||
63acf5d341 | |||
8972c2da37 | |||
5ece7a3bd3 | |||
3fc8d868a6 | |||
32c40f1371 |
13
.github/FUNDING.yml
vendored
Normal file
13
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: DigvijaysinhGohil
|
||||
patreon: DigvijaysinhG
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Digvijaysinh Gohil
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -1,7 +1,10 @@
|
||||
# Godot-Shader-Lib
|
||||
Visual shader node library for Godot engine. The addon supports Godot versions 4.x!
|
||||
Visual shader node library for Godot engine. The addon supports Godot versions 4.1.0 and above!
|
||||
|
||||
Adds various extra nodes to use in built-in visual shader editor.
|
||||
|
||||
## This version is now deprecated and is no longer supported.
|
||||
|
||||
# Installation
|
||||
Copy the contents of **_addons/ShaderLib_** into the same folder in your project. No activation needed. Custom visual shader nodes work the same way as standard visual shader nodes.
|
||||
|
||||
@ -294,7 +297,7 @@ Default value for uv input will be vec2(0, 0) for shader modes <i>PARTICLES</i>,
|
||||
<details>
|
||||
<summary><h3>Flipbook node</h3></summary>
|
||||
Creates a flipbook, or texture sheet animation, of the UVs supplied to input UV. The amount of tiles on the sheet are defined by the values of the inputs <b><i>rows</i></b> and <b><i>columns</i></b>.
|
||||
This node can be used to create a texture animation functionality, commonly used for particle effects and sprites.<br><br><i>This node is only available in shader modes SPATIAL and CANVAS ITEM.</i>
|
||||
This node can be used to create a texture animation functionality, commonly used for particle effects and sprites. Animation frames will go from top left to bottom right.<br><br><i>This node is only available in shader modes SPATIAL and CANVAS ITEM.</i>
|
||||
<hr>
|
||||
|
||||
**Inputs**
|
||||
@ -303,8 +306,6 @@ This node can be used to create a texture animation functionality, commonly used
|
||||
|uv|vec2|UV|Input UV value|
|
||||
|rows|int|none|Amount of horizontal tiles in texture sheet|
|
||||
|columns|int|none|Amount of vertical tiles in texture sheet|
|
||||
|start frame|int|none|Start tile index texture sheet|
|
||||
|end frame|int|none|End tile index texture sheet|
|
||||
|anim speed|float|none|Animation speed|
|
||||
|
||||
**Outputs**
|
||||
|
@ -4,9 +4,7 @@ class_name VisualShaderNodeUVFlipbook extends VisualShaderNodeCustom
|
||||
func _init() -> void:
|
||||
set_input_port_default_value(1, 1)
|
||||
set_input_port_default_value(2, 1)
|
||||
set_input_port_default_value(3, 0)
|
||||
set_input_port_default_value(4, 0)
|
||||
set_input_port_default_value(5, 0.1)
|
||||
set_input_port_default_value(3, 0.1)
|
||||
|
||||
set_output_port_for_preview(0)
|
||||
|
||||
@ -23,7 +21,7 @@ func _get_return_icon_type() -> VisualShaderNode.PortType:
|
||||
return PORT_TYPE_VECTOR_2D
|
||||
|
||||
func _get_input_port_count() -> int:
|
||||
return 6
|
||||
return 4
|
||||
|
||||
func _get_input_port_name(port: int) -> String:
|
||||
match port:
|
||||
@ -34,10 +32,6 @@ func _get_input_port_name(port: int) -> String:
|
||||
2:
|
||||
return "columns"
|
||||
3:
|
||||
return "start frame"
|
||||
4:
|
||||
return "end frame"
|
||||
5:
|
||||
return "anim speed"
|
||||
return ""
|
||||
|
||||
@ -45,9 +39,9 @@ func _get_input_port_type(port: int) -> VisualShaderNode.PortType:
|
||||
match port:
|
||||
0:
|
||||
return PORT_TYPE_VECTOR_2D
|
||||
1, 2, 3, 4:
|
||||
1, 2:
|
||||
return PORT_TYPE_SCALAR_INT
|
||||
5:
|
||||
3:
|
||||
return PORT_TYPE_SCALAR
|
||||
return PORT_TYPE_SCALAR
|
||||
|
||||
@ -85,8 +79,6 @@ func _get_code(input_vars: Array[String], output_vars: Array[String], mode: Shad
|
||||
|
||||
var rows: String = input_vars[1]
|
||||
var columns: String = input_vars[2]
|
||||
var start_frame: String = input_vars[3]
|
||||
var end_frame: String = input_vars[4]
|
||||
var anim_speed: String = input_vars[5]
|
||||
var anim_speed: String = input_vars[3]
|
||||
|
||||
return output_vars[0] + " = flipbook_uv(%s, %s, %s, %s, %s, %s);" % [uv, rows, columns, start_frame, end_frame, anim_speed]
|
||||
return output_vars[0] + " = flipbook_uv(%s, %s, %s, %s);" % [uv, rows, columns, anim_speed]
|
||||
|
@ -1,4 +1,6 @@
|
||||
vec2 flipbook_uv(vec2 uv, int rows, int columns, int start_frame, int end_frame, float anim_speed){
|
||||
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)));
|
||||
@ -7,7 +9,7 @@ vec2 flipbook_uv(vec2 uv, int rows, int columns, int start_frame, int end_frame,
|
||||
_current_sprite.x += _frame * _off_per_frame.x;
|
||||
float _row_index;
|
||||
float _mod = modf(_frame / float(columns), _row_index);
|
||||
_current_sprite.y -= _row_index * _off_per_frame.y;
|
||||
_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;
|
||||
|
Reference in New Issue
Block a user