0

I need to get the actual size of the object within shader graph. I currently only have the Object > Scale node or the option of manually setting the size of object in runtime.

Is there some way I can easily get the size of the object (or bounds) within shader graph?

  • It wouldnt be an easy thing to do since accessing the mesh data is quite resource intensive. I suggest you write a separate script that tracks the size and feed the value from there in update. – error13660 Jan 18 '22 at 07:44
  • ahh man, I was looking for some way to automate it instead of material.setfloat(someVariable) every time just for cleaner finish. thx though – poweredbygeeko Jan 20 '22 at 08:37
  • I can understand that, And it might be possible to do by writing a custom HLSL shader code, but it can get quite complicated very quickly, so i would only do that if that's my only option. – error13660 Jan 20 '22 at 12:17
  • ahh, okay... thanks!!! – poweredbygeeko Jan 20 '22 at 17:16
  • Sorry i was wrong! you can get the size and position, i have just come across it! – error13660 Feb 11 '22 at 16:58

2 Answers2

0

To get the position and scale of your actual game object, you need a node called Object which can be found under Input/Scene/Object.

error13660
  • 120
  • 7
  • mm i'm aware of this but I was looking for the actual size of the object, not just the scale. for e.g. renderer.bounds.size. – poweredbygeeko Feb 13 '22 at 16:24
  • Ah i see. In this case maybe you could attach a script that sets a value in the shader that you are using on the object on Awake(), and while the game is running, you can yust use that value and the Object.scale. (It still wouldn't be that elegant, but performancewise still not bad) – error13660 Feb 14 '22 at 20:36
0

Shader Graph 14.0.3 Object Node has,

  • World Bounds Min: Minimum value of the renderer bounds in world space
  • World Bounds Max: Maximum value of the renderer bounds in world space
  • Bounds Size: Size of the renderer bounds
esgnn
  • 126
  • 4