Commit 681a07c1 authored by Dario Seyb's avatar Dario Seyb

fixed motion vector rendering

parent 9d336d8a
#version 410 core
#if LAST_SHADER == VERTEX
in vec3 vNormal;
in vec2 vTexCoord;
in vec3 vPosition;
#endif
#if LAST_SHADER == TESSELATION
in vec3 teNormal;
in vec2 teTexCoord;
in vec3 tePosition;
#endif
#if LAST_SHADER == GEOMETRY
in vec3 gNormal;
in vec2 gTexCoord;
in vec3 gPosition;
in vec3 gPatchDistance;
in vec3 gTriDistance;
#endif
uniform bool uHasAlbedoMap;
uniform sampler2D uTexture;
......@@ -57,36 +37,10 @@ vec4 emissive();
vec3 normal();
vec4 specularSmoothness();
vec3 inNormal;
vec2 inTexCoord;
vec3 inPosition;
vec3 inPatchDistance;
vec3 inTriDistance;
void main()
{
#if LAST_SHADER == VERTEX
inNormal = vNormal;
inTexCoord = vTexCoord;
inPosition =vPosition;
#endif
#if LAST_SHADER == TESSELATION
inNormal = teNormal;
inTexCoord = teTexCoord;
inPosition = tePosition;
#endif
#if LAST_SHADER == GEOMETRY
inNormal = gNormal;
inTexCoord = gTexCoord;
inPosition = gPosition;
inPatchDistance = gPatchDistance;
inTriDistance = gTriDistance;
#endif
setupInputs();
initShader();
vec4 color = color();
/*float sampl = rand(gl_FragCoord.xy + vec2(mod(uTime,1)));
......@@ -95,13 +49,13 @@ void main()
vec4 thisPosition = uViewProjectionMatrix * vec4(inPosition, 1);
vec4 prevPosition = uPrevViewProjectionMatrix * uPrevModelMatrix * uInverseModelMatrix * vec4(inPosition, 1);
vec2 prevFragCoord = prevPosition.xy/prevPosition.w;
vec2 thisFragCoord = thisPosition.xy/thisPosition.w;
vec2 thisFragCoord = thisPosition.xy/thisPosition.w;
oColor = color;
oEmissive = emissive();
oSpecularSmoothness = specularSmoothness();
oNormalMotion.xy = normalize(normal()).xy;
oNormalMotion.zw = (thisFragCoord-prevFragCoord)*0.5;
oNormalMotion.zw = (thisFragCoord-prevFragCoord)*0.5;
}
......@@ -24,7 +24,7 @@ void main()
vTexCoord = texCoord();
vPosition = position();
gl_Position = uViewProjectionMatrix * vec4(vPosition, 1);
gl_Position = uViewProjectionMatrix * vec4(vPosition, 1);
// Logarithmic Depth buffer
//float Fcoef = 2.0 / log2(uFar + 1.0);
......
#define LAST_SHADER VERTEX
#pragma import "setup/vertex.glsl"
#pragma import "CommonDeferredFrag.glsl"
#pragma import "Utils.glsl"
......
#version 410 core
in vec3 tPosition;
in vec2 tTexCoord;
......
#define LAST_SHADER VERTEX
#pragma import "setup/vertex.glsl"
#pragma import "CommonDeferredFrag.glsl"
#pragma import "Utils.glsl"
......
#version 330
#version 410 core
uniform sampler2D uSamplerColor;
uniform sampler2D uSamplerHistory;
......@@ -30,13 +30,18 @@ void main()
float depthSample = texture(uSamplerDepth, sampleCoord).x;
if(depthSample < depth) {
motion = texture(uSamplerNormalMotion, sampleCoord).zw;
depth = depthSample;
depth = depthSample;
}
}
vec2 samplePos = vTexCoord - motion.xy;
vec4 history = texture(uSamplerHistory, vTexCoord - motion.xy);
vec4 history = texture(uSamplerHistory, samplePos);
oColor.rg = abs(motion.xy) ;
oColor.b = 0;
oColor.a = 1;
//oColor = history;
oColor.a = 1;
//return;
float factor = 0.85;
......@@ -47,9 +52,9 @@ void main()
for(int x = -1; x <= 1; x++) {
for(int y = -1; y <= 1; y++) {
vec4 sample = texture(uSamplerColor, vTexCoord + vec2(x, y)*uOneOverColorSize);
minNeighbour = min(minNeighbour, sample);
maxNeighbour = max(maxNeighbour, sample);
vec4 colorSample = texture(uSamplerColor, vTexCoord + vec2(x, y)*uOneOverColorSize);
minNeighbour = min(minNeighbour, colorSample);
maxNeighbour = max(maxNeighbour, colorSample);
}
}
......
#version 410 core
#define LAST_SHADER GEOMETRY
#pragma import "setup/geometry.glsl"
#pragma import "noise/noise3d.glsl"
#pragma import "noise/noise4d.glsl"
......
#define LAST_SHADER VERTEX
#pragma import "../setup/vertex.glsl"
#pragma import "../CommonDeferredFrag.glsl"
#pragma import "../Utils.glsl"
......
#define LAST_SHADER TESSELATION
#pragma import "../setup/vertex.glsl"
#pragma import "../CommonDeferredFrag.glsl"
#pragma import "../Utils.glsl"
......
#define LAST_SHADER VERTEX
#pragma import "../setup/vertex.glsl"
#pragma import "../CommonDeferredFrag.glsl"
#pragma import "../Utils.glsl"
......
#define LAST_SHADER VERTEX
#pragma import "setup/vertex.glsl"
#pragma import "CommonDeferredFrag.glsl"
......
#version 410 core
#define LAST_SHADER GEOMETRY
#pragma import "../setup/geometry.glsl"
#pragma import "../noise/noise3d.glsl"
#pragma import "../noise/noise4d.glsl"
......
#version 410 core
#define LAST_SHADER GEOMETRY
#pragma import "../setup/geometry.glsl"
#pragma import "../CommonDeferredFrag.glsl"
......
#version 410 core
#define LAST_SHADER GEOMETRY
#pragma import "../setup/geometry.glsl"
#pragma import "../noise/noise3d.glsl"
#pragma import "../Utils.glsl"
......
in vec3 gNormal;
in vec2 gTexCoord;
in vec3 gPosition;
in vec3 gPatchDistance;
in vec3 gTriDistance;
vec3 inNormal;
vec2 inTexCoord;
vec3 inPosition;
vec3 inPatchDistance;
vec3 inTriDistance;
void setupInputs() {
inNormal = gNormal;
inTexCoord = gTexCoord;
inPosition = gPosition;
inPatchDistance = gPatchDistance;
inTriDistance = gTriDistance;
}
\ No newline at end of file
in vec3 teNormal;
in vec2 teTexCoord;
in vec3 tePosition;
vec3 inNormal;
vec2 inTexCoord;
vec3 inPosition;
vec3 inPatchDistance;
vec3 inTriDistance;
void setupInputs() {
inNormal = teNormal;
inTexCoord = teTexCoord;
inPosition = tePosition;
}
\ No newline at end of file
in vec3 vNormal;
in vec2 vTexCoord;
in vec3 vPosition;
vec3 inNormal;
vec2 inTexCoord;
vec3 inPosition;
vec3 inPatchDistance;
vec3 inTriDistance;
void setupInputs() {
inNormal = vNormal;
inTexCoord = vTexCoord;
inPosition =vPosition;
}
\ No newline at end of file
#define LAST_SHADER GEOMETRY
//#pragma import "../CommonDeferredFrag.glsl"
#pragma import "normalApproximation.glsl"
//in vec3 gUpVector_normalized;
......
#define LAST_SHADER GEOMETRY
//#pragma import "../CommonDeferredFrag.glsl"
#pragma import "normalApproximation.glsl"
//in vec3 gUpVector_normalized;
......
#define LAST_SHADER GEOMETRY
in vec3 gPosInModelspace;
void initShader(){};
......
......@@ -175,12 +175,15 @@ bool RendererSystem::startup() {
ImGui::Image((void*)m_specularBuffer->getObjectName(), glm::vec2{ 1280, 720 } *0.2f, { 0, 1 }, { 1, 0 });
ImGui::End();
ImGui::Begin("ShadowMap", 0, ImGuiWindowFlags_AlwaysAutoResize);
for (auto shadowMap : m_shadowMaps) {
ImGui::Image((void*)shadowMap->getDepthAttachment().texture->getObjectName(), { 256, 256 });
ImGui::Begin("Render Passes", 0, ImGuiWindowFlags_AlwaysAutoResize);
for (int i = 0; i < m_passes.size(); i++) {
auto& pass = m_passes[i];
if (ImGui::Button(("Pass_" + std::to_string(i)).c_str())) {
pass.active = !pass.active;
}
}
ImGui::End();
});
}, 1);
return true;
}
......@@ -561,6 +564,7 @@ void RendererSystem::render(RenderPass& pass, double interp, double totalTime) {
// TXAA
glDisable(GL_BLEND);
vao.bind(); // 'empty' VAO -> no attributes are defined
pass.compositingTarget->bind();
int width = pass.compositingTarget->getSize().x;
......
......@@ -405,11 +405,10 @@ void AtmosphereTestScene::loadMainSceneResources() {
auto checkboardTexture =
Texture2DFileManager::the()->get(Texture2DCreator("checkerboard.png"));
auto sunShader =
ShaderProgramCreator("PBR")
.attributeLocations(vaoSun->getAttributeLocations())
.fragmentDataLocations(m_renderer->getGBufferLocations())
.create();
auto sunShader = ShaderProgramFileManager::the()->get(
ShaderProgramCreator("PBR")
.attributeLocations(vaoSun->getAttributeLocations())
.fragmentDataLocations(m_renderer->getGBufferLocations()));
sunGeometry = {vaoSun};
......@@ -427,11 +426,10 @@ void AtmosphereTestScene::loadMainSceneResources() {
{
// create cockpit
auto vaoCockpit = VertexArrayObjectCreator("cockpit/cockpit_v2_outer.obj").create();
auto cockpitShader =
ShaderProgramCreator("PBR")
.attributeLocations(vaoCockpit->getAttributeLocations())
.fragmentDataLocations(m_renderer->getGBufferLocations())
.create();
auto cockpitShader = ShaderProgramFileManager::the()->get(
ShaderProgramCreator("PBR")
.attributeLocations(vaoCockpit->getAttributeLocations())
.fragmentDataLocations(m_renderer->getGBufferLocations()));
cockpitMaterial = {
glm::vec4{0.4, 0.4, 0.4, 1}, glm::vec4{0, 0, 0, 1},
......
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