# HG changeset patch
# User Carli@Carli-PC
# Date 1243424926 -7200
# Node ID 4ee7c369c8bd119d5c1a240296e01c72502f56f1
# Parent  835b92ade7d9ba73117fae433b66cd06552f8ef4
The landscape shader works but:
- Textures are not loaded
- TexCoords are not set

Changelist:
- StartupOptions have a checkbox "Shaders"
- GLFloat Tex[128] in MaterialList -> each Surface8-Pixel%128 is indexed with a texture
- Landscape is rendered multiple times (one time for each material) ->shaders[12]
- Landscape Pixels are stored in Texture0
- Material Texture ist stored in Texture1
- ApplyLighting copies all values of Surface8 to Blue-Channel of Surface32

Todo:
- Load Textures to Tex[] - keep Tex[n]==0 for skipping a renderpass
- Fix StartupOptions LanguageTable
- Change Shader for TextureCoords
- Blurring and darkening material edges (->shader)
- optimize Applylighting (it's done by shader now; Surface32 is unnecessary)

diff -r 835b92ade7d9 -r 4ee7c369c8bd engine/inc/C4Material.h
--- a/engine/inc/C4Material.h	Sat May 16 18:24:44 2009 +0200
+++ b/engine/inc/C4Material.h	Wed May 27 13:48:46 2009 +0200
@@ -160,7 +160,8 @@
     ~C4MaterialMap();
   public:
     int32_t Num;
-    C4Material *Map;
+    C4Material *Map;
+    GLenum Tex[128];
 		C4MaterialReaction **ppReactionMap;
 
 		C4MaterialReaction DefReactConvert, DefReactPoof, DefReactCorrode, DefReactIncinerate, DefReactInsert;
diff -r 835b92ade7d9 -r 4ee7c369c8bd engine/inc/C4StartupOptionsDlg.h
--- a/engine/inc/C4StartupOptionsDlg.h	Sat May 16 18:24:44 2009 +0200
+++ b/engine/inc/C4StartupOptionsDlg.h	Wed May 27 13:48:46 2009 +0200
@@ -139,7 +139,7 @@
 
 		C4GUI::CheckBox *pCheckGfxEngines[3], *pCheckGfxClrDepth[2];
 		C4GUI::GroupBox *pGroupTrouble;
-		C4GUI::CheckBox *pCheckGfxNoAlphaAdd, *pCheckGfxPointFilter, *pCheckGfxNoAddBlit, *pCheckGfxNoBoxFades, *pCheckGfxClipManually;
+		C4GUI::CheckBox *pCheckGfxNoAlphaAdd, *pCheckGfxPointFilter, *pCheckGfxNoAddBlit, *pCheckGfxNoBoxFades, *pCheckGfxClipManually, *pShaders;
 		int32_t iGfxTexIndent, iGfxBlitOff; EditConfig *pEdtGfxBlitOff;
 		C4GUI::ScrollBar *pEffectLevelSlider;
 
diff -r 835b92ade7d9 -r 4ee7c369c8bd engine/src/C4Landscape.cpp
--- a/engine/src/C4Landscape.cpp	Sat May 16 18:24:44 2009 +0200
+++ b/engine/src/C4Landscape.cpp	Wed May 27 13:48:46 2009 +0200
@@ -287,7 +287,7 @@
 	}
 
 void C4Landscape::Draw(C4TargetFacet &cgo, int32_t iPlayer)
