diff --git a/luarules/gadgets/map_texture_generator.lua b/luarules/gadgets/map_texture_generator.lua index 73fc2ea..a86609e 100644 --- a/luarules/gadgets/map_texture_generator.lua +++ b/luarules/gadgets/map_texture_generator.lua @@ -139,7 +139,7 @@ local function SetMapTexture(texturePool, mapTexX, mapTexZ, topTexX, topTexZ, to ) -- specular probably doesn't need to be entirely full reso tbf - local spectex = gl.CreateTexture(MAP_X, MAP_Z, + local spectex = gl.CreateTexture(MAP_X/4, MAP_Z/4, { border = false, min_filter = GL.LINEAR, @@ -150,8 +150,7 @@ local function SetMapTexture(texturePool, mapTexX, mapTexZ, topTexX, topTexZ, to } ) - Spring.Echo("Generated blank fulltex") - local topSplattex = USE_SHADING_TEXTURE and gl.CreateTexture(MAP_X, MAP_Z, + local splattex = USE_SHADING_TEXTURE and gl.CreateTexture(MAP_X/16, MAP_Z/16, { format = GL_RGBA32F, border = false, @@ -161,7 +160,9 @@ local function SetMapTexture(texturePool, mapTexX, mapTexZ, topTexX, topTexZ, to wrap_t = GL.CLAMP_TO_EDGE, fbo = true, } - ) + ) + + Spring.Echo("Generated blank fulltex") Spring.Echo("Generated blank splattex") local vertSrc = [[ @@ -173,6 +174,7 @@ local function SetMapTexture(texturePool, mapTexX, mapTexZ, topTexX, topTexZ, to ]] local fragSrc = VFS.LoadFile("shaders/map_diffuse_generator.glsl"); + local fragSrc_dnts = VFS.LoadFile("shaders/dnts.glsl"); local diffuseShader = glCreateShader({ vertex = vertSrc, @@ -190,11 +192,22 @@ local function SetMapTexture(texturePool, mapTexX, mapTexZ, topTexX, topTexZ, to tex9 = 9, tex10 = 10, tex11 = 11, + tex12 = 12, + tex13 = 13, + }, + }) + + local dntsShader = glCreateShader({ + vertex = vertSrc, + fragment = fragSrc_dnts, + uniformInt = { + tex0 = 0, + tex1 = 1, }, }) Spring.Echo(gl.GetShaderLog()) - if(diffuseShader) then + if(diffuseShader and dntsShader) then Spring.Echo("Diffuse shader created"); else Spring.Echo("SHADER ERROR"); @@ -205,6 +218,7 @@ local function SetMapTexture(texturePool, mapTexX, mapTexZ, topTexX, topTexZ, to end local function DrawLoop() + gl.Blending(false) local loopCount = 0 glColor(1, 1, 1, 1) local ago = Spring.GetTimer() @@ -237,6 +251,10 @@ local function SetMapTexture(texturePool, mapTexX, mapTexZ, topTexX, topTexZ, to glTexture(10, false) glTexture(11,":l:unittextures/tacticalview/terran/diffuse/sand.png"); glTexture(11, false) + glTexture(12,":l:unittextures/tacticalview/terran/height/ramps.png"); + glTexture(12, false) + glTexture(13,":l:unittextures/tacticalview/terran/height/cliffs.png"); + glTexture(13, false) gl.TexRect(-1,-1,1,1,false,true) glUseShader(0) end) @@ -259,18 +277,29 @@ local function SetMapTexture(texturePool, mapTexX, mapTexZ, topTexX, topTexZ, to local cur = Spring.GetTimer() Spring.Echo("FullTex rendered in: "..(Spring.DiffTimers(cur, ago, true))) local ago2 = Spring.GetTimer() - gl.Blending(GL.ONE, GL.ZERO) + --gl.Blending(GL.ONE, GL.ZERO) Sleep() Spring.ClearWatchDogTimer() cur = Spring.GetTimer() - Spring.Echo("Splattex rendered in: "..(Spring.DiffTimers(cur, ago2, true))) glColor(1, 1, 1, 1) - local agoSpec = Spring.GetTimer(); - Spring.Echo("Starting to render specular") + Spring.Echo("Starting to render DNTS-splattex") + glRenderToTexture(splattex, function () + glUseShader(dntsShader) + gl.Blending(false) + glTexture(0, "$heightmap") + glTexture(0, false) + glTexture(1,"$normals") + glTexture(1, false) + gl.TexRect(-1,-1,1,1,false,true) + glUseShader(0) + end) + gl.Blending(false) + glTexture(false) + glDeleteShader(dntsShader); glRenderToTexture(spectex, function () glUseShader(diffuseShader) glTexture(0, "$heightmap") @@ -297,6 +326,10 @@ local function SetMapTexture(texturePool, mapTexX, mapTexZ, topTexX, topTexZ, to glTexture(10, false) glTexture(11,":l:unittextures/tacticalview/terran/specular/sand.png"); glTexture(11, false) + glTexture(12,":l:unittextures/tacticalview/terran/height/ramps.png"); + glTexture(12, false) + glTexture(13,":l:unittextures/tacticalview/terran/height/cliffs.png"); + glTexture(13, false) gl.TexRect(-1,-1,1,1,false,true) glUseShader(0) end) @@ -312,22 +345,11 @@ local function SetMapTexture(texturePool, mapTexX, mapTexZ, topTexX, topTexZ, to glDeleteTexture(":l:unittextures/tacticalview/terran/specular/sand.png"); glTexture(false) glDeleteShader(diffuseShader); - + cur = Spring.GetTimer() - Spring.Echo("Specular rendered in "..(Spring.DiffTimers(cur, ago, true))) + Spring.Echo("Specular and Splat rendered in "..(Spring.DiffTimers(cur, ago2, true))) Spring.Echo("Starting to render SquareTextures") - local splattex = USE_SHADING_TEXTURE and gl.CreateTexture(MAP_X, MAP_Z, - { - format = GL_RGBA32F, - border = false, - min_filter = GL.LINEAR, - mag_filter = GL.LINEAR, - wrap_s = GL.CLAMP_TO_EDGE, - wrap_t = GL.CLAMP_TO_EDGE, - fbo = true, - } - ) gl.Blending(false) @@ -391,9 +413,10 @@ local function SetMapTexture(texturePool, mapTexX, mapTexZ, topTexX, topTexZ, to Spring.Echo("All squaretex rendered and applied in: "..(Spring.DiffTimers(cur, ago3, true))) Spring.SetMapShadingTexture("$ssmf_specular", spectex) - Spring.Echo("specular applied") + Spring.SetMapShadingTexture("$ssmf_splat_distr", splattex) + Spring.Echo("specular and splat applied") - Spring.SetMapShadingTexture("$grass", texOut) + -- Spring.SetMapShadingTexture("$grass", texOut) usedgrass = texOut Spring.SetMapShadingTexture("$minimap", texOut) @@ -407,24 +430,6 @@ local function SetMapTexture(texturePool, mapTexX, mapTexZ, topTexX, topTexZ, to texOut = nil end - if splattex then - texOut = splattex - Spring.SetMapShadingTexture("$ssmf_splat_distr", texOut) - usedsplat = texOut - Spring.Echo("Applied splat texture") - gl.DeleteTextureFBO(splattex) - if texOut and texOut ~= usedsplat then - glDeleteTexture(texOut) - if splattex and texOut == splattex then - splattex = nil - end - texOut = nil - end - if splattex and splattex ~= usedsplat then - glDeleteTexture(splattex) - splattex = nil - end - end local DrawEnd = Spring.GetTimer() Spring.Echo("map fully processed in: "..(Spring.DiffTimers(DrawEnd, DrawStart, true))) @@ -456,4 +461,3 @@ end function gadget:MousePress(x, y, button) return (button == 1) and (not mapfullyprocessed) end - diff --git a/luarules/gadgets/randommapgen_atmosphereparams.lua b/luarules/gadgets/randommapgen_atmosphereparams.lua index 5dea26a..7830780 100644 --- a/luarules/gadgets/randommapgen_atmosphereparams.lua +++ b/luarules/gadgets/randommapgen_atmosphereparams.lua @@ -1,133 +1,133 @@ -local engineVersion = 100 -- just filled this in here incorrectly but old engines arent used anyway -if Engine and Engine.version then - local function Split(s, separator) - local results = {} - for part in s:gmatch("[^"..separator.."]+") do - results[#results + 1] = part - end - return results - end - engineVersion = Split(Engine.version, '-') - if engineVersion[2] ~= nil and engineVersion[3] ~= nil then - engineVersion = tonumber(string.gsub(engineVersion[1], '%.', '')..engineVersion[2]) - else - engineVersion = tonumber(Engine.version) - end -elseif Game and Game.version then - engineVersion = tonumber(Game.version) -end - --- fixed: https://springrts.com/mantis/view.php?id=5864 -if not ((engineVersion < 1000 and engineVersion <= 105) or engineVersion >= 10401803) or (Game and Game.version and tonumber(Game.version) == 103) then - return -end - -function gadget:GetInfo() - return { - name = "Wind generation", - desc = "Sets wind generation values", - author = "Doo", - date = "July,2016", - layer = 11, - enabled = (select(1, Spring.GetGameFrame()) <= 0), - } -end - - --------------------------------------------------------------------------------- --- synced --------------------------------------------------------------------------------- -if gadgetHandler:IsSyncedCode() then - function gadget:Initialize() - local typemap = Spring.GetGameRulesParam("typemap") - local minw, maxw - local r = math.random - if typemap == "arctic" then - minw = r(3,8) - maxw = r(13,20) - elseif typemap == "temperate" then - minw = r(2,4) - maxw = r(8,13) - elseif typemap == "desert" then - minw = r(1,2) - maxw = r(8,16) - else - minw = 0 - maxw = 1 - end - Spring.SetWind(minw,maxw) - end -else -local useShadingTextures = Spring.GetConfigInt("AdvMapShading") == 1 - function gadget:Initialize() - local typemap = Spring.GetGameRulesParam("typemap") - local aparams = {} - local sparam = {} - local r = math.random - if typemap == "arctic" then - aparams = { - sunColor = {0.8, 0.6, 0.3, 1}, - skyColor = {0.4, 0.4, 0.4, 0.6}, - cloudColor = {0.6, 0.6, 0.6, 0.9}, - fogColor = {0.4, 0.4, 0.4, 0}, - } - sparams = { - groundAmbientColor = {0.5, 0.5, 0.5}, - groundDiffuseColor = {0.8, 0.8, 0.8}, - unitAmbientColor = {0.4, 0.4, 0.4}, - unitDiffuseColor = {0.85, 0.85, 0.85}, - } - elseif typemap == "temperate" then - aparams = { - sunColor = {1, 0.8, 0.4, 1}, - skyColor = {0.1, 0.2, 0.9, 1.0}, - cloudColor = {0.85, 0.7, 0.7, 0.4}, - fogColor = {0.85, 0.7, 0.7, 0.4}, - } - sparams = { - groundAmbientColor = {0.4, 0.3, 0.4}, - groundDiffuseColor = {0.7, 0.7, 0.7}, - unitAmbientColor = {0.3, 0.2, 0.3}, - unitDiffuseColor = {0.8, 0.8, 0.8}, - } - elseif typemap == "desert" then - if useShadingTextures then - Spring.SetMapRenderingParams({ - splatTexScales = {0.006, 0.01, 0.02, 0.02}, - }) - end - aparams = { - sunColor = {1, 0.8, 0.4, 1}, - skyColor = {0.1, 0.2, 0.9, 1}, - cloudColor = {0.1, 0.2, 0.9, 0}, - fogColor = {0.1, 0.2, 0.9, 0}, - } - sparams = { - groundAmbientColor = {0.7, 0.7, 0.7}, - groundDiffuseColor = {0.9, 0.9, 0.9}, - unitAmbientColor = {0.8, 0.8, 0.8}, - unitDiffuseColor = {1, 1, 1}, - } - else - if useShadingTextures then - Spring.SetMapRenderingParams({ - splatTexScales = {0.02, 0.015, 0.02, 0.02}, - }) - end - aparams = { - sunColor = {1, 0.8, 0.8, 1}, - skyColor = {0, 0, 0, 1}, - cloudColor = {1, 1, 1, 1}, - fogColor = {0, 0, 0, 1}, - } - sparams = { - ["groundDiffuseColor"]= {0.35, 0.42, 0.41, 1}, - ["groundAmbientColor"]= {0.42, 0.45, 0.365, 1}, - ["groundSpecularColor"]= {0.1, 0.1, 0.1, 1}, - } - end - Spring.SetAtmosphere(aparams) - Spring.SetSunLighting(sparams) - end -end - +local engineVersion = 100 -- just filled this in here incorrectly but old engines arent used anyway +if Engine and Engine.version then + local function Split(s, separator) + local results = {} + for part in s:gmatch("[^"..separator.."]+") do + results[#results + 1] = part + end + return results + end + engineVersion = Split(Engine.version, '-') + if engineVersion[2] ~= nil and engineVersion[3] ~= nil then + engineVersion = tonumber(string.gsub(engineVersion[1], '%.', '')..engineVersion[2]) + else + engineVersion = tonumber(Engine.version) + end +elseif Game and Game.version then + engineVersion = tonumber(Game.version) +end + +-- fixed: https://springrts.com/mantis/view.php?id=5864 +if not ((engineVersion < 1000 and engineVersion <= 105) or engineVersion >= 10401803) or (Game and Game.version and tonumber(Game.version) == 103) then + return +end + +function gadget:GetInfo() + return { + name = "Wind generation", + desc = "Sets wind generation values", + author = "Doo", + date = "July,2016", + layer = 11, + enabled = (select(1, Spring.GetGameFrame()) <= 0), + } +end + + +-------------------------------------------------------------------------------- +-- synced +-------------------------------------------------------------------------------- +if gadgetHandler:IsSyncedCode() then + function gadget:Initialize() + local typemap = Spring.GetGameRulesParam("typemap") + local minw, maxw + local r = math.random + if typemap == "arctic" then + minw = r(3,8) + maxw = r(13,20) + elseif typemap == "temperate" then + minw = r(2,4) + maxw = r(8,13) + elseif typemap == "desert" then + minw = r(1,2) + maxw = r(8,16) + else + minw = 0 + maxw = 1 + end + Spring.SetWind(minw,maxw) + end +else +local useShadingTextures = Spring.GetConfigInt("AdvMapShading") == 1 + function gadget:Initialize() + local typemap = Spring.GetGameRulesParam("typemap") + local aparams = {} + local sparam = {} + local r = math.random + if typemap == "arctic" then + aparams = { + sunColor = {0.8, 0.6, 0.3, 1}, + skyColor = {0.4, 0.4, 0.4, 0.6}, + cloudColor = {0.6, 0.6, 0.6, 0.9}, + fogColor = {0.4, 0.4, 0.4, 0}, + } + sparams = { + groundAmbientColor = {0.5, 0.5, 0.5}, + groundDiffuseColor = {0.8, 0.8, 0.8}, + unitAmbientColor = {0.4, 0.4, 0.4}, + unitDiffuseColor = {0.85, 0.85, 0.85}, + } + elseif typemap == "temperate" then + aparams = { + sunColor = {1, 0.8, 0.4, 1}, + skyColor = {0.1, 0.2, 0.9, 1.0}, + cloudColor = {0.85, 0.7, 0.7, 0.4}, + fogColor = {0.85, 0.7, 0.7, 0.4}, + } + sparams = { + groundAmbientColor = {0.4, 0.3, 0.4}, + groundDiffuseColor = {0.7, 0.7, 0.7}, + unitAmbientColor = {0.3, 0.2, 0.3}, + unitDiffuseColor = {0.8, 0.8, 0.8}, + } + elseif typemap == "desert" then + if useShadingTextures then + Spring.SetMapRenderingParams({ + splatTexScales = {0.006, 0.01, 0.02, 0.02}, + }) + end + aparams = { + sunColor = {1, 0.8, 0.4, 1}, + skyColor = {0.1, 0.2, 0.9, 1}, + cloudColor = {0.1, 0.2, 0.9, 0}, + fogColor = {0.1, 0.2, 0.9, 0}, + } + sparams = { + groundAmbientColor = {0.7, 0.7, 0.7}, + groundDiffuseColor = {0.9, 0.9, 0.9}, + unitAmbientColor = {0.8, 0.8, 0.8}, + unitDiffuseColor = {1, 1, 1}, + } + else + if useShadingTextures then + Spring.SetMapRenderingParams({ + splatTexScales = {0.02, 0.015, 0.02, 0.02}, + }) + end + aparams = { + sunColor = {1, 0.8, 0.8, 1}, + skyColor = {0, 0, 0, 1}, + cloudColor = {1, 1, 1, 1}, + fogColor = {0, 0, 0, 1}, + } + sparams = { + ["groundDiffuseColor"]= {0.35, 0.42, 0.41, 1}, + ["groundAmbientColor"]= {0.42, 0.45, 0.365, 1}, + ["groundSpecularColor"]= {0.1, 0.1, 0.1, 1}, + } + end + Spring.SetAtmosphere(aparams) + Spring.SetSunLighting(sparams) + end +end + diff --git a/mapinfo.lua b/mapinfo.lua index 73609c5..6af8ad7 100644 --- a/mapinfo.lua +++ b/mapinfo.lua @@ -38,19 +38,17 @@ local mapinfo = { }, resources = { - splatDetailTex = "Rock.png", + splatDetailTex = "Zsplat.dds", splatDetailNormalDiffuseAlpha = 1, - splatDetailNormalTex = { - "grass.tga", -- Grass - "rock.tga", -- Rocky grass - "sand.tga", -- shallowSand - "volcano.tga", -- Depth Sand - alpha = true, - }, + splatDetailNormalTex1 = "grass_91_highpass_dnts.tga", + splatDetailNormalTex2 = "rock_288_highpass_dnts.tga", + splatDetailNormalTex3 = "testsand.tga", + splatDetailNormalTex4 = "pebbles_283_highpass_dnts.tga", + splatDistrTex = "fake.png", }, - splats = { - TexScales = { 0.00471, 0.00097, 0.0013, 0.0027 }, - TexMults = { 0.5, 0.31, 0.5, 0.65 }, + splats = { + texScales = { 0.004, 0.0025, .003, .005}, + texMults = { 0.3, 0.75, 0.25, 0.45}, }, atmosphere = { @@ -85,8 +83,8 @@ local mapinfo = { sunDir = {0.35, 1.0, 0.3, 1e9}, --// unit & ground lighting - ["groundDiffuseColor"]= {0.35, 0.42, 0.41, 1}, - ["groundAmbientColor"]= {0.42, 0.45, 0.365, 1}, + ["groundDiffuseColor"]= {0.8, 0.8, 0.8, 1}, + ["groundAmbientColor"]= {0.42, 0.42, 0.42, 1}, ["groundSpecularColor"]= {0.1, 0.1, 0.1, 1}, groundShadowDensity = 0.4, unitAmbientColor = {0.55, 0.55, 0.45}, diff --git a/maps/MapGenParamsSiege.lua b/maps/MapGenParamsSiege.lua new file mode 100644 index 0000000..b68841b --- /dev/null +++ b/maps/MapGenParamsSiege.lua @@ -0,0 +1,183 @@ +local generalWaveMod = 1 +local allParams = { + generalWaveMod = generalWaveMod, + multParams = { + scaleMin = 0.65, + scaleMax = 0.8, + periodMin = 2000, + periodMax = 5000 - 1500*generalWaveMod, + spreadMin = 200, + spreadMax = 900, + offsetMin = -0.2, + offsetMax = 0.2, + growthMin = 0.15, + growthMax = 0.2 + 0.2*generalWaveMod, + wavePeriodMin = 1000, + wavePeriodMax = 2600, + waveRotationsMin = 1, + waveRotationsMax = 8, + spreadScaleMin = 0.2, + spreadScaleMax = 0.4, + }, + + translateParams = { + scaleMin = 60, + scaleMax = 60 + 20*generalWaveMod, + periodMin = 1800, + periodMax = 3000, + spreadMin = 20, + spreadMax = 120, + offsetMin = 30, + offsetMax = 90, + growthMin = 5, + growthMax = 20, + wavePeriodMin = 800, + wavePeriodMax = 1700, + waveRotationsMin = 1, + waveRotationsMax = 8, + spreadScaleMin = 0.025, + spreadScaleMax = 0.07, + }, + + rotParams = { + scaleMin = 60, + scaleMax = 60 + 20*generalWaveMod, + periodMin = 1800, + periodMax = 4000, + spreadMin = 60, + spreadMax = 300, + offsetMin = 30, + offsetMax = 90, + growthMin = 5, + growthMax = 20, + wavePeriodMin = 800, + wavePeriodMax = 1700, + waveRotationsMin = 1, + waveRotationsMax = 8, + }, + + bigMultParams = { + scaleMin = 0.9, + scaleMax = 1 + 0.2*generalWaveMod, + periodMin = 18000, + periodMax = 45000, + spreadMin = 2000, + spreadMax = 8000, + offsetMin = 0.3, + offsetMax = 0.4, + growthMin = 0.02, + growthMax = 0.2, + wavePeriodMin = 3500, + wavePeriodMax = 5000, + waveRotationsMin = 1, + waveRotationsMax = 8, + }, + spaceParams = { + vorPoints = 2, + vorPointsRand = 5, + vorSizePointMult = 0, + vorSizePointMultRand = 0, + vorScaleAdjustPoint = 1.3, + vorScaleAdjustRand = 0.05, + -- These parameters are affected by vorScaleAdjustPoint and vorScaleAdjustRand + midPoints = 1, + midPointRadius = 900, + midPointSpace = 400, + minSpace = 230, + maxSpace = 560, + pointSplitRadius = 660, + edgeBias = 1.25, + ------------ + -- IGLOOS -- + ------------ + longIglooFlatten = 5, + iglooTierDiffOpenThreshold = 300, + openEdgeIglooThreshold = 800, + iglooHeightMult = 0.55, + iglooBoostThreshold = 1.3, + iglooLengthMult = 3, + iglooMaxHeightBase = 150, + iglooMaxHeightTierDiffMult = 60, + iglooMaxHeightVar = 0.2, + highDiffParallelIglooChance = 1, + flatIglooChances = {[-1] = 0.95}, + flatIglooWidthMult = {[-1] = 0.4}, + ---------------------- + -- RAMPS AND CLIFFS -- + ---------------------- + rampWidth = 500, + cliffBotWidth = 1, + steepCliffWidth = 12, + steepCliffChance = 0.01, + bigDiffSteepCliffChance = 0.2, + rampChance = 0.99, + bigDiffRampChance = 0.79, + bigDiffRampReduction = 0.9, + rampVehWidthChance = {[2] = 0.95, [2] = 0.88, [4] = 0.55}, + impassEdgeThreshold = 380, + ------------------ + -- HEIGHT TIERS -- + ------------------ + tierConst = 120, + tierHeight = 150, + vehPassTiers = 2, -- Update based on tierHeight + waveDirectMult = 1, + heightOffsetFactor = 0.9, + mapBorderTier = 1, + bucketBase = 1, + bucketRandomOffset = 0.5, + bucketStdMult = 0.9, + bucketStdMultRand = 0.2, + bucketSizeMult = 0.6, + bucketSizeMultRand = 0.3, + ----------- + -- WATER -- + ----------- + nonBorderSeaNeighbourLimit = 1, -- Allow lone lakes + seaEdgelimit = 400, + seaEdgelimitRepeatFactor = 0.8, + seaLimitMaxAverageTier = -0.7, -- Most nearby area has to be sand. + flatIglooChances = {[-1] = 1}, + flatIglooWidthMult = {[-1] = 1}, + ----------------- + -- METAL SPOTS -- + ----------------- + startPoint = {550, 550}, + startPointSize = 600, + baseMexesPerSide = 17, + baseMexesRand = 4, + forcedMidMexes = 0, + forcedMinMexRadius = 900, + emptyAreaMexes = 5, + emptyAreaMexRadiusMin = 1200, + emptyAreaMexRadiusRand = 200, + mexLoneSize = 1400, + startMexGap = 1200, -- Gap is not size, but distance between mexes + startMexSize = 420, + doubleMexDetectGap = 400, + doubleMexSize = 900, + mexPairSize = 600, + mexPairGapRequirement = 120, + mexPairSizePostSize = 300, + midMexDetectGap = 100, + mexValue = 2.0, + megaMexValue = 5.0, + smallTeamMetalMult = 1.05, + bigTeamMetalMult = 1.2, + predefinedMexSize = 330, + predefinedMexes = { + {1750, 450}, + {450, 1750}, + {2850, 650}, + {650, 2850}, + }, + ---------- + -- MISC -- + ---------- + treeMult = 3, + treeMinTier = 1, + treeMaxTier = 2, + stripeRisk = 0, + }, +} +return allParams \ No newline at end of file diff --git a/maps/grass_91_highpass_dnts.tga b/maps/grass_91_highpass_dnts.tga new file mode 100644 index 0000000..7cc60b5 Binary files /dev/null and b/maps/grass_91_highpass_dnts.tga differ diff --git a/maps/pebbles_283_highpass_dnts.tga b/maps/pebbles_283_highpass_dnts.tga new file mode 100644 index 0000000..ab70355 Binary files /dev/null and b/maps/pebbles_283_highpass_dnts.tga differ diff --git a/maps/rock_288_highpass_dnts.tga b/maps/rock_288_highpass_dnts.tga new file mode 100644 index 0000000..001c3a1 Binary files /dev/null and b/maps/rock_288_highpass_dnts.tga differ diff --git a/maps/testsand.tga b/maps/testsand.tga new file mode 100644 index 0000000..f6e6c22 Binary files /dev/null and b/maps/testsand.tga differ diff --git a/shaders/dnts.glsl b/shaders/dnts.glsl new file mode 100644 index 0000000..3d9f6da --- /dev/null +++ b/shaders/dnts.glsl @@ -0,0 +1,98 @@ +uniform sampler2D tex0; // unqualified heightfield +uniform sampler2D tex1; // 2d normals + +uniform float minHeight; +uniform float maxHeight; + +// should these be uniforms? +const float hardCliffMax = 1.0; // sharpest bot-blocking cliff +const float hardCliffMin = 0.58778525229; // least sharp bot-blocking cliff + +const float vehCliff = 0.4546; +const float botCliff = 0.8065; + +const float softCliffMax = hardCliffMin; +const float bandingMin = 0.12; +const float vehCliffMinus = 0.24; +const float vehCliffEpsilon = 0.492; +const float vehCliffPlus = 0.62; +const float botCliffMinus = botCliff - 0.06; +const float botCliffMinusMinus = 0.65; + +vec2 rotate(vec2 v, float a) { + float s = sin(a); + float c = cos(a); + mat2 m = mat2(c, -s, s, c); + return m * v; +} + +float rand(vec2 co){ + return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453); +} + +void main() +{ + vec2 coord = vec2(gl_TexCoord[0].s,gl_TexCoord[0].t); + vec4 norm = texture2D(tex1, coord); + vec2 norm2d = vec2(norm.x, norm.a); + float slope = length(norm2d); + float factor = 0.0; + float height = texture2D(tex0,coord).r; + float factorRand = rand(coord); + + // tile somewhat + coord = 8.0*coord; + + // base texture + // base texture + gl_FragColor = vec4(0,0,0,0); + // ---- altitude textures ---- + gl_FragColor = vec4(0,0.0,0, 0.0); + if (height > 300.0) { + factor = 1.0-smoothstep(255.0, 330.0, height); + gl_FragColor = mix(gl_FragColor,vec4(1.0,0,0.0,0.0), factor); + factor = smoothstep(300.0,360.0,height); + gl_FragColor = mix(gl_FragColor,vec4(0,0,0.0,0.4), 0.4); + } + else if (height > 120.0){ + if (height > 255.0) { + factor = 1.0-smoothstep(255.0, 330.0, height); + gl_FragColor = mix(gl_FragColor,vec4(1.0,0,0,0.0), factor); + } + else if (height > 150.0) { + gl_FragColor = mix(gl_FragColor,vec4(1.0,0,0,0.0), factorRand); + } + else { + factor = smoothstep(120.0,150.0, height); + gl_FragColor = mix(gl_FragColor,vec4(1.0,0,0,0.0), factor); + } + } + else { + if (factorRand > 0.99) { + gl_FragColor = vec4(0,0.0,0, 0.2); + } + else { + gl_FragColor = mix(gl_FragColor,vec4(0,0,1.0,0.0), factorRand); + } + } + // admix highlands + if (slope > botCliff-0.00001){ + gl_FragColor = vec4(0,0,0, 0.0); + factor = 0.6+0.2*(smoothstep(botCliffMinusMinus, 1.0, slope)); + gl_FragColor = mix(gl_FragColor,vec4(0,1.0,0,0.0), factor); + } + else if (slope < vehCliff) { + if (slope > bandingMin) { + factor = 0.5*smoothstep(bandingMin, vehCliff, slope)*(1.0 - (1.0 - smoothstep(vehCliffMinus, vehCliffPlus, slope))*(sin(height/1.6) + 1.0)*0.5); + gl_FragColor = mix(gl_FragColor,vec4(0,0,0,1.0),factor); + } + } + else if (slope < vehCliffEpsilon) { + factor = 0.6+0.4*smoothstep(vehCliffEpsilon, botCliff, slope); + gl_FragColor = mix(gl_FragColor,vec4(0,0,0,1.0),factor); + } + else if (slope < botCliff) { + factor = 0.8+0.2*smoothstep(vehCliffEpsilon, botCliff, slope); + gl_FragColor = mix(gl_FragColor,vec4(0,0,0,1.0),factor); + } +} diff --git a/shaders/map_diffuse_generator.glsl b/shaders/map_diffuse_generator.glsl index 4bb601a..afaf737 100644 --- a/shaders/map_diffuse_generator.glsl +++ b/shaders/map_diffuse_generator.glsl @@ -10,6 +10,8 @@ uniform sampler2D tex8; // ramp texture uniform sampler2D tex9; // cloud grass uniform sampler2D tex10; // cloud grassdark uniform sampler2D tex11; // cloud sand +uniform sampler2D tex12; +uniform sampler2D tex13; uniform float minHeight; uniform float maxHeight; @@ -28,6 +30,7 @@ const float vehCliffEpsilon = 0.492; const float vehCliffPlus = 0.62; const float botCliffMinus = botCliff - 0.06; const float botCliffMinusMinus = 0.65; +const float heightblendFactor = 0.5; vec2 rotate(vec2 v, float a) { float s = sin(a); @@ -36,6 +39,13 @@ vec2 rotate(vec2 v, float a) { return m * v; } +float heightblend(vec4 input1, float height1, vec4 input2, float height2) { + float height_start = max(height1, height2) - heightblendFactor; + float level1 = max(height1 - height_start, 0); + float level2 = max(height2 - height_start, 0); + return ((input1 * level1) + (input2 * level2)) / (level1 + level2); +} + void main() { vec2 coord = vec2(gl_TexCoord[0].s,gl_TexCoord[0].t); @@ -43,7 +53,11 @@ void main() vec2 norm2d = vec2(norm.x, norm.a); float slope = length(norm2d); float factor = 0.0; + float hFactor = 0.0; + float h1 = 0.0; + float h2 = 0.0; float height = texture2D(tex0,coord).r; + vec4 activeColor = (0.0,0.0,0.0,0.0); // tile somewhat coord = 8.0*coord; @@ -88,27 +102,40 @@ void main() factor = 0.6*(1.0 - (1.0 - smoothstep(vehCliffMinus, vehCliffPlus, vehCliff))*(sin(height/1.6) + 1.0)*0.5); factor = factor*(vehCliffEpsilon - slope)/(vehCliffEpsilon - vehCliff) + (1.0 - (vehCliffEpsilon - slope)/(vehCliffEpsilon - vehCliff)); gl_FragColor = mix(gl_FragColor,texture2D(tex2,coord*4.2), 0.7); - gl_FragColor = mix(gl_FragColor,texture2D(tex8,coord*2.7), 0.8); + gl_FragColor = mix(gl_FragColor,texture2D(tex8,coord*2.7), 0.5 + 0.15*smoothstep(vehCliffEpsilon, botCliff, slope)); } else if (slope < botCliff) { gl_FragColor = mix(gl_FragColor,texture2D(tex2,coord*4.2), 0.7); - gl_FragColor = mix(gl_FragColor,texture2D(tex8,coord*2.7), 0.8 + 0.2*smoothstep(vehCliffEpsilon, botCliff, slope)); + gl_FragColor = mix(gl_FragColor,texture2D(tex8,coord*2.7), 0.6 + 0.2*smoothstep(vehCliffEpsilon, botCliff, slope)); if (slope > botCliffMinus) { factor = smoothstep(botCliffMinus, botCliff, slope); gl_FragColor = mix(gl_FragColor,texture2D(tex3,1.0*coord),factor*0.6); } if (slope > botCliffMinusMinus) { - factor = smoothstep(botCliffMinusMinus, botCliff, slope)*0.3; - gl_FragColor = mix(gl_FragColor,texture2D(tex7,2.0*coord*(1.0 + slope*0.01)),factor); + factor = (1.0 - smoothstep(botCliff, 1.0, slope)); + activeColor = texture2D(tex8,coord*2.7); + h1 = texture2D(tex12,coord*2.7).r; + h2 = texture2D(tex13,2.7*coord).r; + if (h2 > h1) { + gl_FragColor = texture2D(tex3,coord*2.7); + } + else { + gl_FragColor = texture2D(tex8,coord*2.7); + } } } else { // admix cliffsides - factor = (1.0 - smoothstep(botCliff, 1.0, slope)); - gl_FragColor = mix(gl_FragColor,texture2D(tex3,1.0*coord),factor); - gl_FragColor = mix(gl_FragColor,texture2D(tex8,coord*1.5), factor*0.5); - gl_FragColor = mix(gl_FragColor,texture2D(tex3,1.0*coord),0.6); - gl_FragColor = mix(gl_FragColor,texture2D(tex2,5.0*coord),factor*0.22); + factor = (1.0 - smoothstep(botCliff, 1.0, slope)); + activeColor = texture2D(tex8,coord*2.7); + h1 = texture2D(tex12,coord*2.7).r; + h2 = texture2D(tex13,2.7*coord).r; + if (h2 > h1) { + gl_FragColor = texture2D(tex3,coord*2.7); + } + else { + gl_FragColor = texture2D(tex8,coord*2.7); + } } // Show mountains over cliffs diff --git a/unittextures/tacticalview/terran/diffuse/cliffs.png b/unittextures/tacticalview/terran/diffuse/cliffs.png index 2c204aa..0886e8d 100644 Binary files a/unittextures/tacticalview/terran/diffuse/cliffs.png and b/unittextures/tacticalview/terran/diffuse/cliffs.png differ diff --git a/unittextures/tacticalview/terran/diffuse/highlands.png b/unittextures/tacticalview/terran/diffuse/highlands.png index d3136bc..9e6f2cf 100644 Binary files a/unittextures/tacticalview/terran/diffuse/highlands.png and b/unittextures/tacticalview/terran/diffuse/highlands.png differ diff --git a/unittextures/tacticalview/terran/height/cliffs.png b/unittextures/tacticalview/terran/height/cliffs.png new file mode 100644 index 0000000..1484cc7 Binary files /dev/null and b/unittextures/tacticalview/terran/height/cliffs.png differ diff --git a/unittextures/tacticalview/terran/height/ramps.png b/unittextures/tacticalview/terran/height/ramps.png new file mode 100644 index 0000000..34e6fed Binary files /dev/null and b/unittextures/tacticalview/terran/height/ramps.png differ diff --git a/unittextures/tacticalview/terran/height/slopes.png b/unittextures/tacticalview/terran/height/slopes.png new file mode 100644 index 0000000..651be22 Binary files /dev/null and b/unittextures/tacticalview/terran/height/slopes.png differ diff --git a/unittextures/tacticalview/terran/specular/cliffs.png b/unittextures/tacticalview/terran/specular/cliffs.png index a03ddd3..a62fc2b 100644 Binary files a/unittextures/tacticalview/terran/specular/cliffs.png and b/unittextures/tacticalview/terran/specular/cliffs.png differ diff --git a/unittextures/tacticalview/terran/specular/ramps.png b/unittextures/tacticalview/terran/specular/ramps.png index 9656640..4a858ca 100644 Binary files a/unittextures/tacticalview/terran/specular/ramps.png and b/unittextures/tacticalview/terran/specular/ramps.png differ