Skip to content

Commit

Permalink
WIP : OpenGL rendering backend
Browse files Browse the repository at this point in the history
https://trello.com/c/ml2dGm9H
Move motion blur pass after TAA pass/Use converted texture coordinate in TAA pass/Use 4k CSM texture.
  • Loading branch information
zhangdoa committed Apr 11, 2019
1 parent 6e4514b commit de89dc3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
4 changes: 3 additions & 1 deletion res/shaders/GL/TAAPassFragment.sf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ uniform sampler2D uni_motionVectorTexture;
void main()
{
vec2 renderTargetSize = vec2(textureSize(uni_preTAAPassRT0, 0));
vec2 MotionVector = texture(uni_motionVectorTexture, TexCoords).xy;
vec2 texelSize = 1.0 / renderTargetSize;
vec2 screenTexCoords = gl_FragCoord.xy * texelSize;
vec2 MotionVector = texture(uni_motionVectorTexture, screenTexCoords).xy;

vec4 preTAAPassRT0Result = texture(uni_preTAAPassRT0, TexCoords);

Expand Down
7 changes: 1 addition & 6 deletions res/shaders/GL/skyPassFragment.sf
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ vec2 rsi(vec3 r0, vec3 rd, float sr) {
);
}


//https://github.com/wwwtyro/glsl-atmosphere

vec3 atmosphere(vec3 r, vec3 r0, vec3 pSun, float iSun, float rPlanet, float rAtmos, vec3 kRlh, float kMie, float shRlh, float shMie, float g) {
Expand Down Expand Up @@ -93,7 +92,6 @@ vec3 atmosphere(vec3 r, vec3 r0, vec3 pSun, float iSun, float rPlanet, float rAt

// Sample the primary ray.
for (int i = 0; i < iSteps; i++) {

// Calculate the primary ray sample position.
vec3 iPos = r0 + r * (iTime + iStepSize * 0.5);

Expand All @@ -120,7 +118,6 @@ vec3 atmosphere(vec3 r, vec3 r0, vec3 pSun, float iSun, float rPlanet, float rAt

// Sample the secondary ray.
for (int j = 0; j < jSteps; j++) {

// Calculate the secondary ray sample position.
vec3 jPos = iPos + pSun * (jTime + jStepSize * 0.5);

Expand All @@ -144,7 +141,6 @@ vec3 atmosphere(vec3 r, vec3 r0, vec3 pSun, float iSun, float rPlanet, float rAt

// Increment the primary ray time.
iTime += iStepSize;

}

// Calculate and return the final color.
Expand Down Expand Up @@ -175,5 +171,4 @@ void main()
0.758 // Mie preferred scattering direction
);
uni_skyPassRT0 = vec4(color, 1.0);
}

}
4 changes: 2 additions & 2 deletions source/engine/system/GLRenderingBackend/GLMotionBlurPass.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "GLMotionBlurPass.h"
#include "GLOpaquePass.h"
#include "GLPreTAAPass.h"
#include "GLPostTAAPass.h"

#include "GLRenderingSystemUtilities.h"
#include "../../component/GLRenderingSystemComponent.h"
Expand Down Expand Up @@ -67,7 +67,7 @@ bool GLMotionBlurPass::update()
GLOpaquePass::getGLRPC()->m_GLTDCs[3],
0);
activateTexture(
GLPreTAAPass::getGLRPC()->m_GLTDCs[0],
GLPostTAAPass::getGLRPC()->m_GLTDCs[0],
1);

auto l_MDC = g_pCoreSystem->getAssetSystem()->getMeshDataComponent(MeshShapeType::QUAD);
Expand Down
14 changes: 7 additions & 7 deletions source/engine/system/GLRenderingBackend/GLRenderingSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,13 +302,6 @@ bool GLRenderingSystemNS::update()

auto l_canvasGLRPC = GLPreTAAPass::getGLRPC();

if (l_renderingConfig.useMotionBlur)
{
GLMotionBlurPass::update();

l_canvasGLRPC = GLMotionBlurPass::getGLRPC();
}

if (l_renderingConfig.useTAA)
{
GLTAAPass::update(l_canvasGLRPC);
Expand All @@ -317,6 +310,13 @@ bool GLRenderingSystemNS::update()
l_canvasGLRPC = GLPostTAAPass::getGLRPC();
}

if (l_renderingConfig.useMotionBlur)
{
GLMotionBlurPass::update();

l_canvasGLRPC = GLMotionBlurPass::getGLRPC();
}

if (l_renderingConfig.useBloom)
{
GLBloomExtractPass::update(l_canvasGLRPC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void GLShadowRenderPass::initialize()

DirLightShadowPassFBDesc.renderBufferAttachmentType = GL_DEPTH_ATTACHMENT;
DirLightShadowPassFBDesc.renderBufferInternalFormat = GL_DEPTH_COMPONENT32;
DirLightShadowPassFBDesc.sizeX = 2048;
DirLightShadowPassFBDesc.sizeY = 2048;
DirLightShadowPassFBDesc.sizeX = 4096;
DirLightShadowPassFBDesc.sizeY = 4096;
DirLightShadowPassFBDesc.drawColorBuffers = false;

DirLightShadowPassTextureDesc.textureSamplerType = TextureSamplerType::SAMPLER_2D;
Expand Down

0 comments on commit de89dc3

Please sign in to comment.