Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ build/
deps/physx/physx/include/PxConfig.h
Testing/
.mayaSwatches
*.blend1
*.blend2
2 changes: 1 addition & 1 deletion RavEngine
2 changes: 1 addition & 1 deletion Samples/Flags/shaders/flag.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ layout(push_constant) uniform UniformBufferObject{
float time;
} ubo;

LitOutput frag()
LitOutput frag(EnvironmentData envData)
{
LitOutput fs_out;

Expand Down
2 changes: 1 addition & 1 deletion Samples/Flags/shaders/flag_special.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ vec3 calcAlt_v2(vec2 uv){
return resCol;
}

LitOutput frag()
LitOutput frag(EnvironmentData envData)
{
LitOutput fs_out;

Expand Down
2 changes: 1 addition & 1 deletion Samples/Flags/shaders/grass.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ layout(push_constant) uniform UniformBufferObject{
float time;
} ubo;

LitOutput frag()
LitOutput frag(EnvironmentData envData)
{
LitOutput fs_out;

Expand Down
2 changes: 1 addition & 1 deletion Samples/Perf_Draw/shaders/instance_colored.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ layout(push_constant) uniform UniformBufferObject{
float time;
} ubo;

LitOutput frag()
LitOutput frag(EnvironmentData envData)
{
LitOutput fs_out;
fs_out.color = vec4(v_position / 200,1);
Expand Down
31 changes: 27 additions & 4 deletions Samples/Rendering/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,21 @@ struct GlassMatInstance : public MaterialInstance {
GlassMatInstance(Ref<GlassMat> m) : MaterialInstance(m, priority) {}
};

struct BakedMat : public LitMaterial {
BakedMat() : LitMaterial("bakedlight", PipelineOptions{}, { .requiredAttributes = {
.position = true,
.normal = true,
.tangent = true,
.bitangent = true,
.uv0 = true,
.lightmapUV = true
} }) {}
};

struct BakedMatInstance : public MaterialInstance {
BakedMatInstance(Ref<BakedMat> m) : MaterialInstance(m) {}
};

struct Level : public RavEngine::World {

GameObject camRoot, camHeadUD;
Expand Down Expand Up @@ -225,22 +240,27 @@ struct Level : public RavEngine::World {
}

// baked lighting demo
constexpr static renderlayer_t bakedLayer = 0b01;
{
auto bakedMat = RavEngine::New<PBRMaterialInstance>(Material::Manager::Get<PBRMaterial>());
auto bakedMat = RavEngine::New<PBRMaterialBakedInstance>(Material::Manager::Get<PBRMaterialBaked>());
auto lightmapDirTex = Texture::Manager::Get("Lightmap-0_comp_dir.png");
auto lightmapTex = Texture::Manager::Get("Lightmap-0_comp_light.exr");
bakedMat->SetBakedEmissivityTexture(lightmapTex);
bakedMat->SetBakedDirectionTexture(lightmapDirTex);

bakedMat->SetAlbedoColor({1,0,0,1});
auto bakedCubeObj = Instantiate<GameObject>();
bakedCubeObj.EmplaceComponent<StaticMesh>(MeshCollectionStaticManager::Get("bakedcube"), bakedMat);
auto& cubeTransform = bakedCubeObj.GetTransform();
cubeTransform.SetLocalScale({ 0.01 });
cubeTransform.SetLocalPosition({-20,1,0});

bakedCubeObj.SetEntityRenderlayer(bakedLayer); // doesn't exist on any layer the lights illuminate
#if 0
auto bakedPlaneObj = Instantiate<GameObject>();
bakedPlaneObj.EmplaceComponent<StaticMesh>(MeshCollectionStaticManager::Get("bakedplane"), bakedMat);
auto& planeTransform = bakedPlaneObj.GetTransform();
planeTransform.SetLocalScale({ 0.01 });
planeTransform.SetLocalPosition({ -20,1,0 });
#endif
}

// wine glasses
Expand Down Expand Up @@ -285,7 +305,10 @@ struct Level : public RavEngine::World {
auto& light = lightsEntity.EmplaceComponent<DirectionalLight>();
light.SetIntensity(4);
light.SetCastsShadows(true);
lightsEntity.EmplaceComponent<AmbientLight>().SetIntensity(0.2);
light.SetIlluminationLayers(~bakedLayer);
auto& ambientLight = lightsEntity.EmplaceComponent<AmbientLight>();
ambientLight.SetIntensity(0.2);
ambientLight.SetIlluminationLayers(~bakedLayer);


lightsEntity.GetTransform().LocalRotateDelta(vector3{ deg_to_rad(45), deg_to_rad(45),0 });
Expand Down
2 changes: 1 addition & 1 deletion Samples/Rendering/shaders/AsteroidRender.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ vec3 rockTexture(in vec2 uv) {
}


LitOutput frag()
LitOutput frag(EnvironmentData envData)
{
LitOutput mat_out;

Expand Down
2 changes: 1 addition & 1 deletion Samples/Rendering/shaders/wineglass.fsh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ vec3 colors[] = {
vec3(0,0,0.3)
};

LitOutput frag()
LitOutput frag(EnvironmentData envData)
{
LitOutput mat_out;

Expand Down
Binary file added assets/SimpleBakeTest.blend
Binary file not shown.