polarized 3d - anyone tried?

Blitz3D Forums/Blitz3D Programming/polarized 3d - anyone tried?

Modded(Posted 2012) [#1]
I've recently grabbed a polarized 3d monitor, so I was playing about seeing how easy it is or not to "split" the screen, apparently if you use TriDef you cant actually use something not supported... just had a quick play about with the idea (code attached) and it does look to be working.

I had a quick search but it didn't bring up any topics regarding this, has anyone tried it fully? any other quicker ideas? The timer says roughly 1-2 ms for this method.

 Graphics3D 1920,1080,32,2
SetBuffer(BackBuffer())

Global split# = 0.25
Global aim# = 100

camerapiv = CreatePivot()
camera1 = CreateCamera(camerapiv)
camera2 = CreateCamera(camerapiv)
CameraViewport camera1,0,0,1920,540
CameraViewport camera2,0,540,1920,540
PositionEntity camera1,-split#,0,0
PositionEntity camera1, split#,0,0
ScaleEntity camera1,1,2,1
ScaleEntity camera2,1,2,1

cameraaim = CreatePivot(camerapiv)
MoveEntity cameraaim,0,0,aim#
PointEntity camera1,cameraaim
PointEntity camera2,cameraaim

light = CreateLight()
cube = CreateCube()
sphere = CreateSphere(25)

PositionEntity cube,-1,0,7.5
PositionEntity sphere,1,0,10

Global texture = CreateTexture(1920,1080,512+256+1,1)

Color 255,255,255

While Not KeyHit(1)

TurnEntity cube,1,.2,0
TurnEntity light,-1,.2,0

UpdateWorld
RenderWorld

timer = MilliSecs()
polarizerect()

Text 10,10,MilliSecs()-timer
Flip

Wend

Function polarizerect(lr=False)
	CopyRect 0,0,1920,1080,0,0,BackBuffer(),TextureBuffer(texture)
	For y = 0 To 540 Step 1
	If lr=False
		CopyRect 0,y,1920,1,0,y*2,TextureBuffer(texture),BackBuffer()
		CopyRect 0,540+y,1920,1,0,(y*2)+1,TextureBuffer(texture),BackBuffer()
	Else
		CopyRect 0,y,1920,1,0,(y*2)+1,TextureBuffer(texture),BackBuffer()
		CopyRect 0,540+y,1920,1,0,y*2,TextureBuffer(texture),BackBuffer()
	EndIf
Next
End Function

ClearWorld
EndGraphics
End 



Danny(Posted 2012) [#2]
Seems legit.
I get around 2-3ms here (GeForce 9800GT).

I believe the following variation saves about 0.5-1ms on my setup; which prevents calling the BackBuffer() and TextureBuffer functions more than once. Give it a try.
Function polarizeRect(lr=False)
	tBuff% = TextureBuffer(texture)
	bBuff% = BackBuffer()
	CopyRect 0,0,1920,1080,0,0,bBuff,tBuff
	For y = 0 To 540 Step 1
		If lr=False
			CopyRect 0,y,1920,1,0,y*2,tBuff,bBuff
			CopyRect 0,540+y,1920,1,0,(y*2)+1,tBuff,bBuff
		Else
			CopyRect 0,y,1920,1,0,(y*2)+1,tBuff,bBuff
			CopyRect 0,540+y,1920,1,0,y*2,tBuff,bBuff
		EndIf
	Next
End Function

But yeah, it's an interesting problem to try and optimize. If you can interleave them somehow without the first 'CopyRect back->texture', that would surely save a lot (render to texture?). But that's a tricky one ;)

Danny


Tom(Posted 2012) [#3]
No need to check 'lr' 540 times each Function call. :)


Function polarizeRect(lr=False)
	tBuff% = TextureBuffer(texture)
	bBuff% = BackBuffer()
	CopyRect 0,0,1920,1080,0,0,bBuff,tBuff

	If lr=False
		For y = 0 To 540 Step 1
			CopyRect 0,y,1920,1,0,y*2,tBuff,bBuff
			CopyRect 0,540+y,1920,1,0,(y*2)+1,tBuff,bBuff
		Next
	Else
		For y = 0 to 540 Step 1
			CopyRect 0,y,1920,1,0,(y*2)+1,tBuff,bBuff
			CopyRect 0,540+y,1920,1,0,y*2,tBuff,bBuff
		Next
	End if
End Function