Skip to content

Commit

Permalink
New renderer.
Browse files Browse the repository at this point in the history
  • Loading branch information
gonsolo committed Oct 12, 2023
1 parent 39154e2 commit b0984e4
Show file tree
Hide file tree
Showing 7 changed files with 280 additions and 181 deletions.
13 changes: 10 additions & 3 deletions Sources/cudaBridge/LaunchParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@

namespace osc {
using namespace gdt;

struct TriangleMeshSBTData {
vec3f color;
vec3f *vertex;
vec3f *normal;
vec2f *texcoord;
vec3i *index;
bool hasTexture;
cudaTextureObject_t texture;
};

struct LaunchParams
{
Expand All @@ -34,9 +44,6 @@ namespace osc {
vec3f direction;
vec3f horizontal;
vec3f vertical;

bool useRay;
vec3f rayDirection;
} camera;

OptixTraversableHandle traversable;
Expand Down
33 changes: 33 additions & 0 deletions Sources/cudaBridge/Model.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ======================================================================== //
// Copyright 2018-2019 Ingo Wald //
// //
// Licensed under the Apache License, Version 2.0 (the "License"); //
// you may not use this file except in compliance with the License. //
// You may obtain a copy of the License at //
// //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
// Unless required by applicable law or agreed to in writing, software //
// distributed under the License is distributed on an "AS IS" BASIS, //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and //
// limitations under the License. //
// ======================================================================== //

#include "Model.h"
#define TINYOBJLOADER_IMPLEMENTATION
//#include "3rdParty/tiny_obj_loader.h"

#define STB_IMAGE_IMPLEMENTATION
//#include "3rdParty/stb_image.h"

//std
#include <set>

/*! \namespace osc - Optix Siggraph Course */
namespace osc {




}
69 changes: 69 additions & 0 deletions Sources/cudaBridge/Model.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// ======================================================================== //
// Copyright 2018-2019 Ingo Wald //
// //
// Licensed under the Apache License, Version 2.0 (the "License"); //
// you may not use this file except in compliance with the License. //
// You may obtain a copy of the License at //
// //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
// Unless required by applicable law or agreed to in writing, software //
// distributed under the License is distributed on an "AS IS" BASIS, //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and //
// limitations under the License. //
// ======================================================================== //

#pragma once

#include "gdt/math/AffineSpace.h"
#include <vector>

/*! \namespace osc - Optix Siggraph Course */
namespace osc {
using namespace gdt;

/*! a simple indexed triangle mesh that our sample renderer will
render */
struct TriangleMesh {
std::vector<vec3f> vertex;
std::vector<vec3f> normal;
std::vector<vec2f> texcoord;
std::vector<vec3i> index;

// material data:
vec3f diffuse;
int diffuseTextureID { -1 };

void addTriangle(float ax, float ay, float az, float bx, float by, float bz, float cx, float cy, float cz)
{
int firstVertexID = (int)vertex.size();
affine3f xfm;
xfm.p = vec3f(0.f, 0.f, 0.f);
xfm.l.vx = vec3f(1.f ,0.f, 0.f);
xfm.l.vy = vec3f(0.f, 1.f, 0.f);
xfm.l.vz = vec3f(0.f, 0.f, 1.f);
vertex.push_back(xfmPoint(xfm, vec3f( ax, ay, az)));
vertex.push_back(xfmPoint(xfm, vec3f( bx, by, bz)));
vertex.push_back(xfmPoint(xfm, vec3f( cx, cy, cz)));

int indices[] = {0, 1, 2};
index.push_back(firstVertexID+vec3i(indices[0],
indices[1],
indices[2]));
}

};


struct Model {
~Model()
{
//for (auto mesh : meshes) delete mesh;
}

std::vector<TriangleMesh *> meshes;
};

Model *loadOBJ(const std::string &objFile);
}
Loading

0 comments on commit b0984e4

Please sign in to comment.