Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question Simulating wind with render texture and ECS

Discussion in 'Entity Component System' started by mlodinov, Oct 12, 2023.

  1. mlodinov

    mlodinov

    Joined:
    Feb 4, 2014
    Posts:
    4
    I just started learning ECS and I want to simulate strong wind stream from some point. For representing wind I created a custom render texture with Shader graph which is also animated and updates every frame. It a black and white texture where each pixel represents power of the wind. The idea is that I can affect physics objects by calling AddExplosionForce and power value will depend on render texture pixel value for according world position of physics object.
    The problem is that I don’t know how to get reference for wind render texture. I tried creating regular component with render texture as a field but baker gives me some “non-nullable” error.
    Am I doing something wrong? Is it even a good approach?
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,987
    Personally, I would translate the shader graph into a Burst job and not deal with the RenderTexture object. There are known issues with baking RenderTexture object references, so you would have to construct and wire up your RenderTexture at runtime. You'd at least be using async readback for retrieving the RenderTexture, right?