-	{
+	{ //return;  DAS IST DER ZEICHENCODE!!
 	if (Modulation) Application.DDraw->ActivateBlitModulation(Modulation);
   // do relights
   DoRelights();
@@ -295,7 +295,7 @@
 	if (Game.GraphicsSystem.ShowSolidMask)
 		Application.DDraw->Blit8Fast(Surface8, cgo.TargetX, cgo.TargetY, cgo.Surface, cgo.X,cgo.Y,cgo.Wdt,cgo.Hgt);
 	else
-		Application.DDraw->BlitLandscape(Surface32, AnimationSurface, &Game.GraphicsResource.sfcLiquidAnimation, cgo.TargetX, cgo.TargetY, cgo.Surface, cgo.X,cgo.Y,cgo.Wdt,cgo.Hgt);
+		Application.DDraw->BlitLandscape(Surface32, AnimationSurface, &Game.GraphicsResource.sfcLiquidAnimation, cgo.TargetX, cgo.TargetY, cgo.Surface, cgo.X,cgo.Y,cgo.Wdt,cgo.Hgt,&Game.Material.Tex[0]);
 	if (Modulation) Application.DDraw->DeactivateBlitModulation();
 	}
 
@@ -2505,7 +2505,12 @@
 			AboveDensity += GetPlacement(iX, iY - 1);
 			BelowDensity -= GetPlacement(iX, iY);
 			BelowDensity += GetPlacement(iX, iY + 8);
-			BYTE pix = _GetPix(iX, iY);
+			BYTE pix = _GetPix(iX, iY);
+
+			if(DDrawCfg.Shader) {
+			    Surface32->SetPixDw(iX, iY, pix);
+				continue;
+			};
 			// Sky
 			if(!pix)
 				{
diff -r 835b92ade7d9 -r 4ee7c369c8bd engine/src/C4Material.cpp
--- a/engine/src/C4Material.cpp	Sat May 16 18:24:44 2009 +0200
+++ b/engine/src/C4Material.cpp	Wed May 27 13:48:46 2009 +0200
@@ -405,14 +405,21 @@
 			szTextureOverlay = "Smooth";
 		// search/create entry in texmap
 		Map[cnt].DefaultMatTex = Game.TextureMap.GetIndex(Map[cnt].Name, szTextureOverlay, TRUE,
-			FormatString("DefaultMatTex of mat %s", Map[cnt].Name).getData());
+			FormatString("DefaultMatTex of mat %s", Map[cnt].Name).getData());
+		Tex[Map[cnt].DefaultMatTex%128] = 1;
 		// init PXS facet
 		SURFACE sfcTexture;
 		C4Texture * Texture;
 		if (Map[cnt].sPXSGfx.getLength())
-			if (Texture=Game.TextureMap.GetTexture(Map[cnt].sPXSGfx.getData()))
-				if (sfcTexture=Texture->Surface32)
-					Map[cnt].PXSFace.Set(sfcTexture, Map[cnt].PXSGfxRt.x, Map[cnt].PXSGfxRt.y, Map[cnt].PXSGfxRt.Wdt, Map[cnt].PXSGfxRt.Hgt);
+			if (Texture=Game.TextureMap.GetTexture(Map[cnt].sPXSGfx.getData()))
+            {
+				if (sfcTexture=Texture->Surface32)
+				{
+					Map[cnt].PXSFace.Set(sfcTexture, Map[cnt].PXSGfxRt.x, Map[cnt].PXSGfxRt.y, Map[cnt].PXSGfxRt.Wdt, Map[cnt].PXSGfxRt.Hgt);
+					//(*Map[cnt].PXSFace.Surface->ppTex)->Unlock();
+					//Tex[Map[cnt].DefaultMatTex%128]=(*Map[cnt].PXSFace.Surface->ppTex)->texName;
+				};
+            };
 		// evaluate reactions for that material
 		for (unsigned int iRCnt = 0; iRCnt < pMat->CustomReactionList.size(); ++iRCnt)
 			{
diff -r 835b92ade7d9 -r 4ee7c369c8bd engine/src/C4StartupOptionsDlg.cpp
--- a/engine/src/C4StartupOptionsDlg.cpp	Sat May 16 18:24:44 2009 +0200
+++ b/engine/src/C4StartupOptionsDlg.cpp	Wed May 27 13:48:46 2009 +0200
@@ -779,7 +779,9 @@
 #ifndef USE_GL
 	pCheckGfxEngines[GFXENGN_OPENGL]->SetEnabled(false);
 #endif
-	pCheckGfxEngines[GFXENGN_DIRECTXS]->SetEnabled(false); // better not using this
+	pCheckGfxEngines[GFXENGN_DIRECTXS]->SetEnabled(false); // better not using this
+
+
 	// --subgroup resolution
 	C4GUI::GroupBox *pGroupResolution = new C4GUI::GroupBox(caSheetGraphics.GetGridCell(1,2,0,3));
 	pGroupResolution->SetTitle(LoadResStrNoAmp("IDS_CTL_RESOLUTION"));
@@ -830,11 +832,13 @@
 	pGroupTrouble = new C4GUI::GroupBox(caSheetGraphics.GetGridCell(0,1,1,3));
 	pGroupTrouble->SetTitle(LoadResStrNoAmp("IDS_CTL_TROUBLE"));
 	pGroupTrouble->SetFont(pUseFont);
-	pGroupTrouble->SetColors(C4StartupEditBorderColor, C4StartupFontClr);
-	pSheetGraphics->AddElement(pGroupTrouble);
+	pGroupTrouble->SetColors(C4StartupEditBorderColor, C4StartupFontClr);
+	pSheetGraphics->AddElement(pGroupTrouble);
+
+
 	C4GUI::ComponentAligner caGroupTrouble(pGroupTrouble->GetClientRect(), iIndentX1, iIndentY2, true);
 	C4GUI::BaseCallbackHandler *pGfxGroubleCheckCB = new C4GUI::CallbackHandler<C4StartupOptionsDlg>(this, &C4StartupOptionsDlg::OnGfxTroubleCheck);
-	int32_t iNumGfxOptions = 5, iOpt=0;
+	int32_t iNumGfxOptions = 6, iOpt=0;
 	// no alpha adding
 	pCheckGfxNoAlphaAdd = new C4GUI::CheckBox(caGroupTrouble.GetGridCell(0,2,iOpt++,iNumGfxOptions,-1,iCheckHgt,true), LoadResStr("IDS_CTL_NOALPHAADD"), false);
 	pCheckGfxNoAlphaAdd->SetFont(pUseFont, C4StartupFontClr, C4StartupFontClrDisabled);
@@ -858,7 +862,13 @@
 	pCheckGfxNoBoxFades->SetFont(pUseFont, C4StartupFontClr, C4StartupFontClrDisabled);
 	pCheckGfxNoBoxFades->SetToolTip(LoadResStr("IDS_MSG_NOCLRFADE_DESC"));
 	pCheckGfxNoBoxFades->SetOnChecked(pGfxGroubleCheckCB);
-	pGroupTrouble->AddElement(pCheckGfxNoBoxFades);
+	pGroupTrouble->AddElement(pCheckGfxNoBoxFades);
+	// Shaders
+	pShaders = new C4GUI::CheckBox(caGroupTrouble.GetGridCell(0,2,iOpt++,iNumGfxOptions,-1,iCheckHgt,true), "Shaders", false);
+	pShaders->SetFont(pUseFont, C4StartupFontClr, C4StartupFontClrDisabled);
+	pShaders->SetToolTip("Shaders");
+	pShaders->SetOnChecked(pGfxGroubleCheckCB);
+	pGroupTrouble->AddElement(pShaders);
 	// manual clipping
 	pCheckGfxClipManually = new C4GUI::CheckBox(caGroupTrouble.GetGridCell(0,2,iOpt++,iNumGfxOptions,-1,iCheckHgt,true), LoadResStr("IDS_CTL_MANUALCLIP"), false);
 	pCheckGfxClipManually->SetFont(pUseFont, C4StartupFontClr, C4StartupFontClrDisabled);
@@ -1425,7 +1435,8 @@
 	pCheckGfxPointFilter->SetChecked(!!(dwGfxCfg & C4GFXCFG_POINT_FILTERING));
 	pCheckGfxNoAddBlit->SetChecked(!!(dwGfxCfg & C4GFXCFG_NOADDITIVEBLTS));
 	pCheckGfxNoBoxFades->SetChecked(!!(dwGfxCfg & C4GFXCFG_NOBOXFADES));
-	pCheckGfxClipManually->SetChecked(!!(dwGfxCfg & C4GFXCFG_CLIPMANUALLY));
+	pCheckGfxClipManually->SetChecked(!!(dwGfxCfg & C4GFXCFG_CLIPMANUALLY));
+	pShaders->SetChecked(!!DDrawCfg.Shader);
 	pEdtGfxBlitOff->SetIntVal(iGfxBlitOff);
 	// title of troubleshooting-box by config set
 	pGroupTrouble->SetTitle(FormatString("%s: %s", LoadResStrNoAmp("IDS_CTL_TROUBLE"), fUseGL ? "OpenGL" : "DirectX").getData());
@@ -1440,7 +1451,8 @@
 	if (pCheckGfxPointFilter->GetChecked()) dwGfxCfg |= C4GFXCFG_POINT_FILTERING;
 	if (pCheckGfxNoAddBlit->GetChecked()) dwGfxCfg |= C4GFXCFG_NOADDITIVEBLTS;
 	if (pCheckGfxNoBoxFades->GetChecked()) dwGfxCfg |= C4GFXCFG_NOBOXFADES;
-	if (pCheckGfxClipManually->GetChecked()) dwGfxCfg |= C4GFXCFG_CLIPMANUALLY;
+	if (pCheckGfxClipManually->GetChecked()) dwGfxCfg |= C4GFXCFG_CLIPMANUALLY;
+	DDrawCfg.Shader=pShaders->GetChecked();
 	if (DDrawCfg.Windowed) dwGfxCfg |= C4GFXCFG_WINDOWED;
 	pEdtGfxBlitOff->Save2Config();
 	// get config set to be used
diff -r 835b92ade7d9 -r 4ee7c369c8bd planet/Graphics.c4g/EnergyBars.png
Binary file planet/Graphics.c4g/EnergyBars.png has changed
diff -r 835b92ade7d9 -r 4ee7c369c8bd planet/Graphics.c4g/GUIBigArrows.png
Binary file planet/Graphics.c4g/GUIBigArrows.png has changed
diff -r 835b92ade7d9 -r 4ee7c369c8bd planet/Graphics.c4g/GUICheckbox.png
Binary file planet/Graphics.c4g/GUICheckbox.png has changed
diff -r 835b92ade7d9 -r 4ee7c369c8bd planet/Graphics.c4g/GUIContext.png
Binary file planet/Graphics.c4g/GUIContext.png has changed
diff -r 835b92ade7d9 -r 4ee7c369c8bd planet/Graphics.c4g/GUIProgress.png
Binary file planet/Graphics.c4g/GUIProgress.png has changed
diff -r 835b92ade7d9 -r 4ee7c369c8bd planet/Graphics.c4g/GUIScroll.png
Binary file planet/Graphics.c4g/GUIScroll.png has changed
diff -r 835b92ade7d9 -r 4ee7c369c8bd planet/Graphics.c4g/GUISubmenu.png
Binary file planet/Graphics.c4g/GUISubmenu.png has changed
diff -r 835b92ade7d9 -r 4ee7c369c8bd planet/Graphics.c4g/Loader1.jpg
Binary file planet/Graphics.c4g/Loader1.jpg has changed
diff -r 835b92ade7d9 -r 4ee7c369c8bd planet/Graphics.c4g/StartupBookScroll.png
Binary file planet/Graphics.c4g/StartupBookScroll.png has changed
diff -r 835b92ade7d9 -r 4ee7c369c8bd planet/Graphics.c4g/StartupScenSelTitleOv.png
Binary file planet/Graphics.c4g/StartupScenSelTitleOv.png has changed
diff -r 835b92ade7d9 -r 4ee7c369c8bd planet/Graphics.c4g/UpperBoard.png
Binary file planet/Graphics.c4g/UpperBoard.png has changed
diff -r 835b92ade7d9 -r 4ee7c369c8bd standard/inc/StdDDraw2.h
--- a/standard/inc/StdDDraw2.h	Sat May 16 18:24:44 2009 +0200
+++ b/standard/inc/StdDDraw2.h	Wed May 27 13:48:46 2009 +0200
@@ -286,7 +286,7 @@
 		virtual bool PrepareRendering(SURFACE sfcToSurface) = 0; // check if/make rendering possible to given surface
 		// Blit
 		virtual void BlitLandscape(SURFACE sfcSource, SURFACE sfcSource2, SURFACE sfcLiquidAnimation, float fx, float fy,
-		                           SURFACE sfcTarget, float tx, float ty, float wdt, float hgt);
+		                           SURFACE sfcTarget, float tx, float ty, float wdt, float hgt, GLenum *mat);
 		void Blit8Fast(CSurface8 * sfcSource, int fx, int fy,
 		               SURFACE sfcTarget, int tx, int ty, int wdt, int hgt);
 		BOOL Blit(SURFACE sfcSource, float fx, float fy, float fwdt, float fhgt,
diff -r 835b92ade7d9 -r 4ee7c369c8bd standard/inc/StdGL.h
--- a/standard/inc/StdGL.h	Sat May 16 18:24:44 2009 +0200
+++ b/standard/inc/StdGL.h	Wed May 27 13:48:46 2009 +0200
@@ -92,7 +92,7 @@
 		bool fFullscreen;						// fullscreen mode?
 		int iClrDpt;								// color depth
 		// shaders for the ARB extension
-		GLuint shaders[12];
+		GLuint shaders[13];
 		// vertex buffer object
 		GLuint vbo;
 	public:
@@ -117,7 +117,7 @@
 		// Blit
 		void PerformBlt(CBltData &rBltData, CTexRef *pTex, DWORD dwModClr, bool fMod2, bool fExact);
 		virtual void BlitLandscape(SURFACE sfcSource, SURFACE sfcSource2, SURFACE sfcLiquidAnimation, float fx, float fy,
-		                      SURFACE sfcTarget, float tx, float ty, float wdt, float hgt);
+		                      SURFACE sfcTarget, float tx, float ty, float wdt, float hgt, GLenum *mat);
 		void FillBG(DWORD dwClr=0);
 		// Drawing
 		void DrawQuadDw(SURFACE sfcTarget, float *ipVtx, DWORD dwClr1, DWORD dwClr2, DWORD dwClr3, DWORD dwClr4);
diff -r 835b92ade7d9 -r 4ee7c369c8bd standard/src/StdDDraw2.cpp
--- a/standard/src/StdDDraw2.cpp	Sat May 16 18:24:44 2009 +0200
+++ b/standard/src/StdDDraw2.cpp	Wed May 27 13:48:46 2009 +0200
@@ -829,7 +829,7 @@
 	}
 
 void CStdDDraw::BlitLandscape(SURFACE sfcSource, SURFACE sfcSource2, SURFACE sfcSource3, float fx, float fy,
-								SURFACE sfcTarget, float tx, float ty, float wdt, float hgt)
+								SURFACE sfcTarget, float tx, float ty, float wdt, float hgt, GLenum *map)
 	{
 	Blit(sfcSource, fx, fy, wdt, hgt, sfcTarget, tx, ty, wdt, hgt, FALSE);
 	}
