Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merged refactored/rebase pull request from kayru

  • Loading branch information...
commit 8ed2213b6c2968d6e26270e2f8f5e610bad3619a 2 parents f8d83f3 + 07a252a
@aselle aselle authored
View
13 .gitignore
@@ -2,3 +2,16 @@
moc_*
Makefile
Linux-*
+*.dll
+*.exe
+*.filters
+*.ipch
+*.opensdf
+*.pdb
+*.sdf
+*.sln
+*.suo
+*.user
+*.vcxproj
+src/brdf/release
+src/brdf/debug
View
13 README-WIN32
@@ -0,0 +1,13 @@
+How to compile BRDF Explorer for Windows
+========================================
+
+The following external dependencies are required (versions are ones that I used, other might also work):
+ - Qt 4.8.1
+ - GLEW 1.9.0
+ - ZLib 1.2.5
+ - GLUT 3.7
+
+Make sure that qmake is in your PATH. Also put GLEW, ZLib and GLUT include and library directories somewhere VC can find them.
+
+Open Visual Studio 2010 command prompt and navigate to brdf project root directory.
+Run "qmake -r -tp vc prefix=foo", this will generate the vcxproj and sln files.
View
14 make_win32_dist.sh
@@ -1,13 +1,17 @@
+
+VERSION=1.0.0
+
make clean
qmake-qt4 -spec linux-mingw32-custom
make -j 8
-rm -rf brdf-win32
-mkdir brdf-win32
-pushd brdf-win32
+DIR=brdf-$VERSION-win32
+rm -rf $DIR
+mkdir $DIR
+pushd $DIR
cp -a ../src/{data,probes,images,brdfs,shaderTemplates} ./
cp /jobs2/soft/users/aselle/windows-build/QtSDK/Desktop/Qt/4.6.4/bin/{QtGui4.dll,QtCore4.dll,QtOpenGL4.dll,libgcc_s_dw2-1.dll,mingwm10.dll} ./
cp ../src/brdf/release/brdf.exe ./
-cp ../{LICENSE,LICENSE-BINARY} ./
+cp ../{LICENSE,LICENSE-BINARY,README} ./
popd
-zip -r brdf-win32.zip brdf-win32
+zip -r brdf-$VERSION-win32.zip brdf-$VERSION-win32
View
5 src/brdf/IBLWidget.cpp
@@ -45,7 +45,6 @@ infringement.
#include <GL/glew.h>
#include <QtGui>
-#include <QtOpenGL>
#include <QString>
#include <math.h>
#include <stdlib.h>
@@ -446,8 +445,8 @@ void IBLWidget::mouseMoveEvent( QMouseEvent* event )
int d = abs(dx) > abs(dy) ? dx : dy;
lookZoom -= float(d) * lookZoom * 0.05;
- lookZoom = fmaxf( lookZoom, 0.01f );
- lookZoom = fminf( lookZoom, 100.0f );
+ lookZoom = std::max<float>( lookZoom, 0.01f );
+ lookZoom = std::min<float>( lookZoom, 100.0f );
}
View
13 src/brdf/ImageSliceWidget.cpp
@@ -45,7 +45,6 @@ infringement.
#include <GL/glew.h>
#include <QtGui>
-#include <QtOpenGL>
#include <QString>
#include <math.h>
#include "DGLShader.h"
@@ -218,8 +217,8 @@ void ImageSliceWidget::mouseMoveEvent(QMouseEvent *event)
{
int d = abs(dx) > abs(dy) ? dx : dy;
scaleX += float(d) * scaleX * 0.05;
- scaleX = fmaxf( scaleX, 0.01 );
- scaleX = fminf( scaleX, 50.0 );
+ scaleX = std::max<float>( scaleX, 0.01 );
+ scaleX = std::min<float>( scaleX, 50.0 );
}
// control+right adjusts the x-scale of the graph
@@ -227,8 +226,8 @@ void ImageSliceWidget::mouseMoveEvent(QMouseEvent *event)
{
int d = abs(dx) > abs(dy) ? dx : dy;
scaleY += float(d) * scaleY * 0.05;
- scaleY = fmaxf( scaleY, 0.01 );
- scaleY = fminf( scaleY, 50.0 );
+ scaleY = std::max<float>( scaleY, 0.01 );
+ scaleY = std::min<float>( scaleY, 50.0 );
}
// left mouse button adjusts the viewing dir
@@ -248,8 +247,8 @@ void ImageSliceWidget::mouseMoveEvent(QMouseEvent *event)
int d = abs(dx) > abs(dy) ? dx : dy;
lookZoom -= float(d) * lookZoom * 0.05;
- lookZoom = fmaxf( lookZoom, 0.01f );
- lookZoom = fminf( lookZoom, 50.0f );
+ lookZoom = std::max<float>( lookZoom, 0.01f );
+ lookZoom = std::min<float>( lookZoom, 50.0f );
}
View
13 src/brdf/Plot3DWidget.cpp
@@ -51,6 +51,9 @@ infringement.
#include "Plot3DWidget.h"
#include "geodesicHemisphere.h"
+#ifndef M_PI_2
+#define M_PI_2 1.57079632679489661923
+#endif //M_PI_2
Plot3DWidget::Plot3DWidget( QWidget *parent, std::vector<brdfPackage> bList )
: SharedContextGLWidget(parent)
@@ -163,8 +166,8 @@ void Plot3DWidget::paintGL()
// try and set some better viewing planes based on zoom factor... this only kinda works
- float nearPlane = fminf( lookZoom*0.1, 0.5 );
- float farPlane = fminf( lookZoom*10.0, 100.0 );
+ float nearPlane = std::min<float>( lookZoom*0.1, 0.5 );
+ float farPlane = std::min<float>( lookZoom*10.0, 100.0 );
glMatrixMode(GL_PROJECTION);
@@ -293,8 +296,8 @@ void Plot3DWidget::mouseMoveEvent(QMouseEvent *event)
int d = abs(dx) > abs(dy) ? dx : dy;
lookZoom -= float(d) * lookZoom * 0.05;
- lookZoom = fmaxf( lookZoom, 0.01f );
- lookZoom = fminf( lookZoom, 100.0f );
+ lookZoom = std::max<float>( lookZoom, 0.01f );
+ lookZoom = std::min<float>( lookZoom, 100.0f );
}
@@ -350,7 +353,7 @@ void Plot3DWidget::makeGeodesicHemisphereVBO()
int memIndex = 0;
// allocate enough memory for all the vertices in the hemisphere
- numTrianglesInHemisphere = 40 * int(pow(4.0, float(numSubdivisions)));
+ numTrianglesInHemisphere = 40 * int(powf(4.0, float(numSubdivisions)));
hemisphereVertices = new float[ numTrianglesInHemisphere * 3 * 3 ];
//printf( "numTrianglesInHemisphere: %d\n", numTrianglesInHemisphere );
View
13 src/brdf/PlotCartesianWidget.cpp
@@ -45,7 +45,6 @@ infringement.
#include <GL/glew.h>
#include <QtGui>
-#include <QtOpenGL>
#include <QString>
#include <math.h>
#include "DGLShader.h"
@@ -362,8 +361,8 @@ void PlotCartesianWidget::mouseMoveEvent(QMouseEvent *event)
{
int d = abs(dx) > abs(dy) ? dx : dy;
scaleX += float(d) * scaleX * 0.05;
- scaleX = fmaxf( scaleX, 0.01 );
- scaleX = fminf( scaleX, 50.0 );
+ scaleX = std::max<float>( scaleX, 0.01 );
+ scaleX = std::min<float>( scaleX, 50.0 );
}
// control+right adjusts the x-scale of the graph
@@ -371,8 +370,8 @@ void PlotCartesianWidget::mouseMoveEvent(QMouseEvent *event)
{
int d = abs(dx) > abs(dy) ? dx : dy;
scaleY += float(d) * scaleY * 0.05;
- scaleY = fmaxf( scaleY, 0.01 );
- scaleY = fminf( scaleY, 50.0 );
+ scaleY = std::max<float>( scaleY, 0.01 );
+ scaleY = std::min<float>( scaleY, 50.0 );
}
// left mouse button adjusts the viewing dir
@@ -393,8 +392,8 @@ void PlotCartesianWidget::mouseMoveEvent(QMouseEvent *event)
int d = abs(dx) > abs(dy) ? dx : dy;
lookZoom -= float(d) * lookZoom * 0.05;
- lookZoom = fmaxf( lookZoom, 0.01f );
- lookZoom = fminf( lookZoom, 50.0f );
+ lookZoom = std::max<float>( lookZoom, 0.01f );
+ lookZoom = std::min<float>( lookZoom, 50.0f );
}
View
5 src/brdf/PlotPolarWidget.cpp
@@ -45,7 +45,6 @@ infringement.
#include <GL/glew.h>
#include <QtGui>
-#include <QtOpenGL>
#include <QString>
#include <math.h>
#include "DGLShader.h"
@@ -251,8 +250,8 @@ void PlotPolarWidget::mouseMoveEvent(QMouseEvent *event)
int d = abs(dx) > abs(dy) ? dx : dy;
lookZoom -= float(d) * lookZoom * 0.05;
- lookZoom = fmaxf( lookZoom, 0.01f );
- lookZoom = fminf( lookZoom, 50.0f );
+ lookZoom = std::max<float>( lookZoom, 0.01f );
+ lookZoom = std::min<float>( lookZoom, 50.0f );
}
View
12 src/brdf/SimpleModel.cpp
@@ -142,12 +142,12 @@ bool SimpleModel::dataPass( FILE* file, std::vector<float3>& vertices, std::vect
if( line[0] == 'v' && line[1] == ' ' ) {
float3 data;
if( sscanf(line, "v %f %f %f", &data.x, &data.y, &data.z) == 3 ) {
- maxX = std::max( maxX, data.x );
- minX = std::min( minX, data.x );
- maxY = std::max( maxY, data.y );
- minY = std::min( minY, data.y );
- maxZ = std::max( maxZ, data.z );
- minZ = std::min( minZ, data.z );
+ maxX = std::max<float>( maxX, data.x );
+ minX = std::min<float>( minX, data.x );
+ maxY = std::max<float>( maxY, data.y );
+ minY = std::min<float>( minY, data.y );
+ maxZ = std::max<float>( maxZ, data.z );
+ minZ = std::min<float>( minZ, data.z );
vertices.push_back( data );
}
}
View
3  src/brdf/brdf.pro
@@ -55,7 +55,7 @@ SOURCES = \
QT += opengl
-DEFINES += GLEW_STATIC
+DEFINES += PTEX_STATIC NOMINMAX
macx {
INCLUDEPATH += /usr/X11/include
@@ -88,6 +88,7 @@ INSTALLS = target brdfs data images probes shaderTemplates pkgconfig
# Windows cross compile at disney
linux-mingw32-custom{
+ DEFINES += GLEW_STATIC
WINDOWS_BUILD=/jobs2/soft/users/aselle/windows-build
INCLUDEPATH += $$WINDOWS_BUILD/glew-1.9.0/include/
INCLUDEPATH += $$WINDOWS_BUILD/glut-3.7.6-bin/
View
1  src/brdf/main.cpp
@@ -56,6 +56,7 @@ infringement.
#ifdef WIN32
#include <windows.h>
#include <fcntl.h>
+#include <io.h>
#endif
#define BRDF_VERSION "1.0.0"
View
3  src/brdf/ptex/PtexHalf.h
@@ -41,9 +41,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
@brief Half-precision floating-point type.
*/
-// this is extracted from library, so it should be static always
-#define PTEX_STATIC
-
#ifndef PTEXAPI
# if defined(_WIN32) || defined(_WINDOWS) || defined(_MSC_VER)
# ifndef PTEX_STATIC
View
2  src/brdf/ptex/Ptexture.h
@@ -41,8 +41,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
@brief Public API classes for reading, writing, caching, and filtering Ptex files.
*/
-// ptex is static because we aren't building a library
-#define PTEX_STATIC
#if defined(_WIN32) || defined(_WINDOWS) || defined(_MSC_VER)
# ifndef PTEXAPI
# ifndef PTEX_STATIC
View
4 src/brdf/trim.h
@@ -50,13 +50,13 @@ infringement.
// trim from start
static inline std::string &trimFromLeft(std::string &s) {
- s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
+ s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(::isspace))));
return s;
}
// trim from end
static inline std::string &trimFromRight(std::string &s) {
- s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
+ s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(::isspace))).base(), s.end());
return s;
}
View
2  src/brdfs/blinn.brdf
@@ -45,7 +45,7 @@ vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y )
float g = sqrt(ior*ior + c*c - 1);
float F = 0.5 * pow(g-c,2) / pow(g+c,2) * (1 + pow(c*(g+c)-1,2) / pow(c*(g-c)+1,2));
- float val = NdotH < 0 ? 0 : D * G * (include_Fresnel ? F : 1);
+ float val = NdotH < 0 ? 0.0 : D * G * (include_Fresnel ? F : 1.0);
if (divide_by_NdotL)
val = val / dot(N,L);
View
8 src/brdfs/compare.brdf
@@ -66,7 +66,7 @@ float smithG_GGX(float NdotL, float NdotV, float alphaG)
float schlickG1(float v, float m)
{
float k = sqrt(2*m*m/PI);
- return v > 0 ? v/(v-k*v + k) : 0;
+ return v > 0 ? v/(v-k*v + k) : 0.0;
}
float schlickG(float NdotL, float NdotV, float m)
@@ -133,11 +133,11 @@ vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y )
float D =
useBeckmannD ? Beckmann(NdotH, specwidth) :
useTrowbridgeReitzD ? NormalizedTrowbridgeReitz(NdotH, specwidth) :
- 1;
+ 1.0;
float F =
useSchlickF ? SchlickFresnel(F0, 1, LdotH) :
- 1;
+ 1.0;
float G =
useSmithG ? smithG_GGX(NdotL, NdotV, specwidth) / (4*NdotL*NdotV) :
@@ -150,7 +150,7 @@ vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y )
useKurtG ? kurtG(NdotL, NdotV, LdotH, kurtAlpha) :
useKelemenG ? kelemenG(dot(L,V)) :
useDuerG ? duerG(L, V, N) :
- 1;
+ 1.0;
return vec3(Ks*D*F*G) + vec3(Kd,0,0);
}
View
2  src/brdfs/cooktorrance.brdf
@@ -58,7 +58,7 @@ vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y )
oneOverNdotV);
if (include_G) G = oneOverNdotV;
- float val = NdotH < 0 ? 0 : D * G ;
+ float val = NdotH < 0 ? 0.0 : D * G ;
if (include_F) val *= F;
View
8 src/brdfs/dAniso.brdf
@@ -16,12 +16,12 @@ bool kajiya 0
float smoothstep(float a, float b, float x)
{
if ( a < b ) {
- if ( x < a ) return 0;
- if ( x >= b ) return 1;
+ if ( x < a ) return 0.0;
+ if ( x >= b ) return 1.0;
x = (x - a)/(b - a);
} else if (a > b) {
- if ( x <= b ) return 1;
- if ( x > a ) return 0;
+ if ( x <= b ) return 1.0;
+ if ( x > a ) return 0.0;
x = 1 - (x - b)/(a - b);
}
else return x < a ? 0.0 : 1.0;
View
2  src/brdfs/g_schlick.brdf
@@ -21,7 +21,7 @@ float PI = 3.14159265358979323846;
float G(float v, float m)
{
float k = sqrt(2*m*m/PI);
- return v > 0 ? v/(v-k*v + k) : 0;
+ return v > 0 ? v/(v-k*v + k) : 0.0;
}
vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y )
View
2  src/brdfs/walter.brdf
@@ -46,7 +46,7 @@ vec3 BRDF( vec3 L, vec3 V, vec3 N, vec3 X, vec3 Y )
// fresnel
float c = VdotH;
float g = sqrt(ior*ior + c*c - 1);
- float F = useFresnel ? 0.5 * pow(g-c,2) / pow(g+c,2) * (1 + pow(c*(g+c)-1,2) / pow(c*(g-c)+1,2)) : 1;
+ float F = useFresnel ? 0.5 * pow(g-c,2) / pow(g+c,2) * (1 + pow(c*(g+c)-1,2) / pow(c*(g-c)+1,2)) : 1.0;
float val = Kd/PI + Ks * D * G * F / (4 * NdotL * NdotV);
return vec3(val);
View
4 src/shaderTemplates/brdfIBL.frag
@@ -362,9 +362,7 @@ void main(void)
viewVec = vec3(0,0,1);
WorldToLocal = mat3( esTangent, esBitangent, esNormal );
- LocalToWorld._m00_m10_m20 = WorldToLocal._m00_m01_m02;
- LocalToWorld._m01_m11_m21 = WorldToLocal._m10_m11_m12;
- LocalToWorld._m02_m12_m22 = WorldToLocal._m20_m21_m22;
+ LocalToWorld = transpose(WorldToLocal);
envSampleRotMatrix = mat3(envRotMatrix) * WorldToLocal;
Please sign in to comment.
Something went wrong with that request. Please try again.