summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Froehlich <Mathias.Froehlich@web.de>2011-01-31 21:38:04 +0100
committerMathias Froehlich <Mathias.Froehlich@web.de>2011-01-31 21:38:04 +0100
commitd26d8c3e473aa3b0a91ea8a51d2e9b8757871341 (patch)
tree884b3577ed1e77c492c418a2ff7c7fb59c9c2193
parent5974c39955ab9f880388cc390d02799ef5601fed (diff)
x
-rw-r--r--Main.cpp63
-rw-r--r--Makefile2
2 files changed, 64 insertions, 1 deletions
diff --git a/Main.cpp b/Main.cpp
index 44d1eee..e842bd0 100644
--- a/Main.cpp
+++ b/Main.cpp
@@ -232,6 +232,47 @@ void loadData()
void precompute()
{
+// #define LOAD_TEXTURE
+// #define DUMP_TEXTURE
+#ifdef LOAD_TEXTURE
+ void* pixels;
+ FILE* f;
+
+ glActiveTexture(GL_TEXTURE0 + irradianceUnit);
+ glGenTextures(1, &irradianceTexture);
+ glBindTexture(GL_TEXTURE_2D, irradianceTexture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ // glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
+
+ pixels = malloc(sizeof(float)*SKY_W*SKY_H);
+ f = fopen("irradianceTexture.bin", "rb");
+ fread(pixels, sizeof(float), SKY_W*SKY_H, f);
+ fclose(f);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F_ARB, SKY_W, SKY_H, 0, GL_RGB, GL_FLOAT, pixels);
+ free(pixels);
+
+ glActiveTexture(GL_TEXTURE0 + inscatterUnit);
+ glGenTextures(1, &inscatterTexture);
+ glBindTexture(GL_TEXTURE_3D, inscatterTexture);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
+ // glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
+
+ pixels = malloc(sizeof(float)*RES_MU_S*RES_NU*RES_MU*RES_R);
+ f = fopen("inscatterTexture.bin", "rb");
+ fread(pixels, sizeof(float), RES_MU_S*RES_NU*RES_MU*RES_R, f);
+ fclose(f);
+ glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA16F_ARB, RES_MU_S * RES_NU, RES_MU, RES_R, 0, GL_RGB, GL_FLOAT, NULL);
+ free(pixels);
+
+#else
+
glActiveTexture(GL_TEXTURE0 + transmittanceUnit);
glGenTextures(1, &transmittanceTexture);
glBindTexture(GL_TEXTURE_2D, transmittanceTexture);
@@ -494,6 +535,28 @@ void precompute()
glFinish();
cout << "ready." << endl;
+
+#ifdef DUMP_TEXTURE
+ void* pixels;
+ FILE* f;
+ glBindTexture(GL_TEXTURE_2D, irradianceTexture);
+ pixels = malloc(sizeof(float)*SKY_W*SKY_H);
+ glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT, pixels);
+ f = fopen("irradianceTexture.bin", "wb");
+ fwrite(pixels, sizeof(float), SKY_W*SKY_H, f);
+ fclose(f);
+ free(pixels);
+
+ glBindTexture(GL_TEXTURE_3D, inscatterTexture);
+ pixels = malloc(sizeof(float)*RES_MU_S*RES_NU*RES_MU*RES_R);
+ glGetTexImage(GL_TEXTURE_3D, 0, GL_RGB, GL_FLOAT, pixels);
+ f = fopen("inscatterTexture.bin", "wb");
+ fwrite(pixels, sizeof(float), RES_MU_S*RES_NU*RES_MU*RES_R, f);
+ fclose(f);
+ free(pixels);
+#endif
+#endif
+
glUseProgram(drawProg);
}
diff --git a/Makefile b/Makefile
index 84ad8d7..7f72321 100644
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,2 @@
-Main:
+Main: Main.cpp
$(CXX) -g -o Main Main.cpp -lglut -lGLEW -ltiff -lGL