diff -r 835b92ade7d9 -r 4ee7c369c8bd standard/src/StdGL.cpp
--- a/standard/src/StdGL.cpp	Sat May 16 18:24:44 2009 +0200
+++ b/standard/src/StdGL.cpp	Wed May 27 13:48:46 2009 +0200
@@ -303,9 +303,9 @@
 	}
 
 void CStdGL::BlitLandscape(SURFACE sfcSource, SURFACE sfcSource2, SURFACE sfcLiquidAnimation, float fx, float fy,
-								SURFACE sfcTarget, float tx, float ty, float wdt, float hgt)
+								SURFACE sfcTarget, float tx, float ty, float wdt, float hgt, GLenum *mat)
 	{
-	Blit(sfcSource, fx, fy, wdt, hgt, sfcTarget, tx, ty, wdt, hgt);return;
+	//Blit(sfcSource, fx, fy, wdt, hgt, sfcTarget, tx, ty, wdt, hgt);return;
 	// safety
 	if (!sfcSource || !sfcTarget || !wdt || !hgt) return;
 	assert(sfcTarget->IsRenderTarget());
@@ -400,7 +400,8 @@
 			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 			glActiveTexture(GL_TEXTURE0);
-			}
+			}
+		s=12; //Special-Shader!
 		glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shaders[s]);
 		if (Saturation < 255)
 			{
@@ -465,10 +466,10 @@
 				glActiveTexture(GL_TEXTURE0);
 			CTexRef *pTex = *(sfcSource->ppTex + iY * sfcSource->iTexX + iX);
 			glBindTexture(GL_TEXTURE_2D, pTex->texName);
-			if (Zoom != 1.0 && !DDrawCfg.PointFiltering)
+			if (Zoom != 1.0);// && !DDrawCfg.PointFiltering)
 				{
-				glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-				glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+				glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+				glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 				}
 			if (sfcSource2)
 				{
@@ -540,9 +541,34 @@
 				Vtx[i].fty += DDrawCfg.fBlitOff;
 				Vtx[i].ftz = 0;
 				}
+
+                if(DDrawCfg.Shader)
+                {
+                    GLfloat bla[4];
+                    for (int cnt=1;cnt<128;cnt++)
+                    {
+                        if(mat[cnt])
+                        {
+                            bla[0]=static_cast<GLfloat>(cnt)/255.0f;
+                            glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, 0, bla);
+
+                            glActiveTexture(GL_TEXTURE1);   //Bind Mat Texture
+                            glEnable(GL_TEXTURE_2D);
+                            glBindTexture(GL_TEXTURE_2D, mat[cnt]);
+                            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+                            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+                            glActiveTexture(GL_TEXTURE0);
+
+                            glInterleavedArrays(GL_T2F_C4UB_V3F, sizeof(CBltVertex), Vtx);
+                            glDrawArrays(GL_QUADS, 0, 4);
+                        }
+                    }
+                } else {
+                    glInterleavedArrays(GL_T2F_C4UB_V3F, sizeof(CBltVertex), Vtx);
+                    glDrawArrays(GL_QUADS, 0, 4);
+                }
 
