GithubHelp home page GithubHelp logo

landonth / unity-vfx-shadergraph-curves Goto Github PK

View Code? Open in Web Editor NEW
29.0 2.0 2.0 382 KB

Unity Shader Graph generated per particle animation curves for Visual Effect Graph

C# 61.63% HLSL 38.37%

unity-vfx-shadergraph-curves's Introduction

Unity VFX ShaderGraph Curves

An exercise to test the feasibility of using Unity Shader Graph (and custom function nodes) to generate per particle animation curves for Visual Effect Graph. This started as a conversation with Carlos Garcia / L05 on the Unity discord. In this case, ADSR style envelopes (attack, decay, sustain, release) are generated. A simple impulse curve and a test pattern generator is included as well. Credit to fsynth for the adsr and impulse functions and also indirectly to Inigo Quilez.

This could be further simplified in forthcoming release of visual effect graph with support for arrays. Then a custom shader or Shader Graph may not be needed at all. I can think of a few other ways to approach this with futures in mind as well. Such as setting the ADSR float4 directly as an attribute for each particle, and procedurally look up the curve at runtime in the vfx graph compute context using the age attribute, which avoids generating a buffer at all. this would require some sort of custom function block and or operator which I believe is on the roadmap as well.

If it's a workable solution to do the envelope lookup before / outside of vfx graph and just have the current attribute values like "current size" streamed into vfx graph on a smaller buffer.. instead of a buffer of envelopes that vfx graph has to sample per particle to determine the current value of based on particle age.

Currently The main thing I'm not happy with is that there is no built-in way yet to create a Shader Graph that renders directly into a Texture2D or Texture3D. So this example uses an orthographic camera that is masked to only see a quad with the HDRP Unlit shader graph material applied to it. It would be much cleaner and more flexible (Texture3D, Texture2D array support, Alpha Channel support) to have a Render Texture Shader Graph type available. In fact LG has shown this possible in a fork of HDRP they made for a robotics simulator a while back that can be found on github with a "Custom RenderTexture ShaderGraph," but I had limited success in porting it from HDRP 5.1 to 7.1 and decided against pursuing it further as it would actually be cleaner to start over fresh.

ShaderGraph Custom Functions VisualEffectGraph Particles

unity-vfx-shadergraph-curves's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

l05 avatarchik

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.