# How can I detect if I am inside a volumetric cloud? UE5.1.1

**URL:** <https://forums.unrealengine.com/t/how-can-i-detect-if-i-am-inside-a-volumetric-cloud-ue5-1-1/793696>\
**Category:** Blueprint\
**Tags:** unreal-engine, Volumetric-Clouds, Shaders, Blueprint, question\
**Created:** [March 18, 2023, 3:51pm UTC](https://forums.unrealengine.com/t/how-can-i-detect-if-i-am-inside-a-volumetric-cloud-ue5-1-1/793696 "2023-03-18T15:51:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![G31](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@G31](https://forums.unrealengine.com/u/G31)\
**Post date:** [March 18, 2023, 3:51pm UTC](https://forums.unrealengine.com/t/how-can-i-detect-if-i-am-inside-a-volumetric-cloud-ue5-1-1/793696/1 "2023-03-18T15:51:51Z")

</div>

I want to add effects when the player is inside a volumetric cloud. Can someone give me an idea how to do it? Thank you.

---

<div class="post-metadata">

**Author:** ![High500](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/high500/32/906557_2.png) [@High500](https://forums.unrealengine.com/u/High500)\
**Post date:** [March 18, 2023, 8:52pm UTC](https://forums.unrealengine.com/t/how-can-i-detect-if-i-am-inside-a-volumetric-cloud-ue5-1-1/793696/2 "2023-03-18T20:52:30Z")

</div>

Well to do so, how are you implementing the volumetric cloud?

---

<div class="post-metadata">

**Author:** ![G31](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@G31](https://forums.unrealengine.com/u/G31)\
**Post date:** [March 18, 2023, 11:14pm UTC](https://forums.unrealengine.com/t/how-can-i-detect-if-i-am-inside-a-volumetric-cloud-ue5-1-1/793696/3 "2023-03-18T23:14:09Z")

</div>

I am using a volume material based on this tutorial:

https://www.youtube.com/embed/paO-Its5P2Q?feature=oembed&wmode=opaque&list=PLIxJB8bm2Y11ZX8oCMZQxtX4Nx_0kmwj3

My version is a little more complex, since I use more textures to generate the shape of the cloud, but the operation is the same.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![High500](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/high500/32/906557_2.png) [@High500](https://forums.unrealengine.com/u/High500)\
**Post date:** [March 19, 2023, 8:47am UTC](https://forums.unrealengine.com/t/how-can-i-detect-if-i-am-inside-a-volumetric-cloud-ue5-1-1/793696/4 "2023-03-19T08:47:09Z")

</div>

Ok so you made a material what are you attaching it to to in editor to make the cloud appear ingame?

---

<div class="post-metadata">

**Author:** ![G31](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@G31](https://forums.unrealengine.com/u/G31)\
**Post date:** [March 19, 2023, 2:47pm UTC](https://forums.unrealengine.com/t/how-can-i-detect-if-i-am-inside-a-volumetric-cloud-ue5-1-1/793696/5 "2023-03-19T14:47:44Z")

</div>

Is the “Cloud material” of the “Volumetric Cloud Component”

---

<div class="post-metadata">

**Author:** ![High500](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/high500/32/906557_2.png) [@High500](https://forums.unrealengine.com/u/High500)\
**Post date:** [March 19, 2023, 2:54pm UTC](https://forums.unrealengine.com/t/how-can-i-detect-if-i-am-inside-a-volumetric-cloud-ue5-1-1/793696/6 "2023-03-19T14:54:12Z")

</div>

it allows for a physics material not sure if you can manipulate that in any way. thing is im not sure the component has collisions, and im guessing if it did, it would be volume wide and not just where the clouds are. I think im at my limits on this, unless when you create each cloud you can spawn in a volume of some sort per cloud (which may get intense for the engine) then im not the one sorry!

---

<div class="post-metadata">

**Author:** ![GehtSieGarNixAn](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gehtsiegarnixan/32/611835_2.png) [@GehtSieGarNixAn](https://forums.unrealengine.com/u/GehtSieGarNixAn)\
**Post date:** [March 20, 2023, 7:46am UTC](https://forums.unrealengine.com/t/how-can-i-detect-if-i-am-inside-a-volumetric-cloud-ue5-1-1/793696/7 "2023-03-20T07:46:22Z")

</div>

Here’s a [public UE project that implements, among other things, how to sample a volumetric cloud material using a dynamic material instance and render targets in UE](https://gitlab.lrz.de/kenkenberg/cloud-thesis). The basic steps are as follows:

1. Make a copy of your cloud material or use the conservative density, which needs to have a parameter for the UVW coordinates so you can change where it samples the cloud material. Ensure all other settings for the material are the same, so if you set the UVW coordinates to a position in the world, it’s the same as the cloud material.
2. Create a 1px render target and make a dynamic material instance of your cloud material duplicate so you can change the UVW coordinates at runtime to the player position or wherever else you need to sample.
3. Update the render target and then sample the texture on the CPU using either blueprints, which is very inefficient, or C++, which works faster. In the [example project](https://gitlab.lrz.de/kenkenberg/cloud-thesis), a single pixel sample every second should not cause any noticeable performance drop.
4. Use the information from the sample for whatever you want. In the linked example, it is used for wind vectors and rain density to be in sync with the clouds.

I hope this helps!

---

<div class="post-metadata">

**Author:** ![G31](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@G31](https://forums.unrealengine.com/u/G31)\
**Post date:** [March 20, 2023, 10:47pm UTC](https://forums.unrealengine.com/t/how-can-i-detect-if-i-am-inside-a-volumetric-cloud-ue5-1-1/793696/8 "2023-03-20T22:47:50Z")

</div>

Hello. Thanks for the reply.  
Today, before reading you, I had come to a similar solution. Unfortunately, the read operation causes performance drops, even when I am reading only 1 pixel.  
I’ll have to see how to implement it in c++ (never code in c++ for unreal). I’ll see what I’ll do  
If you can guide me I would appreciate it.

---

<div class="post-metadata">

**Author:** ![GehtSieGarNixAn](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gehtsiegarnixan/32/611835_2.png) [@GehtSieGarNixAn](https://forums.unrealengine.com/u/GehtSieGarNixAn)\
**Post date:** [March 21, 2023, 8:30am UTC](https://forums.unrealengine.com/t/how-can-i-detect-if-i-am-inside-a-volumetric-cloud-ue5-1-1/793696/9 "2023-03-21T08:30:34Z")

</div>

I would recommend watching a beginner guide for Visual Studio for UE.

You can optimize the blueprint version by delaying the texture reads to only read every few seconds and not every frame. You could also only updating it if the clouds or the player move far enough.

If most of your code is in blueprints, you could create a C++ function with the functionality and make it BlueprintCallable, so you don’t have to bother with C++ again.

To read textures in a more performant way you want async readback from the GPU, you can use FRHIGPU Readback, which is how the engine does it. There are many resources online for this, and ChatGPT can also provide further information. I haven’t implemented it with C++ yet, but I plan to do so in a month or two.
