Minor graphics fixes
This commit is contained in:
parent
cb58d2dcfa
commit
5a048eb7ea
|
@ -40,10 +40,10 @@ function Client.init()
|
||||||
scheduleEvent(function()
|
scheduleEvent(function()
|
||||||
g_window.show()
|
g_window.show()
|
||||||
|
|
||||||
-- play startup music
|
-- Play startup music (The Silver Tree, by Mattias Westlund)
|
||||||
--g_sounds.playMusic("startup.ogg", 3)
|
g_sounds.playMusic("startup.ogg", 3)
|
||||||
--connect(g_game, { onGameStart = function() g_sounds.stopMusic(3) end })
|
connect(g_game, { onGameStart = function() g_sounds.stopMusic(3) end })
|
||||||
--connect(g_game, { onGameEnd= function() g_sounds.playMusic("startup.ogg", 3) end })
|
connect(g_game, { onGameEnd= function() g_sounds.playMusic("startup.ogg", 3) end })
|
||||||
end, 0)
|
end, 0)
|
||||||
end, 0)
|
end, 0)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
local skin = {
|
local skin = {
|
||||||
name = 'Example',
|
name = 'Example',
|
||||||
|
|
||||||
styles = {
|
styles = {
|
||||||
'topmenu.otui'
|
'topmenu.otui'
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ local shadersPanel
|
||||||
function Shaders.init()
|
function Shaders.init()
|
||||||
importStyle 'shaders.otui'
|
importStyle 'shaders.otui'
|
||||||
|
|
||||||
|
|
||||||
Keyboard.bindKeyDown(HOTKEY, Shaders.toggle)
|
Keyboard.bindKeyDown(HOTKEY, Shaders.toggle)
|
||||||
|
|
||||||
shadersPanel = createWidget('ShadersPanel', GameInterface.getMapPanel())
|
shadersPanel = createWidget('ShadersPanel', GameInterface.getMapPanel())
|
||||||
|
@ -37,6 +36,8 @@ function Shaders.init()
|
||||||
map:setMapShader(g_shaders.getShader(option))
|
map:setMapShader(g_shaders.getShader(option))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not g_graphics.canUseShaders() then return end
|
||||||
|
|
||||||
for _i,opts in pairs(MAP_SHADERS) do
|
for _i,opts in pairs(MAP_SHADERS) do
|
||||||
local shader = g_shaders.createFragmentShader(opts.name, opts.frag)
|
local shader = g_shaders.createFragmentShader(opts.name, opts.frag)
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,6 @@ const float sampleStrength = 2.2;
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
// some sample positions
|
|
||||||
float samples[] = { -0.08,-0.05,-0.03,-0.02,-0.01,0.01,0.02,0.03,0.05,0.08 };
|
|
||||||
|
|
||||||
// 0.5,0.5 is the center of the screen
|
// 0.5,0.5 is the center of the screen
|
||||||
// so substracting v_TexCoord from it will result in
|
// so substracting v_TexCoord from it will result in
|
||||||
// a vector pointing to the middle of the screen
|
// a vector pointing to the middle of the screen
|
||||||
|
@ -29,8 +26,16 @@ void main(void)
|
||||||
|
|
||||||
// take 10 additional blur samples in the direction towards
|
// take 10 additional blur samples in the direction towards
|
||||||
// the center of the screen
|
// the center of the screen
|
||||||
for(int i = 0; i < 10; i++)
|
sum += texture2D(u_Tex0, v_TexCoord - 0.08 * dir * sampleDist);
|
||||||
sum += texture2D(u_Tex0, v_TexCoord + dir * samples[i] * sampleDist);
|
sum += texture2D(u_Tex0, v_TexCoord - 0.05 * dir * sampleDist);
|
||||||
|
sum += texture2D(u_Tex0, v_TexCoord - 0.03 * dir * sampleDist);
|
||||||
|
sum += texture2D(u_Tex0, v_TexCoord - 0.02 * dir * sampleDist);
|
||||||
|
sum += texture2D(u_Tex0, v_TexCoord - 0.01 * dir * sampleDist);
|
||||||
|
sum += texture2D(u_Tex0, v_TexCoord + 0.01 * dir * sampleDist);
|
||||||
|
sum += texture2D(u_Tex0, v_TexCoord + 0.02 * dir * sampleDist);
|
||||||
|
sum += texture2D(u_Tex0, v_TexCoord + 0.03 * dir * sampleDist);
|
||||||
|
sum += texture2D(u_Tex0, v_TexCoord + 0.05 * dir * sampleDist);
|
||||||
|
sum += texture2D(u_Tex0, v_TexCoord + 0.08 * dir * sampleDist);
|
||||||
|
|
||||||
// we have taken eleven samples
|
// we have taken eleven samples
|
||||||
sum *= 1.0/11.0;
|
sum *= 1.0/11.0;
|
||||||
|
@ -42,4 +47,4 @@ void main(void)
|
||||||
|
|
||||||
//Blend the original color with the averaged pixels
|
//Blend the original color with the averaged pixels
|
||||||
gl_FragColor = mix(color, sum, t);
|
gl_FragColor = mix(color, sum, t);
|
||||||
}
|
}
|
|
@ -23,6 +23,8 @@
|
||||||
#include "painter.h"
|
#include "painter.h"
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
|
|
||||||
|
#include <framework/platform/platformwindow.h>
|
||||||
|
|
||||||
Painter *g_painter = nullptr;
|
Painter *g_painter = nullptr;
|
||||||
|
|
||||||
Painter::Painter()
|
Painter::Painter()
|
||||||
|
@ -35,6 +37,7 @@ Painter::Painter()
|
||||||
m_shaderProgram = nullptr;
|
m_shaderProgram = nullptr;
|
||||||
m_texture = nullptr;
|
m_texture = nullptr;
|
||||||
m_alphaWriting = false;
|
m_alphaWriting = false;
|
||||||
|
setResolution(g_window.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Painter::resetState()
|
void Painter::resetState()
|
||||||
|
@ -50,11 +53,11 @@ void Painter::resetState()
|
||||||
|
|
||||||
void Painter::refreshState()
|
void Painter::refreshState()
|
||||||
{
|
{
|
||||||
|
updateGlViewport();
|
||||||
updateGlCompositionMode();
|
updateGlCompositionMode();
|
||||||
updateGlClipRect();
|
updateGlClipRect();
|
||||||
updateGlTexture();
|
updateGlTexture();
|
||||||
updateGlAlphaWriting();
|
updateGlAlphaWriting();
|
||||||
updateGlViewport();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Painter::saveState()
|
void Painter::saveState()
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef OPENGL_ES
|
#if !defined(OPENGL_ES) || OPENGL_ES==1
|
||||||
|
|
||||||
#include "painterogl1.h"
|
#include "painterogl1.h"
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
|
|
|
@ -562,6 +562,7 @@ void Application::registerLuaFunctions()
|
||||||
g_lua.bindSingletonFunction("g_graphics", "isPainterEngineAvailable", &Graphics::isPainterEngineAvailable, &g_graphics);
|
g_lua.bindSingletonFunction("g_graphics", "isPainterEngineAvailable", &Graphics::isPainterEngineAvailable, &g_graphics);
|
||||||
g_lua.bindSingletonFunction("g_graphics", "selectPainterEngine", &Graphics::selectPainterEngine, &g_graphics);
|
g_lua.bindSingletonFunction("g_graphics", "selectPainterEngine", &Graphics::selectPainterEngine, &g_graphics);
|
||||||
g_lua.bindSingletonFunction("g_graphics", "canCacheBackbuffer", &Graphics::canCacheBackbuffer, &g_graphics);
|
g_lua.bindSingletonFunction("g_graphics", "canCacheBackbuffer", &Graphics::canCacheBackbuffer, &g_graphics);
|
||||||
|
g_lua.bindSingletonFunction("g_graphics", "canUseShaders", &Graphics::canUseShaders, &g_graphics);
|
||||||
g_lua.bindSingletonFunction("g_graphics", "getPainterEngine", &Graphics::getPainterEngine, &g_graphics);
|
g_lua.bindSingletonFunction("g_graphics", "getPainterEngine", &Graphics::getPainterEngine, &g_graphics);
|
||||||
g_lua.bindSingletonFunction("g_graphics", "getViewportSize", &Graphics::getViewportSize, &g_graphics);
|
g_lua.bindSingletonFunction("g_graphics", "getViewportSize", &Graphics::getViewportSize, &g_graphics);
|
||||||
g_lua.bindSingletonFunction("g_graphics", "getVendor", &Graphics::getVendor, &g_graphics);
|
g_lua.bindSingletonFunction("g_graphics", "getVendor", &Graphics::getVendor, &g_graphics);
|
||||||
|
|
Loading…
Reference in New Issue