The video shows my issue.
It appears that render targets in seem to have mipmapping turned on by default, even when explicitly turned off. At close range, the texture looks ok, move away and it's block city.#
Also, The depth buffer appears to be wrong as objects are appearing in front of other objects when they shouldn't be, but that could just be my implementation as I haven't used a depth target. (They are drawn onscreen in creation order, with newer objects appearing on top of older objects)
The area within the white rectangle are the contents of the render target, which *should* map 1:1 with the main view, but are slightly off. (I explicitly used a power of 2 resolution. 1024x512)
Here's the code I used for the test... (You'll have to supply your own images.)
// Project: VR Sprite Scaling Test
// Created: 2016-01-14
// set window properties
SetWindowTitle( "VR Sprite Scaling Test" )
SetWindowSize( 1024, 512, 0 )
SetOrientationAllowed( 0, 0, 1, 1 )
SetVirtualResolution( 100, 100 )
SetDisplayAspect( ( GetDeviceWidth() + 0.0 ) / ( GetDeviceHeight() + 0.0 ) )
SetViewZoomMode( 1 )
Type EyeType
RenderImage as integer
Sprite as integer
PosX as float
PosY as float
PosZ as float
EndType
Global LeftEye As EyeType
Global EyeDistance As float : EyeDistance = 10.0
ShowSprite = 2
If ShowSprite >= 1
//set up images to render cameras to
LeftEye.RenderImage = CreateRenderImage( 50, 100, 0, 0 )
LeftEye.Sprite = CreateSprite( 0 )
SetSpriteTransparency( LeftEye.Sprite, 0 )
SetSpriteDepth( LeftEye.Sprite, 1 )
FixSpriteToScreen( LeftEye.Sprite, 1 )
SetSpriteVisible( LeftEye.Sprite, 0 )
Offset# = 0.25
SetSpriteImage( LeftEye.Sprite, LeftEye.RenderImage )
SetSpriteSize( LeftEye.Sprite, 50, 50 )
SetSpritePositionByOffset( LeftEye.Sprite, 50, 50 )
EndIf
SetRawMouseVisible( 0 )
RemStart
Grass = LoadImage( "THE LEGEND OF ZELDA#935021D4#2#1#025691DE_ciByRGBA.png" )
Obj = CreateObjectPlane( 640.0, 640.0 )
SetObjectPosition( Obj, 0.0, -5.0, 0.0 )
SetObjectLookAt( Obj, 0.0, 1.0, 0.0, 0.0 )
SetObjectImage( Obj, Grass, 0 )
Sky = LoadImage( "THE LEGEND OF ZELDA#61DE10A0#2#1#4C5B2160_ciByRGBA.png" )
Obj = CreateObjectPlane( 640.0, 640.0 )
SetObjectPosition( Obj, 0.0, 40.0, 0.0 )
SetObjectLookAt( Obj, 0.0, 0.0, 0.0, 0.0 )
SetObjectImage( Obj, Sky, 0 )
RemEnd
Box = LoadImage( "THE LEGEND OF ZELDA#6ED60D3B#2#1#8721C540_ciByRGBA.png" )
For Amt = 1 to 40
X# = Random( 40.0, 160.0 )
If Random( 0, 1 ) = 1 Then X# = -X#
Z# = Random( 40.0, 160.0 )
If Random( 0, 1 ) = 1 Then Z# = -Z#
Obj = CreateObjectBox( 20.0, 20.0, 20.0 )
SetObjectPosition( Obj, X#, 20.0, Z# )
SetObjectImage( Obj, Box, 0 )
Next Amt
SetCameraPosition( 1, 0.0, 20.0, 0.0 )
SetCameraLookAt( 1, 40.0, 20.0, 40.0, 0.0 )
Repeat
FrameTime# = GetFrameTime()
OldPointerX# = PointerX# : OldPointerY# = PointerY#
If GetKeyboardExists() = 1
PointerX# = GetRawMouseX() : PointerY# = GetRawMouseY()
Else
PointerX# = GetPointerX() : PointerY# = GetPointerY()
EndIf
PointerX# = GetRawMouseX() : PointerY# = GetRawMouseY()
PointerMoveX# = PointerX# - OldPointerX# : PointerMoveY# = PointerY# - OldPointerY#
SetRawMousePosition( 50.0, 50.0 ) : PointerX# = GetRawMouseX() : PointerY# = GetRawMouseY()
CamSpeed# = 400.0
YAng# = GetCameraAngleY( 1 )
If GetJoystickExists() = 1 ` Move player with joystick
//strafe
PlayerPositionX# = PlayerPositionX# + ( GetRawJoystickX( 1 ) * CamSpeed# * Cos( YAng# ) * FrameTime# )
PlayerPositionZ# = PlayerPositionZ# - ( GetRawJoystickX( 1 ) * CamSpeed# * Sin( YAng# ) * FrameTime# )
//forward
PlayerPositionX# = PlayerPositionX# + ( GetRawJoystickY( 1 ) * CamSpeed# * Sin( -YAng# ) * FrameTime# )
PlayerPositionZ# = PlayerPositionZ# - ( GetRawJoystickY( 1 ) * CamSpeed# * Cos( -YAng# ) * FrameTime# )
If GetRawJoystickButtonState( 1, 4 ) Then RotateCameraGlobalY( 1, -0.5 )
If GetRawJoystickButtonState( 1, 2 ) Then RotateCameraGlobalY( 1, 0.5 )
Else ` Use keyboard
//Foward - Backward
PlayerPositionX# = PlayerPositionX# + ( GetJoystickY() * CamSpeed# * Sin( -YAng# ) * FrameTime# )
PlayerPositionZ# = PlayerPositionZ# - ( GetJoystickY() * CamSpeed# * Cos( -YAng# ) * FrameTime# )
//Left - Right
PlayerPositionX# = PlayerPositionX# + ( GetJoystickX() * CamSpeed# * Cos( YAng# ) * FrameTime# )
PlayerPositionZ# = PlayerPositionZ# - ( GetJoystickX() * CamSpeed# * Sin( YAng# ) * FrameTime# )
EndIf
RotateCameraGlobalY( 1, PointerMoveX# )
RotateCameraLocalX( 1, PointerMoveY# )
SetCameraPosition( 1, PlayerPositionX#, 20.0, PlayerPositionZ# )
Render()
If ShowSprite >= 2
SetSpriteVisible( LeftEye.Sprite, 0 )
//Left Eye
SetRenderToImage( LeftEye.RenderImage, 0 )
ClearScreen( )
Render( )
SetRenderToScreen( )
SetSpriteVisible( LeftEye.Sprite, 1 )
FixSprite( LeftEye.Sprite )
EndIf
Print( ScreenFPS() )
Update2D( FrameTime# )
Render2DBack()
ClearDepthBuffer()
Update3D( FrameTime# )
Render3D()
ClearDepthBuffer()
Render2DFront()
Swap()
Until GetRawKeyReleased( 27 )
SetRawMouseVisible( 1 )
End
Function FixSprite( Sprite )
Width# = GetSpriteWidth( Sprite )
Height# = GetSpriteHeight( Sprite )
X# = GetSpriteXByOffset( Sprite )
Y# = GetSpriteYByOffset( Sprite )
UVUOffset# = ( Width# / 100.0 ) / 2.0
UVVOffset# = ( Height# / 100.0 ) / 2.0
DrawLine( X# - ( Width# / 2.0 ), Y# - ( Height# / 2.0 ), X# + ( Width# / 2.0 ), Y# - ( Height# / 2.0 ), 255, 255, 255 )
DrawLine( X# - ( Width# / 2.0 ), Y# + ( Height# / 2.0 ), X# + ( Width# / 2.0 ), Y# + ( Height# / 2.0 ), 255, 255, 255 )
DrawLine( X# - ( Width# / 2.0 ), Y# - ( Height# / 2.0 ), X# - ( Width# / 2.0 ), Y# + ( Height# / 2.0 ), 255, 255, 255 )
DrawLine( X# + ( Width# / 2.0 ), Y# - ( Height# / 2.0 ), X# + ( Width# / 2.0 ), Y# + ( Height# / 2.0 ), 255, 255, 255 )
SetSpriteUV ( LeftEye.Sprite, 0.5 - UVUOffset#, 0.5 - UVVOffset#, 0.5 - UVUOffset#, 0.5 + UVVOffset#, 0.5 + UVUOffset#, 0.5 - UVVOffset#, 0.5 + UVUOffset#, 0.5 + UVVOffset# )
EndFunction