Skip to content
Snippets Groups Projects
Commit 223d801e authored by DarkGod's avatar DarkGod
Browse files

Fixed multiple shader effects on Intel & AMD GPUs

parent 1ad3ab2f
No related branches found
No related tags found
No related merge requests found
......@@ -123,6 +123,11 @@ function _M:getFragment(name)
code[#code+1] = l
end
f:close()
-- if config.settings.cheat then
-- print("====== FRAG")
-- local nb = 1 for line in table.concat(code):gmatch("([^\n]*)\n") do print(nb, line) nb = nb + 1 end
-- print("======")
-- end
self.frags[name] = core.shader.newShader(table.concat(code))
print("[SHADER] created fragment shader from /data/gfx/shaders/"..name..".frag")
return self.frags[name]
......@@ -139,6 +144,11 @@ function _M:getVertex(name)
code[#code+1] = l
end
f:close()
-- if config.settings.cheat then
-- print("====== VERT")
-- local nb = 1 for line in table.concat(code):gmatch("([^\n]*)\n") do print(nb, line) nb = nb + 1 end
-- print("======")
-- end
self.verts[name] = core.shader.newShader(table.concat(code), true)
print("[SHADER] created vertex shader from /data/gfx/shaders/"..name..".vert")
return self.verts[name]
......
......@@ -50,14 +50,15 @@ vec4 GetColor(const int layerIndex, vec2 texPos)
vec2 GetDistortion(vec2 texPos, int layerIndex, int distortionType, float deformRate)
{
float layerIndexF = float(layerIndex);
if (distortionType == 0) {
float alpha = 0.2 * sin(tick / time_factor * (layerIndex * 0.5 + 1.0) + layerIndex * 100.0) * deformRate;
float alpha = 0.2 * sin(tick / time_factor * (layerIndexF * 0.5 + 1.0) + layerIndexF * 100.0) * deformRate;
mat2 rotation = mat2(cos(alpha), sin(alpha), -sin(alpha), cos(alpha));
return clamp(rotation * (texPos - vec2(0.5)) + vec2(0.5), 0.01, 0.99);
} else if (distortionType == 1) {
float phase = length(texPos - vec2(0.5));
float alpha = 0.2 * sin(-tick / time_factor * (layerIndex * 0.5 + 1.0) + phase * 30.0 + layerIndex * 100.0) * deformRate;
float alpha = 0.2 * sin(-tick / time_factor * (layerIndexF * 0.5 + 1.0) + phase * 30.0 + layerIndexF * 100.0) * deformRate;
mat2 rotation = mat2(cos(alpha), sin(alpha), -sin(alpha), cos(alpha));
return clamp(rotation * (texPos - vec2(0.5)) + vec2(0.5), 0.01, 0.99);
......@@ -83,8 +84,8 @@ void main(void)
int backLayersCount = int(backgroundLayersCount + 0.5);
for(int layerIndex = 0; layerIndex < 4; layerIndex++)
{
if(noup == 1 && layerIndex < backLayersCount) continue;
if(noup == 2 && layerIndex >= backLayersCount) continue;
if(noup == 1.0 && layerIndex < backLayersCount) continue;
if(noup == 2.0 && layerIndex >= backLayersCount) continue;
float deformRate = GetDistortionRange(layerIndex, pos);
vec2 texPos = GetDistortion(pos, layerIndex, distortionType, deformRate);
vec4 layerColor = GetColor(layerIndex, texPos);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment