Skip to content

Commit

Permalink
Some small temporary fixes to allow scene changes to work with new UI
Browse files Browse the repository at this point in the history
  • Loading branch information
knightcrawler25 committed Jan 7, 2019
1 parent d728b6b commit 05c92ca
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Nvidia-SBVH/src/GPUScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class GPUScene
GPUScene(const S32 numTris, const S32 numVerts, const Array<Triangle>& tris, const Array<Vec3f>& verts) :
m_numTris(numTris), m_numVerts(numVerts), m_tris(tris), m_verts(verts) {}

~GPUScene(void);
~GPUScene(void) {};

int getNumTriangles(void) const { return m_numTris; }
const Triangle* getTrianglePtr(int idx = 0) { FW_ASSERT(idx >= 0 && idx <= m_numTris); return (const Triangle*)m_tris.getPtr() + idx; }
Expand Down
8 changes: 6 additions & 2 deletions PathTracer/src/GPUBVH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

namespace GLSLPathTracer
{
static int current;

int GPUBVH::traverseBVH(BVHNode *root)
{
AABB *cbox = &root->m_bounds;
Expand Down Expand Up @@ -49,9 +47,15 @@ namespace GLSLPathTracer
GPUBVH::GPUBVH(const BVH* bvh)
{
this->bvh = bvh;
current = 0;
createGPUBVH();
}

GPUBVH::~GPUBVH()
{
delete[] gpuNodes;
}

void GPUBVH::createGPUBVH()
{
gpuNodes = new GPUBVHNode[bvh->getNumNodes()];
Expand Down
2 changes: 2 additions & 0 deletions PathTracer/src/GPUBVH.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ namespace GLSLPathTracer
{
public:
GPUBVH(const BVH *bvh);
~GPUBVH();
void createGPUBVH();
int traverseBVH(BVHNode *root);
GPUBVHNode *gpuNodes;
const BVH *bvh;
int current;
std::vector<TriIndexData> bvhTriangleIndices;
};
}
3 changes: 0 additions & 3 deletions PathTracer/src/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ namespace GLSLPathTracer
glGenTextures(1, &albedoTextures);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D_ARRAY, albedoTextures);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, scene->texData.albedoTextureSize.x, scene->texData.albedoTextureSize.y, scene->texData.albedoTexCount);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB8, scene->texData.albedoTextureSize.x, scene->texData.albedoTextureSize.y, scene->texData.albedoTexCount, 0, GL_RGB, GL_UNSIGNED_BYTE, scene->texData.albedoTextures);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
Expand All @@ -143,7 +142,6 @@ namespace GLSLPathTracer
{
glGenTextures(1, &metallicRoughnessTextures);
glBindTexture(GL_TEXTURE_2D_ARRAY, metallicRoughnessTextures);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, scene->texData.metallicRoughnessTextureSize.x, scene->texData.metallicRoughnessTextureSize.y, scene->texData.metallicRoughnessTexCount);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB8, scene->texData.metallicRoughnessTextureSize.x, scene->texData.metallicRoughnessTextureSize.y, scene->texData.metallicRoughnessTexCount, 0, GL_RGB, GL_UNSIGNED_BYTE, scene->texData.metallicRoughnessTextures);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
Expand All @@ -155,7 +153,6 @@ namespace GLSLPathTracer
{
glGenTextures(1, &normalTextures);
glBindTexture(GL_TEXTURE_2D_ARRAY, normalTextures);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB, scene->texData.normalTextureSize.x, scene->texData.normalTextureSize.y, scene->texData.normalTexCount);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGB8, scene->texData.normalTextureSize.x, scene->texData.normalTextureSize.y, scene->texData.normalTexCount, 0, GL_RGB, GL_UNSIGNED_BYTE, scene->texData.normalTextures);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
Expand Down
8 changes: 5 additions & 3 deletions PathTracer/src/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ namespace GLSLPathTracer
{
delete camera;
delete gpuBVH;
delete gpuScene;
delete bvh;
}
void Scene::buildBVH()
{
Expand All @@ -40,17 +42,17 @@ namespace GLSLPathTracer
}

std::cout << "Building a new GPU Scene\n";
GPUScene* gpuScene = new GPUScene(triCount, verCount, tris, verts);
gpuScene = new GPUScene(triCount, verCount, tris, verts);

std::cout << "Building BVH with spatial splits\n";
// create a default platform
Platform defaultplatform;
BVH::BuildParams defaultparams;
BVH::Stats stats;
BVH *myBVH = new BVH(gpuScene, defaultplatform, defaultparams);
bvh = new BVH(gpuScene, defaultplatform, defaultparams);

std::cout << "Building GPU-BVH\n";
gpuBVH = new GPUBVH(myBVH);
gpuBVH = new GPUBVH(bvh);
std::cout << "GPU-BVH successfully created\n";
}
}
2 changes: 2 additions & 0 deletions PathTracer/src/Scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ namespace GLSLPathTracer
void addCamera(glm::vec3 pos, glm::vec3 lookAt, float fov);
Camera *camera;
GPUBVH *gpuBVH;
GPUScene *gpuScene;
BVH *bvh;
std::vector<TriangleData> triangleIndices;
std::vector<NormalTexData> normalTexData;
std::vector<VertexData> vertexData;
Expand Down
3 changes: 1 addition & 2 deletions PathTracer/src/shaders/Progressive/PathTraceFrag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,7 @@ vec3 PathTrace(Ray r)
if (state.mat.albedo.w == 0.0) // UE4 Brdf
{
state.specularBounce = false;
if(depth < maxDepth - 1)
radiance += DirectLight(r, state) * throughput;
radiance += DirectLight(r, state) * throughput;

bsdfSampleRec.bsdfDir = UE4Sample(r, state);
bsdfSampleRec.pdf = UE4Pdf(r, state, bsdfSampleRec.bsdfDir);
Expand Down

0 comments on commit 05c92ca

Please sign in to comment.