-			glInterleavedArrays(GL_T2F_C4UB_V3F, sizeof(CBltVertex), Vtx);
-			glDrawArrays(GL_POLYGON, 0, 4);
 			}
 		}
 	if (shaders[0])
@@ -833,7 +859,20 @@
 		"TEMP fow;\n"
 		// sample the texture
 		"TXP fow, fragment.texcoord[3], texture[3], 2D;\n"
-		"LRP tmp.rgb, fow.aaaa, tmp, fow;\n";
+		"LRP tmp.rgb, fow.aaaa, tmp, fow;\n";
+		const char * special =
+		"TEMP col;\n"
+		"MOV col.x, program.local[0].x;\n" //Load color to indentify
+		"ADD col.y, col.x, 0.001;\n"
+		"SUB col.z, col.x, 0.001;\n"  //epsilon-range
+		"SGE tmp.r, tmp.b, 0.5015;\n" //Tunnel?
+		"MAD tmp.r, tmp.r, -0.5019, tmp.b;\n"
+		"SGE col.z, tmp.r, col.z;\n" //mat identified?
+		"SLT col.y, tmp.r, col.y;\n"
+        "TXP tmp, fragment.texcoord, texture[1], 2D;\n"
+		"MUL tmp.a, col.y, col.z;\n"
+		"SUB tmp.a, 1.0, tmp.a;\n"
+		;
 		const char * end =
 		"MOV result.color, tmp;\n"
 		"END\n";
