Skip to content

Latest commit

 

History

History
157 lines (88 loc) · 8.2 KB

CIS565FinalProjectREADME.md

File metadata and controls

157 lines (88 loc) · 8.2 KB

Snow Rendering in Cesium

University of Pennsylvania, CIS 565: GPU Programming and Architecture, Final Project

Team Members

Yaoyi Bai

Anton Khabbaz

Yuxin Hu

Demo

Snow Rendering Over Grand Canyon

Snow Rendering Over Bay Area

Online Video Demo

enter image description here

Live Demo (Github page) Link

Live Demo (Github Page)

Main Features

  1. Snow Accumulation on Terrain
  • New Snow Material

  • Ocean Detection

  • Gradually Accumulation Effect

  • Perlin Noise on Slope

  1. Snow Falling
  • Snow Flakes

  • Gray Sky While Snowing

  • Adjustable Falling Speed

  • Adjustable Snow Heaviness

  • Adjustable Wind Direction

  • Snow Flakes Only Above the Horizon and Below 10000 Meters Above Sky

Debug Views

Normal Map Surface Normal with Normal Map
Original Terrain Surface Normal
Slope Without Perlin Noise Slope With Perlin Noise

Progress

Overview of Technique

The goal of this project is to add snow rendering feature in Cesium. We approached the problem from two parts. For snow falling particles, we referred to the ray marching sampling method in Shadertoy. For snow accumulation on ground, we applied a Cesium snow material over the terrain. The idea is taken from paper Real-time Rendering of Accumulated Snow. The snow material has a fixed diffuse color, and a fixed specular term. The alpha value of snow material is depending on the slope value of the terrain fragment. We added Perlin noise to slope and normal maps to make the snow looks more realistic. We finally we made the slope and normal maps as a function of time to animate the snow accumulation process.

Performance Analysis

Overall Performance Analysis

The performance slows down when we apply the snow rendering. The bottleneck comes from both snow material and snow falling post processing. We did the performance analysis for both features individually to find out how we could improve the performance.

Snow Falling Performance Analysis

The snow falling post processing renders the snow flakes three times with different offsets to achieve anti-aliasing. Reducing the rendering passes will improve the efficiency slightly, but even one pass will slow down the system by 1/3. In each pass the glsl shader takes samples from the graynoise texture for 32 times with different uv coordinates to fill up the screen space with snow flakes. We tested performance by reducing the sampling times. Below is the result:

Clearly the sampling times impact the performance. When the sampling times reduced to 8, the performance could match with the original system performance. However, the snow flakes will not be able to fill up the entire screen space with only 8 sampling times. From the second image above we observed that the texture image size does not affect the performance. Texture sampling part is the bottleneck of the snow falling particles rendering. If we could either reduce the number of sampling, or increase the performance of texture read itself, it would speed up the performance significantly.

Snow Material Performance Analysis

Calculation of perlin noise, and reading the normals from normal map will impact the performance. Because perlin noise is generated by adding up noise texture sampling of different frequencies, similar to the texture sampling in snow falling, it could slow down the performance.

For snow falling particles, we improved the performance slightly by reducing the sampling times in snow falling shader, and reduced the rendering pass to a single pass because we found the anti-aliasing does not have significant visual impact. For snow material, we decided to use the numerical calculation to generate the noise value instead of reading from the texture, and with that we can improve the overall performance to 20 FPS.Here is our final performance comparason.

Files Changed

Merged branch Globe Materials with branch post-processing-1.0 into our master branch

1. Snow Accumulation

  • Added SnowMaterial.glsl in "..\Source\Shaders\Materials" to apply snow color over terrain. Inside includes perlin noise generation that will be added to alpha value of the material, which is based on the terrain slope.

  • Revised GlobeFS.glsl in "..\Source\Shaders". Added variables in main() : normalWithNoise, shiness, and specular that will be assigned values in SnowMaterial.glsl. Added a boolean variable isOcean which will be assigned value if water mask is applied. This will ensure that material will only be added over terrain that is not Ocean. Modified ifdef APPLY_MATERIAL section to read extra values added in material. Modified #ifdef ENABLE_VERTEX_LIGHTING. We are checking if shiness read from material is bigger than 0, we used the modified normal read from material for shading and added a specular component in shading.

  • Revised Material.js in "..\Source\Scene", added a new material SnowMaterial.

2. Snow Falling

  • Added SnowFalling.glsl in "..\Source\Shaders\PostProcessFilters";

  • Revised PostProcessLibrary.js in "..\Source\Scene", a new post process stage called createSnowFallingStage added and a new fragment shader called SnowFalling linked to this post process stage;

  • Revised PostProcessScene.js in "..\Source\Scene", a new stage called snowFalling added;

  • Revised Post Processing.html in "..\Apps\Sandcastle\gallery", a new view model linked snow falling post process stage added to create snow falling effect based on the depthTexture in post process stage.

3. Demo HTML

  • We added a demo html page to show our snow rendering feature, under Apps/Sandcastle/gallery/, named "SnowRendering.html".

4. Texture Images Added

  • Source\Assets\Textures\grayNoiseM.png. This texture is used to for snow flake sampling.

  • Under Apps\Sandcastle\images, snowNormalMapLevel1.jpg, snowNormalMapLevel2.jpg, snowNormalMapLevel3.jpg, snowNormalMapLevel4.jpg, snowNormalMapLevel5.jpg. These normal maps are used for bumpy snow material over the terrain.

  • Under Apps\Sandcastle\images\RandomNoise256.png. This image is used for perlin noise generation.

Build Guide

Cesium has a very good documentation on how to build and compile the project on local machine. Please checkout here

Credits