Skip to content

Commit

Permalink
Handle texel-pixel offset with diferents graphics APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisAntonRebollo committed Nov 26, 2014
1 parent bc80fbf commit 0a7a7d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Engine/source/gfx/util/screenspace.cpp
Expand Up @@ -42,11 +42,11 @@ void ScreenSpace::RenderTargetParameters(const Point3I &targetSize, const RectI
Point2F targetScale( (F32)targetViewport.extent.x / (F32)targetSize.x,
(F32)targetViewport.extent.y / (F32)targetSize.y );

bool hasTexelPixelOffset = GFX->getAdapterType() == Direct3D9;
const bool hasTexelPixelOffset = GFX->getAdapterType() == Direct3D9;

// Get the target half pixel size.
const Point2F halfPixel( hasTexelPixelOffset ? 0.5f / targetSize.x : 0.0,
hasTexelPixelOffset ? 0.5f / targetSize.y : 0.0);
const Point2F halfPixel( hasTexelPixelOffset ? (0.5f / targetSize.x) : 0.0,
hasTexelPixelOffset ? (0.5f / targetSize.y) : 0.0 );

rtParams.set( targetOffset.x + halfPixel.x,
targetOffset.y + halfPixel.y,
Expand Down
4 changes: 3 additions & 1 deletion Engine/source/postFx/postEffect.cpp
Expand Up @@ -637,7 +637,9 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
Point2F offset((F32)viewport.point.x / (F32)targetSize.x, (F32)viewport.point.y / (F32)targetSize.y );
Point2F scale((F32)viewport.extent.x / (F32)targetSize.x, (F32)viewport.extent.y / (F32)targetSize.y );

const Point2F halfPixel( 0.5f / targetSize.x, 0.5f / targetSize.y );
const bool hasTexelPixelOffset = GFX->getAdapterType() == Direct3D9;
const Point2F halfPixel( hasTexelPixelOffset ? (0.5f / targetSize.x) : 0.0f,
hasTexelPixelOffset ? (0.5f / targetSize.y) : 0.0f );

Point4F targetParams;
targetParams.x = offset.x + halfPixel.x;
Expand Down

0 comments on commit 0a7a7d4

Please sign in to comment.