@@ -847,8 +886,10 @@
 		DefineShaderARB(FormatString("%s%s%s%s",     preface,         funny_add,       fow, end).getData(), shaders[7]);
 		DefineShaderARB(FormatString("%s%s%s%s%s",   preface, liquid, alpha_add,       fow, end).getData(), shaders[8]);
 		DefineShaderARB(FormatString("%s%s%s%s%s",   preface,         alpha_add, grey, fow, end).getData(), shaders[9]);
-		DefineShaderARB(FormatString("%s%s%s%s%s",   preface,         funny_add, grey, fow, end).getData(), shaders[10]);
-		DefineShaderARB(FormatString("%s%s%s%s%s%s", preface, liquid, alpha_add, grey, fow, end).getData(), shaders[11]);
+		DefineShaderARB(FormatString("%s%s%s%s%s",   preface,         funny_add, grey, fow, end).getData(), shaders[10]);
+		DefineShaderARB(FormatString("%s%s%s%s%s%s", preface, liquid, alpha_add, grey, fow, end).getData(), shaders[11]);
+
+		DefineShaderARB(FormatString("%s%s%s", preface, special, end).getData(), shaders[12]); //SuperSpecialShader!
 		}
 	// done
 	return Active;
diff -r 835b92ade7d9 -r 4ee7c369c8bd standard/src/StdSurface2.cpp
--- a/standard/src/StdSurface2.cpp	Sat May 16 18:24:44 2009 +0200
+++ b/standard/src/StdSurface2.cpp	Wed May 27 13:48:46 2009 +0200
@@ -401,7 +401,7 @@
 	}
 
 #ifdef USE_GL
