Skip to content

Commit

Permalink
bugifx: resolve radial blur and fixed post insanity
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Pollind <[email protected]>
  • Loading branch information
pollend committed Apr 15, 2023
1 parent 97d09e3 commit b21c719
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 150 deletions.
59 changes: 0 additions & 59 deletions HPL2/core/include/graphics/RendererDeferred.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,36 +174,6 @@ namespace hpl {
m_refractionImage = std::move(buffer.m_refractionImage);
m_gBuffer = std::move(buffer.m_gBuffer);
m_gBufferReflection = std::move(buffer.m_gBufferReflection);

// m_gBufferColor = std::move(buffer.m_gBufferColor);
// m_gBufferNormalImage = std::move(buffer.m_gBufferNormalImage);
// m_gBufferPositionImage = std::move(buffer.m_gBufferPositionImage);
// m_gBufferSpecular = std::move(buffer.m_gBufferSpecular);
// m_gBufferDepthStencil = std::move(buffer.m_gBufferDepthStencil);

// m_outputImage = std::move(buffer.m_outputImage);
// m_gBuffer_full = std::move(buffer.m_gBuffer_full);
// m_gBuffer_colorAndDepth = std::move(buffer.m_gBuffer_colorAndDepth);
// m_gBuffer_color = std::move(buffer.m_gBuffer_color);
// m_gBuffer_depth = std::move(buffer.m_gBuffer_depth);
// m_gBuffer_normals = std::move(buffer.m_gBuffer_normals);
// m_gBuffer_linearDepth = std::move(buffer.m_gBuffer_linearDepth);
// m_output_target = std::move(buffer.m_output_target);

// m_gBufferReflectionColor = std::move(buffer.m_gBufferReflectionColor);
// m_gBufferReflectionNormalImage = std::move(buffer.m_gBufferReflectionNormalImage);
// m_gBufferReflectionPositionImage = std::move(buffer.m_gBufferReflectionPositionImage);
// m_gBufferReflectionSpecular = std::move(buffer.m_gBufferReflectionSpecular);
// m_gBufferReflectionDepthStencil = std::move(buffer.m_gBufferReflectionDepthStencil);
// m_outputReflectionImage = std::move(buffer.m_outputReflectionImage);

// m_gBufferReflection_full = std::move(buffer.m_gBufferReflection_full);
// m_gBufferReflection_colorAndDepth = std::move(buffer.m_gBufferReflection_colorAndDepth);
// m_gBufferReflection_color = std::move(buffer.m_gBufferReflection_color);
// m_gBufferReflection_depth = std::move(buffer.m_gBufferReflection_depth);
// m_gBufferReflection_normals = std::move(buffer.m_gBufferReflection_normals);
// m_gBufferReflection_linearDepth = std::move(buffer.m_gBufferReflection_linearDepth);
// m_outputReflection_target = std::move(buffer.m_outputReflection_target);

}

Expand All @@ -213,35 +183,6 @@ namespace hpl {
GBuffer m_gBuffer;
GBuffer m_gBufferReflection;

// std::shared_ptr<Image> m_gBufferColor;
// std::shared_ptr<Image> m_gBufferNormalImage;
// std::shared_ptr<Image> m_gBufferPositionImage;
// std::shared_ptr<Image> m_gBufferSpecular;
// std::shared_ptr<Image> m_gBufferDepthStencil;
// std::shared_ptr<Image> m_outputImage;

// RenderTarget m_gBuffer_full;
// RenderTarget m_gBuffer_colorAndDepth;
// RenderTarget m_gBuffer_color;
// RenderTarget m_gBuffer_depth;
// RenderTarget m_gBuffer_normals;
// RenderTarget m_gBuffer_linearDepth;
// RenderTarget m_output_target; // used for rendering to the screen

// std::shared_ptr<Image> m_gBufferReflectionColor;
// std::shared_ptr<Image> m_gBufferReflectionNormalImage;
// std::shared_ptr<Image> m_gBufferReflectionPositionImage;
// std::shared_ptr<Image> m_gBufferReflectionSpecular;
// std::shared_ptr<Image> m_gBufferReflectionDepthStencil;
// std::shared_ptr<Image> m_outputReflectionImage;

// RenderTarget m_gBufferReflection_full;
// RenderTarget m_gBufferReflection_colorAndDepth;
// RenderTarget m_gBufferReflection_color;
// RenderTarget m_gBufferReflection_depth;
// RenderTarget m_gBufferReflection_normals;
// RenderTarget m_gBufferReflection_linearDepth;
// RenderTarget m_outputReflection_target; // used for rendering to the screen
};

