From f10bdf05cdf1a1c5045cb1204411ddf6ac3b8363 Mon Sep 17 00:00:00 2001
From: Thorsten Renk <thorsten.i.renk@jyu.fi>
Date: Thu, 19 Mar 2015 10:30:58 +0200
Subject: [PATCH] ALS glass effect uses depth-sorted bin and automatically
 falls back to correct transparent rendering for Rembrandt and default

---
 Effects/glass.eff | 87 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 86 insertions(+), 1 deletion(-)

diff --git a/Effects/glass.eff b/Effects/glass.eff
index ce0c2a8c4..2e0b37ff8 100644
--- a/Effects/glass.eff
+++ b/Effects/glass.eff
@@ -16,7 +16,7 @@
 	<!-- placeholder for the function texture used for fogging, wiper area,...-->
 	<texture n="2">
 		<type>white</type>
-	</texture>
+	</texture>	
 	<texture n="3">
 		<type>cubemap</type>
 		<images>
@@ -83,6 +83,10 @@
       <shade-model><use>shade-model</use></shade-model>
       <cull-face><use>cull-face</use></cull-face>
       <rendering-hint><use>rendering-hint</use></rendering-hint>
+      <render-bin>
+        <bin-number>111</bin-number>
+        <bin-name>DepthSortedBin</bin-name>
+      </render-bin>
       <texture-unit>
         <!-- The texture unit is always active because the shaders expect
              that. -->
@@ -279,6 +283,87 @@
     </pass>
   </technique>
 
+  <!-- fall back to a fixed pipeline technique equivalent to model-transparent otherwise -->
+  <!-- Rembrandt technique of model-default comes at 10, so we insert before that -->
+
+  <technique n="9">
+		<pass>
+			<lighting>true</lighting>
+			<depth>
+				<write-mask type="bool">false</write-mask>
+			</depth>
+			<material>
+				<active>
+					<use>material/active</use>
+				</active>
+				<ambient>
+					<use>material/ambient</use>
+				</ambient>
+				<diffuse>
+					<use>material/diffuse</use>
+				</diffuse>
+				<specular>
+					<use>material/specular</use>
+				</specular>
+				<emissive>
+					<use>material/emissive</use>
+				</emissive>
+				<shininess>
+					<use>material/shininess</use>
+				</shininess>
+				<color-mode>
+					<use>material/color-mode</use>
+				</color-mode>
+			</material>
+			<blend>
+				<active>
+					<use>blend/active</use>
+				</active>
+				<source>
+					<use>blend/source</use>
+				</source>
+				<destination>
+					<use>blend/destination</use>
+				</destination>
+			</blend>
+			<shade-model>
+				<use>shade-model</use>
+			</shade-model>
+			<cull-face>
+				<use>cull-face</use>
+			</cull-face>
+				<render-bin>
+					<bin-number>111</bin-number>
+					<bin-name>DepthSortedBin</bin-name>
+				</render-bin>
+			<texture-unit>
+				<unit>0</unit>
+				<active>
+					<use>texture[0]/active</use>
+				</active>
+                <type>
+                    <use>texture[0]/type</use>
+                </type>
+				<image>
+					<use>texture[0]/image</use>
+				</image>
+				<filter>
+					<use>texture[0]/filter</use>
+				</filter>
+				<wrap-s>
+					<use>texture[0]/wrap-s</use>
+				</wrap-s>
+				<wrap-t>
+					<use>texture[0]/wrap-t</use>
+				</wrap-t>
+      
+				<environment>
+					<mode>modulate</mode>
+				</environment>
+			</texture-unit>
+		</pass>
+	</technique>
+
 
 </PropertyList>