0 votes

hi, i'm having trouble changing the shader parameter from gdscript. i know this might be a silly question but it is a huge headache for me, so i'm asking it here

here are my scenes

1) container:
enter image description here
the stars node has a script attached which has the following code

func _ready():
    for i in range(10):
        var instance = star_scene.instance()
        add_child(instance)

2) star:
enter image description here
the star node has a script attached which has the following line in the _ready function
enter image description here
the texturerect node has a material setup like this
enter image description here

the star.shader file just has this

void fragment() {
    COLOR.rgb = col.rgb;
}

when i run the game, all star nodes have the same color, i want them to have separate color
i have made the shadermaterial unique, still the problem persists

Godot version Godot_v3.4-stable_win64
in Engine by (63 points)
edited by

1 Answer

+3 votes
Best answer

I hated this problem in Godot before, now I can gladly share sollution :). There is another parameter required to allow resources to be unique. Look at your 5th posted image, there is Resource tab. Choose it and tag "localtothe_scene".

by (7,925 points)
selected by

this worked! thank you so much

Exactly what I needed!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.