Amplifying your potential.

Scriptable Variable Options

Node-based Shader Editor
2 posts • Page 1 of 1

Scriptable Variable Options

Postby jpac » Fri Dec 29, 2017 4:00 pm

Hi,

I was trying to figure out how to add a Matrix4x4 as a node option, I see it's only global or constant. I know you can't have a property of type Matrix, but in code you can define a matrix and then in c# you can do material.SetMatrix(). Is there a way to do a node that is like that type of a variable? Like a 'scriptable matrix property' or something?

If not, is this something you will add in the future? This would be helpful for all types, Matrix, Textures, floats, etc. I know the node editor won't have any way of 'live editing' the value, but it would be helpful.

My case in particular is that I'm trying to pass a matrix in for a Texture Matrix. I can do this with separate math for translation, rotation, etc. I'd prefer to do a matrix.

Thanks!
jpac
 
Posts: 1
Joined: Fri Dec 29, 2017 3:43 pm

Re: Scriptable Variable Options

Postby Amplify_Borba » Fri Dec 29, 2017 5:09 pm

jpac wrote:Hi,

I was trying to figure out how to add a Matrix4x4 as a node option, I see it's only global or constant. I know you can't have a property of type Matrix, but in code you can define a matrix and then in c# you can do material.SetMatrix(). Is there a way to do a node that is like that type of a variable? Like a 'scriptable matrix property' or something?

If not, is this something you will add in the future? This would be helpful for all types, Matrix, Textures, floats, etc. I know the node editor won't have any way of 'live editing' the value, but it would be helpful.

My case in particular is that I'm trying to pass a matrix in for a Texture Matrix. I can do this with separate math for translation, rotation, etc. I'd prefer to do a matrix.

Thanks!


Hello jpac, thank you for getting in touch!

In shaders, matrices can only be set as global shader variables, not properties, so you may only set them within the editor or via script, since Unity does not recognize matrices as properties and, as a result, they can't be exposed in the material inspector.

The only means of achieving what you intend is via script, which will allow for live editing of the matrices via the script component in the game object, and through the following code as long as the Matrix Nodeit's set to Global in the Node Properties:
Shader.SetGlobalMatrix( "_MyMatrix", matrix );
myMaterial.SetGlobalMatrix( "_MyMatrix", matrix );

Please let us know if this information was useful, we would be happy to elaborate.
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 181
Joined: Mon Jul 24, 2017 9:50 am


2 posts • Page 1 of 1

Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 1 guest