cRendererDeferred(cGraphics* apGraphics, cResources* apResources);
Expand Down
13 changes: 8 additions & 5 deletions HPL2/core/resource/fs_dds_posteffect_insanity.sc
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,24 @@ uniform vec4 u_param[2];
#define u_ampT (u_param[0].z)
#define u_waveAlpha (u_param[0].w)
#define u_zoomAlpha (u_param[1].x)
#define u_screenSize (u_param[1].yz)

void main()
{
vec3 vAmp = texture2D(s_ampMap0, v_texcoord0).xyz*(1.0-u_ampT) + texture2D(s_ampMap1, v_texcoord0).xyz*u_ampT;
vAmp *= u_waveAlpha * 0.04 * v_texcoord0.y;
vAmp *= u_waveAlpha * 0.04 * u_screenSize.y;

vec3 vZoom = texture2D(s_zoomMap, v_texcoord0).xyz;

vec2 vUV = v_texcoord0;
vUV += (vZoom.xy-vec2(0.5, 0.5))*2.0* 0.6 * vZoom.z * u_zoomAlpha;
vec2 vUV = gl_FragCoord.xy;

vUV += (vZoom.xy-vec2(0.5, 0.5))*2.0* 0.6 * vZoom.z * u_screenSize.y * u_zoomAlpha;

vec2 vSinUv = vUV * 0.6;
vec2 vSinUv = (vUV / u_screenSize.y) * 0.6;
vUV.x += sin(u_fT + vSinUv.y) * vAmp.x;
vUV.y += sin(u_fT + vSinUv.x*1.83) * vAmp.y;

vec3 vDiffuseColor = texture2D(s_diffuseMap, vUV).xyz;
vec3 vDiffuseColor = texture2D(s_diffuseMap, vUV * u_viewTexel.xy).xyz;
gl_FragColor.xyz = vDiffuseColor;
gl_FragColor.w = 0.0;
}
4 changes: 2 additions & 2 deletions HPL2/core/resource/fs_posteffect_radial_blur_frag.sc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void main()
vSizeMul[3] = 0.5;
vSizeMul[4] = 1.0;

vec2 vScreenCoord = mul(gl_FragCoord.xy, u_viewTexel.xy);
vec2 vScreenCoord = gl_FragCoord.xy;

vec2 vDir = avHalfScreenSize - vScreenCoord;
float fDist = length(vDir) / avHalfScreenSize.x;
Expand All @@ -41,7 +41,7 @@ void main()

for(int i=0; i<5; ++i)
{
vDiffuseColor += mul(texture2D(s_diffuseMap, vScreenCoord + vDir * vSizeMul[i]).xyz, vColorMul[i]);
vDiffuseColor += mul(texture2D(s_diffuseMap, (vScreenCoord + vDir * vSizeMul[i]) * u_viewTexel.xy).xyz, vColorMul[i]);
}

