Code Monkey home page Code Monkey logo

aurora's Introduction

Aurora

Ray-Marched Aurora Borealis in Unity URP

Auroras

This Aurora Borealis was made using Unity's Scriptable Render Pipeline. The auroras are ray marched in a post processing shader that I wrote.

The idea is as follows:

  1. First we reconstruct the world space position of each uv coordinate in the screen (in our case we sample the depth texture to return early any pixel which is not on the far clipping plane) and then we get the noramlized vector from the camera to this world space position. This is our view direction.

  2. From here, we can define two spheres mathematically. The spheres will share the same origin, whith one having a larger radius than the other. The distance in between the spheres will be the area we draw our auroras. We define the origin of the spheres as somewhere below the camera. From here we can calculate the intersection point of the ray with the sphere. The radius of our inner sphere will be larger than the vertical distance from our camera to our sphere origin, i.e, our camera will be within the sphere.

  3. Once we get this intersection point of our view direction with the inner sphere, we can begin to ray march along this path, that is, along the view direction of the ray. This ray will start at the intersection of the inner sphere, and end at the intersection of the outer sphere. At each point along this ray march, we will get the vector from the ray position to the sphere's origin. We can use this to sample, using uv coordinates, a texture that will represent our aurora.

From here the work is mostley behind us. We can scrolling noise now to create movement in our auroras, and to break up the auroras into different parts.

Here is a GIF of the auraras. Unfortunately Github doens't allow me to upload anything high quality.

movie_010 (2)

aurora's People

Watchers

Alden DelVecchio avatar

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.