- remove Display2DShader class

This commit is contained in:
Magnus Norddahl 2019-08-13 02:43:01 +02:00
parent 2eaf323ad0
commit 0b3725e2fa
7 changed files with 147 additions and 240 deletions

View file

@ -558,7 +558,6 @@
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Rendering\Presentation.cs" />
<Compile Include="Rendering\Display2DShader.cs" />
<Compile Include="Rendering\ColorCollection.cs" />
<Compile Include="Rendering\ColorSetting.cs" />
<Compile Include="Data\ImageData.cs" />

View file

@ -1,127 +0,0 @@
#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
#endregion
namespace CodeImp.DoomBuilder.Rendering
{
internal sealed class Display2DShader : EffectShader
{
#region ================== Variables
// Property handlers
private readonly EffectHandle texture1;
private readonly EffectHandle rendersettings;
private readonly EffectHandle transformsettings;
private readonly EffectHandle filtersettings;
private readonly EffectHandle desaturationHandle;
#endregion
#region ================== Properties
public Texture Texture1 { set { effect.SetTexture(texture1, value); settingschanged = true; } }
// [ZZ]
private float desaturation;
public float Desaturation
{
set
{
if (desaturation != value)
{
effect.SetValue(desaturationHandle, value);
desaturation = value;
settingschanged = true;
}
}
}
#endregion
#region ================== Constructor / Disposer
// Constructor
public Display2DShader(ShaderManager manager) : base(manager)
{
// Load effect from file
effect = LoadEffect("display2d.fx");
// Get the property handlers from effect
if(effect != null)
{
texture1 = effect.GetParameter(null, "texture1");
rendersettings = effect.GetParameter(null, "rendersettings");
transformsettings = effect.GetParameter(null, "transformsettings");
filtersettings = effect.GetParameter(null, "filtersettings");
desaturationHandle = effect.GetParameter(null, "desaturation"); // [ZZ]
}
// Initialize world vertex declaration
VertexElement[] elements = new[]
{
new VertexElement(0, 0, DeclarationType.Float3, DeclarationUsage.Position),
new VertexElement(0, 12, DeclarationType.Color, DeclarationUsage.Color),
new VertexElement(0, 16, DeclarationType.Float2, DeclarationUsage.TextureCoordinate)
};
vertexdecl = new VertexDeclaration(elements);
// We have no destructor
GC.SuppressFinalize(this);
}
// Disposer
public override void Dispose()
{
// Not already disposed?
if(!isdisposed)
{
// Clean up
if(texture1 != null) texture1.Dispose();
if(rendersettings != null) rendersettings.Dispose();
if(transformsettings != null) transformsettings.Dispose();
if(filtersettings != null) filtersettings.Dispose();
if(desaturationHandle != null) desaturationHandle.Dispose();
// Done
base.Dispose();
}
}
#endregion
#region ================== Methods
// This sets the settings
public void SetSettings(float texelx, float texely, float fsaafactor, float alpha, bool bilinear)
{
Vector4 values = new Vector4(texelx, texely, fsaafactor, alpha);
effect.SetValue(rendersettings, values);
Matrix world = manager.D3DDevice.GetTransform(TransformState.World);
Matrix view = manager.D3DDevice.GetTransform(TransformState.View);
effect.SetValue(transformsettings, world * view);
TextureFilter filter = (bilinear ? TextureFilter.Linear : TextureFilter.Point);
effect.SetValue(filtersettings, (int)filter);
settingschanged = true; //mxd
}
#endregion
}
}

View file

