Permalink
Browse files

fix compilation issues with radeon driver

  • Loading branch information...
1 parent 8ed2213 commit f32362852ef3afa48a54dac7a9cb8463b71719bf @jciehl jciehl committed Oct 25, 2012
Showing with 25 additions and 13 deletions.
  1. +12 −0 src/brdf/DGLShader.cpp
  2. +5 −5 src/shaderTemplates/brdftemplateAnglePlotAlbedo.vert
  3. +8 −8 src/shaderTemplates/measured.func
View
@@ -171,6 +171,18 @@ bool DGLShader::compileAndAttachShader( GLuint& shaderID, GLenum shaderType, con
else
printf( "GLSL %s Compile Error (no shader file)\n", shaderTypeStr );
printf( "================================================================================\n" );
+
+ // also display shader source
+ {
+ GLint length;
+ glGetShaderiv(shaderID, GL_SHADER_SOURCE_LENGTH, &length);
+ GLchar *source= new GLchar [length];
+ glGetShaderSource(shaderID, length, NULL, source);
+
+ printf("%s\n", source);
+ delete [] source;
+ }
+
printf( "%s\n", errorMessage );
printf( "\n" );
@@ -88,7 +88,7 @@ float rand(vec2 n) {
//Sampling functions return costheta/pdf
//As passed in, view=vec3(cos(phi), sin(phi), 1.0)
float CosinePDF(in vec3 incident, in vec3 view) {
- if (view.z < 0) return 0;
+ if (view.z < 0.0) return 0.0;
return view.z/PI_;
}
@@ -125,9 +125,9 @@ float PolarSample(in float x1, in vec3 incident, inout vec3 view) {
float BlinnPDF(in float exponent, in vec3 incident, in vec3 view) {
- vec3 half = normalize(incident+view);
- float costhetah = half.z;
- float costhetad = dot(view, half);
+ vec3 H = normalize(incident+view);
+ float costhetah = H.z;
+ float costhetad = dot(view, H);
if (costhetad < 0) return 0.0;
return (exponent+1.0)*pow(costhetah,exponent)/(PI_*8.0*costhetad);
}
@@ -140,7 +140,7 @@ float BlinnSample(in float exponent, in float x1, in vec3 incident, inout vec3 v
if (halfvector.z*incident.z < 0) halfvector = -1.0*halfvector;
view = -incident + 2.0*dot(incident, halfvector)*halfvector;
float pdfinv = PI_*8.0*dot(incident, halfvector)/((exponent+1.0)*pow(costhetah,exponent));
- if (view.z < 0) return 0;
+ if (view.z < 0.0) return 0.0;
return view.z*pdfinv;
}
@@ -92,28 +92,28 @@ int theta_diff_index(float theta_diff)
vec3 BRDF( vec3 toLight, vec3 toViewer, vec3 normal, vec3 tangent, vec3 bitangent )
{
- vec3 half = normalize(toLight + toViewer);
- float theta_half = acos(clamp(dot(normal, half), 0, 1));
- float theta_diff = acos(clamp(dot(half, toLight), 0, 1));
+ vec3 H = normalize(toLight + toViewer);
+ float theta_H = acos(clamp(dot(normal, H), 0, 1));
+ float theta_diff = acos(clamp(dot(H, toLight), 0, 1));
float phi_diff=0;
if (theta_diff < 1e-3) {
// phi_diff indeterminate, use phi_half instead
phi_diff = atan(clamp(-dot(toLight, bitangent), -1, 1), clamp(dot(toLight, tangent), -1, 1));
}
- else if (theta_half > 1e-3) {
+ else if (theta_H > 1e-3) {
// use Gram-Schmidt orthonormalization to find diff basis vectors
- vec3 u = -normalize(normal - dot(normal,half) * half);
- vec3 v = cross(half, u);
+ vec3 u = -normalize(normal - dot(normal,H) * H);
+ vec3 v = cross(H, u);
phi_diff = atan(clamp(dot(toLight,v), -1, 1), clamp(dot(toLight,u), -1, 1));
}
- else theta_half = 0;
+ else theta_H = 0;
// Find index.
// Note that phi_half is ignored, since isotropic BRDFs are assumed
int ind = phi_diff_index(phi_diff) +
theta_diff_index(theta_diff) * BRDF_SAMPLING_RES_PHI_D / 2 +
- theta_half_index(theta_half) * BRDF_SAMPLING_RES_PHI_D / 2 *
+ theta_half_index(theta_H) * BRDF_SAMPLING_RES_PHI_D / 2 *
BRDF_SAMPLING_RES_THETA_D;
int redIndex = ind;

0 comments on commit f323628

Please sign in to comment.