From 22f6061cc6edae24bf6ea0dae6e2cded5f6d153a Mon Sep 17 00:00:00 2001 From: DarkGod <darkgod@net-core.org> Date: Mon, 15 Jul 2013 00:14:46 +0200 Subject: [PATCH] New starfield shader is hungry, so a new video option to enable volumetric shaders is added. It is *off by default*, turn it on if you trust your GPU :) --- .../default/engine/dialogs/VideoOptions.lua | 9 +++++++++ game/engines/default/engine/init.lua | 1 + .../data/general/events/fearscape-portal.lua | 2 +- .../tome/data/zones/abashed-expanse/zone.lua | 2 +- .../tome/data/zones/eidolon-plane/zone.lua | 17 ++++++++++------- .../tome/data/zones/paradox-plane/zone.lua | 14 ++++++++++++-- .../data/zones/stellar-system-shandral/zone.lua | 2 +- .../tome/data/zones/temporal-rift/zone.lua | 14 ++++++++++++-- .../tome/data/zones/town-point-zero/zone.lua | 14 ++++++++++++-- .../tome/data/zones/unhallowed-morass/zone.lua | 14 ++++++++++++-- game/modules/tome/data/zones/void/zone.lua | 14 ++++++++++++-- game/modules/tome/dialogs/DeathDialog.lua | 2 +- 12 files changed, 84 insertions(+), 21 deletions(-) diff --git a/game/engines/default/engine/dialogs/VideoOptions.lua b/game/engines/default/engine/dialogs/VideoOptions.lua index 8f538f2fd6..5feeb6280c 100644 --- a/game/engines/default/engine/dialogs/VideoOptions.lua +++ b/game/engines/default/engine/dialogs/VideoOptions.lua @@ -140,6 +140,15 @@ function _M:generateList() self.c_list:drawItem(item) end,} + local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Activates volumetric shaders.\nThis option allows for volumetricion effects (like deep starfields). Enabling it will severely reduce performance when shaders are displayed.\n\n#LIGHT_RED#You must restart the game for it to take effect.#WHITE#"} + list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#OpenGL Shaders: Volumetricions#WHITE##{normal}#", status=function(item) + return tostring(config.settings.shaders_kind_volumetric and "enabled" or "disabled") + end, fct=function(item) + config.settings.shaders_kind_volumetric = not config.settings.shaders_kind_volumetric + game:saveSettings("shaders_kind_volumetric", ("shaders_kind_volumetric = %s\n"):format(tostring(config.settings.shaders_kind_volumetric))) + self.c_list:drawItem(item) + end,} + local zone = Textzone.new{width=self.c_desc.w, height=self.c_desc.h, text=string.toTString"Use the custom cursor.\nDisabling it will use your normal operating system cursor.#WHITE#"} list[#list+1] = { zone=zone, name=string.toTString"#GOLD##{bold}#Mouse cursor#WHITE##{normal}#", status=function(item) return tostring(config.settings.mouse_cursor and "enabled" or "disabled") diff --git a/game/engines/default/engine/init.lua b/game/engines/default/engine/init.lua index 87d32f71e9..04f366f9b2 100644 --- a/game/engines/default/engine/init.lua +++ b/game/engines/default/engine/init.lua @@ -55,6 +55,7 @@ fbo_active = true shaders_active = true shaders_kind_distort = true shaders_kind_adv = true +shaders_kind_volumetric = false particles_density = 100 background_saves = false mouse_cursor = true diff --git a/game/modules/tome/data/general/events/fearscape-portal.lua b/game/modules/tome/data/general/events/fearscape-portal.lua index cb7cef7ae9..d013d12e6e 100644 --- a/game/modules/tome/data/general/events/fearscape-portal.lua +++ b/game/modules/tome/data/general/events/fearscape-portal.lua @@ -85,7 +85,7 @@ local changer = function(id) post_process = function(level) local Map = require "engine.Map" local Quadratic = require "engine.Quadratic" - if core.shader.allow("adv") then + if core.shader.allow("volumetric") then level.starfield_shader = require("engine.Shader").new("starfield", {size={Map.viewport.width, Map.viewport.height}}) else level.background_particle1 = require("engine.Particles").new("starfield_static", 1, {width=Map.viewport.width, height=Map.viewport.height, nb=300, a_min=0.5, a_max = 0.8, size_min = 1, size_max = 3}) diff --git a/game/modules/tome/data/zones/abashed-expanse/zone.lua b/game/modules/tome/data/zones/abashed-expanse/zone.lua index c27cf1b0f8..32053fd0ae 100644 --- a/game/modules/tome/data/zones/abashed-expanse/zone.lua +++ b/game/modules/tome/data/zones/abashed-expanse/zone.lua @@ -228,7 +228,7 @@ return { post_process = function(level) local Map = require "engine.Map" local Quadratic = require "engine.Quadratic" - if core.shader.allow("adv") then + if core.shader.allow("volumetric") then level.starfield_shader = require("engine.Shader").new("starfield", {size={Map.viewport.width, Map.viewport.height}}) else level.background_particle1 = require("engine.Particles").new("starfield_static", 1, {width=Map.viewport.width, height=Map.viewport.height, nb=300, a_min=0.5, a_max = 0.8, size_min = 1, size_max = 3}) diff --git a/game/modules/tome/data/zones/eidolon-plane/zone.lua b/game/modules/tome/data/zones/eidolon-plane/zone.lua index 1bac2a1823..62acdcc76d 100644 --- a/game/modules/tome/data/zones/eidolon-plane/zone.lua +++ b/game/modules/tome/data/zones/eidolon-plane/zone.lua @@ -22,7 +22,7 @@ return { level_range = {1, 1}, level_scheme = "player", max_level = 1, - width = 10, height = 10, + width = 50, height = 50, all_remembered = true, all_lited = true, no_worldport = true, @@ -33,26 +33,29 @@ return { ambient_music = "Alchemist.ogg", generator = { map = { - class = "engine.generator.map.Forest", + class = "engine.generator.map.Empty", noise = "fbm_perlin", floor = "VOID", - wall = "VOID", up = "VOID", - down = "VOID", }, actor = { class = "mod.class.generator.actor.Random", nb_npc = {0, 0}, - guardian = "EIDOLON", }, }, effects = {"EFF_EIDOLON_PROTECT"}, - post_process = function(level) + post_process = function(level, zone) + local eidolon = zone:makeEntityByName(level, "actor", "EIDOLON", true) + if eidolon then zone:addEntity(level, eidolon, "actor", 25, 25) end + + level.default_up = {x=22, y=25} + level.default_down = {x=22, y=25} + if level.level == 1 then local Map = require "engine.Map" - if core.shader.allow("adv") then + if core.shader.allow("volumetric") then level.starfield_shader = require("engine.Shader").new("starfield", {size={Map.viewport.width, Map.viewport.height}, speed=200}) else level.background_particle = require("engine.Particles").new("starfield", 1, {width=Map.viewport.width, height=Map.viewport.height}) diff --git a/game/modules/tome/data/zones/paradox-plane/zone.lua b/game/modules/tome/data/zones/paradox-plane/zone.lua index 4397628f5a..1474f5be59 100644 --- a/game/modules/tome/data/zones/paradox-plane/zone.lua +++ b/game/modules/tome/data/zones/paradox-plane/zone.lua @@ -66,7 +66,11 @@ return { post_process = function(level) local Map = require "engine.Map" - level.background_particle = require("engine.Particles").new("starfield", 1, {width=Map.viewport.width, height=Map.viewport.height}) + if core.shader.allow("volumetric") then + level.starfield_shader = require("engine.Shader").new("starfield", {size={Map.viewport.width, Map.viewport.height}}) + else + level.background_particle = require("engine.Particles").new("starfield", 1, {width=Map.viewport.width, height=Map.viewport.height}) + end end, portal_next = function(npc) @@ -83,6 +87,12 @@ return { if level.level ~= 1 then return end local Map = require "engine.Map" - level.background_particle.ps:toScreen(x, y, true, 1) + if level.starfield_shader and level.starfield_shader.shad then + level.starfield_shader.shad:use(true) + core.display.drawQuad(x, y, Map.viewport.width, Map.viewport.height, 1, 1, 1, 1) + level.starfield_shader.shad:use(false) + elseif level.background_particle then + level.background_particle.ps:toScreen(x, y, true, 1) + end end, } diff --git a/game/modules/tome/data/zones/stellar-system-shandral/zone.lua b/game/modules/tome/data/zones/stellar-system-shandral/zone.lua index 598c35e54e..daca37d38c 100644 --- a/game/modules/tome/data/zones/stellar-system-shandral/zone.lua +++ b/game/modules/tome/data/zones/stellar-system-shandral/zone.lua @@ -44,7 +44,7 @@ return { post_process = function(level) local Map = require "engine.Map" - if core.shader.allow("adv") then + if core.shader.allow("volumetric") then level.starfield_shader = require("engine.Shader").new("starfield", {size={Map.viewport.width, Map.viewport.height}}) else level.background_particle1 = require("engine.Particles").new("starfield_static", 1, {width=Map.viewport.width, height=Map.viewport.height, nb=300, a_min=0.5, a_max = 0.8, size_min = 1, size_max = 3}) diff --git a/game/modules/tome/data/zones/temporal-rift/zone.lua b/game/modules/tome/data/zones/temporal-rift/zone.lua index ea8ed1a277..b0b5b420e6 100644 --- a/game/modules/tome/data/zones/temporal-rift/zone.lua +++ b/game/modules/tome/data/zones/temporal-rift/zone.lua @@ -113,7 +113,11 @@ return { post_process = function(level) if level.level == 1 then local Map = require "engine.Map" - level.background_particle = require("engine.Particles").new("starfield", 1, {width=Map.viewport.width, height=Map.viewport.height}) + if core.shader.allow("volumetric") then + level.starfield_shader = require("engine.Shader").new("starfield", {size={Map.viewport.width, Map.viewport.height}}) + else + level.background_particle = require("engine.Particles").new("starfield", 1, {width=Map.viewport.width, height=Map.viewport.height}) + end end if level.level <= 2 then @@ -165,6 +169,12 @@ return { if level.level ~= 1 then return end local Map = require "engine.Map" - level.background_particle.ps:toScreen(x, y, true, 1) + if level.starfield_shader and level.starfield_shader.shad then + level.starfield_shader.shad:use(true) + core.display.drawQuad(x, y, Map.viewport.width, Map.viewport.height, 1, 1, 1, 1) + level.starfield_shader.shad:use(false) + elseif level.background_particle then + level.background_particle.ps:toScreen(x, y, true, 1) + end end, } diff --git a/game/modules/tome/data/zones/town-point-zero/zone.lua b/game/modules/tome/data/zones/town-point-zero/zone.lua index e160c10a58..da0e7f7e9e 100644 --- a/game/modules/tome/data/zones/town-point-zero/zone.lua +++ b/game/modules/tome/data/zones/town-point-zero/zone.lua @@ -66,7 +66,11 @@ return { -- Cosmetic stuff local Map = require "engine.Map" - level.background_particle = require("engine.Particles").new("starfield", 1, {width=Map.viewport.width, height=Map.viewport.height}) + if core.shader.allow("volumetric") then + level.starfield_shader = require("engine.Shader").new("starfield", {size={Map.viewport.width, Map.viewport.height}}) + else + level.background_particle = require("engine.Particles").new("starfield", 1, {width=Map.viewport.width, height=Map.viewport.height}) + end game.state:makeWeather(level, 6, {max_nb=12, chance=1, dir=120, speed={1.5, 5.9}, r=0.2, g=0.4, b=1, alpha={0.2, 0.4}, particle_name="weather/grey_cloud_%02d"}) @@ -134,7 +138,13 @@ return { background = function(level, x, y, nb_keyframes) local Map = require "engine.Map" - level.background_particle.ps:toScreen(x, y, true, 1) + if level.starfield_shader and level.starfield_shader.shad then + level.starfield_shader.shad:use(true) + core.display.drawQuad(x, y, Map.viewport.width, Map.viewport.height, 1, 1, 1, 1) + level.starfield_shader.shad:use(false) + elseif level.background_particle then + level.background_particle.ps:toScreen(x, y, true, 1) + end end, foreground = function(level, x, y, nb_keyframes) diff --git a/game/modules/tome/data/zones/unhallowed-morass/zone.lua b/game/modules/tome/data/zones/unhallowed-morass/zone.lua index ff7f1bb61c..1a7600c193 100644 --- a/game/modules/tome/data/zones/unhallowed-morass/zone.lua +++ b/game/modules/tome/data/zones/unhallowed-morass/zone.lua @@ -62,7 +62,11 @@ return { post_process = function(level) local Map = require "engine.Map" - level.background_particle = require("engine.Particles").new("starfield", 1, {width=Map.viewport.width, height=Map.viewport.height}) + if core.shader.allow("volumetric") then + level.starfield_shader = require("engine.Shader").new("starfield", {size={Map.viewport.width, Map.viewport.height}}) + else + level.background_particle = require("engine.Particles").new("starfield", 1, {width=Map.viewport.width, height=Map.viewport.height}) + end game.state:makeWeather(level, 6, {max_nb=12, chance=1, dir=120, speed={1.5, 5.9}, r=0.2, g=0.4, b=1, alpha={0.2, 0.4}, particle_name="weather/grey_cloud_%02d"}) @@ -74,7 +78,13 @@ return { background = function(level, x, y, nb_keyframes) local Map = require "engine.Map" - level.background_particle.ps:toScreen(x, y, true, 1) + if level.starfield_shader and level.starfield_shader.shad then + level.starfield_shader.shad:use(true) + core.display.drawQuad(x, y, Map.viewport.width, Map.viewport.height, 1, 1, 1, 1) + level.starfield_shader.shad:use(false) + elseif level.background_particle then + level.background_particle.ps:toScreen(x, y, true, 1) + end end, foreground = function(level, x, y, nb_keyframes) diff --git a/game/modules/tome/data/zones/void/zone.lua b/game/modules/tome/data/zones/void/zone.lua index c26f9532e9..499cd89d7e 100644 --- a/game/modules/tome/data/zones/void/zone.lua +++ b/game/modules/tome/data/zones/void/zone.lua @@ -55,11 +55,21 @@ return { post_process = function(level) local Map = require "engine.Map" - level.background_particle = require("engine.Particles").new("starfield", 1, {width=Map.viewport.width, height=Map.viewport.height}) + if core.shader.allow("volumetric") then + level.starfield_shader = require("engine.Shader").new("starfield", {size={Map.viewport.width, Map.viewport.height}}) + else + level.background_particle = require("engine.Particles").new("starfield", 1, {width=Map.viewport.width, height=Map.viewport.height}) + end end, background = function(level, x, y, nb_keyframes) local Map = require "engine.Map" - level.background_particle.ps:toScreen(x, y, true, 1) + if level.starfield_shader and level.starfield_shader.shad then + level.starfield_shader.shad:use(true) + core.display.drawQuad(x, y, Map.viewport.width, Map.viewport.height, 1, 1, 1, 1) + level.starfield_shader.shad:use(false) + elseif level.background_particle then + level.background_particle.ps:toScreen(x, y, true, 1) + end end, } diff --git a/game/modules/tome/dialogs/DeathDialog.lua b/game/modules/tome/dialogs/DeathDialog.lua index 28435569d9..d61bb3941d 100644 --- a/game/modules/tome/dialogs/DeathDialog.lua +++ b/game/modules/tome/dialogs/DeathDialog.lua @@ -173,7 +173,7 @@ function _M:eidolonPlane() game.zone_name_s = nil for _, act in ipairs(acts) do - local x, y = util.findFreeGrid(5, 5, 20, true, {[Map.ACTOR]=true}) + local x, y = util.findFreeGrid(23, 25, 20, true, {[Map.ACTOR]=true}) if x then level:addEntity(act) act:move(x, y, true) -- GitLab