vDiffuseColor /= fTotalMul;
Expand Down
75 changes: 0 additions & 75 deletions HPL2/core/sources/graphics/RendererDeferred.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,23 +946,6 @@ namespace hpl {
gBuffer.m_specularImage = colorImage();
gBuffer.m_depthStencilImage = depthImage();
gBuffer.m_outputImage = colorImage();

// {
// std::array<std::shared_ptr<Image>, 5> images = { gBuffer.m_colorImage,
// gBuffer.m_normalImage,
// gBuffer.m_positionImage,
// gBuffer.m_specularImage,
// gBuffer.m_depthStencilImage };
// gBuffer.m_outputTarget = RenderTarget(std::span(images));
// }
// {
// std::array<std::shared_ptr<Image>, 2> images = { gBuffer.m_colorImage, gBuffer.m_depthStencilImage };
// gBuffer.m_colorAndDepthTarget = RenderTarget(std::span(images));
// }
// {
// std::array<std::shared_ptr<Image>, 2> images = { gBuffer.m_outputImage, gBuffer.m_depthStencilImage };
// gBuffer.m_outputTarget = RenderTarget(std::span(images));
// }

gBuffer.m_colorTarget = RenderTarget(gBuffer.m_colorImage);
gBuffer.m_depthTarget = RenderTarget(gBuffer.m_depthStencilImage);
Expand Down Expand Up @@ -1001,64 +984,6 @@ namespace hpl {
sharedData->m_refractionImage = image;
}

// sharedData->m_gBufferColor = colorImage();
// sharedData->m_gBufferNormalImage = normalImage();
// sharedData->m_gBufferPositionImage = positionImage();
// sharedData->m_gBufferSpecular = colorImage();
// sharedData->m_gBufferDepthStencil = depthImage();
// sharedData->m_outputImage = colorImage();

// {
// std::array<std::shared_ptr<Image>, 5> images = { sharedData->m_gBufferColor,
// sharedData->m_gBufferNormalImage,
// sharedData->m_gBufferPositionImage,
// sharedData->m_gBufferSpecular,
// sharedData->m_gBufferDepthStencil };
// sharedData->m_gBuffer_full = RenderTarget(std::span(images));
// }
// {
// std::array<std::shared_ptr<Image>, 2> images = { sharedData->m_gBufferColor, sharedData->m_gBufferDepthStencil };
// sharedData->m_gBuffer_colorAndDepth = RenderTarget(std::span(images));
// }
// {
// std::array<std::shared_ptr<Image>, 2> images = { sharedData->m_outputImage, sharedData->m_gBufferDepthStencil };
// sharedData->m_output_target = RenderTarget(std::span(images));
// }

// sharedData->m_gBuffer_color = RenderTarget(sharedData->m_gBufferColor);
// sharedData->m_gBuffer_depth = RenderTarget(sharedData->m_gBufferDepthStencil);
// sharedData->m_gBuffer_normals = RenderTarget(sharedData->m_gBufferNormalImage);
// sharedData->m_gBuffer_linearDepth = RenderTarget(sharedData->m_gBufferPositionImage);

// sharedData->m_gBufferReflectionColor = colorImage();
// sharedData->m_gBufferReflectionNormalImage = normalImage();
// sharedData->m_gBufferReflectionPositionImage = positionImage();
// sharedData->m_gBufferReflectionSpecular = colorImage();
// sharedData->m_gBufferReflectionDepthStencil = depthImage();
// sharedData->m_outputReflectionImage = colorImage();

// sharedData->m_gBufferReflection_color = RenderTarget(sharedData->m_gBufferReflectionColor);
// sharedData->m_gBufferReflection_depth = RenderTarget(sharedData->m_gBufferReflectionDepthStencil);
// sharedData->m_gBufferReflection_normals = RenderTarget(sharedData->m_gBufferReflectionNormalImage);
// sharedData->m_gBufferReflection_linearDepth = RenderTarget(sharedData->m_gBufferReflectionPositionImage);

// {
// std::array<std::shared_ptr<Image>, 5> images = { sharedData->m_gBufferReflectionColor,
// sharedData->m_gBufferReflectionNormalImage,
// sharedData->m_gBufferReflectionPositionImage,
// sharedData->m_gBufferReflectionSpecular,
// sharedData->m_gBufferReflectionDepthStencil };
// sharedData->m_gBufferReflection_full = RenderTarget(std::span(images));
// }
// {
// std::array<std::shared_ptr<Image>, 2> images = { sharedData->m_gBufferReflectionColor, sharedData->m_gBufferReflectionDepthStencil };
// sharedData->m_gBufferReflection_colorAndDepth = RenderTarget(std::span(images));
// }
// {
// std::array<std::shared_ptr<Image>, 2> images = { sharedData->m_outputReflectionImage, sharedData->m_gBufferReflectionDepthStencil };
// sharedData->m_outputReflection_target = RenderTarget(std::span(images));
// }

return sharedData;
},
[](cViewport& viewport, SharedViewportData& target) {
Expand Down
4 changes: 2 additions & 2 deletions amnesia/src/game/LuxInventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ cLuxInventory::cLuxInventory() : iLuxUpdateable("LuxInventory")

///////////////////////////////
//Load settings
mvScreenSize = gpBase->mpEngine->GetGraphics()->GetLowLevel()->GetScreenSizeFloat();
// mvScreenSize = gpBase->mpEngine->GetGraphics()->GetLowLevel()->GetScreenSizeFloat();

mfFadeInTime = gpBase->mpMenuCfg->GetFloat("Inventory","FadeInTime", 10);
mfFadeOutTime = gpBase->mpMenuCfg->GetFloat("Inventory","FadeOutTime",10);
Expand Down Expand Up @@ -1590,7 +1590,7 @@ void cLuxInventory::RenderBackgroundImage()
auto screenTarget = RenderTarget(m_screenImage);

auto screenSize = viewport->GetSize();
cRect2l screenRect(0, 0, mvScreenSize.x, mvScreenSize.y);
cRect2l screenRect(0, 0, screenSize.x, screenSize.y);

graphicsContext.CopyTextureToFrameBuffer(
*renderer->GetOutputImage(*viewport), screenRect, screenTarget);
Expand Down
2 changes: 1 addition & 1 deletion amnesia/src/game/LuxInventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ friend class cLuxInventory_Item;

std::vector<cWidgetImage*> mvImageWidgets;

cVector2f mvScreenSize;
// cVector2f mvScreenSize;
cVector2f mvGuiSetCenterSize;
cVector2f mvGuiSetSize;
cVector2f mvGuiSetOffset;
Expand Down
2 changes: 1 addition & 1 deletion amnesia/src/game/LuxMainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ iLuxMainMenuWindow::iLuxMainMenuWindow(cGuiSet *apGuiSet, cGuiSkin *apGuiSkin)

mpWindow = NULL;

mvScreenSize = gpBase->mpEngine->GetGraphics()->GetLowLevel()->GetScreenSizeFloat();
// mvScreenSize = gpBase->mpEngine->GetGraphics()->GetLowLevel()->GetScreenSizeFloat();
}

