@@ -45,7 +45,7 @@ namespace Syndra {
4545 // ------------------------------------------------Deferred Geometry Render Pass----------------------------------------//
4646 FramebufferSpecification GeoFbSpec;
4747 GeoFbSpec.Attachments =
48- {
48+ {
4949 FramebufferTextureFormat::RGBA16F, // Position texture attachment
5050 FramebufferTextureFormat::RGBA16F, // Normal texture attachment
5151 FramebufferTextureFormat::RGBA16F, // Albedo-specular texture attachment
@@ -73,14 +73,14 @@ namespace Syndra {
7373 RenderPassSpecification finalPassSpec;
7474 finalPassSpec.TargetFrameBuffer = FrameBuffer::Create (postProcFB);
7575 s_Data.lightingPass = RenderPass::Create (finalPassSpec);
76-
76+
7777 // -----------------------------------------------Shadow Pass---------------------------------------------//
7878 FramebufferSpecification shadowSpec;
7979 shadowSpec.Attachments = { FramebufferTextureFormat::DEPTH32 };
8080 shadowSpec.Width = 4096 ;
8181 shadowSpec.Height = 4096 ;
8282 shadowSpec.Samples = 1 ;
83- shadowSpec.ClearColor = {0 .0f , 0 .0f , 0 .0f , 1 .0f };
83+ shadowSpec.ClearColor = { 0 .0f , 0 .0f , 0 .0f , 1 .0f };
8484
8585 RenderPassSpecification shadowPassSpec;
8686 shadowPassSpec.TargetFrameBuffer = FrameBuffer::Create (shadowSpec);
@@ -97,9 +97,9 @@ namespace Syndra {
9797 RenderPassSpecification aaPassSpec;
9898 aaPassSpec.TargetFrameBuffer = FrameBuffer::Create (aaFB);
9999 s_Data.aaPass = RenderPass::Create (aaPassSpec);
100-
100+
101101 // ------------------------------------------------Shaders-----------------------------------------------//
102-
102+
103103 // s_Data.fxaa = Shader::Create("assets/shaders/FXAA.glsl");
104104
105105 if (!s_Data.main ) {
@@ -152,7 +152,7 @@ namespace Syndra {
152152 s_Data.lightFar = 200 .0f ;
153153 // Light uniform Buffer layout: -- point lights -- spotlights -- directional light--Binding point 2
154154 s_Data.lightManager = CreateRef<LightManager>(2 );
155-
155+
156156 GeneratePoissonDisk (s_Data.distributionSampler0 , 64 );
157157 GeneratePoissonDisk (s_Data.distributionSampler1 , 64 );
158158
@@ -188,7 +188,7 @@ namespace Syndra {
188188 Renderer::BeginScene (camera);
189189 }
190190
191- void SceneRenderer::UpdateLights ()
191+ void SceneRenderer::UpdateLights ()
192192 {
193193 auto viewLights = s_Data.scene ->m_Registry .view <TransformComponent, LightComponent>();
194194 // point light index
@@ -248,7 +248,7 @@ namespace Syndra {
248248 {
249249 auto & tc = view.get <TransformComponent>(ent);
250250 auto & mc = view.get <MeshComponent>(ent);
251- if (!mc.path .empty ())
251+ if (!mc.path .empty ())
252252 {
253253 s_Data.depth ->SetMat4 (" transform.u_trans" , tc.GetTransform ());
254254 SceneRenderer::RenderEntity (ent, mc, s_Data.depth );
@@ -267,7 +267,7 @@ namespace Syndra {
267267 {
268268 auto & tc = view.get <TransformComponent>(ent);
269269 auto & mc = view.get <MeshComponent>(ent);
270- if (!mc.path .empty ())
270+ if (!mc.path .empty ())
271271 {
272272 if (s_Data.scene ->m_Registry .has <MaterialComponent>(ent)) {
273273 auto & mat = s_Data.scene ->m_Registry .get <MaterialComponent>(ent);
@@ -296,7 +296,7 @@ namespace Syndra {
296296 s_Data.geoPass ->UnbindTargetFrameBuffer ();
297297 }
298298
299- void SceneRenderer::RenderEntity (const entt::entity& entity, MeshComponent& mc,const Ref<Shader>& shader)
299+ void SceneRenderer::RenderEntity (const entt::entity& entity, MeshComponent& mc, const Ref<Shader>& shader)
300300 {
301301 // RenderCommand::SetState(RenderState::CULL, false);
302302 Renderer::Submit (shader, mc.model );
@@ -324,7 +324,7 @@ namespace Syndra {
324324 Texture1D::BindTexture (s_Data.distributionSampler1 ->GetRendererID (), 5 );
325325
326326 // Push constant variables
327- s_Data.deferredLighting ->SetFloat (" pc.size" , s_Data.lightSize * 0 .0001f );
327+ s_Data.deferredLighting ->SetFloat (" pc.size" , s_Data.lightSize * 0 .0001f );
328328 s_Data.deferredLighting ->SetInt (" pc.numPCFSamples" , s_Data.numPCF );
329329 s_Data.deferredLighting ->SetInt (" pc.numBlockerSearchSamples" , s_Data.numBlocker );
330330 s_Data.deferredLighting ->SetInt (" pc.softShadow" , (int )s_Data.softShadow );
@@ -362,15 +362,17 @@ namespace Syndra {
362362
363363 s_Data.lightingPass ->UnbindTargetFrameBuffer ();
364364 // -------------------------------------------------ANTI ALIASING PASS------------------------------------------------------------------//
365-
366- s_Data.aaPass ->BindTargetFrameBuffer ();
367- s_Data.fxaa ->Bind ();
368- s_Data.fxaa ->SetFloat (" pc.width" , (float )s_Data.aaPass ->GetSpecification ().TargetFrameBuffer ->GetSpecification ().Width );
369- s_Data.fxaa ->SetFloat (" pc.height" , (float )s_Data.aaPass ->GetSpecification ().TargetFrameBuffer ->GetSpecification ().Height );
370- Texture2D::BindTexture (s_Data.lightingPass ->GetFrameBufferTextureID (0 ), 0 );
371- Renderer::Submit (s_Data.fxaa , s_Data.screenVao );
372- s_Data.fxaa ->Unbind ();
373- s_Data.aaPass ->UnbindTargetFrameBuffer ();
365+
366+ if (s_Data.useFxaa ) {
367+ s_Data.aaPass ->BindTargetFrameBuffer ();
368+ s_Data.fxaa ->Bind ();
369+ s_Data.fxaa ->SetFloat (" pc.width" , (float )s_Data.aaPass ->GetSpecification ().TargetFrameBuffer ->GetSpecification ().Width );
370+ s_Data.fxaa ->SetFloat (" pc.height" , (float )s_Data.aaPass ->GetSpecification ().TargetFrameBuffer ->GetSpecification ().Height );
371+ Texture2D::BindTexture (s_Data.lightingPass ->GetFrameBufferTextureID (0 ), 0 );
372+ Renderer::Submit (s_Data.fxaa , s_Data.screenVao );
373+ s_Data.fxaa ->Unbind ();
374+ s_Data.aaPass ->UnbindTargetFrameBuffer ();
375+ }
374376
375377 Renderer::EndScene ();
376378 }
@@ -437,12 +439,16 @@ namespace Syndra {
437439 ImGui::Image (reinterpret_cast <void *>(s_Data.geoPass ->GetFrameBufferTextureID (3 )), frameSize, ImVec2{ 0 , 1 }, ImVec2{ 1 , 0 });
438440 ImGui::End ();
439441 }
440-
441- ImGui::NewLine ();
442+ ImGui::Separator ();
442443 // V-Sync
443444 static bool vSync = true ;
444445 ImGui::Checkbox (" V-Sync" , &vSync);
445446 Application::Get ().GetWindow ().SetVSync (vSync);
447+ ImGui::Separator ();
448+
449+ ImGui::Text (" Anti Aliasing" );
450+ ImGui::Checkbox (" FXAA" , &s_Data.useFxaa );
451+ ImGui::Separator ();
446452
447453 // Exposure
448454 ImGui::DragFloat (" exposure" , &s_Data.exposure , 0 .01f , -2 , 4 );
@@ -453,10 +459,10 @@ namespace Syndra {
453459
454460 // shadow
455461 ImGui::Checkbox (" Soft Shadow" , &s_Data.softShadow );
456- ImGui::DragFloat (" PCF samples" , &s_Data.numPCF ,1 , 1 , 64 );
457- ImGui::DragFloat (" blocker samples" , &s_Data.numBlocker ,1 , 1 , 64 );
462+ ImGui::DragFloat (" PCF samples" , &s_Data.numPCF , 1 , 1 , 64 );
463+ ImGui::DragFloat (" blocker samples" , &s_Data.numBlocker , 1 , 1 , 64 );
458464 ImGui::DragFloat (" Size" , &s_Data.lightSize , 0 .01f , 0 , 100 );
459-
465+
460466 ImGui::PushMultiItemsWidths (2 , ImGui::CalcItemWidth ());
461467 if (ImGui::DragFloat (" near" , &s_Data.lightNear , 0 .01f , 0 .1f , 100 .0f )) {
462468 s_Data.lightProj = glm::perspective (45 .0f , 1 .0f , s_Data.lightNear , s_Data.lightFar );
@@ -469,7 +475,7 @@ namespace Syndra {
469475 ImGui::PopItemWidth ();
470476 ImGui::NewLine ();
471477 ImGui::Separator ();
472- std::string label = " shader" ;
478+ std::string label = " shader" ;
473479 static Ref<Shader> selectedShader;
474480 if (selectedShader) {
475481 label = selectedShader->GetName ();
@@ -478,7 +484,7 @@ namespace Syndra {
478484 static int index = 0 ;
479485 if (ImGui::BeginCombo (" ##Shaders" , label.c_str ()))
480486 {
481- for (auto & shader : s_Data.shaders .GetShaders ())
487+ for (auto & shader : s_Data.shaders .GetShaders ())
482488 {
483489 // const bool is_selected = (item_current_idx == n);
484490 if (ImGui::Selectable (shader.first .c_str (), true )) {
@@ -503,12 +509,12 @@ namespace Syndra {
503509 // Add texture as sRGB color space if it is binded to 0 (diffuse texture binding)
504510 s_Data.environment = CreateRef<Environment>(Texture2D::CreateHDR (*path, false , true ));
505511 s_Data.scene ->m_EnvironmentPath = *path;
506- }
512+ }
507513 }
508514 if (s_Data.environment ) {
509515 ImGui::Image (reinterpret_cast <void *>(s_Data.environment ->GetBackgroundTextureID ()), { 300 , 150 }, ImVec2{ 0 , 1 }, ImVec2{ 1 , 0 });
510516 }
511- if (ImGui::DragFloat (" Intensity" , &s_Data.intensity , 0 .01f , 1 ,20 )) {
517+ if (ImGui::DragFloat (" Intensity" , &s_Data.intensity , 0 .01f , 1 , 20 )) {
512518 if (s_Data.environment ) {
513519 s_Data.environment ->SetIntensity (s_Data.intensity );
514520 }
@@ -530,7 +536,13 @@ namespace Syndra {
530536
531537 uint32_t SceneRenderer::GetTextureID (int index)
532538 {
533- return s_Data.aaPass ->GetSpecification ().TargetFrameBuffer ->GetColorAttachmentRendererID (index);
539+ if (s_Data.useFxaa ) {
540+ return s_Data.aaPass ->GetSpecification ().TargetFrameBuffer ->GetColorAttachmentRendererID (index);
541+ }
542+ else
543+ {
544+ return s_Data.lightingPass ->GetSpecification ().TargetFrameBuffer ->GetColorAttachmentRendererID (index);
545+ }
534546 }
535547
536548 Syndra::FramebufferSpecification SceneRenderer::GetMainFrameSpec ()
0 commit comments