@ -389,6 +389,61 @@ namespace CodeImp.DoomBuilder.Rendering
{
return new Vector2D(v2.X, v2.Y);
}
public void SetShader(Shader shader) { }
public void SetUniform(Uniform uniform, float value) { }
public void SetUniform(Uniform uniform, Vector2 value) { }
public void SetUniform(Uniform uniform, Vector3 value) { }
public void SetUniform(Uniform uniform, Vector4 value) { }
public void SetUniform(Uniform uniform, Matrix value) { }
public void SetUniform(Uniform uniform, Texture value) { }
}
public enum Shader : int
{
basic,
display2d_fsaa,
display2d_normal,
display2d_fullbright,
things2d_thing,
things2d_sprite,
things2d_fill,
world3d_main,
world3d_fullbright,
world3d_main_highlight,
world3d_fullbright_highlight,
world3d_main_vertexcolor,
world3d_skybox,
world3d_main_highlight_vertexcolor,
world3d_main_fog,
world3d_main_highlight_fog,
world3d_main_fog_vertexcolor,
world3d_main_highlight_fog_vertexcolor,
world3d_vertex_color,
world3d_constant_color,
world3d_lightpass // AlphaBlendEnable = true
}
public enum Uniform : int
{
rendersettings,
transformsettings,
filtersettings,
desaturation,
texture1,
highlightcolor,
worldviewproj,
world,
modelnormal,
vertexColor,
stencilColor,
lightPosAndRadius,
lightOrientation,
light2Radius,
lightColor,
ignoreNormals,
spotLight,
campos,
}
public enum Cull : int { None, Counterclockwise }

View file

