many changes

* Fixes in WIN32 platform
* Remove unused files
* Make StaticText work more like tibia
* Fix WIN32 compilation
* Fix regression in framebuffers that caused battle to disappear
* Shader fixes for DX9
* Add two new shaders: noise and heat
This commit is contained in:
Eduardo Bart
2012-06-15 19:18:30 -03:00
parent 10b60a3871
commit 4813b7eb4b
19 changed files with 203 additions and 177 deletions

View File

@@ -1,11 +0,0 @@
uniform float opacity; // painter opacity
uniform vec4 color; // painter color
uniform float time; // time in seconds since shader linkage
uniform sampler2D tex0; // map texture
varying vec2 texCoord; // map texture coords
//uniform int itemId; // item id
void main()
{
gl_FragColor = texture2D(tex0, texCoord);
}

View File

@@ -1,62 +0,0 @@
uniform float opacity; // painter opacity
uniform vec4 color; // painter color
uniform float time; // time in seconds since shader linkage
uniform sampler2D tex0; // outfit texture
uniform sampler2D tex1; // outfit color mask
varying vec2 texCoord; // outfit texture coords
uniform vec4 headColor;
uniform vec4 bodyColor;
uniform vec4 legsColor;
uniform vec4 feetColor;
vec4 calcOutfitPixel()
{
vec4 pixel = texture2D(tex0, texCoord);
vec4 maskColor = texture2D(tex1, texCoord);
vec4 outColor = vec4(1.0, 1.0, 1.0, 1.0);
if(maskColor.r > 0.1 && maskColor.g > 0.1)
outColor = headColor;
else if(maskColor.r > 0.1)
outColor = bodyColor;
else if(maskColor.g > 0.1)
outColor = legsColor;
else if(maskColor.b > 0.1)
outColor = feetColor;
return pixel * outColor;
}
/*
// optimized to handle antialising
vec4 calcOutfitPixel()
{
vec4 pixel = texture2D(texture, textureCoords);
vec4 maskColor = texture2D(maskTexture, textureCoords);
const vec4 white = vec4(1,1,1,1);
float headFactor = 0.0;
if(maskColor.r > 0.1 && maskColor.g > 0.1) {
headFactor = min(maskColor.r, maskColor.g);
maskColor.r -= headFactor;
maskColor.g -= headFactor;
}
float tot = headFactor + maskColor.r + maskColor.g + maskColor.b;
vec4 outColor = headFactor * headColor + bodyColor * maskColor.r + legsColor * maskColor.g + feetColor * maskColor.b;
if(tot < 1.0)
outColor += white * (1.0 - tot);
outColor.a = 1.0;
return pixel * outColor;
}
*/
void main()
{
gl_FragColor = calcOutfitPixel();
}

View File

