Skip to content

Commit

Permalink
[2D] - Fixed an issue in the displacement effect where supplying a di…
Browse files Browse the repository at this point in the history
…fferent background texture wouldn't reset the pixel shader state.
  • Loading branch information
Tape-Worm committed Sep 26, 2021
1 parent dcfd86c commit e67cf8a
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ private struct GpuData
private GorgonTexture2DView _displaceTexture;
// The output render target.
private GorgonRenderTarget2DView _output;
// Flag to indicate that the displacement texture has changed.
private bool _displaceTextureUpdated = true;
#endregion

#region Properties.
Expand Down Expand Up @@ -273,7 +275,7 @@ protected override PassContinuationState OnBeforeRenderPass(int passIndex, Gorgo
/// <returns>The 2D batch state.</returns>
protected override Gorgon2DBatchState OnGetBatchState(int passIndex, IGorgon2DEffectBuilders builders, bool statesChanged)
{
if ((statesChanged) || (_displacementState is null) || (_batchState is null))
if ((statesChanged) || (_displacementState is null) || (_batchState is null) || (_displaceTextureUpdated))
{
if (_displacementState is null)
{
Expand All @@ -287,6 +289,8 @@ protected override Gorgon2DBatchState OnGetBatchState(int passIndex, IGorgon2DEf
_batchState = builders.BatchBuilder
.PixelShaderState(_displacementState)
.Build(BatchStateAllocator);

_displaceTextureUpdated = false;
}

return _batchState;
Expand Down Expand Up @@ -330,7 +334,11 @@ protected override void Dispose(bool disposing)
public bool BeginDisplacementBatch(GorgonTexture2DView backgroundTexture, GorgonRenderTarget2DView output, GorgonDepthStencilState depthStencilState = null, GorgonCameraCommon camera = null)
{
_currentRtv = Graphics.RenderTargets[0];
_displaceTexture = backgroundTexture;
if (_displaceTexture != backgroundTexture)
{
_displaceTexture = backgroundTexture;
_displaceTextureUpdated = true;
}
_output = output;

// No texture? Nothing to displace.
Expand Down

0 comments on commit e67cf8a

Please sign in to comment.