Skip to content

Commit

Permalink
plague rat (test custom texture)
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Aug 26, 2024
1 parent f691cdf commit 6c6feb3
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 1 deletion.
Binary file added data/cage-tests/plagueRat/Rat.glb
Binary file not shown.
9 changes: 9 additions & 0 deletions data/cage-tests/plagueRat/Rat.glb_Grey.cpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[base]
albedo = 0.5, 0.5, 0.5
roughness = 0.9

[textures]
custom = postules.png

[render]
shader = plague.glsl
3 changes: 3 additions & 0 deletions data/cage-tests/plagueRat/Rat.glb_Pink.cpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[base]
albedo = 1, 0.75, 0.8
roughness = 0.5
3 changes: 3 additions & 0 deletions data/cage-tests/plagueRat/Rat.object
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[]
Rat.glb?Cylinder-0_Pink
Rat.glb?Cylinder-1_Grey
24 changes: 24 additions & 0 deletions data/cage-tests/plagueRat/plague.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

$include /cage/shader/shaderConventions.h

$include /cage/shader/engine/vertex.glsl

void main()
{
updateVertex();
}

$include /cage/shader/engine/fragment.glsl

layout(binding = CAGE_SHADER_TEXTURE_CUSTOM) uniform sampler2D texPostules;

void main()
{
#ifndef DepthOnly
updateNormal();
Material material = loadMaterial();
float postule = texture(texPostules, varUv.xy).r;
material.albedo = mix(material.albedo, vec3(0.5, 1, 0), postule);
outColor = lighting(material);
#endif // DepthOnly
}
Binary file added data/cage-tests/plagueRat/postules.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions data/cage-tests/plagueRat/rat.assets
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[]
scheme = model
bones = true
trianglesOnly = true
scale = 0.2
axes = -x+y-z
Rat.glb?Cylinder-0_Pink
Rat.glb?Cylinder-1_Grey

[]
scheme = skeleton
Rat.glb;skeleton

[]
scheme = animation
Rat.glb?Rat_Death
Rat.glb?Rat_Idle
Rat.glb?Rat_Jump
Rat.glb?Rat_Walk

[]
scheme = object
Rat.object

[]
scheme = shader
plague.glsl

[]
scheme = texture
postules.png

[]
scheme = pack
rat.pack
11 changes: 11 additions & 0 deletions data/cage-tests/plagueRat/rat.pack
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[]
Rat.glb;skeleton
Rat.glb?Cylinder-0_Pink
Rat.glb?Cylinder-1_Grey
Rat.glb?Rat_Death
Rat.glb?Rat_Idle
Rat.glb?Rat_Jump
Rat.glb?Rat_Walk
Rat.object

/cage-tests/skeletons/floor/floor.pack
2 changes: 1 addition & 1 deletion externals/cage
Submodule cage updated 41 files
+37 −0 externals/assimp/CMakeLists.txt
+24 −0 externals/pmp/CMakeLists.txt
+4 −0 sources/CMakeLists.txt
+3 −0 sources/asset-processor/model.cpp
+1 −2 sources/include/cage-core/assetManager.h
+1 −0 sources/include/cage-core/meshImport.h
+7 −0 sources/include/cage-core/networkSteam.h
+1 −1 sources/include/cage-engine/guiComponents.h
+1 −1 sources/include/cage-engine/shaderConventions.h
+2 −4 sources/include/cage-engine/shaderProgram.h
+1 −1 sources/include/cage-engine/window.h
+8 −9 sources/libcore/assets/assetManager.cpp
+4 −4 sources/libcore/concurrent/concurrent.cpp
+4 −4 sources/libcore/concurrent/process.cpp
+2 −2 sources/libcore/config.cpp
+2 −0 sources/libcore/crashHandler.cpp
+3 −3 sources/libcore/filesystem/abstractFiles.cpp
+4 −4 sources/libcore/filesystem/api.cpp
+6 −6 sources/libcore/filesystem/paths.cpp
+7 −7 sources/libcore/filesystem/realFiles.cpp
+1 −1 sources/libcore/filesystem/realWatcher.cpp
+23 −23 sources/libcore/filesystem/zipArchives.cpp
+36 −4 sources/libcore/logger.cpp
+5 −2 sources/libcore/mesh/importAssimp.cpp
+1 −0 sources/libcore/mesh/importConvert.cpp
+107 −76 sources/libcore/network/steam.cpp
+2 −4 sources/libcore/scheduler.cpp
+227 −131 sources/libcore/systemInformation.cpp
+1 −1 sources/libengine/graphics/font.cpp
+4 −10 sources/libengine/graphics/graphicsError.cpp
+1 −1 sources/libengine/graphics/renderPipeline.cpp
+12 −30 sources/libengine/graphics/shaderProgram.cpp
+1 −1 sources/libengine/graphics/uniformBuffer.cpp
+4 −4 sources/libengine/gui/guiBuilder.cpp
+5 −5 sources/libengine/sound/speaker.cpp
+20 −0 sources/libengine/window/glfw.cpp
+46 −3 sources/libengine/window/window.cpp
+2 −1 sources/libsimple/gameloop.cpp
+4 −4 sources/test-core/assetManager.cpp
+1 −1 sources/test-core/networkSteam.cpp
+1 −1 sources/test-core/systemInformation.cpp
89 changes: 89 additions & 0 deletions sources/simple/plagueRat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#include <cage-core/assetManager.h>
#include <cage-core/entities.h>
#include <cage-core/hashString.h>
#include <cage-core/logger.h>
#include <cage-engine/highPerformanceGpuHint.h>
#include <cage-engine/scene.h>
#include <cage-engine/window.h>
#include <cage-simple/engine.h>
#include <cage-simple/fpsCamera.h>
#include <cage-simple/statisticsGui.h>

