Coder Social home page Coder Social logo

simeonradivoev / gpu-planetary-rendering Goto Github PK

View Code? Open in Web Editor NEW
182.0 16.0 22.0 14.27 MB

GPU atmosphertic scattering and planet generation in Unity 3D

License: Apache License 2.0

C# 73.62% HLSL 20.50% ShaderLab 5.87%
unity charp postprocessing graphics compute-shader shader unity3d planet atmosphere hlsl

gpu-planetary-rendering's Introduction

Unity Planet Rendering

A full scale planetary rendering in Unity 3D. Using precomputed atmospheric scattering as an image effect. Generating large planets with GPU noise, using compute shaders.

Atmosphere Scattering Based on Eric Bruneton's Precomputed Atmospheric Scattering

Instructions

The main scene is called PlanetSphereTest. The camera Controls are as follows:

  • E/Q - row camera
  • W/A/S/D - move camera
  • Mouse Scroll - Increase/Decrease camera speed
  • Space - Show/Hide mouse
  • C - Take Screenshot at Double the Screen Resolution
  • X - Exit Application

Updated to Unity 2019.2.8f1

Requirements

  • A GPU with compute shader capability
  • A GPU with async GPU reading capability

Screenshots

Screenshot1 Screenshot2 Screenshot3 Screenshot4 Screenshot5 Screenshot6

gpu-planetary-rendering's People

Contributors

simeonradivoev avatar

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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

gpu-planetary-rendering's Issues

Physics not working in Unity 2021?

Hi,
When I add an object with a RigidBody, the object keeps going through the planet mesh.
I noticed that if I disable and then re-enable the mesh collider on the chunck of the planet mesh from the Unity editor instead, the physics works again.

Looks like the mesh collider bounds need to be recalculated somewhere.

Any suggestion?

I am using Unity 2021.3.3f1

How to create continent?

I am looking into how to generate separated continents instead of a massive land.
Having some flat zones helped, even though it still looks like a repetitive amount of mountains with some flat zones.

Is there a way to get some control on how to create separated continents which would feel more organic?

I am trying to play with the noise values, but the overall profile is always the same.

I read the way to do it is to mix multiple noises, but I can't see any good result.

Any suggestion / in-code pointers?

How to define the sea level?

Hi, this project is really cool, I was wondering if there is a specific noise configuration to define a sea level for the generated world?

At the moment it gets generated like a massive land with mountains, but is there a way to have flat zones which would translate in water?

VR Support

Hello, I'm looking into adding VR Support. I've read unity docs here on single pass instanced and it seems like this is bugged for the deferred rendering pipeline. Multi Pass seems to work, but I'm not sure how I should be calculating the offset for this. Currently it is doubling, I see two suns because they do not align properly on each eye.

I've tried using UnityStereoScreenSpaceUVAdjust but this returns my UV coord unmodified. I'm guessing its only for single pass stereo rendering. Now I'm looking into grabbing the left and right cameras and injecting the offset/scale manually into the ComputeBuffer although I'm not completely sure how to calculate this. Do you know how to set this up for VR?

I'll post my solution if I find one.

Skybox support?

Great work! Is it possible to get some sort of skybox support with this atmospheric scattering effect?

Horizon Boundary Artifact

I noticed that when you transition from the ground calculations to the look up texture that is the upper sky for both attenuation and inscatter, it fails to detect mountains and uses the lookup texture instead. Do you have any ideas how to go about fixing this, I'm a little bit stumped on a solution.

bug

Creating an earth sized planet

Hi,
Looking at the code I can see that the radius of the planet is set around 6300 , which is kind of the earth radius (6371 km).

Can you confirm that radius value is expressed in km? Or are these meters instead?

If they are meters, any suggestions how to achieve 1000 times bigger radius?

Elevation based mesh colors

Hi,
I am trying to give the planet different colours to the mesh based on the elevation.

For instance:
Blue->green->light brown -> dark brown -> white

Can you suggest how I could achieve this in your code?

I see there is a terrainHeight property in the surface shader, but doesn't look like it used.

I would assume what is needed to do is something like:

  1. Calculate the min and max elevation of the planet while it gets generated
  2. Define a gradient which maps the minMax range.
  3. Evaluate the color of the current vertex based on its elevation against the gradient

Do you have any suggestion on how to achieve this? Quite new to shaders, so any suggestion/guidance on how to implement this in your code would be appreciated.

The first issue would be how to know Min and max elevation of the planet and how to know the elevation of the single vertex.

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.