-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
temp: MeshIcosahedron shader settings
- Loading branch information
Showing
5 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
extends RefCounted | ||
class_name ShaderUtils | ||
|
||
static func set_shader_param(node: MeshInstance3D, _name: String, value: Variant, idx: int = 0): | ||
var m = node.get_active_material(0) as ShaderMaterial | ||
if idx == 0: | ||
m.set_shader_parameter(_name, value) | ||
elif idx == 1 and m.next_pass: | ||
(m.next_pass as ShaderMaterial).set_shader_parameter(_name, value) | ||
elif idx == 2 and m.next_pass and m.next_pass.next_pass: | ||
(m.next_pass.next_pass as ShaderMaterial).set_shader_parameter(_name, value) | ||
elif idx == 3 and m.next_pass and m.next_pass.next_pass and m.next_pass.next_pass.next_pass: | ||
(m.next_pass.next_pass.next_pass as ShaderMaterial).set_shader_parameter(_name, value) | ||
return | ||
|
||
static func create_shader_material(_shader: Shader) -> ShaderMaterial: | ||
var sm = ShaderMaterial.new() | ||
sm.shader = _shader | ||
return sm | ||
|
||
static func apply_shaders(_shaders: Array[Shader], node: MeshInstance3D) -> MeshInstance3D: | ||
for i in _shaders.size(): | ||
var m := create_shader_material(_shaders[i]) | ||
node.set("material_override" + "/next_pass".repeat(i), m) | ||
return node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters