From 5d47e331d81b689b4b0dddeaa3e212295515c48d Mon Sep 17 00:00:00 2001
From: MaxED <j.maxed@gmail.com>
Date: Tue, 26 Jan 2016 08:00:54 +0000
Subject: [PATCH] Fixed, DB2 bug: hlsl effect stream was not rewound when
 trying to compile it in debug mode, which resulted in always receiving
 IndexOutOfRangeException when trying to do it. Fixed, Visual mode: textures
 on floors, ceilings and single-sided wall parts are now rendered ignoring
 texture alpha. Changed, Game configurations, Sector_Set3dFloor:160 action:
 renamed the fourth argument from "Alpha" to "Opacity".

---
 Build/Configurations/Includes/ZDoom_linedefs.cfg | 2 +-
 Source/Core/Rendering/D3DShader.cs               | 3 +++
 Source/Core/Resources/world3d.fx                 | 8 ++++----
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Build/Configurations/Includes/ZDoom_linedefs.cfg b/Build/Configurations/Includes/ZDoom_linedefs.cfg
index 769aec1fc..b5f7f64b1 100644
--- a/Build/Configurations/Includes/ZDoom_linedefs.cfg
+++ b/Build/Configurations/Includes/ZDoom_linedefs.cfg
@@ -3324,7 +3324,7 @@ zdoom
 			}
 			arg3
 			{
-				title = "Alpha";
+				title = "Opacity";
 				default = 255;
 			}
 		}
diff --git a/Source/Core/Rendering/D3DShader.cs b/Source/Core/Rendering/D3DShader.cs
index deae788bc..b5275e416 100644
--- a/Source/Core/Rendering/D3DShader.cs
+++ b/Source/Core/Rendering/D3DShader.cs
@@ -112,6 +112,9 @@ namespace CodeImp.DoomBuilder.Rendering
 				// Compiling failed, try with debug information
 				try
 				{
+					//mxd. Rewind before use!
+					fxdata.Seek(0, SeekOrigin.Begin);
+					
 					// Compile effect
 					fx = Effect.FromStream(General.Map.Graphics.Device, fxdata, null, null, null, ShaderFlags.Debug, null, out errors);
 					if(!string.IsNullOrEmpty(errors))
diff --git a/Source/Core/Resources/world3d.fx b/Source/Core/Resources/world3d.fx
index 256786b15..68ef41faa 100644
--- a/Source/Core/Resources/world3d.fx
+++ b/Source/Core/Resources/world3d.fx
@@ -169,7 +169,7 @@ float4 ps_fullbright(PixelData pd) : COLOR
 float4 ps_main_highlight(PixelData pd) : COLOR
 {
 	float4 tcolor = tex2D(texturesamp, pd.uv);
-	if(tcolor.a == 0) clip(-1);
+	if(tcolor.a == 0) return tcolor;
 	
 	// Blend texture color and vertex color
 	float4 ncolor = tcolor * pd.color;
@@ -181,7 +181,7 @@ float4 ps_main_highlight(PixelData pd) : COLOR
 float4 ps_fullbright_highlight(PixelData pd) : COLOR
 {
 	float4 tcolor = tex2D(texturesamp, pd.uv);
-	if(tcolor.a == 0) clip(-1);
+	if(tcolor.a == 0) return tcolor;
 	
 	// Blend texture color and vertex color
 	float4 ncolor = tcolor * pd.color;
@@ -204,7 +204,7 @@ float4 getFogColor(LitPixelData pd, float4 color)
 float4 ps_main_fog(LitPixelData pd) : COLOR 
 {
 	float4 tcolor = tex2D(texturesamp, pd.uv);
-	if(tcolor.a == 0) clip(-1);
+	if(tcolor.a == 0) return tcolor;
 	
 	return getFogColor(pd, tcolor * pd.color);
 }
@@ -213,7 +213,7 @@ float4 ps_main_fog(LitPixelData pd) : COLOR
 float4 ps_main_highlight_fog(LitPixelData pd) : COLOR 
 {
 	float4 tcolor = tex2D(texturesamp, pd.uv);
-	if(tcolor.a == 0) clip(-1);
+	if(tcolor.a == 0) return tcolor;
 	
 	// Blend texture color and vertex color
 	float4 ncolor = getFogColor(pd, tcolor * pd.color);
-- 
GitLab