@ -186,12 +186,12 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetFogEnable(false);
graphics.SetVertexBuffer(0, screenverts, 0, sizeof(FlatVertex));
graphics.SetTransform(TransformState.World, Matrix.Identity);
graphics.Shaders.Display2D.Begin();
graphics.SetVertexDeclaration(graphics.Shaders.FlatVertexDecl);
// Go for all layers
foreach(PresentLayer layer in present.layers)
{
int aapass;
Shader aapass;
// Set blending mode
switch(layer.blending)
@ -226,7 +226,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// Check which pass to use
if(layer.antialiasing && General.Settings.QualityDisplay) aapass = 0; else aapass = 1;
if(layer.antialiasing && General.Settings.QualityDisplay) aapass = Shader.display2d_fsaa; else aapass = Shader.display2d_normal;
// Render layer
switch(layer.layer)
@ -234,68 +234,61 @@ namespace CodeImp.DoomBuilder.Rendering
// BACKGROUND
case RendererLayer.Background:
if((backimageverts == null) || (General.Map.Grid.Background.Texture == null)) break;
graphics.Shaders.Display2D.Texture1 = General.Map.Grid.Background.Texture;
graphics.Shaders.Display2D.SetSettings(1f / windowsize.Width, 1f / windowsize.Height, FSAA_FACTOR, layer.alpha, false);
graphics.Shaders.Display2D.BeginPass(aapass);
graphics.SetShader(aapass);
graphics.SetUniform(Uniform.texture1, General.Map.Grid.Background.Texture);
graphics.Shaders.SetDisplay2DSettings(1f / windowsize.Width, 1f / windowsize.Height, FSAA_FACTOR, layer.alpha, false);
graphics.DrawUserPrimitives(PrimitiveType.TriangleStrip, 0, 2, backimageverts);
graphics.Shaders.Display2D.EndPass();
graphics.SetVertexBuffer(0, screenverts, 0, sizeof(FlatVertex));
break;
// GRID
case RendererLayer.Grid:
graphics.Shaders.Display2D.Texture1 = backtex;
graphics.Shaders.Display2D.SetSettings(1f / backsize.Width, 1f / backsize.Height, FSAA_FACTOR, layer.alpha, false);
graphics.Shaders.Display2D.BeginPass(aapass);
graphics.SetShader(aapass);
graphics.SetUniform(Uniform.texture1, backtex);
graphics.Shaders.SetDisplay2DSettings(1f / backsize.Width, 1f / backsize.Height, FSAA_FACTOR, layer.alpha, false);
graphics.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
graphics.Shaders.Display2D.EndPass();
break;
// GEOMETRY
case RendererLayer.Geometry:
graphics.Shaders.Display2D.Texture1 = plottertex;
graphics.Shaders.Display2D.SetSettings(1f / structsize.Width, 1f / structsize.Height, FSAA_FACTOR, layer.alpha, false);
graphics.Shaders.Display2D.BeginPass(aapass);
graphics.SetShader(aapass);
graphics.SetUniform(Uniform.texture1, plottertex);
graphics.Shaders.SetDisplay2DSettings(1f / structsize.Width, 1f / structsize.Height, FSAA_FACTOR, layer.alpha, false);
graphics.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
graphics.Shaders.Display2D.EndPass();
break;
// THINGS
case RendererLayer.Things:
graphics.Shaders.Display2D.Texture1 = thingstex;
graphics.Shaders.Display2D.SetSettings(1f / thingssize.Width, 1f / thingssize.Height, FSAA_FACTOR, layer.alpha, false);
graphics.Shaders.Display2D.BeginPass(aapass);
graphics.SetShader(aapass);
graphics.SetUniform(Uniform.texture1, thingstex);
graphics.Shaders.SetDisplay2DSettings(1f / thingssize.Width, 1f / thingssize.Height, FSAA_FACTOR, layer.alpha, false);
graphics.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
graphics.Shaders.Display2D.EndPass();
break;
// OVERLAY
case RendererLayer.Overlay:
graphics.Shaders.Display2D.Texture1 = overlaytex;
graphics.Shaders.Display2D.SetSettings(1f / overlaysize.Width, 1f / overlaysize.Height, FSAA_FACTOR, layer.alpha, false);
graphics.Shaders.Display2D.BeginPass(aapass);
graphics.SetShader(aapass);
graphics.SetUniform(Uniform.texture1, overlaytex);
graphics.Shaders.SetDisplay2DSettings(1f / overlaysize.Width, 1f / overlaysize.Height, FSAA_FACTOR, layer.alpha, false);
graphics.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
graphics.Shaders.Display2D.EndPass();
break;
// SURFACE
case RendererLayer.Surface:
graphics.Shaders.Display2D.Texture1 = surfacetex;
graphics.Shaders.Display2D.SetSettings(1f / overlaysize.Width, 1f / overlaysize.Height, FSAA_FACTOR, layer.alpha, false);
graphics.Shaders.Display2D.BeginPass(aapass);
graphics.SetShader(aapass);
graphics.SetUniform(Uniform.texture1, surfacetex);
graphics.Shaders.SetDisplay2DSettings(1f / overlaysize.Width, 1f / overlaysize.Height, FSAA_FACTOR, layer.alpha, false);
graphics.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
graphics.Shaders.Display2D.EndPass();
break;
}
}
// Done
graphics.Shaders.Display2D.End();
graphics.FinishRendering();
graphics.Present();
// Release binds
graphics.Shaders.Display2D.Texture1 = null;
graphics.SetUniform(Uniform.texture1, null);
graphics.SetVertexBuffer(0, null, 0, 0);
}
@ -1586,7 +1579,7 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetTextureFactor(-1);
graphics.SetFogEnable(false);
SetWorldTransformation(true);
graphics.Shaders.Display2D.SetSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
graphics.Shaders.SetDisplay2DSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
// Prepare for rendering
switch(viewmode)
@ -1643,16 +1636,14 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetAlphaTestEnable(false);
graphics.SetTextureFactor(-1);
graphics.SetFogEnable(false);
graphics.Shaders.Display2D.Texture1 = t;
graphics.SetVertexDeclaration(graphics.Shaders.FlatVertexDecl);
graphics.SetShader(Shader.display2d_normal);
graphics.SetUniform(Uniform.texture1, t);
SetWorldTransformation(transformcoords);
graphics.Shaders.Display2D.SetSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
graphics.Shaders.SetDisplay2DSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
// Draw
graphics.Shaders.Display2D.Begin();
graphics.Shaders.Display2D.BeginPass(1);
graphics.DrawUserPrimitives(PrimitiveType.TriangleList, 0, vertices.Length / 3, vertices);
graphics.Shaders.Display2D.EndPass();
graphics.Shaders.Display2D.End();
}
}
@ -1699,17 +1690,15 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetAlphaTestEnable(false);
graphics.SetTextureFactor(-1);
graphics.SetFogEnable(false);
graphics.Shaders.Display2D.Texture1 = label.Texture;
graphics.SetVertexDeclaration(graphics.Shaders.FlatVertexDecl);
graphics.SetShader(Shader.display2d_normal);
graphics.SetUniform(Uniform.texture1, label.Texture);
SetWorldTransformation(false);
graphics.Shaders.Display2D.SetSettings(1f, 1f, 0f, 1f, false);
graphics.Shaders.SetDisplay2DSettings(1f, 1f, 0f, 1f, false);
graphics.SetVertexBuffer(0, label.VertexBuffer, 0, FlatVertex.Stride);
// Draw
graphics.Shaders.Display2D.Begin();
graphics.Shaders.Display2D.BeginPass(1); //mxd
graphics.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
graphics.Shaders.Display2D.EndPass();
graphics.Shaders.Display2D.End();
}
//mxd. This renders text
@ -1734,29 +1723,22 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetTextureFactor(-1);
graphics.SetFogEnable(false);
SetWorldTransformation(false);
graphics.Shaders.Display2D.SetSettings(1f, 1f, 0f, 1f, false);
graphics.SetVertexDeclaration(graphics.Shaders.FlatVertexDecl);
graphics.SetShader(Shader.display2d_normal);
graphics.Shaders.SetDisplay2DSettings(1f, 1f, 0f, 1f, false);
// Begin drawing
graphics.Shaders.Display2D.Begin();
graphics.Shaders.Display2D.BeginPass(1);
foreach(ITextLabel label in labels)
{
// Text is created?
if(!label.SkipRendering)
{
graphics.Shaders.Display2D.Texture1 = label.Texture;
graphics.Shaders.Display2D.ApplySettings();
graphics.SetUniform(Uniform.texture1, label.Texture);
graphics.SetVertexBuffer(0, label.VertexBuffer, 0, FlatVertex.Stride);
// Draw
graphics.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
}
}
// Finish drawing
graphics.Shaders.Display2D.EndPass();
graphics.Shaders.Display2D.End();
}
// This renders a rectangle with given border size and color
@ -1809,18 +1791,16 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetTextureFactor(-1);
graphics.SetFogEnable(false);
SetWorldTransformation(false);
graphics.Shaders.Display2D.Texture1 = General.Map.Data.WhiteTexture.Texture;
graphics.Shaders.Display2D.SetSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
graphics.SetVertexDeclaration(graphics.Shaders.FlatVertexDecl);
graphics.SetShader(Shader.display2d_normal);
graphics.SetUniform(Uniform.texture1, General.Map.Data.WhiteTexture.Texture);
graphics.Shaders.SetDisplay2DSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
// Draw
graphics.Shaders.Display2D.Begin();
graphics.Shaders.Display2D.BeginPass(1);
quads[0].Render(graphics);
quads[1].Render(graphics);
quads[2].Render(graphics);
quads[3].Render(graphics);
graphics.Shaders.Display2D.EndPass();
graphics.Shaders.Display2D.End();
}
// This renders a filled rectangle with given color
@ -1847,15 +1827,13 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetTextureFactor(-1);
graphics.SetFogEnable(false);
SetWorldTransformation(false);
graphics.Shaders.Display2D.Texture1 = General.Map.Data.WhiteTexture.Texture;
graphics.Shaders.Display2D.SetSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
graphics.SetVertexDeclaration(graphics.Shaders.FlatVertexDecl);
graphics.SetShader(Shader.display2d_normal);
graphics.SetUniform(Uniform.texture1, General.Map.Data.WhiteTexture.Texture);
graphics.Shaders.SetDisplay2DSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
// Draw
graphics.Shaders.Display2D.Begin();
graphics.Shaders.Display2D.BeginPass(1);
quad.Render(graphics);
graphics.Shaders.Display2D.EndPass();
graphics.Shaders.Display2D.End();
}
// This renders a filled rectangle with given color
@ -1882,15 +1860,13 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetTextureFactor(-1);
graphics.SetFogEnable(false);
SetWorldTransformation(false);
graphics.Shaders.Display2D.Texture1 = texture.Texture;
graphics.Shaders.Display2D.SetSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
graphics.SetVertexDeclaration(graphics.Shaders.FlatVertexDecl);
graphics.SetShader(Shader.display2d_normal);
graphics.SetUniform(Uniform.texture1, texture.Texture);
graphics.Shaders.SetDisplay2DSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
// Draw
graphics.Shaders.Display2D.Begin();
graphics.Shaders.Display2D.BeginPass(1);
quad.Render(graphics);
graphics.Shaders.Display2D.EndPass();
graphics.Shaders.Display2D.End();
}
//mxd
@ -1984,16 +1960,14 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetTextureFactor(-1);
graphics.SetFogEnable(false);
SetWorldTransformation(false);
graphics.Shaders.Display2D.Texture1 = General.Map.Data.WhiteTexture.Texture;
graphics.Shaders.Display2D.SetSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
graphics.SetVertexDeclaration(graphics.Shaders.FlatVertexDecl);
graphics.SetShader(Shader.display2d_normal);
graphics.SetUniform(Uniform.texture1, General.Map.Data.WhiteTexture.Texture);
graphics.Shaders.SetDisplay2DSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
// Draw
graphics.Shaders.Display2D.Begin();
graphics.Shaders.Display2D.BeginPass(1);
graphics.SetVertexBuffer(0, vb, 0, FlatVertex.Stride);
graphics.DrawPrimitives(PrimitiveType.LineList, 0, pointscount / 2);
graphics.Shaders.Display2D.EndPass();
graphics.Shaders.Display2D.End();
vb.Dispose();
}
@ -2039,15 +2013,13 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetTextureFactor(-1);
graphics.SetFogEnable(false);
SetWorldTransformation(false);
graphics.Shaders.Display2D.Texture1 = General.Map.Data.WhiteTexture.Texture;
graphics.Shaders.Display2D.SetSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
graphics.SetVertexDeclaration(graphics.Shaders.FlatVertexDecl);
graphics.SetShader(Shader.display2d_normal);
graphics.SetUniform(Uniform.texture1, General.Map.Data.WhiteTexture.Texture);
graphics.Shaders.SetDisplay2DSettings(1f, 1f, 0f, 1f, General.Settings.ClassicBilinear);
// Draw
graphics.Shaders.Display2D.Begin();
graphics.Shaders.Display2D.BeginPass(0);
graphics.DrawUserPrimitives(PrimitiveType.TriangleStrip, 0, 2, verts);
graphics.Shaders.Display2D.EndPass();
graphics.Shaders.Display2D.End();
}
#endregion

