-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d689356
commit 5ac7fb6
Showing
17 changed files
with
336 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#include <tricore/tricore.h> | ||
#include <triutil/triutil.h> | ||
|
||
|
||
using namespace tri::core; | ||
using namespace tri::core::materials; | ||
using namespace tri::core::meshes; | ||
using namespace tri::util; | ||
|
||
static constexpr auto width = 480; | ||
static constexpr auto height = 480; | ||
|
||
int main(){ | ||
Window window("scene3", width, height); | ||
Camera camera(width, height, {0, 0, 3.0}, {0, 0, -1.0f}); | ||
|
||
Renderer renderer(*window.get(), camera); | ||
|
||
auto light = light::make_point({ | ||
.pos = {0, 0, -4.0}, | ||
.color = {1, 1, 1}, | ||
.attentuation = { | ||
.constant = 1.0, | ||
.linear = 0.0, | ||
.quadratic = 0.0 | ||
} | ||
}); | ||
|
||
static constexpr glm::vec3 secondLightPos = {-10, 1, -10}; | ||
|
||
auto lightModel = std::make_shared<Model>(); | ||
lightModel->setMesh(Sphere()) | ||
.setMaterial<LightMaterial>(glm::vec3{1.0, 1.0, 1.0}) | ||
.setTranslation({0, 4.0, -4.0}) | ||
.setScaleXYZ({0.3, 0.3, 0.3}); | ||
|
||
renderer | ||
.setSkybox(Cubemap({ | ||
.right = "examples/data/skybox/space/right.png", | ||
.left = "examples/data/skybox/space/left.png", | ||
.top = "examples/data/skybox/space/top.png", | ||
.bottom = "examples/data/skybox/space/bottom.png", | ||
.front = "examples/data/skybox/space/front.png", | ||
.back = "examples/data/skybox/space/back.png" | ||
})) | ||
.add([](){ | ||
auto cubeModel = std::make_shared<Model>(); | ||
cubeModel->setMesh(VertexCube()) | ||
.setMaterial<SolidMaterial>(glm::vec3{1.0, 0.0, 0.0}) | ||
.setTranslation({-7, -0.5, -10}); | ||
return cubeModel; | ||
}()) | ||
.add([](){ | ||
auto capsule = std::make_shared<Model>(); | ||
capsule->setMesh(Mesh::fromFile("examples/data/mesh/textured_with_normals.obj")) | ||
.setMaterial<SolidMaterial>(glm::vec3{0.0, 0.0, 1.0}, 1.0, 0.3, 1.0) | ||
.setTranslation({-5, -0.5, -5}); | ||
return capsule; | ||
}()) | ||
.add([](){ | ||
auto lightModel = std::make_shared<Model>(); | ||
lightModel->setMesh(Sphere()) | ||
.setMaterial<LightMaterial>(glm::vec3{1.0, 1.0, 1.0}) | ||
.setTranslation(secondLightPos) | ||
.setScaleXYZ({0.3, 0.3, 0.3}); | ||
return lightModel; | ||
}()) | ||
.add(lightModel) | ||
.add([](){ | ||
auto floor = std::make_shared<Model>(); | ||
floor->setMesh(Plane()) | ||
.setMaterial(TextureMaterialBuilder() | ||
.setShininess(1024) | ||
.setTexture(std::move(Texture("examples/data/textures/brickwall.jpg"))) | ||
.setNormalMap(std::move(Texture("examples/data/textures/brickwall_normal.jpg"))) | ||
.build() | ||
).setScaleXYZ({20, 20, 20}) | ||
.setTranslation({-5, -2, -10}); | ||
return floor; | ||
}()) | ||
.addLightSource(light) | ||
.addLightSource(light::make_point({ | ||
.pos = secondLightPos, | ||
.color = {1, 1, 1}, | ||
.attentuation = { | ||
.constant = 1.0, | ||
.linear = 0.1, | ||
.quadratic = 0.0 | ||
} | ||
})); | ||
|
||
static constexpr auto R = 5.0; | ||
while (!glfwWindowShouldClose(window.get())) | ||
{ | ||
renderer.render(); | ||
camera.poll(window.get()); | ||
auto theta = glfwGetTime(); | ||
glm::vec3 pos = glm::vec3{R * sin(theta), 3.0, R * cos(theta)}; | ||
light->pos = pos; | ||
lightModel->setTranslation(pos); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
out vec4 FragColor; | ||
|
||
in vec2 TexCoords; | ||
|
||
uniform sampler2D screenTexture; | ||
|
||
void main() | ||
{ | ||
FragColor = texture(screenTexture, TexCoords); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
in vec2 aPos; | ||
in vec2 aTexCoords; | ||
|
||
out vec2 TexCoords; | ||
|
||
void main() | ||
{ | ||
gl_Position = vec4(aPos.x, aPos.y, 0.0, 1.0); | ||
TexCoords = aTexCoords; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.