Home > OS >  Get position of other GameObject with a certain shader
Get position of other GameObject with a certain shader

Time:10-25

If I have shader X and shader Y, how could shader Y get the world positions of all gameObjects with shader X?

Due to my restrictions, I can't use any MonoBehaviours for this. Only shaders.

CodePudding user response:

They cannot, shaders can't communicate with each other.

CodePudding user response:

The answer is no.

Shaders are executed as part of the rendering pipeline on the GPU, while Unity's game logic is on the CPU. So not only are shaders executed outside of Unity, they're on an entirely separate piece of hardware.

You can find more details in this link : [From unity answer][https://answers.unity.com/questions/456516/can-a-glsl-shader-fetch-gameobject-properties.html]

  • Related