This
is the personal web site of Rafwrobel. It deals with GPU programming. Currently
four demos are available for download with source code:
“Light propagation volumes“
(platform independent, C++/OpenGL 2.0/GLSL)
“Spherical
harmonic lighting” (platform independent, requires Python and OpenGL 2.0)
“Sky
rendering” (platform independent, requires Python and OpenGL 2.0)
“Shadowed
volumetric fog” (C++ code, Windows only, requires an Nvidia GPU, NV30 or
higher)
Contact
mailto:rafwrobel@googlemail.com
Light propagation
volumes
by
Rafwrobel
February 2010
light
propagation volumes:
this
technique is descibed in Crytek's "Light_Propagation_Volumes.pdf"
the
purpose of it is to add indirect light into the scene without any
precalculations
this
demo requires a D3D10 compatible GPU since it uses layered rendering to inject
virtual point lights into the radiance grid (3d texture)
the rendering
loop in this demo consists of following steps:
- draw
virtual point lights into reflective shadow maps
- use
the reflective shadow maps to inject secondary lights into the radiance volume
-
propagate radiance in the radiance volume
- draw
the scene with direct lighting and shadow
- add
indirect lighting using the radiance volume texture
this is
an initial version, it is in an experimental state and needs a lot of
improvments and optimizations
you can
press F1 to switch indirect lighting on and off
all
source code is included
the
code is platform independent
you can
download and compile it without any additional libraries
it is a
VisualStudio.NET project
How to run:
Download it using
the link below and unzip. Then execute the program “Light_Propagation_Volumes.exe”
Screenshots
The
images on the left were rendered with indirect light, the images on the right
without indirect lighting


Downloads
spherical
harmonic lighting
by
Rafwrobel
October 2009
this
program demonstrates spherical harmonic lighting (SH lighting) calculated per
pixel on the GPU.
please
refer to Robin Green's "Spherical Harmonic Lighting: The Gritty
Details" for more details about spherical harmonics.
normally
you would calculate SH coefficients per vertex on the CPU.
I
decided to move some calculations to the GPU to speed it up.
description of the steps to
calculate the shadowed diffuse transfer function SH coefficients of each pixel
in a scene using a GPU
the demo takes advantage
of the ability of GPUs to process data very fast using rasterization
1 precompute the SH
basis function values using jittered sh samples on a sphere. in my case I will
generate 2025 sh samples
2 each sh sample (from
previous step) will be applied to each pixel using rasterization
first render
pass:
select next sh sample and perform a parallel
projection of the scene along the direction of the current sh sample and store
the depth (most distant depth layer)
in a depth map,
this depth map will be used in the next render pass to make a visibility test
second render
pass:
if this render pass is called for the first
time then render the scene into geometry buffers (vertices and normals)
draw a full screen quad sampling the geometry
buffers and check for each sample if it is occluded by another object along the
direction of the current sh sample
by sampling the depth map, if it is occluded
then discard the sample otherwise output the contribution to the light transfer
function SH coefficients,
alpha blending is enabled to add the
contribution to the light transfer function SH coefficients
my pixel shader outputs 16 sh coefficients
for each pixel using 4 render targets (each one has four channels)
if not last
sh sample continue
it will
take some seconds or minutes (depending on your GPU and complexity of the
scene) to process the steps described above
once
the sh coefficients have been calculated the scene can be rendered in real time
by sampling the sh coefficients of each pixel and calculating
the dot
product with sh coefficients of a light source
the
program shows this by using different light directions.
since
this demo has been written in Python you must install Python, PyOpenGL, numpy
and PIL to run it you also need a GPU with OpenGL 2.0 support
the
demo is platform independent. I used Windows XP and an NVIDIA Quadro NVS 160M
with Forceware 6.14.11.7968 (3-11-2009)
Installation guide
for Windows:
Step 1:
Download Python 2.5
http://www.python.org/download/
and install
Step 2:
Download
“PyOpenGL-3.0.0b1-py2.5.egg” or higher from http://pyopengl.sourceforge.net/ or
download it from my site
Step 3:
Before installing
the PyOpenGL package you need to install the setuptools (easy_install) from
http://pypi.python.org/pypi/setuptools/0.6c8 or download it from my site
Step 4:
Execute
easy_install from the command line to install the PyOpenGL package. Make sure
that Python and easy_install are added to the PATH environment variable (on
Windows: c:\Python25\;c:\Python25\Scripts\)
call easy_install:
easy_install
PyOpenGL-3.0.0b1-py2.5.egg
Step 5:
Download numpy
from
http://numpy.scipy.org/
and install
Step 6:
Download PIL from
http://www.pythonware.com/products/pil/
and install
Step 7:
download GLUT and
GLU and copy the glut32.dll and glu32.dll to your system folder
Running
the demo:
download
the python scripts from the download section below and unzip to any folder.
Then execute the batch file "launch.bat" from the folder where you
copied
the
demo files.
Screenshots





