Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
water [2020/01/10 08:07] – created admin | water [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Water ====== | ||
- | <file pascal> | ||
- | procedure TForm1.CreateWater(const AAssetsPath : String); | ||
- | var LTexPath : String; | ||
- | begin | ||
- | LTexPath := IncludeTrailingPathDelimiter(AAssetsPath + ' | ||
- | |||
- | /// create the water plane | ||
- | FWaterPlane := TGorillaPlane.Create(FTerrain); | ||
- | FWaterPlane.Name := ' | ||
- | FWaterPlane.BeginUpdate(); | ||
- | try | ||
- | FWaterPlane.Parent := FTerrain; | ||
- | FWaterPlane.HitTest := false; | ||
- | FWaterPlane.RotationAngle.X := -90; | ||
- | FWaterPlane.Width | ||
- | FWaterPlane.Height := MAP_SIZE; | ||
- | FWaterPlane.Depth | ||
- | FWaterPlane.SubdivisionsHeight := 64; | ||
- | FWaterPlane.SubdivisionsWidth | ||
- | 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 + ' | ||
- | FWaterMaterial.DUDVTexture.LoadFromFile(LTexPath + ' | ||
- | FWaterMaterial.SpecularTexture.LoadFromFile(LTexPath + ' | ||
- | FWaterMaterial.FoamTexture.LoadFromFile(LTexPath + ' | ||
- | |||
- | /// link reflection and refraction render pass to water material | ||
- | FWaterMaterial.ReflectionPass := FReflection; | ||
- | FWaterMaterial.RefractionPass := FRefraction; | ||
- | |||
- | FWaterPlane.MaterialSource := FWaterMaterial; | ||
- | end; | ||
- | </ |