Page 1 of 1

How to access a value via script?

PostPosted: Sun Sep 09, 2018 11:38 pm
by AndrewMyriad
Hi there,

Is there a way to access a value that's being calculated by a shader at runtime (that isn't an input value that can be set to Property)?

For example I'm using sine of time and remapping the values to within a certain range to alter a value over time in my shader. I'm wanting to access via script what the result of those calculations are at any given time to affect something else. All I've been able to find so far is accessing values that are set to Property which are used as inputs via script, not the result of something being calculated within the shader.

Thanks!

Re: How to access a value via script?

PostPosted: Mon Sep 10, 2018 11:49 am
by Ricardo Teixeira
AndrewMyriad wrote:Hi there,

Is there a way to access a value that's being calculated by a shader at runtime (that isn't an input value that can be set to Property)?

For example I'm using sine of time and remapping the values to within a certain range to alter a value over time in my shader. I'm wanting to access via script what the result of those calculations are at any given time to affect something else. All I've been able to find so far is accessing values that are set to Property which are used as inputs via script, not the result of something being calculated within the shader.

Thanks!


Hello,

I don't believe that's possible with the currently provided shader types, with or without ASE. Perhaps with Compute Shaders, which we don't currently support, but I don't recommend it.

What type of shader are you trying to build, and why not pass the Sine Time value directly to the shader instead of the other way around?

Looking forward to your reply, thanks!

Re: How to access a value via script?

PostPosted: Tue Sep 11, 2018 2:19 am
by AndrewMyriad
Thanks for the reply! It's just a pulsating light effect on an object and another team member handling audio wanted to be able to access the intensity to be able to reference that pulse timing.

I hadn't considered using a script to calculate the intensity and then passing that into the shader instead of trying to pull the calculated value out from the shader, that makes a lot of sense. Will definitely give that a go. :)

Thanks!

Re: How to access a value via script?

PostPosted: Tue Sep 11, 2018 11:12 am
by Ricardo Teixeira
AndrewMyriad wrote:Thanks for the reply! It's just a pulsating light effect on an object and another team member handling audio wanted to be able to access the intensity to be able to reference that pulse timing.

I hadn't considered using a script to calculate the intensity and then passing that into the shader instead of trying to pull the calculated value out from the shader, that makes a lot of sense. Will definitely give that a go. :)

Thanks!


Hope it works out!