From 7dc2087a87b54e16e9fa52b7d2f33952c1e86c34 Mon Sep 17 00:00:00 2001 From: lsalzman Date: Thu, 6 Jun 2013 10:05:25 +0300 Subject: [PATCH] fix material shader slots --- data/default_map_settings.cfg | 6 ++---- src/engine/water.cpp | 16 +++++++--------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/data/default_map_settings.cfg b/data/default_map_settings.cfg index 2bae221..a4220c4 100644 --- a/data/default_map_settings.cfg +++ b/data/default_map_settings.cfg @@ -22,15 +22,13 @@ loop i 4 [ texture [glass@(+ $i 1)] "textures/glassn.png" // glass normals texture [water@(+ $i 1)] "golgotha/water2.jpg" // water surface - texture 1 "textures/waterfall.jpg" // waterfall texture 1 "textures/watern.jpg" // water normals - texture 1 "textures/waterdudv.jpg" // water distortion + texture 1 "textures/waterfall.jpg" // waterfall texture 1 "textures/waterfalln.jpg" // waterfall normals - texture 1 "textures/waterfalldudv.jpg" // waterfall distortion texture [lava@(+ $i 1)] "dg/floor_lava2.jpg" 0 0 0 2 // lava surface - texture 1 "dg/floor_lava2.jpg" // falling lava texture 1 "textures/watern.jpg" // lava normals + texture 1 "dg/floor_lava2.jpg" // falling lava texture 1 "textures/waterfalln.jpg" // lavafall normals ] diff --git a/src/engine/water.cpp b/src/engine/water.cpp index e54871c..855f3f3 100644 --- a/src/engine/water.cpp +++ b/src/engine/water.cpp @@ -538,7 +538,7 @@ void renderlava() Texture *tex = lslot.sts.inrange(0) ? lslot.sts[0].t: notexture; glBindTexture(GL_TEXTURE_2D, tex->id); glActiveTexture_(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, lslot.sts.inrange(2) ? lslot.sts[2].t->id : notexture->id); + glBindTexture(GL_TEXTURE_2D, lslot.sts.inrange(1) ? lslot.sts[1].t->id : notexture->id); glActiveTexture_(GL_TEXTURE0); vector &surfs = lavasurfs[k]; @@ -548,7 +548,7 @@ void renderlava() if(drawtex != DRAWTEX_MINIMAP && lavafallsurfs[k].length()) { - Texture *tex = lslot.sts.inrange(1) ? lslot.sts[1].t : (lslot.sts.inrange(0) ? lslot.sts[0].t : notexture); + Texture *tex = lslot.sts.inrange(2) ? lslot.sts[2].t : (lslot.sts.inrange(0) ? lslot.sts[0].t : notexture); float angle = fmod(float(lastmillis/2000.0f/(2*M_PI)), 1.0f), s = angle - int(angle) - 0.5f; s *= 8 - fabs(s)*16; @@ -559,7 +559,7 @@ void renderlava() glBindTexture(GL_TEXTURE_2D, tex->id); glActiveTexture_(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, lslot.sts.inrange(3) ? lslot.sts[3].t->id : notexture->id); + glBindTexture(GL_TEXTURE_2D, lslot.sts.inrange(2) ? (lslot.sts.inrange(3) ? lslot.sts[3].t->id : notexture->id) : (lslot.sts.inrange(1) ? lslot.sts[1].t->id : notexture->id)); glActiveTexture_(GL_TEXTURE0); vector &surfs = lavafallsurfs[k]; @@ -582,7 +582,7 @@ void renderwaterfalls() MSlot &wslot = lookupmaterialslot(MAT_WATER+k); - Texture *tex = wslot.sts.inrange(1) ? wslot.sts[1].t : notexture; + Texture *tex = wslot.sts.inrange(2) ? wslot.sts[2].t : (wslot.sts.inrange(0) ? wslot.sts[0].t : notexture); float angle = fmod(float(lastmillis/600.0f/(2*M_PI)), 1.0f), s = angle - int(angle) - 0.5f; s *= 8 - fabs(s)*16; @@ -606,9 +606,7 @@ void renderwaterfalls() glBindTexture(GL_TEXTURE_2D, tex->id); glActiveTexture_(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, wslot.sts.inrange(4) ? wslot.sts[4].t->id : notexture->id); - glActiveTexture_(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, wslot.sts.inrange(5) ? wslot.sts[5].t->id : notexture->id); + glBindTexture(GL_TEXTURE_2D, wslot.sts.inrange(2) ? (wslot.sts.inrange(3) ? wslot.sts[3].t->id : notexture->id) : (wslot.sts.inrange(1) ? wslot.sts[1].t->id : notexture->id)); if(waterfallenv) { glActiveTexture_(GL_TEXTURE3); @@ -634,9 +632,9 @@ void renderwater() MSlot &wslot = lookupmaterialslot(MAT_WATER+k); - glBindTexture(GL_TEXTURE_2D, wslot.sts.inrange(2) ? wslot.sts[2].t->id : notexture->id); + glBindTexture(GL_TEXTURE_2D, wslot.sts.inrange(0) ? wslot.sts[0].t->id : notexture->id); glActiveTexture_(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, wslot.sts.inrange(3) ? wslot.sts[3].t->id : notexture->id); + glBindTexture(GL_TEXTURE_2D, wslot.sts.inrange(1) ? wslot.sts[1].t->id : notexture->id); if(caustics && causticscale && causticmillis) setupcaustics(2); if(waterenvmap && !waterreflect && drawtex != DRAWTEX_MINIMAP) {