Skip to content

Commit

Permalink
• Added SH filtering when dynamic updating (especially strong on Sun …
Browse files Browse the repository at this point in the history
…light!)
  • Loading branch information
Patapom committed Mar 26, 2015
1 parent f5175f2 commit cdf5113
Show file tree
Hide file tree
Showing 14 changed files with 948 additions and 0 deletions.
Binary file added Packages/tetgen1.5.1-beta1.zip
Binary file not shown.
14 changes: 14 additions & 0 deletions Packages/tetgen1.5.1-beta1/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Set the minimum required version of cmake for a project.
cmake_minimum_required(VERSION 2.6)

# Add an executable to the project using the specified source files.
add_executable(tetgen tetgen.cxx predicates.cxx)

#Add a library to the project using the specified source files.
# In Linux/Unix, it will creates the libtet.a
add_library(tet STATIC tetgen.cxx predicates.cxx)

#Set properties on a target.
#We use this here to set -DTETLIBRARY for when compiling the
#library
set_target_properties(tet PROPERTIES "COMPILE_DEFINITIONS" TETLIBRARY)
666 changes: 666 additions & 0 deletions Packages/tetgen1.5.1-beta1/LICENSE

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions Packages/tetgen1.5.1-beta1/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
This is TetGen version 1.5.1-beta1 (released on May 31, 2014)

Please see the documentation of TetGen for compiling and using TetGen.
It is available at the following link:

http://www.tetgen.org

For more information on this product, contact :

Hang Si
Research Group of Numerical Mathematics and Scientific Computing
Weierstrass Institute for Applied Analysis and Stochastics
Mohrenstr. 39
10117 Berlin, Germany

Phone: +49 (0) 30-20372-446 Fax: +49 (0) 30-2044975
EMail: <si@wias-berlin.de>
Web Site: http://www.wias-berlin.de/~si

------------------- IMPORTANCE NOTICE -----------------------------

BEFORE INTALLING OR USING TetGen(R) READ the
GENERAL LICENSE TERMS AND CONDITIONS

-------------------------------------------------------------------
84 changes: 84 additions & 0 deletions Packages/tetgen1.5.1-beta1/example.poly
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
28 3 0 1
1 0 0 0 1
2 2 0 0 1
3 2 2 0 1
4 0 2 0 1
5 0 0 4 9
6 2 0 4 9
7 2 2 3 9
8 0 2 3 9
9 0 0 5 2
10 2 0 5 2
11 2 2 5 2
12 0 2 5 2
13 0.25 0.25 0.5 4
14 1.75 0.25 0.5 4
15 1.75 1.5 0.5 4
16 0.25 1.5 0.5 4
17 0.25 0.25 1 4
18 1.75 0.25 1 4
19 1.75 1.5 1 4
20 0.25 1.5 1 4
21 0.25 0 2 4
22 1.75 0 2 4
23 1.75 1.5 2 4
24 0.25 1.5 2 4
25 0.25 0 2.5 4
26 1.75 0 2.5 4
27 1.75 1.5 2.5 4
28 0.25 1.5 2.5 4
23 1
1 0 1 # 1
4 1 2 3 4
1 0 9 # 2
4 5 6 7 8
2 1 3 # 3
4 1 2 6 5
4 21 22 26 25
1 1 0 2.25
1 0 3 # 4
4 2 3 7 6
1 0 3 # 5
4 3 4 8 7
1 0 3 # 6
4 4 1 5 8
1 0 2 # 7
4 9 10 11 12
1 0 3 # 8
4 9 10 6 5
1 0 3 # 9
4 10 11 7 6
1 0 3 # 10
4 11 12 8 7
1 0 3 # 11
4 12 9 5 8
1 0 4 # 12
4 13 14 15 16
1 0 4 # 13
4 17 18 19 20
1 0 4 # 14
4 13 14 18 17
1 0 4 # 15
4 14 15 19 18
1 0 4 # 16
4 15 16 20 19
1 0 4 # 17
4 16 13 17 20
1 0 4 # 18
4 21 22 23 24
1 0 4 # 19
4 25 26 27 28
1 0 4 # 20
4 21 22 26 25
1 0 4 # 21
4 22 23 27 26
1 0 4 # 22
4 23 24 28 27
1 0 4 # 23
4 24 21 25 28
2
1 1 0.4 2.25
2 1 0.4 0.75
2
1 1 0.25 0.1 10 0.001
2 1 0.5 4 20 0.01
62 changes: 62 additions & 0 deletions Packages/tetgen1.5.1-beta1/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
###############################################################################
# #
# makefile for TetGen #
# #
# Type "make" to compile TetGen into an executable program (tetgen). #
# Type "make tetlib" to compile TetGen into a library (libtet.a). #
# Type "make distclean" to delete all object (*.o) files. #
# #
###############################################################################

