Skip to content

Commit 8efb739

Browse files
author
Ravbug
committed
add more stuff to Shadows for testing
1 parent a3ef4ba commit 8efb739

14 files changed

Lines changed: 79860 additions & 9 deletions

File tree

RavEngine

Samples/Rendering/main.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ struct GlassMat : public LitMaterial {
9898
};
9999

100100
struct GlassMatInstance : public MaterialInstance {
101-
GlassMatInstance(Ref<GlassMat> m) : MaterialInstance(m) {}
101+
constexpr static uint32_t priority = 2;
102+
GlassMatInstance(Ref<GlassMat> m) : MaterialInstance(m, priority) {}
102103
};
103104

104105
struct Level : public RavEngine::World {
@@ -139,7 +140,8 @@ struct Level : public RavEngine::World {
139140
};
140141

141142
struct TQuadMatInstance : public MaterialInstance {
142-
TQuadMatInstance(Ref<TQuadMat>m) : MaterialInstance(m) {}
143+
constexpr static uint32_t priority = 1;
144+
TQuadMatInstance(Ref<TQuadMat>m) : MaterialInstance(m,priority) {}
143145
};
144146

145147
struct alignas(4) ParticleRenderData {
@@ -195,7 +197,7 @@ struct Level : public RavEngine::World {
195197
floor.GetTransform().SetLocalScale(vector3(floorSize, 1, floorSize));
196198

197199
auto floorMesh = New<MeshCollectionStatic>(MeshAsset::Manager::Get("quad"));
198-
auto floorMat = RavEngine::New<PBRMaterialInstance>(Material::Manager::Get<PBRMaterial>());
200+
auto floorMat = RavEngine::New<PBRMaterialInstance>(Material::Manager::Get<PBRMaterial>(),2);
199201
floorMat->SetAlbedoColor({ 0.5,0.5,0.5,1 });
200202
floor.EmplaceComponent<StaticMesh>(floorMesh, floorMat);
201203

@@ -330,7 +332,7 @@ struct Level : public RavEngine::World {
330332

331333
auto helmetObj = Instantiate<GameObject>();
332334
auto helmetMesh = New<MeshCollectionStatic>(MeshAsset::Manager::Get("helmet"));
333-
auto helmetMat = New<PBRMaterialInstance>(Material::Manager::Get<PBRMaterial>());
335+
auto helmetMat = New<PBRMaterialInstance>(Material::Manager::Get<PBRMaterial>(),1);
334336
helmetMat->SetAlbedoTexture(Texture::Manager::Get("Default_albedo.png"));
335337
helmetMat->SetNormalTexture(Texture::Manager::Get("Default_normal.png"));
336338
helmetMat->SetMetallicTexture(Texture::Manager::Get("Default_metalness.png"));

Samples/Rendering/shaders/star.vsh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ UnlitVertexOut vert(EntityIn entity, EngineData data)
1010
UnlitVertexOut vs_out;
1111

1212
vs_out.localPosition = inPosition;
13+
outUV = inUV;
1314

1415
return vs_out;
1516
}

Samples/Shadows/main.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,20 @@ struct Level : public RavEngine::World{
147147
auto pointLight = Instantiate<GameObject>();
148148
auto& pLight = pointLight.EmplaceComponent<PointLight>();
149149
pLight.debugEnabled = true;
150-
pLight.SetColorRGBA({1,0,0,1});
151-
pLight.SetIntensity(2);
150+
pLight.SetColorRGBA({1,1,1,1});
151+
pLight.SetIntensity(15);
152152
pLight.SetCastsShadows(true);
153153

154154
constexpr static vector3 spotLightInitialPos{0,3,2};
155-
155+
#if 0
156156
auto spotLightEntity = Instantiate<GameObject>();
157157
auto& spotLight = spotLightEntity.EmplaceComponent<SpotLight>();
158158
spotLight.SetCastsShadows(true);
159159
spotLight.debugEnabled = true;
160160
spotLightEntity.GetTransform().LocalTranslateDelta(spotLightInitialPos).LocalRotateDelta(vector3(deg_to_rad(30),0,0));
161161
spotLight.SetIntensity(10);
162162
auto sfwd = spotLightEntity.GetTransform().WorldForward();
163-
163+
#endif
164164
auto im = GetApp()->inputManager = RavEngine::New<InputManager>();
165165
im->AddAxisMap(InputNames::TurnLR, SDL_SCANCODE_D);
166166
im->AddAxisMap(InputNames::TurnLR, SDL_SCANCODE_A, -1);
@@ -172,6 +172,22 @@ struct Level : public RavEngine::World{
172172
im->AddAxisMap(InputNames::Zoom, SDL_SCANCODE_DOWN);
173173
im->BindAxis(InputNames::Zoom, GetInput(this), &Level::Zoom, CID::ANY);
174174

175+
struct DemoObj {
176+
vector3 pos;
177+
std::string name;
178+
};
179+
DemoObj objs[] = {
180+
{{0,0,-3},"bunny_decimated"},
181+
{{0,0,3},"wineglass"},
182+
{{0,3,0},"helmet"},
183+
{{0,-2,0},"rat"},
184+
};
185+
for (const auto& obj : objs) {
186+
auto ent = Instantiate<GameObject>();
187+
ent.GetTransform().SetWorldPosition(obj.pos);
188+
ent.EmplaceComponent<StaticMesh>(MeshCollectionStaticManager::Get(obj.name), cubeMat);
189+
}
190+
175191
// initial orientation
176192
TurnUD(-5);
177193

469 KB
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"file": "bunny_decimated.fbx"
3+
}

Samples/Shadows/meshes/helmet.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"file": "helmet.obj"
3+
}

0 commit comments

Comments
 (0)