hi!
i tried to make refraction. (at first, i'll do it without use of shaders)
somehow, the water looks like i was using transparency only. i put the cubemap texture detail very low, so you don't think that the water is transparent. it's alpha is turned to 1.0
here is my code:
and the image:

thank you for any help :)
i tried to make refraction. (at first, i'll do it without use of shaders)
somehow, the water looks like i was using transparency only. i put the cubemap texture detail very low, so you don't think that the water is transparent. it's alpha is turned to 1.0
here is my code:
Graphics3D 1024, 768, 32, 2 SetBuffer BackBuffer() ;Camera Global Cam = CreateCamera() PositionEntity Cam, -25, 25, -25 CameraRange Cam, 1, 100000 ;Light RotateEntity CreateLight(), 70, 20, 0 ;Sky c = CreateSphere() ScaleEntity c, -10000, -10000, -10000 EntityFX c, 1 t=LoadTexture("Media\SkyBox.png", 385) SetCubeMode t,2 EntityTexture c, t ;Water Water = CreateWater(50, 5) MoveMouse GraphicsWidth() / 2, GraphicsHeight() / 2 FlushMouse() FlushKeys() While Not KeyHit(1) WireFrame KeyDown(57) FreeLook(.5) UpdateWater(Cam, Water) RenderWorld Text 10, 10, "FPS: " + GetFPS() Flip Wend End Global FPS, FPS_temp, FPS_time Function GetFPS() ctime = MilliSecs() FPS_temp = FPS_temp + 1 If ctime - FPS_time > 500 Then FPS = FPS_temp * 2 FPS_temp = 0 FPS_time = ctime EndIf Return FPS End Function Global CamXS#, CamZS#, CamRotXS#, CamRotYS# Function FreeLook(sp# = .1) If sp# > 0 Then CamXS# = (CamXS# + ((KeyDown(32) Or KeyDown(205)) - (KeyDown(30) Or KeyDown(203))) * sp#) * .75 CamZS# = (CamZS# + ((KeyDown(17) Or KeyDown(200)) - (KeyDown(31) Or KeyDown(208))) * sp#) * .75 MoveEntity Cam, CamXS#, 0, CamZS# EndIf CamRotXS# = ((MouseXSpeed() - CamRotXS#) * .35 + CamRotXS#) * .75 CamRotYS# = ((MouseYSpeed() - CamRotYS#) * .35 + CamRotYS#) * .75 If EntityPitch(Cam) + CamRotYS# < -85 pitch# = -85 ElseIf EntityPitch(Cam) + CamRotYS# > 85 pitch# = 85 Else pitch# = EntityPitch(Cam) + CamRotYS# yaw# = -CamRotXS# + EntityYaw(Cam) RotateEntity Cam, pitch#, yaw#, 0 MoveMouse GraphicsWidth() / 2, GraphicsHeight() / 2 End Function ;v1 = x * (WaterSize + 1) + z ;v2 = v1 + 1 ;v3 = (x + 1) * (WaterSize + 1) + z + 1 ;v4 = v3 - 1 ;AddTriangle WaterSurf, v1, v2, v3 ;AddTriangle WaterSurf, v1, v3, v4 Type Water Field ent, surf Field size, v[256 ^ 2], vh[256 ^ 2] Field tex, cam End Type Function CreateWater(size = 10, size_multiplicator# = 1) w.Water = New Water w\ent = CreateMesh() w\surf = CreateSurface(w\ent) w\size = size For x = 0 To w\size For y = 0 To w\size w\v[cnt] = AddVertex(w\surf, x, Rnd(-1, 1), y) cnt = cnt + 1 Next Next For x = 0 To w\size - 1 For y = 0 To w\size - 1 v1 = x * (w\size + 1) + y v2 = v1 + 1 v3 = (x + 1) * (w\size + 1) + y + 1 v4 = v3 - 1 AddTriangle w\surf, v1, v2, v3 AddTriangle w\surf, v1, v3, v4 Next Next PositionMesh w\ent, -size / 2.0, 0, -size / 2.0 UpdateNormals w\ent EntityFX w\ent, 17 ScaleEntity w\ent, size_multiplicator#, 1, size_multiplicator# EntityColor w\ent, 200, 200, 255 w\tex = CreateTexture(8, 8, 128) EntityTexture w\ent, w\tex SetCubeMode w\tex, 3 w\cam = CreateCamera() CameraRange w\cam, 1, 100000 Return Handle(w) End Function Function UpdateWater(camera, wat) w.Water = Object.Water(wat) HideEntity w\ent RenderWater(w\tex, w\cam, camera) ShowEntity w\ent End Function Function RenderWater(tex, camera, entity) tex_sz = TextureWidth(tex) ShowEntity camera HideEntity entity PositionEntity camera, EntityX(entity, True), EntityY(entity, True), EntityZ(entity, True), True CameraViewport camera, 0, 0, tex_sz, tex_sz SetCubeFace tex, 0: RotateEntity camera, 0, 90, 0: RenderWorld: CopyRect 0, 0, tex_sz, tex_sz, 0, 0, BackBuffer(), TextureBuffer(tex) SetCubeFace tex, 1: RotateEntity camera, 0, 0, 0: RenderWorld: CopyRect 0, 0, tex_sz, tex_sz, 0, 0, BackBuffer(), TextureBuffer(tex) SetCubeFace tex, 2: RotateEntity camera, 0, -90, 0: RenderWorld: CopyRect 0, 0, tex_sz, tex_sz, 0, 0, BackBuffer(), TextureBuffer(tex) SetCubeFace tex, 3: RotateEntity camera, 0, 180, 0: RenderWorld: CopyRect 0, 0, tex_sz, tex_sz, 0, 0, BackBuffer(), TextureBuffer(tex) SetCubeFace tex, 4: RotateEntity camera, -90, 0, 0: RenderWorld: CopyRect 0, 0, tex_sz, tex_sz, 0, 0, BackBuffer(), TextureBuffer(tex) SetCubeFace tex, 5: RotateEntity camera, 90, 0, 0: RenderWorld: CopyRect 0, 0, tex_sz, tex_sz, 0, 0, BackBuffer(), TextureBuffer(tex) ShowEntity entity HideEntity camera End Function
and the image:

thank you for any help :)