-/*bool CSurface::CreatePrimaryGLTextures()
+bool CSurface::CreatePrimaryGLTextures()
 	{
 	if (!pGL) return false;
 	// primary OpenGL-surface: ensure context is selected
@@ -423,7 +423,7 @@
 			}
 	// done, success
 	return true;
-	}*/
+	}
 #endif
 
 #ifdef USE_DIRECTX
# HG changeset patch
# User Carli@Carli-PC
# Date 1243442933 -7200
# Node ID 868b7eff614ce2cd8716ec2fed3342d85ca5870e
# Parent  8fe3e2685f60c4d99b4cd27ebc4eef26c20cac20
Landscape shader is working

diff -r 8fe3e2685f60 -r 868b7eff614c engine/src/C4Landscape.cpp
--- a/engine/src/C4Landscape.cpp	Wed May 27 13:48:46 2009 +0200
+++ b/engine/src/C4Landscape.cpp	Wed May 27 18:48:53 2009 +0200
@@ -294,8 +294,17 @@
 	// blit landscape
 	if (Game.GraphicsSystem.ShowSolidMask)
 		Application.DDraw->Blit8Fast(Surface8, cgo.TargetX, cgo.TargetY, cgo.Surface, cgo.X,cgo.Y,cgo.Wdt,cgo.Hgt);
