From f351822859989dbb4d98f6680aa6859d609008d3 Mon Sep 17 00:00:00 2001 From: codeimp Date: Sun, 4 Jan 2009 11:59:24 +0000 Subject: [PATCH] added full brightness toggle feature in visual mode --- Documents/todo.txt | 4 ---- Source/BuilderModes/Resources/Actions.cfg | 10 +++++++++ .../VisualModes/BaseVisualMode.cs | 10 ++++++--- Source/Rendering/IRenderer3D.cs | 1 + Source/Rendering/Renderer3D.cs | 18 +++++++++++----- Source/Resources/world3d.fx | 21 +++++++++++++++++-- 6 files changed, 50 insertions(+), 14 deletions(-) diff --git a/Documents/todo.txt b/Documents/todo.txt index 28126fa1..bfe3fe99 100644 --- a/Documents/todo.txt +++ b/Documents/todo.txt @@ -3,10 +3,6 @@ quality over quantity. It is done when it's done. The order and included items may also change any time. ========================================================= -- Offsets in info panel are not updated when dragging textue or changing texture offsets. - -- Full brightness option in Visual Mode - - Info panel should be collapsable - Create menus for different modes diff --git a/Source/BuilderModes/Resources/Actions.cfg b/Source/BuilderModes/Resources/Actions.cfg index 16efd2f2..68747334 100644 --- a/Source/BuilderModes/Resources/Actions.cfg +++ b/Source/BuilderModes/Resources/Actions.cfg @@ -477,6 +477,16 @@ togglegravity allowscroll = true; } +togglebrightness +{ + title = "Toggle Full Brightness"; + category = "visual"; + description = "Toggles the use of sector brightness on and off. When sector brightness is off, the world is displayed fully bright, without lighting effects."; + allowkeys = true; + allowmouse = true; + allowscroll = true; +} + placevisualstart { title = "Place Visual Mode Camera"; diff --git a/Source/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/BuilderModes/VisualModes/BaseVisualMode.cs index 989416b1..8884f4ae 100644 --- a/Source/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/BuilderModes/VisualModes/BaseVisualMode.cs @@ -349,11 +349,10 @@ namespace CodeImp.DoomBuilder.BuilderModes #endregion #region ================== Actions - + [BeginAction("visualselect", BaseAction = true)] public void BeginSelect() { - General.WriteLogLine("BeginSelect"); PickTargetUnlocked(); if(target.picked != null) (target.picked as IVisualEventReceiver).OnSelectBegin(); } @@ -361,7 +360,6 @@ namespace CodeImp.DoomBuilder.BuilderModes [EndAction("visualselect", BaseAction = true)] public void EndSelect() { - General.WriteLogLine("EndSelect"); if(target.picked != null) (target.picked as IVisualEventReceiver).OnSelectEnd(); } @@ -536,6 +534,12 @@ namespace CodeImp.DoomBuilder.BuilderModes { BuilderPlug.Me.UseGravity = !BuilderPlug.Me.UseGravity; } + + [BeginAction("togglebrightness")] + public void ToggleBrightness() + { + renderer.FullBrightness = !renderer.FullBrightness; + } #endregion } diff --git a/Source/Rendering/IRenderer3D.cs b/Source/Rendering/IRenderer3D.cs index aec26620..f13ba1b4 100644 --- a/Source/Rendering/IRenderer3D.cs +++ b/Source/Rendering/IRenderer3D.cs @@ -44,6 +44,7 @@ namespace CodeImp.DoomBuilder.Rendering // Properties ProjectedFrustum2D Frustum2D { get; } bool DrawThingCages { get; set; } + bool FullBrightness { get; set; } // General methods void PositionAndLookAt(Vector3D pos, Vector3D lookat); diff --git a/Source/Rendering/Renderer3D.cs b/Source/Rendering/Renderer3D.cs index 99548521..fe71bf4d 100644 --- a/Source/Rendering/Renderer3D.cs +++ b/Source/Rendering/Renderer3D.cs @@ -58,6 +58,10 @@ namespace CodeImp.DoomBuilder.Rendering private Matrix view2d; private Matrix world; private Vector3D cameraposition; + private int shaderpass; + + // Options + private bool fullbrightness; // Window size private Size windowsize; @@ -94,6 +98,7 @@ namespace CodeImp.DoomBuilder.Rendering public ProjectedFrustum2D Frustum2D { get { return frustum; } } public bool DrawThingCages { get { return renderthingcages; } set { renderthingcages = value; } } + public bool FullBrightness { get { return fullbrightness; } set { fullbrightness = value; } } #endregion @@ -376,6 +381,9 @@ namespace CodeImp.DoomBuilder.Rendering world = Matrix.Identity; ApplyMatrices3D(); + // Determine shader pass to use + if(fullbrightness) shaderpass = 1; else shaderpass = 0; + // Create crosshair vertices if(crosshairverts == null) CreateCrosshairVerts(new Size(General.Map.Data.Crosshair3D.Width, General.Map.Data.Crosshair3D.Height)); @@ -419,7 +427,7 @@ namespace CodeImp.DoomBuilder.Rendering // SOLID PASS world = Matrix.Identity; ApplyMatrices3D(); - graphics.Shaders.World3D.BeginPass(0); + graphics.Shaders.World3D.BeginPass(shaderpass); RenderSinglePass((int)RenderPass.Solid); graphics.Shaders.World3D.EndPass(); @@ -427,7 +435,7 @@ namespace CodeImp.DoomBuilder.Rendering world = Matrix.Identity; ApplyMatrices3D(); graphics.Device.SetRenderState(RenderState.AlphaTestEnable, true); - graphics.Shaders.World3D.BeginPass(0); + graphics.Shaders.World3D.BeginPass(shaderpass); RenderSinglePass((int)RenderPass.Mask); graphics.Shaders.World3D.EndPass(); @@ -439,7 +447,7 @@ namespace CodeImp.DoomBuilder.Rendering graphics.Device.SetRenderState(RenderState.ZWriteEnable, false); graphics.Device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha); graphics.Device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha); - graphics.Shaders.World3D.BeginPass(0); + graphics.Shaders.World3D.BeginPass(shaderpass); RenderSinglePass((int)RenderPass.Alpha); graphics.Shaders.World3D.EndPass(); @@ -450,7 +458,7 @@ namespace CodeImp.DoomBuilder.Rendering world = Matrix.Identity; ApplyMatrices3D(); graphics.Device.SetRenderState(RenderState.DestinationBlend, Blend.One); - graphics.Shaders.World3D.BeginPass(0); + graphics.Shaders.World3D.BeginPass(shaderpass); RenderSinglePass((int)RenderPass.Additive); graphics.Shaders.World3D.EndPass(); @@ -475,7 +483,7 @@ namespace CodeImp.DoomBuilder.Rendering graphics.Device.SetTexture(0, General.Map.Data.ThingBox.Texture); graphics.Shaders.World3D.Texture1 = General.Map.Data.ThingBox.Texture; - graphics.Shaders.World3D.BeginPass(0); + graphics.Shaders.World3D.BeginPass(shaderpass); foreach(VisualThing t in thingsbydistance) { // Setup matrix diff --git a/Source/Resources/world3d.fx b/Source/Resources/world3d.fx index 263fae76..ccd6032e 100644 --- a/Source/Resources/world3d.fx +++ b/Source/Resources/world3d.fx @@ -56,21 +56,38 @@ PixelData vs_main(VertexData vd) return pd; } -// Pixel shader +// Normal pixel shader float4 ps_main(PixelData pd) : COLOR { float4 tcolor = tex2D(texturesamp, pd.uv); - // Blend texture color and vertex color + // Blend texture color, vertex color and modulation color return tcolor * pd.color * modulatecolor; } +// Full-bright pixel shader +float4 ps_fullbright(PixelData pd) : COLOR +{ + float4 tcolor = tex2D(texturesamp, pd.uv); + + // Blend texture color and modulation color + return tcolor * modulatecolor; +} + // Technique for shader model 2.0 technique SM20 { + // Normal pass p0 { VertexShader = compile vs_2_0 vs_main(); PixelShader = compile ps_2_0 ps_main(); } + + // Full brightness mode + pass p1 + { + VertexShader = compile vs_2_0 vs_main(); + PixelShader = compile ps_2_0 ps_fullbright(); + } }