using namespace cage;
constexpr uint32 AssetsName = HashString("cage-tests/plagueRat/rat.pack");

int main(int argc, char *args[])
{
try
{
// log to console
Holder<Logger> log1 = newLogger();
log1->format.bind<logFormatConsole>();
log1->output.bind<logOutputStdOut>();

engineInitialize(EngineCreateConfig());

// events
//const auto updateListener = controlThread().update.listen(&update);
const auto closeListener = engineWindow()->events.listen(inputFilter([](input::WindowClose) { engineStop(); }));

// window
engineWindow()->setMaximized();
engineWindow()->title("plague rat (test custom texture)");

// entities
EntityManager *ents = engineEntities();
{ // camera
Entity *e = ents->create(1);
e->value<TransformComponent>().position = Vec3(0, 3, 7);
e->value<TransformComponent>().orientation = Quat(Degs(-20), Degs(), Degs());
CameraComponent &c = e->value<CameraComponent>();
c.near = 0.1;
c.far = 1000;
c.ambientColor = Vec3(1);
c.ambientIntensity = 0.2;
}
{ // sun
Entity *e = ents->createUnique();
TransformComponent &t = e->value<TransformComponent>();
t.orientation = Quat(Degs(-50), Degs(270), Degs());
t.position = Vec3(0, 2, 0);
LightComponent &l = e->value<LightComponent>();
l.lightType = LightTypeEnum::Directional;
l.color = Vec3(1);
l.intensity = 1;
ShadowmapComponent &s = e->value<ShadowmapComponent>();
s.resolution = 2048;
s.directionalWorldSize = 15;
}
{ // floor
Entity *e = ents->createUnique();
e->value<TransformComponent>().position = Vec3();
e->value<RenderComponent>().object = HashString("cage-tests/skeletons/floor/floor.obj");
}
{ // the rat
Entity *e = ents->createAnonymous();
e->value<TransformComponent>().position = Vec3(0, 0, 0);
e->value<TransformComponent>().orientation = Quat({}, Degs(180), {});
e->value<RenderComponent>().object = HashString("cage-tests/plagueRat/Rat.object");
e->value<SkeletalAnimationComponent>().name = HashString("cage-tests/plagueRat/Rat.glb?Rat_Walk");
}

Holder<FpsCamera> cameraCtrl = newFpsCamera(ents->get(1));
cameraCtrl->mouseButton = MouseButtonsFlags::Left;
cameraCtrl->movementSpeed = 0.3;
Holder<StatisticsGui> statistics = newStatisticsGui();

engineAssets()->load(AssetsName);
engineRun();
engineAssets()->unload(AssetsName);
engineFinalize();

return 0;
}
catch (...)
{
detail::logCurrentCaughtException();
return 1;
}
}

0 comments on commit 6c6feb3

Please sign in to comment.