Skip to content

Commit 7648911

Browse files
committed
Restore PalettedDrawNoDepth shader
1 parent cc52d18 commit 7648911

File tree

5 files changed

+70
-3
lines changed

5 files changed

+70
-3
lines changed

src/TSMapEditor/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace TSMapEditor
44
{
55
public static class Constants
66
{
7-
public const string ReleaseVersion = "1.6.4";
7+
public const string ReleaseVersion = "1.6.5";
88

99
public static int CellSizeX = 48;
1010
public static int CellSizeY = 24;

src/TSMapEditor/Content/Content.mgcb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
/processorParam:DebugMode=Auto
3232
/build:Shaders/PalettedColorDraw.fx
3333

34+
#begin Shaders/PalettedDrawNoDepth.fx
35+
/importer:EffectImporter
36+
/processor:EffectProcessor
37+
/processorParam:DebugMode=Auto
38+
/build:Shaders/PalettedDrawNoDepth.fx
39+
3440
#begin Shaders/PalettedTerrainDraw.fx
3541
/importer:EffectImporter
3642
/processor:EffectProcessor
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#pragma enable_d3d11_debug_symbols
2+
3+
#if OPENGL
4+
#define SV_POSITION POSITION
5+
#define VS_SHADERMODEL vs_3_0
6+
#define PS_SHADERMODEL ps_3_0
7+
#else
8+
#define VS_SHADERMODEL vs_4_0
9+
#define PS_SHADERMODEL ps_4_0
10+
#endif
11+
12+
// Used for drawing paletted graphics in contexts where no depth is required.
13+
// Particularly, the overlay frame selector.
14+
15+
float4 Lighting;
16+
17+
sampler2D SpriteTextureSampler : register(s0)
18+
{
19+
Texture = (SpriteTexture); // this is set by spritebatch
20+
MipFilter = Point;
21+
MinFilter = Point;
22+
MagFilter = Point;
23+
};
24+
25+
Texture2D PaletteTexture;
26+
sampler2D PaletteTextureSampler
27+
{
28+
Texture = <PaletteTexture>; // passed in
29+
AddressU = wrap;
30+
AddressV = wrap;
31+
MipFilter = Point;
32+
MinFilter = Point;
33+
MagFilter = Point;
34+
};
35+
36+
struct VertexShaderOutput
37+
{
38+
float4 Position : SV_POSITION;
39+
float4 Color : COLOR0;
40+
float2 TextureCoordinates : TEXCOORD0;
41+
};
42+
43+
float4 MainPS(VertexShaderOutput input) : COLOR
44+
{
45+
float4 tex = tex2D(SpriteTextureSampler, input.TextureCoordinates);
46+
47+
// Get color from palette
48+
float4 paletteColor = tex2D(PaletteTextureSampler, float2(tex.a, 0.5));
49+
50+
return paletteColor * Lighting;
51+
}
52+
53+
technique SpriteDrawing
54+
{
55+
pass P0
56+
{
57+
PixelShader = compile PS_SHADERMODEL MainPS();
58+
}
59+
};

src/TSMapEditor/UI/OverlayFrameSelector.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Rampastring.XNAUI.XNAControls;
55
using System;
66
using System.Collections.Generic;
7+
using System.IO;
78
using TSMapEditor.Models;
89
using TSMapEditor.Rendering;
910

@@ -99,7 +100,7 @@ public override void Initialize()
99100
BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 196), 2, 2);
100101
PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
101102

102-
palettedDrawEffect = AssetLoader.LoadEffect("Shaders/PalettedDrawNoDepth");
103+
palettedDrawEffect = AssetLoader.LoadEffect("Shaders/PalettedDrawNoDepth") ?? throw new FileNotFoundException("Shader not found: PalettedDrawNoDepth");
103104

104105
KeyboardCommands.Instance.NextTile.Triggered += NextTile_Triggered;
105106
KeyboardCommands.Instance.PreviousTile.Triggered += PreviousTile_Triggered;

src/TSMapEditor/UI/TileDisplay.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Rampastring.XNAUI.XNAControls;
66
using System;
77
using System.Collections.Generic;
8+
using System.IO;
89
using TSMapEditor.CCEngine;
910
using TSMapEditor.Models;
1011
using TSMapEditor.Rendering;
@@ -93,7 +94,7 @@ public override void Initialize()
9394
BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 196), 2, 2);
9495
PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
9596

96-
palettedDrawEffect = AssetLoader.LoadEffect("Shaders/PalettedDrawNoDepth");
97+
palettedDrawEffect = AssetLoader.LoadEffect("Shaders/PalettedDrawNoDepth") ?? throw new FileNotFoundException("Shader not found: PalettedDrawNoDepth"); ;
9798

9899
KeyboardCommands.Instance.NextTile.Action = NextTile;
99100
KeyboardCommands.Instance.PreviousTile.Action = PreviousTile;

0 commit comments

Comments
 (0)