-	else
-		Application.DDraw->BlitLandscape(Surface32, AnimationSurface, &Game.GraphicsResource.sfcLiquidAnimation, cgo.TargetX, cgo.TargetY, cgo.Surface, cgo.X,cgo.Y,cgo.Wdt,cgo.Hgt,&Game.Material.Tex[0]);
+	else
+	{
+	    for (int i=0;i<C4M_MaxTexIndex+1;i++)
+	    {
+	    	Game.Material.Tex[i]=0;
+			if(Game.TextureMap.GetEntry(i))
+				if(Game.TextureMap.GetEntry(i)->getPattern().getSurface())
+					Game.Material.Tex[i]=(*Game.TextureMap.GetEntry(i)->getPattern().getSurface()->ppTex)->texName;
+	    };
+		Application.DDraw->BlitLandscape(Surface32, AnimationSurface, &Game.GraphicsResource.sfcLiquidAnimation, cgo.TargetX, cgo.TargetY, cgo.Surface, cgo.X,cgo.Y,cgo.Wdt,cgo.Hgt,&Game.Material.Tex[0]);
+	}
 	if (Modulation) Application.DDraw->DeactivateBlitModulation();
 	}
 
diff -r 8fe3e2685f60 -r 868b7eff614c engine/src/C4Material.cpp
--- a/engine/src/C4Material.cpp	Wed May 27 13:48:46 2009 +0200
+++ b/engine/src/C4Material.cpp	Wed May 27 18:48:53 2009 +0200
@@ -406,7 +406,6 @@
 		// search/create entry in texmap
 		Map[cnt].DefaultMatTex = Game.TextureMap.GetIndex(Map[cnt].Name, szTextureOverlay, TRUE,
 			FormatString("DefaultMatTex of mat %s", Map[cnt].Name).getData());
-		Tex[Map[cnt].DefaultMatTex%128] = 1;
 		// init PXS facet
 		SURFACE sfcTexture;
 		C4Texture * Texture;