View file

@ -2057,26 +2057,25 @@ namespace CodeImp.DoomBuilder.Rendering
graphics.SetTransform(TransformState.World, Matrix.Identity);
graphics.SetTransform(TransformState.Projection, Matrix.Identity);
ApplyMatrices2D();
graphics.SetVertexDeclaration(graphics.Shaders.FlatVertexDecl);
graphics.SetShader(Shader.display2d_normal);
// Texture
if(crosshairbusy)
{
if(General.Map.Data.CrosshairBusy3D.Texture == null) General.Map.Data.CrosshairBusy3D.CreateTexture();
graphics.Shaders.Display2D.Texture1 = General.Map.Data.CrosshairBusy3D.Texture;
graphics.SetUniform(Uniform.texture1, General.Map.Data.CrosshairBusy3D.Texture);
}
else
{
if(General.Map.Data.Crosshair3D.Texture == null) General.Map.Data.Crosshair3D.CreateTexture();
graphics.Shaders.Display2D.Texture1 = General.Map.Data.Crosshair3D.Texture;
graphics.SetUniform(Uniform.texture1, General.Map.Data.Crosshair3D.Texture);
}
// Draw
graphics.Shaders.Display2D.Begin();
graphics.Shaders.Display2D.SetSettings(1.0f, 1.0f, 0.0f, 1.0f, true);
graphics.Shaders.Display2D.BeginPass(1);
graphics.Shaders.SetDisplay2DSettings(1.0f, 1.0f, 0.0f, 1.0f, true);
graphics.DrawUserPrimitives(PrimitiveType.TriangleStrip, 0, 2, crosshairverts);
graphics.Shaders.Display2D.EndPass();
graphics.Shaders.Display2D.End();
}
// This switches fog on and off

