Coder Social home page Coder Social logo

pclod / shtest Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dwilliamson/shtest

0.0 1.0 0.0 9.56 MB

Spherical Harmonic Lighting (Direct/Shadowed/Indirect/Subsurface)

C++ 1.67% Roff 10.75% HTML 1.44% Shell 1.81% C 79.13% Makefile 0.03% PostScript 2.63% Tcl 2.54% Batchfile 0.01%

shtest's Introduction

Spherical Harmonic Lighting

Don Williamson, June 2003

This is an implementation of Spherical Harmonic Lighting to partially simulate Global Illumination on a per-vertex level in real-time.

Screenshot

The structure of the program follows directly from the material written in Robin Green's excellent GDC2003 presentation. It basically functions as an object viewer with many modes. You can rotate all objects you can see by clicking the left mouse button on the window and dragging in any direction. You can change modes by pressing the space bar. The modes are:

  1. Monte-carlo estimator samples on the sphere.
  2. Associated Legendre plot.
  3. 3D representation of spherical harmonic bases.
  4. Comparison of an original spherical lighting function (left) and it's SH projected equivalent (right, 4 bands).
  5. Simple OpenGL-lit beethoven bust.
  6. Same model diffusely lit by HDR lightsource (rnl_probe.hdr).
  7. Diffusely lit with self-shadowing.
  8. Diffusely lit with self-shadowing and inter-reflectance.

This is a Win32 OpenGL program that any recent (last 13 years) video card should be able to run.

The simulation starts by generating SH co-efficients for each vertex in 3 types of lighting model: diffuse unshadowed, diffuse shadowed, and diffuse inter-reflected. For each vertex, integration over the sphere is performed using a Monte-Carlo integrator with 10,000 samples, and then projected onto 4 bands of spherical harmonics. For the first time the program starts you're going to have

SH rotation is performed using my verbose implementation of the method of Ivanic/Ruedenberg and is unoptimised. I've also implemented the SH rotation method of Choi et. al. but it is not present in this release. I am currently co-ordinating an SH rotation specific release with Robin Green for later. I have also removed Robin's implementation of Blanco SH rotation as it's not mine so the code won't compile as-is: you will just have to uncomment any errors that occur (everything is included for you to be able to compile the demo itself).

I apologise for the messy state of the code but this is purely and simply a spare time test which I hope you all can benefit from. In order to compile this you need to download my SDLApp framework which is available on my website.

Acknowledgements

Thanks to Robin Green for his excellent GDC2003 presentation and accompany documentation, and for help and discussion with regard to SH lighting. Thanks to Joseph Ivanic and Klaus Ruedenberg for help with SH rotation.

The HDR image rnl_probe.hdr is taken directly from Paul Debevec's HDR gallery at http://www.debevec.org.

References

Precomputed Radiance Transfer for Real-Time Rendering in Dynamic, Low-Frequency Lighting Environments Peter-Pike Sloan, Jan Kautz, and John Snyder SIGGRAPH 2002, July 2002 http://www.ppsloan.org/publications/

Spherical Harmonic Lighting: The Gritty Details Robin Green GDC 2003, Presentation https://basesandframes.wordpress.com/2016/05/11/spherical-harmonic-lighting-the-gritty-details/

Rotation Matrices for Real Spherical Harmonics. Direct Determination by Recursion Joseph Ivanic and Klaus Ruedenberg J. Phys. Chem. 1996, 100, 6342-5347

Additions and Corrections (to previous paper) Joseph Ivanic and Klaus Ruedenberg J. Phys. Chem. A, 1998, Vol. 102, No. 45, 9099

Rapid and stable determination of rotation matrices between spherical harmonics by direct recursion Cheol Ho Choi, Joseph Ivanic, Mark S. Gordon, and Klaus Ruedenberg J. Chem. Phys, 1999, Vol. 111, No. 19

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.