Coder Social home page Coder Social logo

hlembeck / cascadedshadowmap Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 272 KB

Originally created to learn DX12 by making a cascaded shadow map (multiple shadow maps that cover the view frustum, to increase precision) and testing on many instanced cubes. Is now a project that aims to create a simulator for exploring celestial bodies.

C++ 51.79% HLSL 9.28% C 38.93%
cascaded-shadow-mapping directx12 level-of-detail procedural-generation

cascadedshadowmap's Introduction

Cascaded Shadow Map (CSM)

The implementation of CSM is standard, but is not linked with Celestial Body implementation yet (no shadows for celestial bodies). This portion will be updated when the two are linked.

Celestial Body

Planet

A planet is defined in part by its roughly spherical shape, although in reality planets form an ellipsoid. For simplicity, the spherical base is used for all planets.

The surface of any planet can be bound between two spheres, namely the inner sphere and the outer sphere. The inner sphere has radius equal to the minimum altitude of the planet's surface, and the outer sphere has radius equal to the maximum altitude of the planet's surface. The minimum and maximum values can be easily shown to exist by noting that the image of a compact space under a continuous map is compact (continuous map is $S^2\to\mathbb{R}$ taking point on sphere to its altitude; here we use that our terrain is a heightmap on the sphere). One might also take the outer sphere to be defined by the planet's atmosphere, and in fact the implementation may use this radius in the future.

The planet can be roughly rendered with no LOD by passing a cube to the graphics pipeline, normalizing its points, and then applying noise and transforming to world coordinates. Applying LOD using this scheme may be difficult if the input cube is not oriented to the camera position, so a transform is done to align the cube so that its close face is orthogonal to the vector from the camera position to the planet center. Given this orientation, LOD can be applied by determining a rectangular region of each face to be rendered, and applying a sort of persistent grid to this region. The interested reader may see the code in Planet.cpp and PlanetTiler.hlsl.

Determining the rectangles to render is done based on the view cone (not frustum, for simplicity). First, for each bounding ray of the cone, determine the points of intersection with the outer sphere.

cascadedshadowmap's People

Contributors

hlembeck avatar

Watchers

 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.