View file

@ -31,7 +31,7 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Variables
// Shaders
private Display2DShader display2dshader;
private VertexDeclaration flatvertexdecl;
private Things2DShader things2dshader;
private World3DShader world3dshader;
@ -45,7 +45,7 @@ namespace CodeImp.DoomBuilder.Rendering
#region ================== Properties
public Display2DShader Display2D { get { return display2dshader; } }
public VertexDeclaration FlatVertexDecl { get { return flatvertexdecl; } }
public Things2DShader Things2D { get { return things2dshader; } }
public World3DShader World3D { get { return world3dshader; } }
public bool IsDisposed { get { return isdisposed; } }
@ -96,7 +96,7 @@ namespace CodeImp.DoomBuilder.Rendering
// Clean up resources
public void UnloadResource()
{
display2dshader.Dispose();
flatvertexdecl.Dispose();
things2dshader.Dispose();
world3dshader.Dispose();
}
@ -104,12 +104,28 @@ namespace CodeImp.DoomBuilder.Rendering
// Load resources
public void ReloadResource()
{
// Initialize effects
display2dshader = new Display2DShader(this);
things2dshader = new Things2DShader(this);
flatvertexdecl = new VertexDeclaration(new VertexElement[] {
new VertexElement(0, 0, DeclarationType.Float3, DeclarationUsage.Position),
new VertexElement(0, 12, DeclarationType.Color, DeclarationUsage.Color),
new VertexElement(0, 16, DeclarationType.Float2, DeclarationUsage.TextureCoordinate)
});
things2dshader = new Things2DShader(this);
world3dshader = new World3DShader(this);
}
#endregion
}
#endregion
public void SetDisplay2DSettings(float texelx, float texely, float fsaafactor, float alpha, bool bilinear)
{
Vector4 values = new Vector4(texelx, texely, fsaafactor, alpha);
D3DDevice.SetUniform(Uniform.rendersettings, values);
Matrix world = D3DDevice.GetTransform(TransformState.World);
Matrix view = D3DDevice.GetTransform(TransformState.View);
D3DDevice.SetUniform(Uniform.transformsettings, world * view);
TextureFilter filter = (bilinear ? TextureFilter.Linear : TextureFilter.Point);
D3DDevice.SetUniform(Uniform.filtersettings, (int)filter);
}
}
}