void iLuxMainMenuWindow::SetActive(bool abX)
Expand Down
2 changes: 1 addition & 1 deletion amnesia/src/game/LuxMainMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class iLuxMainMenuWindow

cWidgetWindow *mpWindow;

cVector2f mvScreenSize;
// cVector2f mvScreenSize;
};


Expand Down
11 changes: 7 additions & 4 deletions amnesia/src/game/LuxPostEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void cLuxPostEffect_Insanity::RenderEffect(cPostEffectComposite& compositor, cVi
GraphicsContext::ViewConfiguration viewConfiguration {target};
viewConfiguration.m_viewRect = cRect2l(0, 0, viewportSize.x, viewportSize.y);
viewConfiguration.m_projection = projMtx;
bgfx::ViewId view = context.StartPass("Bloom Pass", viewConfiguration);
bgfx::ViewId view = context.StartPass("DDS_Insanity", viewConfiguration);

struct {
float alpha;
Expand All @@ -144,7 +144,8 @@ void cLuxPostEffect_Insanity::RenderEffect(cPostEffectComposite& compositor, cVi
float waveAlpha;

float zoomAlpha;
float pad[3];
float screenSize[2];
float pad;
} param = { 0 };

int lAmp0 = static_cast<int>(mfAnimCount);
Expand All @@ -168,8 +169,10 @@ void cLuxPostEffect_Insanity::RenderEffect(cPostEffectComposite& compositor, cVi
param.ampT = fAmpT;
param.waveAlpha = mfWaveAlpha;
param.alpha = 1.0f;

shaderProgram.m_uniforms.push_back({ m_u_param, &param, 1 });
param.screenSize[0] = viewportSize.x;
param.screenSize[1] = viewportSize.y;

shaderProgram.m_uniforms.push_back({ m_u_param, &param, 2 });
GraphicsContext::DrawRequest request{ layoutStream, shaderProgram };

context.Submit(view, request);
Expand Down

0 comments on commit b21c719

Please sign in to comment.