Commit 3deec03d authored by Dario Seyb's avatar Dario Seyb

filled another screen

parent 779f0f9e
...@@ -96,6 +96,7 @@ void main() ...@@ -96,6 +96,7 @@ void main()
vec3 lightDir = vec3(0); vec3 lightDir = vec3(0);
float lightDistance = 1; float lightDistance = 1;
float attenuation = 1;
if(uLightIsDirectional) { if(uLightIsDirectional) {
lightDir = uLightDir; lightDir = uLightDir;
...@@ -103,6 +104,7 @@ void main() ...@@ -103,6 +104,7 @@ void main()
lightDir = uLightPosition - worldPosition; lightDir = uLightPosition - worldPosition;
lightDistance = length(lightDir); lightDistance = length(lightDir);
lightDir /= lightDistance; lightDir /= lightDistance;
attenuation = max(1, 1.0/pow(lightDistance, 2));
} }
vec3 viewDir = normalize(cameraPosition - worldPosition); vec3 viewDir = normalize(cameraPosition - worldPosition);
...@@ -115,5 +117,7 @@ void main() ...@@ -115,5 +117,7 @@ void main()
float ssao = ssaoFactor(); float ssao = ssaoFactor();
oColor = vec4(lighting.rgb * ssao * shadowFactor(worldPosition) + emissive.rgb, uOneOverLightCount * albedo.a);
oColor = vec4(lighting.rgb * ssao * shadowFactor(worldPosition) * attenuation + emissive.rgb, uOneOverLightCount * albedo.a);
} }
...@@ -40,7 +40,7 @@ private: ...@@ -40,7 +40,7 @@ private:
Entity planetViewCam; Entity planetViewCam;
Material cockpitMaterial, sunMaterial, skyboxMaterial, windshieldMaterial; Material cockpitMaterial, sunMaterial, skyboxMaterial, windshieldMaterial;
Geometry cockpitGeometry, sunGeometry, skyboxGeometry, planetViewGeom; Geometry cockpitGeometry, sunGeometry, skyboxGeometry, planetViewGeom, logoViewGeom;
Geometry consoleGeom, consoleFrontLeftGeom, consoleFrontRightGeom, consoleBackLeftGeom, consoleBackRightGeom, consoleMiddleLeftGeom, consoleMiddleRightGeom, windShieldGeom; Geometry consoleGeom, consoleFrontLeftGeom, consoleFrontRightGeom, consoleBackLeftGeom, consoleBackRightGeom, consoleMiddleLeftGeom, consoleMiddleRightGeom, windShieldGeom;
SharedTexture2D outOfOrderTexture; SharedTexture2D outOfOrderTexture;
...@@ -50,6 +50,9 @@ private: ...@@ -50,6 +50,9 @@ private:
double planetRotationSpeed = 0; double planetRotationSpeed = 0;
Transform::Handle planetViewTransform; Transform::Handle planetViewTransform;
Transform::Handle logoViewTransform;
std::shared_ptr<Sound> soundTrackIntro, soundTrackMain; std::shared_ptr<Sound> soundTrackIntro, soundTrackMain;
bool resourceLoadingFinished = false; bool resourceLoadingFinished = false;
......
...@@ -91,6 +91,9 @@ bool AtmosphereTestScene::startup() { ...@@ -91,6 +91,9 @@ bool AtmosphereTestScene::startup() {
m_renderer->addRenderPass(planetViewCam, "PlanetView"_sh, ScreenSpaceSize::HALF); m_renderer->addRenderPass(planetViewCam, "PlanetView"_sh, ScreenSpaceSize::HALF);
m_renderer->setRenderPassOnlyTexture("PlanetView"_sh, true); m_renderer->setRenderPassOnlyTexture("PlanetView"_sh, true);
m_renderer->addRenderPass(planetViewCam, "LogoView"_sh, ScreenSpaceSize::HALF);
m_renderer->setRenderPassOnlyTexture("LogoView"_sh, true);
m_console.m_events = m_events; m_console.m_events = m_events;
m_console.m_renderer = m_renderer; m_console.m_renderer = m_renderer;
m_console.m_sceneGraph = m_sceneGraph; m_console.m_sceneGraph = m_sceneGraph;
...@@ -177,6 +180,9 @@ bool AtmosphereTestScene::startup() { ...@@ -177,6 +180,9 @@ bool AtmosphereTestScene::startup() {
planetRotationSpeed -= planetRotationSpeed * e.dt * 0.3; planetRotationSpeed -= planetRotationSpeed * e.dt * 0.3;
planetViewTransform->rotation = glm::rotate<double>(planetViewTransform->rotation, planetRotationSpeed * e.dt, glm::dvec3{ 0.0, 1.0, 0.0 }); planetViewTransform->rotation = glm::rotate<double>(planetViewTransform->rotation, planetRotationSpeed * e.dt, glm::dvec3{ 0.0, 1.0, 0.0 });
logoViewTransform->rotation = glm::inverse(m_player->getShipRotation()); // glm::rotate<double>(logoViewTransform->rotation, 1.0 * e.dt, glm::dvec3{ 0.0, 1.0, 0.0 });
}); });
m_events->subscribe<KeyboardEvent>([this](const KeyboardEvent &e) { m_events->subscribe<KeyboardEvent>([this](const KeyboardEvent &e) {
...@@ -306,7 +312,7 @@ void AtmosphereTestScene::switchToMainScene() { ...@@ -306,7 +312,7 @@ void AtmosphereTestScene::switchToMainScene() {
cockpitTransform->position = glm::dvec3(0, 0, 0); cockpitTransform->position = glm::dvec3(0, 0, 0);
cockpitDrawable->visible = true; cockpitDrawable->visible = true;
auto cockpitLight = auto cockpitLight =
cockpit.assign<Light>(glm::vec4(1, 1, 1, 0.2), glm::vec3(1, 0, 0), cockpit.assign<Light>(glm::vec4(1, 1, 1, 0.0), glm::vec3(1, 0, 0),
false, LightType::POINT, cockpitPassId); false, LightType::POINT, cockpitPassId);
...@@ -318,6 +324,15 @@ void AtmosphereTestScene::switchToMainScene() { ...@@ -318,6 +324,15 @@ void AtmosphereTestScene::switchToMainScene() {
cockpitSun.assign<Light>(glm::vec4(1, 1, 1, 3), glm::vec3(1, 0, 0), cockpitSun.assign<Light>(glm::vec4(1, 1, 1, 3), glm::vec3(1, 0, 0),
true, LightType::DIRECTIONAL, cockpitPassId); true, LightType::DIRECTIONAL, cockpitPassId);
auto lightLeft = m_sceneGraph->create();
lightLeft.assign<Transform>()->position = { -0.6, 0.6, -2.34 };
lightLeft.assign<Light>(glm::vec4(1.0, 0.5, 0.3, 0.5), glm::vec3(1, 0, 0), false, LightType::POINT, cockpitPassId);
auto lightRight= m_sceneGraph->create();
lightRight.assign<Transform>()->position = { 0.6, 0.6, -2.34 };
lightRight.assign<Light>(glm::vec4(0.3, 1.0, 0.4, 0.5), glm::vec3(1, 0, 0), false, LightType::POINT, cockpitPassId);
auto console = m_sceneGraph->create(); auto console = m_sceneGraph->create();
console.assign<Drawable>( console.assign<Drawable>(
consoleGeom, consoleGeom,
...@@ -334,9 +349,9 @@ void AtmosphereTestScene::switchToMainScene() { ...@@ -334,9 +349,9 @@ void AtmosphereTestScene::switchToMainScene() {
auto consoleFrontLeft = m_sceneGraph->create(); auto consoleFrontLeft = m_sceneGraph->create();
consoleFrontLeft.assign<Drawable>( consoleFrontLeft.assign<Drawable>(
consoleFrontLeftGeom, consoleFrontLeftGeom,
Material{ glm::vec4{ 1, 1, 1, 1 }, glm::vec4{ 1, 1, 1, 1 }, Material{ glm::vec4{ 0.2, 0.2, 0.2, 1 }, glm::vec4{ 1, 1, 1, 1 },
outOfOrderTexture, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, m_renderer->getRenderPassTarget("LogoView"_sh),
skyboxMaterial.prog, true, RenderQueue::OPAQUE, GL_NONE }, defaultPbrProg, true, RenderQueue::OPAQUE, GL_NONE },
0, cockpitPassId); 0, cockpitPassId);
consoleFrontLeft.assign<Transform>(); consoleFrontLeft.assign<Transform>();
...@@ -411,6 +426,23 @@ void AtmosphereTestScene::switchToMainScene() { ...@@ -411,6 +426,23 @@ void AtmosphereTestScene::switchToMainScene() {
false, LightType::POINT, planetViewPassId); false, LightType::POINT, planetViewPassId);
} }
{
auto logoViewPassId = m_renderer->getRenderPassId("LogoView"_sh);
auto logoView = m_sceneGraph->create();
logoView.assign<Drawable>(
logoViewGeom,
Material{ glm::vec4{ 1, 1, 1, 1 }, glm::vec4{ 1.0, 0.5, 0.3, 1 },
nullptr, nullptr, nullptr, nullptr,
defaultPbrProg, true, RenderQueue::OPAQUE, GL_NONE },
0, logoViewPassId);
logoViewTransform = logoView.assign<Transform>();
logoViewTransform->position = { 0.0, 0.0, -5.0 };;
logoViewTransform->scale = { 0.75, 0.75, 0.75 };
logoView.assign<Light>(glm::vec4(1, 1, 1, 0.2), glm::vec3(1, 0, 0),
false, LightType::POINT, logoViewPassId);
}
loadingText.component<Drawable>()->visible = false; loadingText.component<Drawable>()->visible = false;
loadingText.destroy(); loadingText.destroy();
} }
...@@ -521,6 +553,7 @@ void AtmosphereTestScene::loadMainSceneResources() { ...@@ -521,6 +553,7 @@ void AtmosphereTestScene::loadMainSceneResources() {
{ {
planetViewGeom = Geometry{ VertexArrayObjectCreator("planet_wireframe.obj").create() }; planetViewGeom = Geometry{ VertexArrayObjectCreator("planet_wireframe.obj").create() };
logoViewGeom = Geometry{ VertexArrayObjectCreator("title_text.obj").create() };
} }
resourceLoadingFinished = true; resourceLoadingFinished = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment