View Full Version : OT: Spherical Harmonics Coefficients from light-probe HDR file

flamz

08-30-2007, 09:49 AM

Sorry about posting something a little Off-topic.

I am looking for documentation, or code or an example of how to extract spherical harmonics coefficients from a light-probe HDR file.

I currently use a HDR cube-map as a skybox in my game, but would like the SH coefficient to do some relighting.

can anyone help?

ZbuffeR

08-30-2007, 12:07 PM

this paper looks promising :

http://qhxb.lib.tsinghua.edu.cn/myweb/english/2007/2007e1/44-50.pdf

lodder

08-31-2007, 01:59 AM

You treat each pixel in the skybox as a single directional light. For a HDR-cubemap you need an additional scale value.

/// Calculate the sh coefficients for the given HDR image

CoefficientType *ProjectHDRImage(const Sirenia::HDRImage &image, Real HDRFactor)

{

Real dWeight = 4.0 * PI;

Real factor = dWeight / _nSamples;

CoefficientType *result = new CoefficientType[_nCoefficients];

memset(result, 0, sizeof(CoefficientType) * _nCoefficients);

for(Uint32 i=0; i < _nSamples; i++)

{

Color color = image.GetColor(_Samples[i].vec, HDRFactor);

for(Uint32 c=0; c < _nCoefficients; c++)

{

result[c] += color * _Samples[i].coefficients[c];

}

}

// Scale the PRT coefficients

for(Uint32 i = 0; i < _nCoefficients; i++)

{

result[i] = result[i] * factor;

}

return result;

}"CoefficientType" is a RGB-tupel. Fetching color values from an HDR-Skybox is done by a routine from Paul Debevec (see his page).

I have a lot more PRT-code if needed :)

ZbuffeR

08-31-2007, 07:35 AM

lodder, what PRT stands for ? How is it related to Spherical Harmonics ?

Lord crc

08-31-2007, 01:08 PM

Precomputed Radiance Transfer, see http://en.wikipedia.org/wiki/Precomputed_Radiance_Transfer

lodder

09-03-2007, 04:26 AM

PRT is "Precomputed Radiance Transfer". It uses Spherical Harmonic Lighting. Do you know the paper from Robin Green?

tfpsly

09-04-2007, 07:28 PM

ZbuffeR:

Spherical harmonics is a way of storing/compressing data/functions that are defined on the surface of a sphere, by storing them as being made up of a sum of spherical harmonic functions. It's simply a mathematical object and it is not directly related to any kind of lighting.

PRT is the actual à la mode lighting system using SH to store light information in all direction around an object.

Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.