Hi
I have made severals tests, and I have always that strange reflection :
The code :
// 1* for every new object you must setup a shader with the clipping plane or you will get strange reflections in the water
// render the refraction
/*
For i= 0 to 10
SetObjectVisible(51+i,0)
next
//SetObjectVisible(50,0)
*/
SetObjectVisible(TerrainObjectID,0)
SetShaderConstantByName(5,"clippingPlane",0,1,0,-10)
SetShaderConstantByName(TerrainShaderID,"clippingPlane",0,1,0,-2)
SetRenderToImage(RefractionImageID,DepthImageID)
ClearScreen()
Render3D()
SetCameraPosition(1,CameraX#,GWaterHeight#-(CameraY#-GWaterHeight#),CameraZ#)
SetCameraRotation(1,-CameraAngleX#,CameraAngleY#,CameraAngleZ#)
// 1* here too
// render the reflection
/*
For i= 0 to 10
SetObjectVisible(51+i,1)
next
//SetObjectVisible(50,1)
*/
SetShaderConstantByName(5,"clippingPlane",0,-1,0,-1)
SetShaderConstantByName(TerrainShaderID,"clippingPlane",0,-1,0,GWaterHeight#)
SetRenderToImage(ReflectionImageID,-1)
ClearScreen()
Update(0)
Render3D()
SetCameraPosition(1,CameraX#,CameraY#,CameraZ#)
SetCameraRotation(1,CameraAngleX#,CameraAngleY#,CameraAngleZ#)
SetObjectVisible(WaterObjectID,1)
SetShaderConstantByName(TerrainShaderID,"clippingPlane",0,-1,0,0)
SetShaderConstantByName(5,"clippingPlane",0,-1,0,0)
I have use the depth texture, and it work, but only for the terrain if I don't use the shader of terrain, else, it doesn't work with the terrain.
And it's good with the depth texture in the water shader
You can test easyli the "bug" witht the reflection with only the water and some big object (box, sphere), like on the next image ( +The debug images) :
I hope this can help.
Another question, I have tried to add a normalmap on the terrain or object shader, but Do I need to add, afetr I have add :
// apply normalmap
vec4 normalColor = texture2D(texture1, uv1Varying);
vec3 normal = vec3(normalColor.r * 2.0 - 1.0, normalColor.b, normalColor.g * 2.0 -1.0);
normal = normalize(normal);
To see the normal map on the shader ?
AGK2 tier1 - http://www.dracaena-studio.com