0
\$\begingroup\$

@Seyed Morteza Kamali solved his own problem of rotating a mesh cubemap with shadergraph here: How can I rotate cubemap in shadergraph?

However, I have a starry night cubemap inside my Skybox shader done in Unity Shader Graph, and as there is no way to directly attach a script to a Skybox material, I've been accessing the skybox material and the shader via external script. I've been using the Bolt visual scripting, and with this script, it is fairly easy to access other properties of the skybox but not the rotation (4x4 matrix). It is possible to access floats, vector2's, texture maps and even the Cubemap, but even if I have set the cubemap rotation, which to my knowledge has to be done with a Matrix 4, as an Exposed property, when trying to access it, e.g with FindPropertyIndex it gives the value -1, indicating that the property is not found.

Edit: ok, I found this in the Unity documentation:

Matrix parameters are not exposed in the material inspector, but can be set and queried with SetMatrix and GetMatrix from scripts.

As far as I understand the documentation, the example assumes a mesh renderer, which the skybox doesn't have. Another idea would be to use 3 vectors, which could be exposed and then apply the rotation somehow to them at the same time, I did some tests in this, but all I managed to create was to distort the cubemap.

Again I am not trying to rotate the entire skybox, but just a cubemap inside the skybox shader – this would allow different rotations to daytime clouds and nighttime stars.

Would be best if everything could be done inside ShaderGraph, with the speed and axis values published as properties. A custom function perhaps? I am using URP 7.2.0 and Unity 2019.3.0f6.

\$\endgroup\$
3
  • \$\begingroup\$ What do you mean you can't use a script with a skybox material? What stops you? \$\endgroup\$
    – DMGregory
    Commented May 20, 2020 at 11:39
  • \$\begingroup\$ I mean there is no way to add / attach a script to a skybox as it is possible for a game object. I've been trying to acess the skybox through script, and can access many of the variables, but not the cubemap or its properties. \$\endgroup\$
    – Laiton Kuu
    Commented May 22, 2020 at 17:31
  • \$\begingroup\$ You should include in your question details about which rendering pipeline you're using, how you've configured your skybox so far, and how you've attempted to change it through script/shaders. \$\endgroup\$
    – DMGregory
    Commented May 22, 2020 at 17:41

0

You must log in to answer this question.

Browse other questions tagged .