# CXX should be set to the name of your favorite C++ compiler.
# ===========================================================

CXX = g++
#CXX = icpc
#CXX = CC

# CXXFLAGS is the level of optimiztion, default is -O. One should try
# -O2, -O3 ... to find the best optimization level.
# ===================================================================

CXXFLAGS = -O3

# PREDCXXFLAGS is for compiling J. Shewchuk's predicates.

PREDCXXFLAGS = -O0

# SWITCHES is a list of switches to compile TetGen.
# =================================================
#
# By default, TetGen uses double precision floating point numbers. If you
# prefer single precision, use the -DSINGLE switch.
#
# The source code of TetGen includes a lot of assertions, which are mainly
# used for catching bugs at that places. These assertions somewhat slow
# down the speed of TetGen. They can be skipped by define the -DNDEBUG
# switch.

SWITCHES =

# RM should be set to the name of your favorite rm (file deletion program).

RM = /bin/rm

# The action starts here.

tetgen: tetgen.cxx predicates.o
$(CXX) $(CXXFLAGS) $(SWITCHES) -o tetgen tetgen.cxx predicates.o -lm

tetlib: tetgen.cxx predicates.o
$(CXX) $(CXXFLAGS) $(SWITCHES) -DTETLIBRARY -c tetgen.cxx
ar r libtet.a tetgen.o predicates.o

predicates.o: predicates.cxx
$(CXX) $(PREDCXXFLAGS) -c predicates.cxx

clean:
$(RM) *.o *.a tetgen *~




Binary file modified Resources/Shaders/Binary/GIUpdateProbe.CS.fxbin
Binary file not shown.
9 changes: 9 additions & 0 deletions Resources/Shaders/GIUpdateProbe.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,15 @@ void CS( uint3 _GroupID : SV_GroupID, // Defines the group offset within a D
SHDynamicSun.SH[i] = gs_SamplesSHSun[9*0+i] + gs_SamplesSHSun[9*1+i] + gs_SamplesSHSun[9*2+i] + gs_SamplesSHSun[9*3+i];
}

// Filter out dynamic
FilterLanczos( SHDynamic.SH, 3.0 ); // Nice result

// Filter out Sun
FilterLanczos( SHDynamicSun.SH, 2.0 ); // Nice result
// FilterHanning( SHDynamicSun.SH, 2.0 );
// FilterGaussian( SHDynamicSun.SH, 4.0 ); // 2.0 => Covers the entire sphere even for a very directional source, 4 is okay bit like lanczos 2.0


//SHDynamic.SH[0] = float3( 1, 0, 0 );
//SHDynamicSun.SH[0] = float3( 1, 1, 0 );
//
Expand Down
45 changes: 45 additions & 0 deletions Resources/Shaders/Inc/SH.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,51 @@ void BuildSHCosineLobe( const in float3 _Direction, out float _Coeffs[9] )
ZHRotate( _Direction, ZHCoeffs, _Coeffs );
}

// Applies Hanning filter for given window size
void FilterHanning( inout float3 _SH[9], float _WindowSize ) {

float rcpWindow = 1.0 / _WindowSize;
float2 Factors = float2( 0.5 * (1.0 + cos( PI * rcpWindow )), 0.5 * (1.0 + cos( 2.0 * PI * rcpWindow )) );
_SH[1] *= Factors.x;
_SH[2] *= Factors.x;
_SH[3] *= Factors.x;
_SH[4] *= Factors.y;
_SH[5] *= Factors.y;
_SH[6] *= Factors.y;
_SH[7] *= Factors.y;
_SH[8] *= Factors.y;
}

