mirror problem

Blitz3D Forums/Blitz3D Programming/mirror problem

everything above and below a mirror seems to be reflected. but when you need to attach a mirror to a infinite water plane, all objects below the mirror don't have to be reflected.
Is it possible to use a mirror in order to reflect ony objects above it ?

try using CreateMirror() function code - which u can get it from BlitzSupport... but some bug noticeable when the camera too close with the mirror plane - or u have to wait for B3D update which is come with cube mapping reflections...

i can't find it... where is it?

try find it under my thread about creating a mirror - i dont even remember where it is - or u can ask BlitzSupport for code call 'RealMirror'.

note: i think it not suitable for Water Reflection, like it name, maybe only for mirror reflection - but worth try

when is the b3d update comming through? anyone know?

nope... nobody know even mark himself

You could two Render Passes on the scene.
1st Pass
Hide water surface, mirror + all objects above water level
Render all objects below water

2nd Pass
Hide all objects below water
Render all other objects

So roughly,
; not really code, just procedure
; Underwater Objects
HideEntity WaterAndObjectsAbove
ShowEntity ObjectsBelow
UpdateWorld()
RenderWorld()

; Overwater and Water Surface
ShowEntity WaterAndObjectsAbove
HideEntity ObjectsBelow
UpdateWorld()
RenderWorld()
Flip()


NOTE -
1. the mirror plane is grouped with the ObjectsAbove the water plane
2.for objects which actually intersect the mirror-plane, you should group them with the ObjectsBelow (so they dont reflect)

here's some code i made up. should do the trick. when your rendering a mirror tho, try and hide all the things you know or you can check that won't be in view :D

Graphics3D 800,600,16

cube=CreateCube()
PositionEntity cube,-3,0,2

plane=CreatePlane()
EntityColor plane,40,40,200
MoveEntity plane,0,-2,0

planetex=CreateTexture(256,256)
SetBuffer TextureBuffer(planetex)
For loop=0 To 255 Step 2
	For loop1=0 To 255 Step 2
		Color 50,50,200
		Rect loop,loop1,1,1
		Color 20,20,200
		Rect loop+1,loop,1,1
		Color 50,50,200
		Rect loop,loop1+1,1,1
		Color 20,20,200
		Rect loop+1,loop1+1,1,1
	Next
Next

SetBuffer BackBuffer()

ScaleTexture planetex,200,200
EntityTexture plane,planetex

sphere=CreateSphere()


camera=CreateCamera(sphere)
PositionEntity camera,0,3,-5
CameraRange camera,1,100

mirror=CreateCube()
PositionEntity mirror,0,3,10
ScaleEntity mirror,3,1.5,0.2

mirrorframe=CreateCube()
PositionEntity mirrorframe,0,3,10.2
ScaleEntity mirrorframe,3.3,1.7,0.3
RotateEntity mirrorframe,20,180,0
EntityColor mirrorframe,70,70,200

mirrorcam=CreateCamera(mirror)
PositionEntity mirrorcam,0,0,0
HideEntity mirrorcam
CameraRange mirrorcam,1,100

mirrortex=CreateTexture(256,256,256)
EntityTexture mirror,mirrortex
ScaleTexture mirrortex,-1,1

light=CreateLight()

RotateEntity mirror,20,180,0

Color 255,255,255

While Not KeyHit(1)
	
	
	If KeyDown(200) Then MoveEntity sphere,0,0,0.1
	If KeyDown(208) Then MoveEntity sphere,0,0,-0.1
	If KeyDown(203) Then TurnEntity sphere,0,1,0
	If KeyDown(205) Then TurnEntity sphere,0,-1,0

	If MilliSecs()<timer+1000 Then
								frame=frame+1
	Else
								fps=frame
								frame=0
								timer=MilliSecs()
	End If
	Gosub updatemirror
	UpdateWorld
	RenderWorld
	Text 0,0,"fps="+fps
	Flip
Wend
End

.updatemirror
	HideEntity camera
	ShowEntity mirrorcam
	RenderWorld
	CopyRect 272,172,255,255,0,0,BackBuffer,TextureBuffer(mirrortex)
	HideEntity mirrorcam
	ShowEntity camera
Return