@@ -416,8 +415,6 @@
 				if (sfcTexture=Texture->Surface32)
 				{
 					Map[cnt].PXSFace.Set(sfcTexture, Map[cnt].PXSGfxRt.x, Map[cnt].PXSGfxRt.y, Map[cnt].PXSGfxRt.Wdt, Map[cnt].PXSGfxRt.Hgt);
-					//(*Map[cnt].PXSFace.Surface->ppTex)->Unlock();
-					//Tex[Map[cnt].DefaultMatTex%128]=(*Map[cnt].PXSFace.Surface->ppTex)->texName;
 				};
             };
 		// evaluate reactions for that material
diff -r 8fe3e2685f60 -r 868b7eff614c standard/inc/StdDDraw2.h
--- a/standard/inc/StdDDraw2.h	Wed May 27 13:48:46 2009 +0200
+++ b/standard/inc/StdDDraw2.h	Wed May 27 18:48:53 2009 +0200
@@ -121,8 +121,8 @@
 // pattern
 class CPattern
 	{
-	private:
-		// pattern surface for new-style patterns
+	private:
+		// pattern surface for new-style patterns
 		class CSurface *sfcPattern32;
 		// Faster access
 		uint32_t * CachedPattern; int Wdt; int Hgt;
@@ -134,8 +134,9 @@
 		uint32_t *pClrs;
 		// alpha array for old-style patterns
 		uint32_t *pAlpha;
-	public:
-		CPattern& operator=(const CPattern&);
+	public:
+		CPattern& operator=(const CPattern&);
+		const CSurface *getSurface() const { return sfcPattern32; }
 		bool PatternClr(int iX, int iY, BYTE &byClr, DWORD &dwClr, CStdPalette &rPal) const;	// apply pattern to color
 		bool IsNewStyle() { if (sfcPattern32) return true; }
 		bool Set(class CSurface *sfcSource, int iZoom=0, bool fMonochrome=false);	// set and enable pattern
diff -r 8fe3e2685f60 -r 868b7eff614c standard/src/StdGL.cpp
--- a/standard/src/StdGL.cpp	Wed May 27 13:48:46 2009 +0200
+++ b/standard/src/StdGL.cpp	Wed May 27 18:48:53 2009 +0200
@@ -556,7 +556,10 @@
                             glEnable(GL_TEXTURE_2D);
                             glBindTexture(GL_TEXTURE_2D, mat[cnt]);
                             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-                            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+                            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+							glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+							glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
 
                             glActiveTexture(GL_TEXTURE0);
 
@@ -868,8 +871,12 @@
 		"SGE tmp.r, tmp.b, 0.5015;\n" //Tunnel?
 		"MAD tmp.r, tmp.r, -0.5019, tmp.b;\n"
 		"SGE col.z, tmp.r, col.z;\n" //mat identified?
-		"SLT col.y, tmp.r, col.y;\n"
-        "TXP tmp, fragment.texcoord, texture[1], 2D;\n"
+		"SLT col.y, tmp.r, col.y;\n"
+		"TEMP coo;\n"
+		"MOV coo, fragment.texcoord;\n"
+		"MUL coo.x, coo.x, 7.0;\n"
+		"MUL coo.y, coo.y, 7.0;\n"
+        "TXP tmp, coo, texture[1], 2D;\n"
 		"MUL tmp.a, col.y, col.z;\n"
 		"SUB tmp.a, 1.0, tmp.a;\n"
 		;
diff -r 8fe3e2685f60 -r 868b7eff614c standard/src/StdSurface2.cpp
--- a/standard/src/StdSurface2.cpp	Wed May 27 13:48:46 2009 +0200
+++ b/standard/src/StdSurface2.cpp	Wed May 27 18:48:53 2009 +0200
@@ -401,7 +401,7 @@
 	}
 
 #ifdef USE_GL
-bool CSurface::CreatePrimaryGLTextures()
+/*bool CSurface::CreatePrimaryGLTextures()
 	{
 	if (!pGL) return false;
 	// primary OpenGL-surface: ensure context is selected
@@ -424,6 +424,7 @@
 	// done, success
 	return true;
 	}
+*/
 #endif
 
 #ifdef USE_DIRECTX