@@ -1,17 +1,23 @@
Shaders = {}
local HOTKEY = 'Ctrl+X'
local SHADERS = {
['Default'] = 'shaders/default.frag',
['Bloom'] = 'shaders/bloom.frag',
['Sepia'] = 'shaders/sepia.frag',
['Grayscale'] = 'shaders/grayscale.frag',
['Pulse'] = 'shaders/pulse.frag',
['Old Tv'] = 'shaders/oldtv.frag',
['Fog'] = 'shaders/fog.frag',
['Party'] = 'shaders/party.frag',
['Radial Blur'] = 'shaders/radialblur.frag',
['Zomg'] = 'shaders/zomg.frag',
local MAP_SHADERS = {
{ name = 'Default', frag = 'shaders/default.frag' },
{ name = 'Bloom', frag = 'shaders/bloom.frag'},
{ name = 'Sepia', frag ='shaders/sepia.frag' },
{ name = 'Grayscale', frag ='shaders/grayscale.frag' },
{ name = 'Pulse', frag = 'shaders/pulse.frag' },
{ name = 'Old Tv', frag = 'shaders/oldtv.frag' },
{ name = 'Fog', frag = 'shaders/fog.frag', tex1 = 'images/clouds.png' },
{ name = 'Party', frag = 'shaders/party.frag' },
{ name = 'Radial Blur', frag ='shaders/radialblur.frag' },
{ name = 'Zomg', frag ='shaders/zomg.frag' },
{ name = 'Heat', frag ='shaders/heat.frag' },
{ name = 'Noise', frag ='shaders/noise.frag' },
}
local ITEM_SHADERS = {
{ name = 'Fake 3D', vert = 'shaders/fake3d.vert' }
}
local shadersPanel
@@ -29,16 +35,19 @@ function Shaders.init()
mapComboBox.onOptionChange = function(combobox, option)
local map = GameInterface.getMapPanel()
map:setMapShader(g_shaders.getShader(option))
print(option)
end
for name,file in pairs(SHADERS) do
local shader = g_shaders.createFragmentShader(name, file)
mapComboBox:addOption(name)
for _i,opts in pairs(MAP_SHADERS) do
local shader = g_shaders.createFragmentShader(opts.name, opts.frag)
if name == 'Fog' then
shader:addMultiTexture('images/clouds.png')
if opts.tex1 then
shader:addMultiTexture(opts.tex1)
end
if opts.tex2 then
shader:addMultiTexture(opts.tex2)
end
mapComboBox:addOption(opts.name)
end
local map = GameInterface.getMapPanel()

View File

@@ -0,0 +1,56 @@
uniform sampler2D u_Tex0;
varying vec2 v_TexCoord;
uniform float u_Time;
uniform vec2 u_Resolution;
const float PI = 3.1415926535897932;
// speed
const float speed = 0.06;
const float speed_x = 0.03;
const float speed_y = 0.02;
// geometry
const float intensity = 30.;
const int steps = 5;
const float frequency = 3.0;
const int angle = 7; // better when a prime
// reflection and emboss
const float delta = 100.;
const float intence = 1.2;
const float emboss = 0.1;
//---------- crystals effect
float col(vec2 coord)
{
float delta_theta = 2.0 * PI / float(angle);
float col = 0.0;
float theta = 0.0;
for(int i = 0; i < steps; i++) {
vec2 adjc = coord;
theta = delta_theta*float(i);
adjc.x += cos(theta)*u_Time*speed + u_Time * speed_x;
adjc.y -= sin(theta)*u_Time*speed - u_Time * speed_y;
col = col + cos( (adjc.x*cos(theta) - adjc.y*sin(theta))*frequency)*intensity;
}
return cos(col);
}
void main(void)
{
vec2 p = v_TexCoord, c1 = p, c2 = p;
float cc1 = col(c1);
c2.x += u_Resolution.x/delta;
float dx = emboss*(cc1-col(c2))/delta;
c2.x = p.x;
c2.y += u_Resolution.y/delta;
float dy = emboss*(cc1-col(c2))/delta;
c1.x += dx;
c1.y += dy;
float alpha = 1.+dot(dx,dy)*intence;
gl_FragColor = texture2D(u_Tex0,c1)*(alpha);
}

View File

@@ -0,0 +1,56 @@
uniform sampler2D u_Tex0;
varying vec2 v_TexCoord;
uniform float u_Time;
uniform vec2 u_Resolution;
const float PI = 3.1415926535897932;
// speed
const float speed = 0.16;
const float speed_x = 0.13;
const float speed_y = 0.12;
// geometry
const float intensity = 100.;
const int steps = 3;
const float frequency = 100.0;
const int angle = 7; // better when a prime
// reflection and emboss
const float delta = 1000.;
const float intence = 10.2;
const float emboss = 1.;
//---------- crystals effect
float col(vec2 coord)
{
float delta_theta = 2.0 * PI / float(angle);
float col = 0.0;
float theta = 0.0;
for(int i = 0; i < steps; i++) {
vec2 adjc = coord;
theta = delta_theta*float(i);
adjc.x += cos(theta)*u_Time*speed + u_Time * speed_x;
adjc.y -= sin(theta)*u_Time*speed - u_Time * speed_y;
col = col + cos( (adjc.x*cos(theta) - adjc.y*sin(theta))*frequency)*intensity;
}
return cos(col);
}
void main(void)
{
vec2 p = v_TexCoord, c1 = p, c2 = p;
float cc1 = col(c1);
c2.x += u_Resolution.x/delta;
float dx = emboss*(cc1-col(c2))/delta;
c2.x = p.x;
c2.y += u_Resolution.y/delta;
float dy = emboss*(cc1-col(c2))/delta;
c1.x += dx;
c1.y += dy;
float alpha = 1.+dot(dx,dy)*intence;
gl_FragColor = texture2D(u_Tex0,c1)*(alpha);
}

View File

@@ -5,9 +5,9 @@ varying vec2 v_TexCoord;
void main()
{
vec4 col = texture2D(u_Tex0, v_TexCoord);
float d = u_Time * 2;
float d = u_Time * 2.0;
col.x += (1.0 + sin(d))*0.25;
col.y += (1.0 + sin(d*2))*0.25;
col.z += (1.0 + sin(d*4))*0.25;
col.y += (1.0 + sin(d*2.0))*0.25;
col.z += (1.0 + sin(d*4.0))*0.25;
gl_FragColor = col;
}

View File

@@ -8,8 +8,7 @@ const float sampleStrength = 2.2;
void main(void)
{
// some sample positions
float samples[10] =
float[](-0.08,-0.05,-0.03,-0.02,-0.01,0.01,0.02,0.03,0.05,0.08);
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
// so substracting v_TexCoord from it will result in

View File

@@ -14,7 +14,7 @@ TopCenterLabel < UILabel
anchors.top: parent.top
anchors.bottom: centerTextMessagePanel.top
anchors.horizontalCenter: parent.horizontalCenter
width: 360
width: 275
BottomLabel < CenterLabel
anchors.bottom: parent.bottom