Skip to content

Commit

Permalink
#149 Fix error shadow opengl, fix some issue on Driver
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamhong committed Jun 6, 2022
1 parent 859696d commit dfeba3f
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Assets/BuiltIn/Shader/PostProcessing/HLSL/PostEffectFS.d.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ float4 main(PS_INPUT input) : SV_TARGET

#if defined(TONE_MAPPING)
float target = 0.2;
float threshold = 2.5;
float threshold = 2.0;
#else
float target = 0.3;
float threshold = 2.5;
float threshold = 2.0;
#endif

float linearExposure = max((target / avgLuminance), 0.0001);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ float4 main(PS_INPUT input) : SV_TARGET
float4 color = uTexColor.Sample(uTexColorSampler, input.tex0);
float avgLuminance = uTexLuminance.SampleLevel(uTexLuminanceSampler, input.tex0, 10.0).x;
float target = 0.2;
float threshold = 2.5;
float threshold = 2.0;
float linearExposure = max((target / avgLuminance), 0.0001);
float exposure = min(exp2(log2(linearExposure)), threshold);
return float4(linearRGB(exposure * color.rgb), color.a);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ precision mediump float;

uniform vec4 uLightPosition;

in vec4 varWorldPos;
in vec4 varPos;

out float FragColor;

void main(void)
{
vec3 lightToVertex = varWorldPos.xyz - uLightPosition.xyz;
vec3 lightToVertex = varPos.xyz - uLightPosition.xyz;

float lightToPixelDistance = length(lightToVertex);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ in vec4 inColor;
uniform mat4 uMvpMatrix;
uniform mat4 uWorldMatrix;

out vec4 varWorldPos;
out vec4 varPos;

void main(void)
{
gl_Position = uMvpMatrix * inPosition;
varWorldPos = uWorldMatrix * inPosition;
varPos = uWorldMatrix * inPosition;
}
4 changes: 4 additions & 0 deletions Projects/Irrlicht/Source/CD3D11Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,8 @@ namespace irr
// set blend
BlendDesc.IndependentBlendEnable = FALSE;

BridgeCalls->resetState();

core::dimension2du size = getCurrentRenderTargetSize();
// don't forget to set viewport
setViewPort(core::rect<s32>(0, 0, size.Width, size.Height));
Expand Down Expand Up @@ -1166,6 +1168,8 @@ namespace irr
// set blend
BlendDesc.IndependentBlendEnable = FALSE;

BridgeCalls->resetState();

core::dimension2du size = getCurrentRenderTargetSize();

// don't forget to set viewport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace Skylicht

}

void CShaderDeferred::OnSetConstants(CShader *shader, SUniform *uniform, IMaterialRenderer* matRender, bool vertexShader)
void CShaderDeferred::OnSetConstants(CShader* shader, SUniform* uniform, IMaterialRenderer* matRender, bool vertexShader)
{
switch (uniform->Type)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@ namespace Skylicht

// save projection/view for advance shader SSR
CShaderDeferred::setProjection(driver->getTransform(video::ETS_PROJECTION));
CShaderDeferred::setView(m_viewMatrix = driver->getTransform(video::ETS_VIEW));

m_viewMatrix = driver->getTransform(video::ETS_VIEW);
CShaderDeferred::setView(m_viewMatrix);

// STEP 01:
// draw baked indirect lighting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,11 @@ namespace Skylicht
beginRender2D(renderW, renderH);
renderBufferToTarget(0.0f, 0.0f, renderW, renderH, m_linearPass);

m_lastFrameBuffer->regenerateMipMapLevels();

driver->setRenderTarget(finalTarget, false, false);
if (viewport.getWidth() > 0 && viewport.getHeight() > 0)
driver->setViewPort(viewport);

m_lastFrameBuffer->regenerateMipMapLevels();
}
// END SCREEN SPACE REFLECTION

Expand Down

0 comments on commit dfeba3f

Please sign in to comment.