Hi
Thank you for your answer.
I have tried to create a simple example to have a reflection.
It work, but I don't know if there is a way to get an orthographic view with the camera.
Quote: "You may have to construct an orthographic matrix in the shader from some uniform values
"
I'm sorry, I don't know how to construct an orthographic matrix in the shader ^^
What is myOrthoMat ?
Here is the code for a reflection/shadowmap, If the camera should be orthographic, I think it could work ^^ :
// Project: 3D_reflection
// For reflection and shadow
// Created: 2015-12-04
SetWindowTitle( "3D_reflection" )
SetWindowSize( 1024, 768, 0 )
DW = 1024
DH = 768
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetClearColor(0.64*255,0.84*255,255)
// position and orientate camera
SetCameraPosition(1,0,20,-50)
SetCameraLookAt(1,0,0,0,0)
// Two sphere to reflect
CreateObjectSphere(1,5,15,15)
SetObjectPosition(1,5,5,5)
CreateObjectSphere(2,5,15,15)
SetObjectPosition(2,-5,5,5)
CreateObjectBox(4,5,30,5)
SetObjectPosition(4,-18,0,12)
// for the reflection
CreateRenderImage(1,512,512,0,0)
CreateObjectPlane(3,50,50)
SetObjectRotation(3,90,0,0)
SetObjectPosition(3,0,-10,5)
SetObjectImage(3,1,0)
a = 0
d = 1
SetCameraPosition(1,0,20,-50)
SetCameraLookAt(1,0,0,0,0)
do
oldx#=GetCameraX(1)
oldy#=GetCameraY(1) //-45.0
oldz#=GetCameraZ(1)
oldrx#=GetCameraAngleX(1)
oldry#=GetCameraAngleY(1) //-45.0
oldrz#=GetCameraAngleZ(1)
// render to image, for reflection // should be the same for shadow
SetRenderToImage(1,-1)
SetCameraFov(1,110)
SetCameraAspect(1, 1.0)
SetCameraPosition(1,0,-10,0)
SetCameraLookAt(1,0,10,0,0)
SetObjectVisible(3,0)
ClearScreen()
Render()
SetObjectVisible(3,1)
SetObjectImage(3,1,0)
SetRenderToScreen()
//SetCameraAspect(1, DW/DH)
SetCameraFov(1,70)
SetCameraPosition(1,oldx#,oldy#,oldz#)
SetCameraRotation(1,oldrx#,oldry#,oldrz#)
endif
inc a
SetObjectPosition(2,-5,10+sin(a)*3,5)
rem Move camera
if ( GetRawKeyState(38)) then MoveCameraLocalZ( 1, d )
if ( GetRawKeyState(40)) then MoveCameraLocalZ( 1, -d )
if ( GetRawKeyState(37) ) then MoveCameraLocalX( 1, -d*0.2 )
if ( GetRawKeyState(39) ) then MoveCameraLocalX( 1, d*0.2)
if ( GetPointerPressed() )
startx# = GetPointerX()
starty# = GetPointerY()
angx# = GetCameraAngleX(1)
angy# = GetCameraAngleY(1)
pressed = 1
endif
if ( GetPointerState() = 1 )
fDiffX# = (GetPointerX() - startx#)/1.0
fDiffY# = (GetPointerY() - starty#)/1.0
newX# = angx# + fDiffY#
if ( newX# > 89 ) then newX# = 89
if ( newX# < -89 ) then newX# = -89
SetCameraRotation( 1, newX#, angy# + fDiffX#, 0 )
endif
ClearScreen()
Sync()
loop
http://www.dracaena-studio.com