This is an old revision of the document!
Water
procedure TForm1.CreateWater(const AAssetsPath : String); var LTexPath : String; begin LTexPath := IncludeTrailingPathDelimiter(AAssetsPath + 'water'); /// create the water plane FWaterPlane := TGorillaPlane.Create(FTerrain); FWaterPlane.Name := 'WaterPlane1'; FWaterPlane.BeginUpdate(); try FWaterPlane.Parent := FTerrain; FWaterPlane.HitTest := false; FWaterPlane.RotationAngle.X := -90; FWaterPlane.Width := MAP_SIZE; FWaterPlane.Height := MAP_SIZE; FWaterPlane.Depth := 1; FWaterPlane.SubdivisionsHeight := 64; FWaterPlane.SubdivisionsWidth := 64; FWaterPlane.Position.Y := -25; finally FWaterPlane.EndUpdate(); end; /// create reflection render pass for water material FReflection := TGorillaRenderPassReflection.Create(FViewport); FReflection.Viewport := FViewport; FReflection.Camera := FCamera; FReflection.IgnoreControl(FWaterPlane); FReflection.MirrorSize := FWaterPlane.Width; // set the current position of the water plane as mirror plane // this needs to be updated, if water plane moves FReflection.MirrorPosition := TPoint3D(FWaterPlane.AbsolutePosition); FReflection.Enabled := true; /// create refraction render pass for water material FRefraction := TGorillaRenderPassRefraction.Create(FViewport); FRefraction.Viewport := FViewport; FRefraction.IgnoreControl(FWaterPlane); FRefraction.Enabled := true; /// create material source FWaterMaterial := TGorillaWaterMaterialSource.Create(FWaterPlane); FWaterMaterial.Parent := FWaterPlane; FWaterMaterial.NormalTexture.LoadFromFile(LTexPath + 'water_normal.png'); FWaterMaterial.DUDVTexture.LoadFromFile(LTexPath + 'water3-dudv.jpg'); FWaterMaterial.SpecularTexture.LoadFromFile(LTexPath + 'water_height.png'); FWaterMaterial.FoamTexture.LoadFromFile(LTexPath + 'foam.png'); /// link reflection and refraction render pass to water material FWaterMaterial.ReflectionPass := FReflection; FWaterMaterial.RefractionPass := FRefraction; FWaterPlane.MaterialSource := FWaterMaterial; end;