Made bruneton source code dump intermediary textures

... but they produce more artifacts than my modified version,
so it's not immediately usable.
This commit is contained in:
Michaël Lemaire 2013-12-25 18:01:44 +01:00
parent e9c16481e0
commit 5c253081a0
7 changed files with 109 additions and 5 deletions

View file

@ -59,7 +59,6 @@ package:build
rm -f paysages3d-linux.tar.bz2
mkdir paysages3d-linux
mkdir paysages3d-linux/lib
mkdir paysages3d-linux/cache
cp $(BUILDPATH)/system/libpaysages_system.so* paysages3d-linux/lib/
cp $(BUILDPATH)/basics/libpaysages_basics.so* paysages3d-linux/lib/
cp $(BUILDPATH)/definition/libpaysages_definition.so* paysages3d-linux/lib/
@ -69,7 +68,6 @@ package:build
cp $(BUILDPATH)/interface/desktop/paysages-gui paysages3d-linux/lib/
chmod +x paysages3d-linux/lib/paysages-gui
cp -r data paysages3d-linux/
cp -r cache/*.cache paysages3d-linux/cache/
cp dist/paysages3d.sh paysages3d-linux/
chmod +x paysages3d-linux/paysages3d.sh
cp dist/collectlib.sh paysages3d-linux/

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 512 KiB

View file

@ -700,6 +700,101 @@ void idleFunc()
glutPostRedisplay();
}
#include "Texture2D.h"
#include "Texture4D.h"
#include "Color.h"
#include "Logs.h"
#include "PackStream.h"
void dumpTextures()
{
PackStream stream;
int x, y, z, w;
float* texdata;
/* Dump irradiance */
Texture2D irradiance(SKY_W, SKY_H);
texdata = new float[SKY_W * SKY_H * 3 * sizeof(float)];
glBindTexture(GL_TEXTURE_2D, irradianceTexture);
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT, texdata);
for (x = 0; x < SKY_W; x++)
{
for (y = 0; y < SKY_H; y++)
{
float* pixel = texdata + (y * SKY_W + x) * 3;
irradiance.setPixel(x, y, Color(pixel[0], pixel[1], pixel[2], 1.0));
}
}
stream = PackStream();
stream.bindToFile("atmo-br-irradiance-64-16-0-0-0.cache", true);
irradiance.save(&stream);
irradiance.saveToFile("irradiance.png");
delete[] texdata;
/* Dump transmittance */
Texture2D transmittance(TRANSMITTANCE_W, TRANSMITTANCE_H);
texdata = new float[TRANSMITTANCE_W * TRANSMITTANCE_H * 3 * sizeof(float)];
glBindTexture(GL_TEXTURE_2D, transmittanceTexture);
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGB, GL_FLOAT, texdata);
for (x = 0; x < TRANSMITTANCE_W; x++)
{
for (y = 0; y < TRANSMITTANCE_H; y++)
{
float* pixel = texdata + (y * TRANSMITTANCE_W + x) * 3;
transmittance.setPixel(x, y, Color(pixel[0], pixel[1], pixel[2], 1.0));
}
}
stream = PackStream();
stream.bindToFile("atmo-br-transmittance-256-64-0-0-0.cache", true);
transmittance.save(&stream);
transmittance.saveToFile("transmittance.png");
delete[] texdata;
/* Dump inscatter */
Texture4D inscatter(RES_MU, RES_MU_S, RES_NU, RES_R);
//Texture3D inscatter(RES_MU_S * RES_NU, RES_MU, RES_R);
texdata = new float[RES_MU * RES_MU_S * RES_NU * RES_R * 4 * sizeof(float)];
glBindTexture(GL_TEXTURE_3D, inscatterTexture);
glGetTexImage(GL_TEXTURE_3D, 0, GL_RGBA, GL_FLOAT, texdata);
for (x = 0; x < RES_MU; x++)
{
for (y = 0; y < RES_MU_S; y++)
{
for (z = 0; z < RES_NU; z++)
{
for (w = 0; w < RES_R; w++)
{
float* pixel = texdata + (w * (RES_MU * RES_MU_S * RES_NU) + z * (RES_MU_S) + y + x * (RES_MU_S * RES_NU)) * 4;
inscatter.setPixel(x, y, z, w, Color(pixel[0], pixel[1], pixel[2], pixel[3]));
}
}
}
}
stream = PackStream();
stream.bindToFile("atmo-br-inscatter-128-32-8-32-0.cache", true);
inscatter.save(&stream);
inscatter.saveToFile("inscatter.png");
delete[] texdata;
/* Check errors */
int error_code;
while ((error_code = glGetError()) != GL_NO_ERROR)
{
logWarning("[OpenGL] ERROR : %s", (const char*)gluErrorString(error_code));
}
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
@ -718,6 +813,7 @@ int main(int argc, char* argv[])
loadData();
precompute();
dumpTextures();
updateView();
glutMainLoop();
}

View file

@ -1,7 +1,5 @@
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
TARGET = paysages-experiment-bruneton
@ -23,3 +21,15 @@ HEADERS += \
mat4.h \
vec3.h
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../system/release/ -lpaysages_system
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../system/debug/ -lpaysages_system
else:unix: LIBS += -L$$OUT_PWD/../../system/ -lpaysages_system
INCLUDEPATH += $$PWD/../../system
DEPENDPATH += $$PWD/../../system
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../basics/release/ -lpaysages_basics
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../basics/debug/ -lpaysages_basics
else:unix: LIBS += -L$$OUT_PWD/../../basics/ -lpaysages_basics
INCLUDEPATH += $$PWD/../../basics
DEPENDPATH += $$PWD/../../basics

View file

@ -5,7 +5,7 @@ CacheFile::CacheFile(const char* module, const char* ext, const char* tag1, int
datapath = (char*)malloc(sizeof(char) * 501);
filepath = (char*)malloc(sizeof(char) * 501);
snprintf(datapath, 500, "/usr/share/paysages3d/%s-%s-%d-%d-%d-%d-%d.%s", module, tag1, tag2, tag3, tag4, tag5, tag6, ext);
snprintf(datapath, 500, "./data/cache/%s-%s-%d-%d-%d-%d-%d.%s", module, tag1, tag2, tag3, tag4, tag5, tag6, ext);
snprintf(filepath, 500, "./cache/%s-%s-%d-%d-%d-%d-%d.%s", module, tag1, tag2, tag3, tag4, tag5, tag6, ext);
}