Downloads
Sky Rendering
by
Rafwrobel
December 2008
This
demo uses the method proposed by Nishita in his specification 'Display of The
Earth Taking into Account Atmospheric Scattering' to determine the color of the
sky. Sky color in this demo depends on sun direction, viewer position and view
direction.
The
demo uses the GPU for most of its calculations. Nishita's specification can be
downloaded from the internet, search for the file 'sig93_nis.pdf'.
The
procedure:
Two
lookup tables get created to speed up the integration of Rayleigh and Mie
inscattering in a pixel shader.
To precalculate
the lookup tables an atmosphere is used which is devided into multiple
spherical-shells. Each spherical-shell is assigned an altitude and density
ratio. The most outer spherical-shell is the top of the atmosphere.
Since
the earth in this demo is assumed to be a sphere one can precalculate for each
spherical-shell optical depths by defining a number of rays i.e. the first of
these rays points to the center of the earth.
The
other rays get created by rotating the first ray until reaching the last ray
which is the ray rotated by 180 degrees.
For
each ray one can calculate the optical depth by finding the intersection points
of the given ray with all spherical-shells and integrating densities assigned
to the intersected spherical-shells. This way the optical depth
along
each ray will be precalculated. The lookup tables are two dimensional matrices.
Each column contains precalculated optical depths for a given view direction
(ray).
Two
lookup tables are being used, one to determine optical depths from arbitrary
view directions and one to determine the optical depths between the sun and
arbitrary points on spherical-shells.
The
precalculated lookup tables get copied into textures to make them accessable to
shaders which calculate the color of the sky.
The
pixel shaders determine from clip space positions view rays in world space (a
full screen quad gets drawn) then they calculate at each intersection with
spherical-shells along that rays the amount of inscattered light and sum them
up.
To run
the demo you must install Python, PyOpenGL, numpy and PIL you also need a GPU
with OpenGL 2.0 support.
The
demo is platform independent I used Windows XP and an NVIDIA Quadro NVS 160M
with Forceware 6.14.11.7968 (3-11-2009)
Once the
demo has been started it will slowly change the altitude of the sun (you will
see the sun sinking) and thus altering the direction of the sun and updating
the sky color by passing current sun direction, viewer position and direction
to the shaders. Finally you will see how the horizon becomes reddish when the
sun will be very low.
Installation guide
for Windows:
Step 1:
Download Python
2.5
http://www.python.org/download/
and install
Step 2:
Download
“PyOpenGL-3.0.0b1-py2.5.egg” or higher from http://pyopengl.sourceforge.net/ or
download it from my site
Step 3:
Before installing
the PyOpenGL package you need to install the setuptools (easy_install) from
http://pypi.python.org/pypi/setuptools/0.6c8 or download it from my site
Step 4:
Execute
easy_install from the command line to install the PyOpenGL package. Make sure
that Python and easy_install are added to the PATH environment variable (on
Windows: c:\Python25\;c:\Python25\Scripts\)
call easy_install:
easy_install
PyOpenGL-3.0.0b1-py2.5.egg
Step 5:
Download numpy
from
http://numpy.scipy.org/
and install
Step 6:
Download PIL from
http://www.pythonware.com/products/pil/
and install
Step 7:
download GLUT and
GLU and copy the glut32.dll and glu32.dll to your system folder
Running
the demo:
download
the python scripts from the download section below and unzip to any folder.
Then execute the batch file "launch.bat" from the folder where you
copied
the
demo files. First an intro will be shown which takes 15 seconds. Then the demo
will run for three minutes showing how the sky color changes as the sun goes
down.
Screenshots







Downloads
movie (sunset) IrfanView
Slideshow
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Shadowed
Volumetric Fog (very old)
Download
source code + binaries


