Still haven't got my shader back to work:
This is the code to init the shader. Anything weird in here? (worked fine in previous version)
function Water_Init(WaterHeight#,PlaneWidth,PlaneHeight,ImageWidth,ImageHeight,CameraNear#,CameraFar#)
global Water_Height#
Water_Height#=WaterHeight#
global Water_ReflectionImageID
Water_ReflectionImageID=CreateRenderImage(ImageWidth,ImageHeight,0,0)
global Water_RefractionImageID
Water_RefractionImageID=CreateRenderImage(ImageWidth,ImageHeight,0,0)
global Water_DepthImageID
Water_DepthImageID=CreateRenderImage(ImageWidth,ImageHeight,1,0)
global Water_WaterShaderID
Water_WaterShaderID=LoadShader("\media\shader\water.vs","\media\shader\water.ps")
SetShaderConstantByName(Water_WaterShaderID,"cameraRange",CameraNear#,CameraFar#,0,0)
global Water_ObjectShaderID
Water_ObjectShaderID=LoadShader("\media\shader\clipping.vs","\media\shader\clipping.ps")
global Water_TerrainShaderID
Water_TerrainShaderID=LoadShader("\media\shader\terrain.vs", "\media\shader\terrain.ps" )
WaterDuDvImageID=LoadImage("\media\shader\waterDUDV.png")
SetImageWrapU(WaterDuDvImageID,1)
SetImageWrapV(WaterDuDvImageID,1)
WaterNormalImageID=LoadImage("\media\shader\waterNormal.png")
SetImageWrapU(WaterNormalImageID,1)
SetImageWrapV(WaterNormalImageID,1)
global Water_WaterObjectID
Water_WaterObjectID=CreateObjectPlane(PlaneWidth,PlaneHeight)
SetObjectPosition(Water_WaterObjectID,PlaneWidth*0.5,1+WaterHeight#,PlaneHeight*0.5)
SetObjectRotation(Water_WaterObjectID,90,0,0)
SetObjectTransparency(Water_WaterObjectID,1)
SetObjectImage(Water_WaterObjectID,Water_ReflectionImageID,0)
SetObjectImage(Water_WaterObjectID,Water_RefractionImageID,1)
SetObjectImage(Water_WaterObjectID,WaterDuDvImageID,2)
SetObjectImage(Water_WaterObjectID,WaterNormalImageID,3)
SetObjectImage(Water_WaterObjectID,Water_DepthImageID,4)
SetObjectUVScale(Water_WaterObjectID,0,128,128)
SetObjectColor(Water_WaterObjectID,0,32,64,255)
SetObjectShader(Water_WaterObjectID,Water_WaterShaderID)
global Water_GroundObjectID
//Water_GroundObjectID=land
endfunction
function Water_AddObject(ObjectID)
SetObjectShader(ObjectID,Water_ObjectShaderID)
endfunction
function Water_AddTerrain(ObjectID)
SetObjectShader(ObjectID,Water_TerrainShaderID)
endfunction
function Water_Update(SunDirX#,SunDirY#,SunDirZ#,SunRed#,SunGreen#,SunBlue#)
Update3D(0)
CameraX#=GetCameraX(1)
CameraY#=GetCameraY(1)
CameraZ#=GetCameraZ(1)
CameraAngleX#=GetCameraAngleX(1)
CameraAngleY#=GetCameraAngleY(1)
CameraAngleZ#=GetCameraAngleZ(1)
SetObjectVisible(Water_WaterObjectID,0)
SetShaderConstantByName(Water_ObjectShaderID,"clippingPlane",0,1,0,-Water_Height#-0.1)
SetShaderConstantByName(Water_TerrainShaderID,"clippingPlane",0,1,0,-Water_Height#-0.1)
SetRenderToImage(Water_RefractionImageID,Water_DepthImageID)
ClearScreen()
Render()
SetCameraPosition(1,CameraX#,Water_Height#-(CameraY#-Water_Height#),CameraZ#)
SetCameraRotation(1,-CameraAngleX#,CameraAngleY#,-CameraAngleZ#)
SetShaderConstantByName(Water_ObjectShaderID,"clippingPlane",0,-1,0,Water_Height#)
SetShaderConstantByName(Water_TerrainShaderID,"clippingPlane",0,-1,0,Water_Height#)
SetRenderToImage(Water_ReflectionImageID,-1)
//SetObjectVisible(Water_GroundObjectID,0)
ClearScreen()
Render()
//SetObjectVisible(Water_GroundObjectID,1)
SetCameraPosition(1,CameraX#,CameraY#,CameraZ#)
SetCameraRotation(1,CameraAngleX#,CameraAngleY#,CameraAngleZ#)
SetObjectVisible(Water_WaterObjectID,1)
//SetShaderConstantByName(Water_ObjectShaderID,"clippingPlane",0,-1,0,GetObjectY(Water_GroundObjectID))
//SetShaderConstantByName(Water_TerrainShaderID,"clippingPlane",0,-1,0,GetObjectY(Water_GroundObjectID))
SetShaderConstantByName(Water_WaterShaderID,"lightVector",SunDirX#,SunDirY#,SunDirZ#,0)
SetShaderConstantByName(Water_WaterShaderID,"lightColor",SunRed#,SunGreen#,SunBlue#,0)
// render the scene as normal
SetRenderToScreen()
// Water
//SetCameraRange(1,5, 10000)
//Render()
//
//SetCameraRange(1,5, 25)
//ClearDepthBuffer()
//Render()
//SetCameraRange(1,0.116, 5)
//ClearDepthBuffer()
//Render()
// cockpit
//SetCameraRange(1,0.01, 5)
//ClearDepthBuffer()
//Render()
endfunction
Dutch