Compare commits
No commits in common. "v10.2" and "v10.1" have entirely different histories.
4 changed files with 8 additions and 26 deletions
10
README.md
10
README.md
|
@ -62,17 +62,15 @@ Example:
|
||||||
//!load ...
|
//!load ...
|
||||||
//!steps 5
|
//!steps 5
|
||||||
|
|
||||||
uniform int STEP;
|
uniform int STEP; // this is mandatory!
|
||||||
uniform int STEPS;
|
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
if (STEP == 0) {
|
if (STEP == 0) {
|
||||||
...
|
...
|
||||||
} else if (STEP == 1) {
|
} else if (STEP == 1) {
|
||||||
...
|
...
|
||||||
} else if (STEP == STEPS-1) {
|
|
||||||
...
|
|
||||||
}
|
}
|
||||||
|
// ... and so on
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ config_version=5
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Fragmented"
|
config/name="Fragmented"
|
||||||
config/version="v10.2"
|
config/version="v10.1"
|
||||||
run/main_scene="res://src/scenes/main.tscn"
|
run/main_scene="res://src/scenes/main.tscn"
|
||||||
config/features=PackedStringArray("4.4", "Mobile")
|
config/features=PackedStringArray("4.4", "Mobile")
|
||||||
config/icon="res://src/assets/icon.png"
|
config/icon="res://src/assets/icon.png"
|
||||||
|
|
|
@ -13,15 +13,3 @@ vec4 alpha_blend(vec4 b, vec4 a) {
|
||||||
vec3 col = ((a.rgb*a.a) + ((b.rgb*b.a) * (1.0 - a.a)) / alpha);
|
vec3 col = ((a.rgb*a.a) + ((b.rgb*b.a) * (1.0 - a.a)) / alpha);
|
||||||
return vec4(col.r, col.g, col.b, alpha);
|
return vec4(col.r, col.g, col.b, alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Rotate UV
|
|
||||||
*/
|
|
||||||
|
|
||||||
vec2 rotateUV(vec2 uv, float rotation, vec2 center) {
|
|
||||||
float cosRot = cos(rotation);
|
|
||||||
float sinRot = sin(rotation);
|
|
||||||
return vec2(
|
|
||||||
cosRot * (uv.x - center.x) + sinRot * (uv.y - center.y) + center.x,
|
|
||||||
cosRot * (uv.y - center.y) - sinRot * (uv.x - center.x) + center.y);
|
|
||||||
}
|
|
||||||
|
|
|
@ -37,9 +37,9 @@ func validate_shader_compilation(shader: Shader) -> bool:
|
||||||
# test if uniform list is empty -> if it is empty, the shader compilation failed
|
# test if uniform list is empty -> if it is empty, the shader compilation failed
|
||||||
return len(shader.get_shader_uniform_list()) > 0
|
return len(shader.get_shader_uniform_list()) > 0
|
||||||
|
|
||||||
func shader_has_uniform(shader: Shader, name: String, type: int) -> bool:
|
func shader_has_step_uniform(shader: Shader) -> bool:
|
||||||
for u in shader.get_shader_uniform_list():
|
for u in shader.get_shader_uniform_list():
|
||||||
if u["name"] == name && u["type"] == type:
|
if u["name"] == "STEP" && u["type"] == 2:
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
@ -55,8 +55,7 @@ func update(overwrite_image_path: String = "") -> Array: # returns error message
|
||||||
return ["No shader opened!"]
|
return ["No shader opened!"]
|
||||||
# get number of steps & check if code has STEP uniform
|
# get number of steps & check if code has STEP uniform
|
||||||
var steps: int = ShaderDirectiveParser.parse_steps_directive(shader.code)
|
var steps: int = ShaderDirectiveParser.parse_steps_directive(shader.code)
|
||||||
var has_step_uniform: bool = shader_has_uniform(shader, "STEP", 2)
|
var has_step_uniform: bool = shader_has_step_uniform(shader)
|
||||||
var has_steps_uniform: bool = shader_has_uniform(shader, "STEPS", 2)
|
|
||||||
# validate shader
|
# validate shader
|
||||||
if not validate_shader_compilation(shader):
|
if not validate_shader_compilation(shader):
|
||||||
return ["Shader compilation failed!"]
|
return ["Shader compilation failed!"]
|
||||||
|
@ -106,9 +105,6 @@ func update(overwrite_image_path: String = "") -> Array: # returns error message
|
||||||
image_sprite.material = mat
|
image_sprite.material = mat
|
||||||
# iterate n times
|
# iterate n times
|
||||||
set_vsync(false) # speed up processing
|
set_vsync(false) # speed up processing
|
||||||
if has_steps_uniform:
|
|
||||||
# set STEPS param
|
|
||||||
mat.set_shader_parameter("STEPS", steps)
|
|
||||||
for i in range(steps):
|
for i in range(steps):
|
||||||
if has_step_uniform:
|
if has_step_uniform:
|
||||||
# set STEP param
|
# set STEP param
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue