RT Dual Paraboloid Environment Mapping
Download Demo: https://www.dropbox.com/s/282zgdtf93jln9r/paraboloid.zip?dl=0
// Project: Paraboloid
// Created: 2015-04-30
// set window properties
SetWindowTitle("Paraboloid")
SetWindowSize(0, 0, -1)
SetPrintSize(16)
DW# = GetDeviceWidth()
DH# = GetDeviceHeight()
// set display properties
SetVirtualResolution(DW#, DH#)
SetOrientationAllowed(0, 0, 1, 1)
//skybox
CreateObjectBox(1, 1000, 1000, 1000)
SetObjectCullMode(1, 2)
LoadImage( 1, "ft.jpg" )
LoadImage( 2, "bk.jpg" )
LoadImage( 3, "lf.jpg" )
LoadImage( 4, "rt.jpg" )
LoadImage( 5, "up.jpg" )
LoadImage( 6, "dn.jpg" )
SetObjectImage( 1, 1, 0 )
SetObjectImage( 1, 2, 1 )
SetObjectImage( 1, 3, 2 )
SetObjectImage( 1, 4, 3 )
SetObjectImage( 1, 5, 4 )
SetObjectImage( 1, 6, 5 )
LoadShader( 1, "skybox.vs", "skybox.ps" )
SetObjectShader(1, 1)
// object dual para. env. mapping
LoadObject(2, "torus.obj")
SetObjectScale(2, 0.25, 0.25, 0.25)
CreateRenderImage( 11, 1024, 1024, 0, 0)
CreateRenderImage( 12, 1024, 1024, 0, 0)
SetObjectImage(2, 11, 0)
SetObjectImage(2, 12, 1)
LoadShader(2, "dpem.vs", "dpem.ps")
SetObjectShader(2, 2)
SetObjectLightMode(2, 1)
/*
for i = 3 to 50
CreateObjectSphere(i, 20, 32, 32)
SetObjectPosition(i, 500 - Random(0, 1000), 500 - Random(0, 1000), 500 - Random(0, 1000))
SetObjectColor(i, 160, 160, 255, 0)
SetObjectLightMode(i, 1)
next i
*/
CreateLightDirectional(1, 0, 0, -1, 255, 255, 255)
SetCameraRange(1, 1, 1500)
SetSyncRate(60, 1)
repeat
// fov 90° - ratio 1:1
SetCameraFOV(1, 90)
SetCameraAspect(1, 1.0)
// render cam 1
SetRenderToImage(11, -1)
SetCameraPosition(1, 0, 0, -500)
SetCameraRotation(1, 0, 0, 0)
SetShaderConstantByName(2, "CameraPos", 0, 0, -500, 0)
Render()
//render cam 2
SetRenderToImage(12, -1)
SetCameraPosition(1, 0, 0, 500)
SetCameraRotation(1, 0, 180, 0)
SetShaderConstantByName(2, "CameraPos", 0, 0, 500, 0)
Render()
// render screen default
SetRenderToScreen()
SetCameraFOV(1, 45)
SetCameraAspect(1, DW# / DH#)
PrintC("FPS: ")
Print((ScreenFPS()))
Render2DFront()
// move cam
if Round(x1#) = x2# then x2# = 100 - Random(0, 200)
if Round(y1#) = y2# then y2# = 100 - Random(0, 200)
if Round(z1#) = z2# then z2# = 100 - Random(0, 200)
x1# = CosInt(x1#, x2#, 0.07)
y1# = CosInt(y1#, y2#, 0.07)
z1# = CosInt(z1#, z2#, 0.07)
SetCameraPosition( 1, x1#, y1#, z1#)
SetCameraLookAt(1, 0, 0, 0, 0)
Render()
Swap()
until GetRawKeyPressed(27)
end
function CosInt(a#, b#, c#)
f# = (1 - cos(c# * 180.0)) / 2
r# = a# * (1 - f#) + b# * f#
endfunction r#
.