/// <summary> /// Renders the sampling visualization /// </summary> public void RenderVisualisation() { var device = _graphicsDeviceManager.GraphicsDevice; device.SetRenderTargets(device.BackBuffer); _viewerEffect.Texture = _colorTextureRenderTarget; _viewerGeometry.Draw(_viewerEffect); }
void IScene.Render() { Device device = this.Host.Device; if (device == null) { return; } //currentFov = Lerp(currentFov, targetFov, 5f * deltaTime); currentFov = currentFov.LerpInPlace(targetFov, 5f * deltaTime); projectionMatrix = Matrix.PerspectiveFovRH((float)(currentFov * Math.PI / 180f), (float)16f / 9f, 0.0001f, 50.0f); UpdateInput(); // Little planet makes sense only in sphere and dome projections var littlePlanetProjections = new[] { ProjectionMode.Sphere, ProjectionMode.Dome }; if (littlePlanet && !littlePlanetProjections.Contains(projectionMode)) { RectlinearProjection(); } //if (!textureReleased) //{ customEffect.Parameters["WorldViewProj"].SetValue(worldMatrix * viewMatrix * projectionMatrix); if (requestContent) { if (requestContentCallback(this)) { requestContent = false; } } lock (localCritical) { // requiestContentCallback should ensure that primitive is set at this point primitive?.Draw(customEffect); } }
public void Render(float deltaTime, Matrix viewMatrix, Matrix projectionMatrix, Vector3 viewPosition, bool pause) { uiEffect.View = viewMatrix; uiEffect.Projection = projectionMatrix; showAlpha = showAlpha.LerpInPlace(pause ? 1 : 0, 8f * deltaTime); if (showAlpha < 0.01f) { showAlpha = 0f; } else if (showAlpha > 0.99f) { showAlpha = 1f; } isUIHidden = showAlpha <= 0; // distance ui plane - eye // { 0 for d <= uiDistanceDisappear // { 0..1 for uiDistanceDisappear d < uiDistanceFade // { 1 for d >= uiDistanceFade float dot; Vector3.Dot(ref uiPlane.Normal, ref viewPosition, out dot); float d = Math.Abs(dot - uiPlane.D); float overrideShowAlpha = (d - uiDistanceDisappear) / uiDistanceFade; if (overrideShowAlpha < 0) { overrideShowAlpha = 0; } else if (overrideShowAlpha > 1) { overrideShowAlpha = 1; } uiEffect.Alpha = showAlpha * overrideShowAlpha; if (uiEffect.Alpha > 0) { uiPrimitive.Draw(uiEffect); } }
/// <summary> /// Render the visualisation showing that tiles are loaded for each managed resource /// </summary> public void RenderVisualization() { var viewport = _graphicsDeviceManager.GraphicsDevice.Viewport; var yOffset = 0f; foreach (var resource in _managedTiledResources) { var visualWidth = Math.Max(256.0f, viewport.Width / SampleSettings.Sampling.Ratio); var visualHeight = visualWidth * (float)Math.Sqrt(3) / 3f; var xPosition = viewport.Width - visualWidth - 48f; var yPosition = viewport.Height - visualHeight - 48f - yOffset; _viewerEffect.Scale = new Vector2(visualWidth / viewport.Width, visualHeight / viewport.Height); _viewerEffect.Offset = new Vector2(2f * (xPosition + visualWidth / 2f) / viewport.Width - 1f, 1f - 2f * (yPosition + visualHeight / 2f) / viewport.Height); _viewerEffect.Texture = resource.ResidencyTexture; _viewerGeometry.Draw(_viewerEffect); yOffset += visualHeight + 24f; } }
/// <summary> /// Draw the prepared geometry /// </summary> public void Draw(SharpDX.Toolkit.Graphics.Effect effect = null) { _terrainGeometry.Draw(effect ?? _terrainRendererEffect); }