Git Product home page Git Product logo

brunetons-atmospheric-scatter's Introduction

Brunetons-Atmospheric-Scatter

This is a port of Eric Brunetons precomputed atmospheric scattering project into Unity. Single scatter is quite easy to compute but most of the interesting atmospheric effects come from multiple scattering. The idea is that the effects from multiple scattering can be precomputed and stored as a lookup table.

The inscatter table is unfortunately 4 dimensional. This means it must be stored in a 3D texture which makes sampling from it a little tricky but it is possible. I have also included the code to create the tables. There's also a transmittance and a irradiance table but these are only 2D so can be stored in a normal texture. The irradiance one is not actually used for this project. These tables are stored as raw files. Unity wont include these in the build so you will have to manually place them in the build or change them to a supported file format like exr.

The code to make the tables was found in the Proland project by the same author. This is all done on the GPU using shaders. The process is very complicated and was rather difficult to port from OpenGL to Direct Compute and produce the same effect. I have got my code to reproduce the tables very closely but they are not quite the same. Mine are off slightly less intensity and there is a pixel offset issue at the horizon. Never did work out the cause of those issues but it still works fine.

This project contains three scenes. One is just the atmospheric scattering on a sky dome. The other one will create the tables when run. The third one applies the scattering as a post effect so all objects in the scene will automatically have the effect applied to them with no changes required to their materials.

The post effect is something I have added and works quite well but more work would be needed to be practical. There is a issue with how to blend between the sky which needs to be handled differently (it has the scatter applied in its material, not the post effect) and everything else in the scene. I have just presumed where the depth buffer is one it has not been written to so must be the sky. This mostly works but you will end up will artifacts due to precision issues.

You can download a Unity package here.

There is a newer improved version of this project here.

Brunetons Atmospheric Scatter

brunetons-atmospheric-scatter's People

Contributors

scrawk 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.