Search Unity

Question Can't expose any of the Matrix properties

Discussion in 'Shader Graph' started by TheSmokingGnu, Jun 24, 2020.

  1. TheSmokingGnu

    TheSmokingGnu

    Joined:
    May 1, 2017
    Posts:
    22
    Hello, so we are not able to expose even the Matrix4x4 property which is supported by the shaders (SetMatrix/GetMatrix), or am I missing something?
    upload_2020-6-25_0-1-6.png
     
  2. ExatexX

    ExatexX

    Joined:
    Jun 24, 2018
    Posts:
    3
    I have the same issue. If you create the property, you cannot set the Tickbox "Expose". You can Create A Matrix node by right clicking -> Create Node -> e.g. Matrix/Matrix4x4and then right click on the node -> convert to -> Property (than the box is automatically ticked), but the generated code till does not show the Matrix as exposed uniform.
     
    ChaoAT1 likes this.
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    You can't expose matrices because Unity's material inspector & serialization doesn't support matrices. If you want an exposed matrix you need to use 4 Vector 4 properties and combine them into a matrix in the graph. If you plan on setting the matrix via script, which is usually the case when you're using matrices, then there's no need for it to be exposed. You can still use
    SetMatrix()
    on the material to set the value.
     
  4. LagField

    LagField

    Joined:
    Nov 30, 2015
    Posts:
    4
    the issue is if we can not enable the expose option,the generated code will put the float4x4 property outside the CBUFFER_START(UnityPerMaterial) Block,which will cause shading error when enable the srp batch options.the urp will share wrong property between materials.
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    I'd report this as a bug then. Still probably don't want it "exposed" as I wouldn't expect them to add support to the material class or inspector for matrices, but perhaps a "per material" option specifically for matrices would be a nice add.

    Though they'll probably just tell you to use multiple Vector4 properties instead.
     
  6. acnestis

    acnestis

    Joined:
    Sep 11, 2019
    Posts:
    15
    I am trying to create a custom decal projector. The VP matrix is set via script, determining the decal's position. If _VPmatrix is not an exposed property, then all the decal materials will share the same _VPmatrix, making all the decals overlap. In URP I put
    float4x4 _VPmatrix;
    into CBUFFER so that different materials can have different _VPmatrix. The result looks nice but I am not sure if this is the right solution?