|
|
|
 |
Attention |
Topic was automatically imported from the old Question2Answer platform. |
 |
Asked By |
MikeMikeMike |
Hi…,
I am new to shader code. My code starts like this:
shader_type particles;
const vec3 node_pos = vec3(0,0,0); // how to get the node world position?
const vec3 aabb_xyz = vec3(-1,-1,-1); // how to get this node property?
const vec3 aabb_whd = vec3(2,2,2); // how to get this node property?
Is there a way to get node parameters in the shader code? I need the node position and the aabb parameter.
Thanks
Mike
|
|
|
 |
Reply From: |
MikeMikeMike |
Hi…,
I have found the solution with the script function
set_shader_param(param: String, value: Variant)
I’ve added this script to my Particles node:
tool
extends Particles
func _process( delta : float ):
self.process_material.set_shader_param( "node_position", self.translation )
self.process_material.set_shader_param( "visi_aabb_position", self.visibility_aabb.position )
self.process_material.set_shader_param( "visi_aabb_size", self.visibility_aabb.size )
and changed the shader code to:
shader_type particles;
uniform vec3 node_position;
uniform vec3 visi_aabb_position;
uniform vec3 visi_aabb_size;
...
Thanks
Mike