mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
Merge pull request #622 from BeamNG/texel_pixel_offset
Handle texel-pixel offset with diferents graphics APIs.
This commit is contained in:
commit
3e7c7b3e49
2 changed files with 8 additions and 3 deletions
|
|
@ -21,6 +21,7 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "gfx/util/screenspace.h"
|
#include "gfx/util/screenspace.h"
|
||||||
|
#include "gfx/gfxDevice.h"
|
||||||
|
|
||||||
// The conversion from screen space to the render target
|
// The conversion from screen space to the render target
|
||||||
// is made more complex because screen space is relative
|
// is made more complex because screen space is relative
|
||||||
|
|
@ -41,9 +42,11 @@ void ScreenSpace::RenderTargetParameters(const Point3I &targetSize, const RectI
|
||||||
Point2F targetScale( (F32)targetViewport.extent.x / (F32)targetSize.x,
|
Point2F targetScale( (F32)targetViewport.extent.x / (F32)targetSize.x,
|
||||||
(F32)targetViewport.extent.y / (F32)targetSize.y );
|
(F32)targetViewport.extent.y / (F32)targetSize.y );
|
||||||
|
|
||||||
|
const bool hasTexelPixelOffset = GFX->getAdapterType() == Direct3D9;
|
||||||
|
|
||||||
// Get the target half pixel size.
|
// Get the target half pixel size.
|
||||||
const Point2F halfPixel( 0.5f / targetSize.x,
|
const Point2F halfPixel( hasTexelPixelOffset ? (0.5f / targetSize.x) : 0.0f,
|
||||||
0.5f / targetSize.y );
|
hasTexelPixelOffset ? (0.5f / targetSize.y) : 0.0f );
|
||||||
|
|
||||||
rtParams.set( targetOffset.x + halfPixel.x,
|
rtParams.set( targetOffset.x + halfPixel.x,
|
||||||
targetOffset.y + halfPixel.y,
|
targetOffset.y + halfPixel.y,
|
||||||
|
|
|
||||||
|
|
@ -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 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 );
|
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;
|
Point4F targetParams;
|
||||||
targetParams.x = offset.x + halfPixel.x;
|
targetParams.x = offset.x + halfPixel.x;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue