Skip to content

Commit a8a0385

Browse files
author
Ravbug
committed
Begin loading baked light data
1 parent b3158ba commit a8a0385

File tree

6 files changed

+67
-3
lines changed

6 files changed

+67
-3
lines changed

RavEngine

Samples/Rendering/main.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,21 @@ struct GlassMatInstance : public MaterialInstance {
102102
GlassMatInstance(Ref<GlassMat> m) : MaterialInstance(m, priority) {}
103103
};
104104

105+
struct BakedMat : public LitMaterial {
106+
BakedMat() : LitMaterial("bakedlight", PipelineOptions{}, { .requiredAttributes = {
107+
.position = true,
108+
.normal = true,
109+
.tangent = true,
110+
.bitangent = true,
111+
.uv0 = true,
112+
.lightmapUV = true
113+
} }) {}
114+
};
115+
116+
struct BakedMatInstance : public MaterialInstance {
117+
BakedMatInstance(Ref<BakedMat> m) : MaterialInstance(m) {}
118+
};
119+
105120
struct Level : public RavEngine::World {
106121

107122
GameObject camRoot, camHeadUD;
@@ -226,10 +241,9 @@ struct Level : public RavEngine::World {
226241

227242
// baked lighting demo
228243
{
229-
auto bakedMat = RavEngine::New<PBRMaterialInstance>(Material::Manager::Get<PBRMaterial>());
244+
auto bakedMat = RavEngine::New<BakedMatInstance>(Material::Manager::Get<BakedMat>());
230245
auto lightmapTex = Texture::Manager::Get("Lightmap-0_comp_light.exr");
231246

232-
bakedMat->SetAlbedoColor({1,0,0,1});
233247
auto bakedCubeObj = Instantiate<GameObject>();
234248
bakedCubeObj.EmplaceComponent<StaticMesh>(MeshCollectionStaticManager::Get("bakedcube"), bakedMat);
235249
auto& cubeTransform = bakedCubeObj.GetTransform();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
layout(location = 0) in vec2 inUV;
3+
4+
LitOutput frag()
5+
{
6+
LitOutput mat_out;
7+
8+
mat_out.color = vec4(1,0,0,1);
9+
10+
mat_out.normal = vec3(0,0,1);
11+
12+
mat_out.ao = 1;
13+
14+
mat_out.roughness = 0.6;
15+
mat_out.specular = 0;
16+
mat_out.metallic = 0;
17+
mat_out.emissiveColor = vec3(0);
18+
19+
return mat_out;
20+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
layout(location = 0) out vec2 outUV;
3+
4+
LitVertexOut vert(EntityIn entity, EngineData data)
5+
{
6+
LitVertexOut v_out;
7+
8+
v_out.localPosition = inPosition;
9+
10+
outUV = inUV;
11+
12+
return v_out;
13+
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"shader": "bakedlight.fsh",
3+
"stage": "fragment",
4+
"type": "lit-mesh",
5+
"defines": [
6+
"RVE_LIGHTMAP_UV"
7+
]
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"shader": "bakedlight.vsh",
3+
"stage": "vertex",
4+
"type": "lit-mesh",
5+
"defines": [
6+
"RVE_LIGHTMAP_UV 1"
7+
]
8+
}

0 commit comments

Comments
 (0)