View file

@ -607,21 +607,18 @@ namespace CodeImp.DoomBuilder.Rendering
{
if(!resourcesunloaded)
{
int pass = Renderer.FullBrightness ? 2 : 1; //mxd
graphics.Shaders.Display2D.Begin();
Shader pass = Renderer.FullBrightness ? Shader.display2d_fullbright : Shader.display2d_normal; //mxd
graphics.SetVertexDeclaration(graphics.Shaders.FlatVertexDecl);
foreach(KeyValuePair<ImageData, List<SurfaceEntry>> imgsurfaces in surfaces)
{
// Set texture
graphics.Shaders.Display2D.Texture1 = imgsurfaces.Key.Texture;
graphics.Shaders.Display2D.BeginPass(pass);
graphics.SetShader(pass);
graphics.SetUniform(Uniform.texture1, imgsurfaces.Key.Texture);
// Go for all surfaces
VertexBuffer lastbuffer = null;
foreach(SurfaceEntry entry in imgsurfaces.Value)
{
graphics.Shaders.Display2D.Desaturation = entry.desaturation;
graphics.Shaders.Display2D.ApplySettings();
graphics.SetUniform(Uniform.desaturation, entry.desaturation);
// Set the vertex buffer
SurfaceBufferSet set = sets[entry.numvertices];
@ -634,12 +631,8 @@ namespace CodeImp.DoomBuilder.Rendering
// Draw
graphics.DrawPrimitives(PrimitiveType.TriangleList, entry.vertexoffset + (entry.numvertices * surfacevertexoffsetmul), entry.numvertices / 3);
}
graphics.Shaders.Display2D.EndPass();
}
graphics.Shaders.Display2D.End();
graphics.Shaders.Display2D.Desaturation = 0;
graphics.Shaders.Display2D.ApplySettings();
graphics.SetUniform(Uniform.desaturation, 0);
}
}