// Applies Lanczos filter for given window size
void FilterLanczos( inout float3 _SH[9], float _WindowSize ) {

float rcpWindow = 1.0 / _WindowSize;
float2 Factors = float2( sin( PI * rcpWindow ) / (PI * rcpWindow), sin( 2.0 * PI * rcpWindow ) / (2.0 * PI * rcpWindow) );
_SH[1] *= Factors.x;
_SH[2] *= Factors.x;
_SH[3] *= Factors.x;
_SH[4] *= Factors.y;
_SH[5] *= Factors.y;
_SH[6] *= Factors.y;
_SH[7] *= Factors.y;
_SH[8] *= Factors.y;
}

// Applies gaussian filter for given window size
void FilterGaussian( inout float3 _SH[9], float _WindowSize ) {

float rcpWindow = 1.0 / _WindowSize;
float2 Factors = float2( exp( -0.5 * (PI * rcpWindow) * (PI * rcpWindow) ), exp( -0.5 * (2.0 * PI * rcpWindow) * (2.0 * PI * rcpWindow) ) );
_SH[1] *= Factors.x;
_SH[2] *= Factors.x;
_SH[3] *= Factors.x;
_SH[4] *= Factors.y;
_SH[5] *= Factors.y;
_SH[6] *= Factors.y;
_SH[7] *= Factors.y;
_SH[8] *= Factors.y;
}

// Performs the SH triple product r = a * b
// From John Snyder
//
Expand Down
Binary file modified Tools/BRDFSlices.exe
Binary file not shown.
Binary file modified Tools/Cirrus.Utility.dll
Binary file not shown.
Binary file modified Tools/SharpMath.dll
Binary file not shown.
36 changes: 36 additions & 0 deletions Utility/SH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,42 @@ float3 SH::Yup2Zup( const float3& _Yup )
}


//////////////////////////////////////////////////////////////////////////
// SH Filtering
// Code stolen from https://github.com/rlk/sht
//
void SH::FilterHanning( float3 _SH[9], float w ) {
for ( int l = 0; l < 3; l++ )
if ( l > w )
Filter( _SH, l, 0 );
else if ( l > 0 )
Filter( _SH, l, 0.5f * (cosf(PI * l / w) + 1.0f) );
}

void SH::FilterLanczos( float3 _SH[9], float w ) {
for ( int l = 0; l < 3; l++ )
if ( l > 0 ) {
float angle = PI * l / w;
Filter( _SH, l, sinf(angle) / angle );
}
}

void SH::FilterGaussian( float3 _SH[9], float w ) {
for ( int l = 0; l < 3; l++ ) {
float angle = PI * l / w;
Filter( _SH, l, expf( -0.5f * angle * angle ) );
}
}

// Modulate all coefficients of degree l by scalar a.
void SH::Filter( float3 _SH[9], int l, float a )
{
for ( int m=-l; m <= l; m++ ) {
int offset = l*(l+1)+m;
_SH[offset] = a * _SH[offset];
}
}

//////////////////////////////////////////////////////////////////////////
// SH Coefficients & Legendre Polynomials & Windowing Sigma Factors
//
Expand Down
7 changes: 7 additions & 0 deletions Utility/SH.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class SH
static void SphericalToCartesian( double _θ, double _ϕ, float3& _Direction );
static float3 Yup2Zup( const float3& _Yup );

// Filters
static void FilterHanning( float3 _SH[9], float w ); // Applies a Hanning window of width w (usually the SH order).
static void FilterLanczos( float3 _SH[9], float w ); // Applies a Lanczos window of width w (usually the SH order).
static void FilterGaussian( float3 _SH[9], float w ); // Applies a Gaussian window of width w (usually the SH order).


// Y-up helpers
// These functions are the same as the SH.hlsl shader helpers and are all ordered using our familiar Y-up reference frame:
//
Expand All @@ -81,4 +87,5 @@ class SH
static double ComputeSigmaFactorSinc( int l, int _Order );
static double ComputeSigmaFactorCos( int l, int _Order );
static double ComputeSigmaFactorCos( int l, double h );
static void Filter( float3 _SH[9], int l, float a ); // Modulate all coefficients of degree l by scalar a.
};

0 comments on commit cdf5113

Please sign in to comment.