protected override void OnLoad(EventArgs e) { multisampling = new Multisampling(4); GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest); GL.ClearColor(State.ClearColor); GL.Enable(EnableCap.Blend); GL.Enable(EnableCap.Texture2D); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); GL.MinSampleShading(1.0f); Map.New(2048); debug = new ObjectRenderer(); camera = new Camera(); terrain = new TerrainRenderer(camera); water = new WaterRenderer(); light = new Light(); assets = new AssetRenderer(); ui = new Ui(); sky = new SkyRenderer(); shadows = new ShadowBox(); }
public Water(int width, int height, int columns, WaterRenderer renderer = null, float tension = 0.025f, float dampening = 0.025f, float spread = 0.025f) { _width = width; _height = height; _renderer = renderer; _tension = tension; _dampening = dampening; _spread = spread; _columns = new WaterColumn[columns]; for (int i = 0; i < _columns.Length; i++) { _columns[i] = new WaterColumn() { Height = height, TargetHeight = height, Speed = 0 }; } // Apply basic water renderer if non set if (renderer == null) renderer = new BasicWaterRenderer(); AddNode(renderer); }
private void Initialize() { graphicsDevice = ScreenManager.GraphicsDevice; content = ScreenManager.Content; spriteBatch = ScreenManager.SpriteBatch; font = ScreenManager.Font; MeshManager.InitializeManager(graphicsDevice, content); screenWidth = graphicsDevice.Viewport.Width; screenHeight = graphicsDevice.Viewport.Height; clearColor = new Color(0.0f, 0.0f, 0.0f, 0.0f); // Create Render Targets mainRT = new RenderTarget2D(graphicsDevice, screenWidth, screenHeight, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents); reflectionRT = new RenderTarget2D(graphicsDevice, screenWidth / 2, screenHeight / 2, true, SurfaceFormat.Color, DepthFormat.Depth24Stencil8); occlusionRT = new RenderTarget2D(graphicsDevice, screenWidth / 8, screenHeight / 8, false, SurfaceFormat.Color, DepthFormat.None); bloomRT = new RenderTarget2D(graphicsDevice, screenWidth / 8, screenHeight / 8, false, SurfaceFormat.Color, DepthFormat.None); postEffects = new PostProcessingEffects(graphicsDevice, content.Load <Effect>(@"Effects\PostProcessingEffects")); // Create renderers lightRenderer = new LightRenderer(graphicsDevice, content.Load <Effect>(@"Effects\Light")); terrainRenderer = new TerrainRenderer(graphicsDevice, content.Load <Effect>(@"Effects\Terrain")); surfaceRenderer = new SurfaceRenderer(graphicsDevice, content.Load <Effect>(@"Effects\Surface")); waterRenderer = new WaterRenderer(graphicsDevice, content.Load <Effect>(@"Effects\Water")); billboardRenderer = new BillboardRenderer(graphicsDevice, content.Load <Effect>(@"Effects\Billboard")); meshRenderer = new MeshRenderer(graphicsDevice, content.Load <Effect>(@"Effects\Mesh")); // Create camera camera = new FirstPersonCamera(); camera.AspectRatio = graphicsDevice.Viewport.AspectRatio; camera.AABBSize = new Vector2(1.0f, 8.0f); camera.DrawDistance = 10000.0f; camera.MoveSpeed = 25.0f; camera.FreeFlyEnabled = false; camera.PitchMinDegrees = -75.0f; camera.PitchMaxDegrees = 60.0f; camera.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), camera.AspectRatio, 0.1f, 10000.0f); secretSFX = content.Load <SoundEffect>(@"SoundEffects\shotgun_pump"); // Load level data LoadLevel(@"Levels\" + levelFileName); }
private void Start() { terrainData.ApplyToMaterial(terrainMaterial); viewerPositionLastUpdate = Vector3.negativeInfinity; WaterRenderer waterRenderer = gameObject.AddComponent <WaterRenderer>(); waterRenderer.waterMaterial = waterMaterial; waterRenderer.CreateCameras(waterData.resolution, waterData.waterLevelY); InvokeRepeating("UpdateTerrainChunks", 0, 0.1f); }
/// <summary> /// Initializes water and lava asset definitions /// and liquid properties /// TODO: Move this to another file. /// </summary> public void CreateLiquids() { WaterRenderer = new WaterRenderer(GraphicsDevice); LiquidAsset waterAsset = new LiquidAsset { Type = LiquidType.Water, Opactiy = 0.3f, SloshOpacity = 0.7f, WaveHeight = 0.1f, WaveLength = 0.05f, WindForce = 0.001f, BumpTexture = TextureManager.GetTexture(ContentPaths.Terrain.water_normal), FoamTexture = TextureManager.GetTexture(ContentPaths.Terrain.foam), BaseTexture = TextureManager.GetTexture(ContentPaths.Terrain.cartoon_water), MinOpacity = 0.0f, RippleColor = new Vector4(0.1f, 0.1f, 0.1f, 0.0f), FlatColor = new Vector4(0.3f, 0.3f, 0.9f, 1.0f) }; WaterRenderer.AddLiquidAsset(waterAsset); LiquidAsset lavaAsset = new LiquidAsset { Type = LiquidType.Lava, Opactiy = 0.99f, SloshOpacity = 1.0f, WaveHeight = 0.1f, WaveLength = 0.05f, WindForce = 0.001f, MinOpacity = 0.99f, BumpTexture = TextureManager.GetTexture(ContentPaths.Terrain.water_normal), FoamTexture = TextureManager.GetTexture(ContentPaths.Terrain.lavafoam), BaseTexture = TextureManager.GetTexture(ContentPaths.Terrain.lava), RippleColor = new Vector4(0.5f, 0.4f, 0.04f, 0.0f), FlatColor = new Vector4(0.9f, 0.7f, 0.2f, 1.0f) }; WaterRenderer.AddLiquidAsset(lavaAsset); }