mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
added a small layer of fog to the far plane (looks nicer than just cutting off the geometry)
This commit is contained in:
parent
136413d29a
commit
c987240b5e
5 changed files with 30 additions and 5 deletions
|
@ -48,7 +48,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
#region ================== Constants
|
||||
|
||||
// Object picking interval
|
||||
private double PICK_INTERVAL = 100.0d;
|
||||
private const double PICK_INTERVAL = 100.0d;
|
||||
private const float PICK_RANGE = 0.98f;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -104,7 +105,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Find the object we are aiming at
|
||||
Vector3D start = CameraPosition;
|
||||
Vector3D delta = CameraTarget - CameraPosition;
|
||||
delta = delta.GetFixedLength(General.Settings.ViewDistance);
|
||||
delta = delta.GetFixedLength(General.Settings.ViewDistance * PICK_RANGE);
|
||||
VisualPickResult newtarget = PickObject(start, start + delta);
|
||||
|
||||
// Object changed?
|
||||
|
@ -170,6 +171,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Start drawing
|
||||
if(renderer.Start())
|
||||
{
|
||||
// Use fog!
|
||||
renderer.SetFogMode(true);
|
||||
|
||||
// Begin with geometry
|
||||
renderer.StartGeometry();
|
||||
|
||||
|
|
|
@ -56,5 +56,6 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// Rendering methods
|
||||
void AddGeometry(VisualGeometry g);
|
||||
void RenderCrosshair();
|
||||
void SetFogMode(bool usefog);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,6 +204,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// Renderstates that count for this whole sequence
|
||||
graphics.Device.SetRenderState(RenderState.CullMode, Cull.None);
|
||||
graphics.Device.SetRenderState(RenderState.ZEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.FogEnable, false);
|
||||
graphics.Device.SetStreamSource(0, screenverts, 0, sizeof(FlatVertex));
|
||||
graphics.Device.SetTransform(TransformState.World, Matrix.Identity);
|
||||
graphics.Shaders.Display2D.Begin();
|
||||
|
@ -590,7 +591,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
{
|
||||
if(renderlayer != RenderLayers.None) throw new InvalidOperationException("Renderer starting called before finished previous layer. Call Finish() first!");
|
||||
renderlayer = RenderLayers.Plotter;
|
||||
|
||||
graphics.Device.SetRenderState(RenderState.FogEnable, false);
|
||||
|
||||
// Rendertargets available?
|
||||
if(plottertex != null)
|
||||
{
|
||||
|
@ -625,7 +627,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
{
|
||||
if(renderlayer != RenderLayers.None) throw new InvalidOperationException("Renderer starting called before finished previous layer. Call Finish() first!");
|
||||
renderlayer = RenderLayers.Things;
|
||||
|
||||
graphics.Device.SetRenderState(RenderState.FogEnable, false);
|
||||
|
||||
// Rendertargets available?
|
||||
if(thingstex != null)
|
||||
{
|
||||
|
@ -663,7 +666,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
{
|
||||
if(renderlayer != RenderLayers.None) throw new InvalidOperationException("Renderer starting called before finished previous layer. Call Finish() first!");
|
||||
renderlayer = RenderLayers.Overlay;
|
||||
|
||||
graphics.Device.SetRenderState(RenderState.FogEnable, false);
|
||||
|
||||
// Rendertargets available?
|
||||
if(overlaytex != null)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
private const int RENDER_PASSES = 4;
|
||||
private const float PROJ_NEAR_PLANE = 1f;
|
||||
private const float CROSSHAIR_SCALE = 0.06f;
|
||||
private const float FOG_RANGE = 0.9f;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
@ -254,6 +256,13 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.Device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
|
||||
graphics.Device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
|
||||
graphics.Device.SetRenderState(RenderState.TextureFactor, -1);
|
||||
graphics.Device.SetRenderState(RenderState.FogEnable, false);
|
||||
graphics.Device.SetRenderState(RenderState.FogDensity, 1.0f);
|
||||
graphics.Device.SetRenderState(RenderState.FogColor, General.Colors.Background.ToInt());
|
||||
graphics.Device.SetRenderState(RenderState.FogStart, General.Settings.ViewDistance * FOG_RANGE);
|
||||
graphics.Device.SetRenderState(RenderState.FogEnd, General.Settings.ViewDistance);
|
||||
graphics.Device.SetRenderState(RenderState.FogTableMode, FogMode.Linear);
|
||||
graphics.Device.SetRenderState(RenderState.RangeFogEnable, false);
|
||||
|
||||
// Matrices
|
||||
ApplyMatrices3D();
|
||||
|
@ -447,6 +456,12 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.Shaders.Display2D.EndPass();
|
||||
graphics.Shaders.Display2D.End();
|
||||
}
|
||||
|
||||
// This switches fog on and off
|
||||
public void SetFogMode(bool usefog)
|
||||
{
|
||||
graphics.Device.SetRenderState(RenderState.FogEnable, usefog);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
1
Source/Windows/PreferencesForm.Designer.cs
generated
1
Source/Windows/PreferencesForm.Designer.cs
generated
|
@ -560,6 +560,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
//
|
||||
this.viewdistance.LargeChange = 2;
|
||||
this.viewdistance.Location = new System.Drawing.Point(103, 196);
|
||||
this.viewdistance.Maximum = 15;
|
||||
this.viewdistance.Minimum = 1;
|
||||
this.viewdistance.Name = "viewdistance";
|
||||
this.viewdistance.Size = new System.Drawing.Size(150, 42);
|
||||
|
|
Loading…
Reference in a new issue