-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add limitless samples for materials and effects
- Loading branch information
1 parent
e9e1108
commit 9101618
Showing
97 changed files
with
1,326 additions
and
126 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,14 @@ | ||
#pragma once | ||
|
||
#include <limitless/assets.hpp> | ||
#include <limitless/renderer/renderer.hpp> | ||
|
||
namespace LimitlessMaterials { | ||
class Assets : public Limitless::Assets { | ||
private: | ||
void setUpEffects(); | ||
void setUpCommon(Limitless::Context &ctx); | ||
public: | ||
Assets(Limitless::Context& ctx, const fs::path& path); | ||
}; | ||
} |
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,135 @@ | ||
#include "scene.hpp" | ||
#include "assets.hpp" | ||
|
||
#include <limitless/core/context_observer.hpp> | ||
#include <limitless/text/text_instance.hpp> | ||
#include <limitless/util/color_picker.hpp> | ||
#include <limitless/core/state_query.hpp> | ||
#include <limitless/core/texture/state_texture.hpp> | ||
#include <limitless/renderer/renderer.hpp> | ||
|
||
namespace LimitlessMaterials { | ||
class MaterialsScene | ||
: public Limitless::MouseMoveObserver, | ||
public Limitless::KeyObserver, | ||
public Limitless::FramebufferObserver { | ||
private: | ||
glm::uvec2 window_size {1080, 720}; | ||
|
||
Limitless::ContextEventObserver context; | ||
Limitless::Camera camera; | ||
Limitless::Renderer render; | ||
Assets assets; | ||
Scene scene; | ||
|
||
bool done{}; | ||
bool hidden_text{}; | ||
public: | ||
MaterialsScene() | ||
: context {"Limitless-demo", window_size, {{Limitless::WindowHint::Resizable, false}}} | ||
, camera {window_size} | ||
, render {context} | ||
, assets {context, ENGINE_ASSETS_DIR} | ||
, scene {context, assets} { | ||
camera.setPosition({-3.0f, 2.0f, 3.0f}); | ||
|
||
if (!Limitless::ContextInitializer::checkMinimumRequirements()) { | ||
throw std::runtime_error("Minimum requirements are not met!"); | ||
} | ||
|
||
context.setCursorMode(Limitless::CursorMode::Normal); | ||
context.setSwapInterval(1); | ||
context.setStickyKeys(true); | ||
|
||
context.registerObserver(static_cast<KeyObserver *>(this)); | ||
context.registerObserver(static_cast<MouseMoveObserver *>(this)); | ||
context.registerObserver(static_cast<FramebufferObserver *>(this)); | ||
|
||
assets.recompileAssets(context, render.getSettings()); | ||
} | ||
|
||
~MaterialsScene() override { | ||
context.unregisterObserver(static_cast<KeyObserver *>(this)); | ||
context.unregisterObserver(static_cast<MouseMoveObserver *>(this)); | ||
context.unregisterObserver(static_cast<FramebufferObserver *>(this)); | ||
} | ||
|
||
void onMouseMove(glm::dvec2 pos) override { | ||
static glm::dvec2 last_move = {0, 0}; | ||
|
||
auto offset = glm::vec2{pos.x - last_move.x, last_move.y - pos.y}; | ||
last_move = pos; | ||
|
||
camera.mouseMove(offset); | ||
} | ||
|
||
void onKey(int key, [[maybe_unused]] int scancode, Limitless::InputState state, [[maybe_unused]] Limitless::Modifier modifier) override { | ||
using namespace Limitless; | ||
if (key == GLFW_KEY_ESCAPE && state == Limitless::InputState::Pressed) { | ||
done = true; | ||
} | ||
|
||
if (key == GLFW_KEY_SPACE && state == Limitless::InputState::Pressed) { | ||
camera.getMoveSpeed() *= 5.0f; | ||
} | ||
|
||
if (key == GLFW_KEY_SPACE && state == Limitless::InputState::Released) { | ||
camera.getMoveSpeed() /= 5.0f; | ||
} | ||
|
||
if (key == GLFW_KEY_GRAVE_ACCENT && state == Limitless::InputState::Released) { | ||
hidden_text = !hidden_text; | ||
} | ||
} | ||
|
||
void onFramebufferChange(glm::uvec2 size) override { | ||
camera.updateProjection(size); | ||
window_size = size; | ||
|
||
} | ||
|
||
void handleInput(float delta) noexcept { | ||
using namespace Limitless; | ||
|
||
if (context.isPressed(GLFW_KEY_W)) { | ||
camera.movement(CameraMovement::Forward, delta); | ||
} | ||
|
||
if (context.isPressed(GLFW_KEY_S)) { | ||
camera.movement(CameraMovement::Backward, delta); | ||
} | ||
|
||
if (context.isPressed(GLFW_KEY_A)) { | ||
camera.movement(CameraMovement::Left, delta); | ||
} | ||
|
||
if (context.isPressed(GLFW_KEY_D)) { | ||
camera.movement(CameraMovement::Right, delta); | ||
} | ||
} | ||
|
||
void gameLoop() { | ||
using namespace std::chrono; | ||
while (!context.shouldClose() && !done) { | ||
auto current_time = steady_clock::now(); | ||
static auto last_time = steady_clock::now(); | ||
auto delta_time = duration_cast<duration<float>>(current_time - last_time).count(); | ||
last_time = current_time; | ||
|
||
scene.update(context, camera); | ||
render.draw(context, assets, scene.getScene(), camera); | ||
|
||
context.swapBuffers(); | ||
context.pollEvents(); | ||
|
||
handleInput(delta_time); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
int main() { | ||
LimitlessMaterials::MaterialsScene scene; | ||
scene.gameLoop(); | ||
return 0; | ||
} |
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,119 @@ | ||
#include "scene.hpp" | ||
|
||
#include <limitless/scene.hpp> | ||
#include <limitless/instances/instanced_instance.hpp> | ||
#include <limitless/ms/material.hpp> | ||
#include <limitless/lighting/light.hpp> | ||
#include <limitless/fx/modules/mesh_location.hpp> | ||
#include <limitless/fx/particle.hpp> | ||
#include <limitless/fx/emitters/sprite_emitter.hpp> | ||
|
||
using namespace LimitlessMaterials; | ||
using namespace Limitless; | ||
|
||
LimitlessMaterials::Scene::Scene(Limitless::Context& ctx, Limitless::Assets& assets) | ||
: scene(ctx) | ||
, assets {assets} { | ||
setUpLighting(); | ||
setUpEffects(); | ||
} | ||
|
||
void LimitlessMaterials::Scene::update(Limitless::Context& context, const Limitless::Camera& camera) { | ||
scene.update(context, camera); | ||
hurricane->rotateBy(glm::vec3(0.0f, 0.3f, 0.0f)); | ||
} | ||
|
||
void LimitlessMaterials::Scene::setUpEffects() { | ||
using namespace Limitless; | ||
|
||
auto floor = std::make_shared<InstancedInstance>(); | ||
for (int i = 0; i < 30; ++i) { | ||
for (int j = 0; j < 30; ++j) { | ||
floor->add(Instance::builder() | ||
.model(assets.models.at("plane")) | ||
.material(assets.materials.at("basic1")) | ||
.position(glm::vec3{i, 0.0f, j}) | ||
.asModel() | ||
); | ||
} | ||
} | ||
scene.add(floor); | ||
|
||
scene.add(Instance::builder() | ||
.effect(assets.effects.at("blink")) | ||
.position({29.0f, 1.0f, 1.0f}) | ||
.build() | ||
); | ||
|
||
scene.add(Instance::builder() | ||
.effect(assets.effects.at("shield")) | ||
.position({29.0f, 1.0f, 4.0f}) | ||
.build() | ||
); | ||
|
||
scene.add(Instance::builder() | ||
.effect(assets.effects.at("fireball")) | ||
.position({29.0f, 1.0f, 7.0f}) | ||
.build() | ||
); | ||
|
||
scene.add(Instance::builder() | ||
.effect(assets.effects.at("explosion")) | ||
.position({29.0f, 1.0f, 10.0f}) | ||
.build() | ||
); | ||
|
||
hurricane = Instance::builder() | ||
.effect(assets.effects.at("hurricane")) | ||
.position({29.0f, 1.0f, 13.0f}) | ||
.asEffect(); | ||
scene.add(hurricane); | ||
|
||
scene.add(Instance::builder() | ||
.effect(assets.effects.at("lightning")) | ||
.position({29.0f, 1.0f, 16.0f}) | ||
.build() | ||
); | ||
|
||
auto stem = Instance::builder() | ||
.model(assets.models.at("model")) | ||
.position({29.0f, 1.0f, 19.0f}) | ||
.asSkeletal(); | ||
stem->play(stem->getAllAnimations()[0].name); | ||
scene.add(stem); | ||
|
||
auto mod = Instance::builder() | ||
.effect(assets.effects.at("modeldrop")) | ||
.position({0.0f, 0.0f, 0.0f}) | ||
.asEffect(); | ||
|
||
const auto& module = mod->get<fx::SpriteEmitter>("sparks").getModule(fx::ModuleType::InitialMeshLocation); | ||
|
||
dynamic_cast<fx::InitialMeshLocation<fx::SpriteParticle>&>(*module).attachModelInstance(stem.get()); | ||
|
||
scene.add(mod); | ||
|
||
scene.add(Instance::builder() | ||
.effect(assets.effects.at("skeleton")) | ||
.position({23.0f, 1.0f, 1.0f}) | ||
.build() | ||
); | ||
|
||
scene.add(Instance::builder() | ||
.effect(assets.effects.at("aura")) | ||
.position({23.0f, 1.0f, 4.0f}) | ||
.build() | ||
); | ||
} | ||
|
||
void LimitlessMaterials::Scene::setUpLighting() { | ||
scene.getLighting().setAmbientColor(glm::vec4(1.0f)); | ||
|
||
scene.setSkybox(assets.skyboxes.at("skybox")); | ||
|
||
scene.add(Light::builder() | ||
.color(glm::vec4(1.0, 1.0, 1.0, 1.0f)) | ||
.direction(glm::vec3{0.3f, -0.99f, 0.0f}) | ||
.build() | ||
); | ||
} |
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.