jiaozi158 / UnityVolumetricCloudsURP

Volumetric Clouds for Unity URP (Universal Render Pipeline).
MIT License
133 stars 9 forks source link

Help with implementing floating point origin script for the clouds #7

Closed CommanderRT closed 1 week ago

CommanderRT commented 1 week ago

I was trying to move the clouds in my own floating origin script but I have found no way to serialize the clouds in my own script, any suggestions? Any help would be appreciated.

jiaozi158 commented 1 week ago

Hi, can you briefly describe what you need to do with the clouds so that I could help?

I assume you're trying to offset the clouds so that the appearance stays the same after moving the camera (changing origin).

You can refer to this HDRP Volumetric Clouds discussion thread to know more about applying the offset.

but I have found no way to serialize the clouds in my own script

Not sure if I understand it correctly, but an example (untested) to change the Shape Offset property could be like this:

using UnityEngine.Rendering;

// Get the interpolated volume stack from current scene
var stack = VolumeManager.instance.stack;

// Get the volumetric clouds volume
VolumetricClouds cloudsVolume = stack.GetComponent<VolumetricClouds>();
bool isValid = cloudsVolume != null && cloudsVolume.IsActive();

// Apply your offset value
if (isValid)
{
    cloudsVolume.shapeOffset.value = newShapeOffset;
}

Hope this helps!

CommanderRT commented 1 week ago

Hi, I was trying to implement the offset in my own script and was looking for a way to serialize the clouds in my script and I haven't found a way to do so. I will test out your solutions and get back with the results I hope it will work, thanks for help!

CommanderRT commented 1 week ago

And it worked! Thanks for the solution, it was also an issue with my origin shift script, after I pasted this code to the script it gave me the same error but after pasting it to another much simplier code it worked! Thank you again, and your URP port of clouds is amazing!