Remove legacy OpenGL support.
This commit is contained in:
@@ -20,13 +20,12 @@ namespace OpenRA
|
||||
Automatic,
|
||||
ANGLE,
|
||||
Modern,
|
||||
Embedded,
|
||||
Legacy
|
||||
Embedded
|
||||
}
|
||||
|
||||
public interface IPlatform
|
||||
{
|
||||
IPlatformWindow CreateWindow(Size size, WindowMode windowMode, float scaleModifier, int vertexBatchSize, int indexBatchSize, int videoDisplay, GLProfile profile, bool enableLegacyGL);
|
||||
IPlatformWindow CreateWindow(Size size, WindowMode windowMode, float scaleModifier, int vertexBatchSize, int indexBatchSize, int videoDisplay, GLProfile profile);
|
||||
ISoundEngine CreateSound(string device);
|
||||
IFont CreateFont(byte[] data);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace OpenRA
|
||||
|
||||
Window = platform.CreateWindow(new Size(resolution.Width, resolution.Height),
|
||||
graphicSettings.Mode, graphicSettings.UIScale, TempVertexBufferSize, TempIndexBufferSize,
|
||||
graphicSettings.VideoDisplay, graphicSettings.GLProfile, !graphicSettings.DisableLegacyGL);
|
||||
graphicSettings.VideoDisplay, graphicSettings.GLProfile);
|
||||
|
||||
Context = Window.Context;
|
||||
|
||||
|
||||
@@ -210,9 +210,6 @@ namespace OpenRA
|
||||
[Desc("Disable operating-system provided cursor rendering.")]
|
||||
public bool DisableHardwareCursors = false;
|
||||
|
||||
[Desc("Disable legacy OpenGL 2.1 support.")]
|
||||
public bool DisableLegacyGL = true;
|
||||
|
||||
[Desc("Display index to use in a multi-monitor fullscreen setup.")]
|
||||
public int VideoDisplay = 0;
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ namespace OpenRA.Platforms.Default
|
||||
{
|
||||
public class DefaultPlatform : IPlatform
|
||||
{
|
||||
public IPlatformWindow CreateWindow(Size size, WindowMode windowMode, float scaleModifier, int vertexBatchSize, int indexBatchSize, int videoDisplay, GLProfile profile, bool enableLegacyGL)
|
||||
public IPlatformWindow CreateWindow(Size size, WindowMode windowMode, float scaleModifier, int vertexBatchSize, int indexBatchSize, int videoDisplay, GLProfile profile)
|
||||
{
|
||||
return new Sdl2PlatformWindow(size, windowMode, scaleModifier, vertexBatchSize, indexBatchSize, videoDisplay, profile, enableLegacyGL);
|
||||
return new Sdl2PlatformWindow(size, windowMode, scaleModifier, vertexBatchSize, indexBatchSize, videoDisplay, profile);
|
||||
}
|
||||
|
||||
public ISoundEngine CreateSound(string device)
|
||||
|
||||
@@ -491,7 +491,7 @@ namespace OpenRA.Platforms.Default
|
||||
|
||||
#endregion
|
||||
|
||||
public static void Initialize(bool preferLegacyProfile)
|
||||
public static void Initialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -508,7 +508,7 @@ namespace OpenRA.Platforms.Default
|
||||
throw new InvalidProgramException("Failed to initialize low-level OpenGL bindings. GPU information is not available.", e);
|
||||
}
|
||||
|
||||
if (!DetectGLFeatures(preferLegacyProfile))
|
||||
if (!DetectGLFeatures())
|
||||
{
|
||||
WriteGraphicsLog("Unsupported OpenGL version: " + glGetString(GL_VERSION));
|
||||
throw new InvalidProgramException("OpenGL Version Error: See graphics.log for details.");
|
||||
@@ -615,49 +615,29 @@ namespace OpenRA.Platforms.Default
|
||||
glTexParameteri = Bind<TexParameteri>("glTexParameteri");
|
||||
glTexParameterf = Bind<TexParameterf>("glTexParameterf");
|
||||
|
||||
if (Profile != GLProfile.Legacy)
|
||||
if (Profile != GLProfile.Embedded)
|
||||
{
|
||||
if (Profile != GLProfile.Embedded)
|
||||
{
|
||||
glGetTexImage = Bind<GetTexImage>("glGetTexImage");
|
||||
glBindFragDataLocation = Bind<BindFragDataLocation>("glBindFragDataLocation");
|
||||
}
|
||||
else
|
||||
{
|
||||
glGetTexImage = null;
|
||||
glBindFragDataLocation = null;
|
||||
}
|
||||
|
||||
glGenVertexArrays = Bind<GenVertexArrays>("glGenVertexArrays");
|
||||
glBindVertexArray = Bind<BindVertexArray>("glBindVertexArray");
|
||||
glGenFramebuffers = Bind<GenFramebuffers>("glGenFramebuffers");
|
||||
glBindFramebuffer = Bind<BindFramebuffer>("glBindFramebuffer");
|
||||
glFramebufferTexture2D = Bind<FramebufferTexture2D>("glFramebufferTexture2D");
|
||||
glDeleteFramebuffers = Bind<DeleteFramebuffers>("glDeleteFramebuffers");
|
||||
glGenRenderbuffers = Bind<GenRenderbuffers>("glGenRenderbuffers");
|
||||
glBindRenderbuffer = Bind<BindRenderbuffer>("glBindRenderbuffer");
|
||||
glRenderbufferStorage = Bind<RenderbufferStorage>("glRenderbufferStorage");
|
||||
glDeleteRenderbuffers = Bind<DeleteRenderbuffers>("glDeleteRenderbuffers");
|
||||
glFramebufferRenderbuffer = Bind<FramebufferRenderbuffer>("glFramebufferRenderbuffer");
|
||||
glCheckFramebufferStatus = Bind<CheckFramebufferStatus>("glCheckFramebufferStatus");
|
||||
glGetTexImage = Bind<GetTexImage>("glGetTexImage");
|
||||
glBindFragDataLocation = Bind<BindFragDataLocation>("glBindFragDataLocation");
|
||||
}
|
||||
else
|
||||
{
|
||||
glGenVertexArrays = null;
|
||||
glBindVertexArray = null;
|
||||
glGetTexImage = null;
|
||||
glBindFragDataLocation = null;
|
||||
glGetTexImage = Bind<GetTexImage>("glGetTexImage");
|
||||
glGenFramebuffers = Bind<GenFramebuffers>("glGenFramebuffersEXT");
|
||||
glBindFramebuffer = Bind<BindFramebuffer>("glBindFramebufferEXT");
|
||||
glFramebufferTexture2D = Bind<FramebufferTexture2D>("glFramebufferTexture2DEXT");
|
||||
glDeleteFramebuffers = Bind<DeleteFramebuffers>("glDeleteFramebuffersEXT");
|
||||
glGenRenderbuffers = Bind<GenRenderbuffers>("glGenRenderbuffersEXT");
|
||||
glBindRenderbuffer = Bind<BindRenderbuffer>("glBindRenderbufferEXT");
|
||||
glRenderbufferStorage = Bind<RenderbufferStorage>("glRenderbufferStorageEXT");
|
||||
glDeleteRenderbuffers = Bind<DeleteRenderbuffers>("glDeleteRenderbuffersEXT");
|
||||
glFramebufferRenderbuffer = Bind<FramebufferRenderbuffer>("glFramebufferRenderbufferEXT");
|
||||
glCheckFramebufferStatus = Bind<CheckFramebufferStatus>("glCheckFramebufferStatusEXT");
|
||||
}
|
||||
|
||||
glGenVertexArrays = Bind<GenVertexArrays>("glGenVertexArrays");
|
||||
glBindVertexArray = Bind<BindVertexArray>("glBindVertexArray");
|
||||
glGenFramebuffers = Bind<GenFramebuffers>("glGenFramebuffers");
|
||||
glBindFramebuffer = Bind<BindFramebuffer>("glBindFramebuffer");
|
||||
glFramebufferTexture2D = Bind<FramebufferTexture2D>("glFramebufferTexture2D");
|
||||
glDeleteFramebuffers = Bind<DeleteFramebuffers>("glDeleteFramebuffers");
|
||||
glGenRenderbuffers = Bind<GenRenderbuffers>("glGenRenderbuffers");
|
||||
glBindRenderbuffer = Bind<BindRenderbuffer>("glBindRenderbuffer");
|
||||
glRenderbufferStorage = Bind<RenderbufferStorage>("glRenderbufferStorage");
|
||||
glDeleteRenderbuffers = Bind<DeleteRenderbuffers>("glDeleteRenderbuffers");
|
||||
glFramebufferRenderbuffer = Bind<FramebufferRenderbuffer>("glFramebufferRenderbuffer");
|
||||
glCheckFramebufferStatus = Bind<CheckFramebufferStatus>("glCheckFramebufferStatus");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -671,7 +651,7 @@ namespace OpenRA.Platforms.Default
|
||||
return (T)(object)Marshal.GetDelegateForFunctionPointer(SDL.SDL_GL_GetProcAddress(name), typeof(T));
|
||||
}
|
||||
|
||||
public static bool DetectGLFeatures(bool preferLegacyProfile)
|
||||
public static bool DetectGLFeatures()
|
||||
{
|
||||
var hasValidConfiguration = false;
|
||||
try
|
||||
@@ -708,15 +688,6 @@ namespace OpenRA.Platforms.Default
|
||||
var hasDebugMessagesCallback = SDL.SDL_GL_ExtensionSupported("GL_KHR_debug") == SDL.SDL_bool.SDL_TRUE;
|
||||
if (hasDebugMessagesCallback)
|
||||
Features |= GLFeatures.DebugMessagesCallback;
|
||||
|
||||
if (preferLegacyProfile || (major == 2 && minor == 1) || (major == 3 && minor < 2))
|
||||
{
|
||||
if (SDL.SDL_GL_ExtensionSupported("GL_EXT_framebuffer_object") == SDL.SDL_bool.SDL_TRUE)
|
||||
{
|
||||
hasValidConfiguration = true;
|
||||
Profile = GLProfile.Legacy;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception) { }
|
||||
|
||||
@@ -743,14 +714,9 @@ namespace OpenRA.Platforms.Default
|
||||
Log.Write("graphics", $"Shader Version: {glGetString(GL_SHADING_LANGUAGE_VERSION)}");
|
||||
Log.Write("graphics", "Available extensions:");
|
||||
|
||||
if (Profile != GLProfile.Legacy)
|
||||
{
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, out var extensionCount);
|
||||
for (var i = 0; i < extensionCount; i++)
|
||||
Log.Write("graphics", glGetStringi(GL_EXTENSIONS, (uint)i));
|
||||
}
|
||||
else
|
||||
Log.Write("graphics", glGetString(GL_EXTENSIONS));
|
||||
glGetIntegerv(GL_NUM_EXTENSIONS, out var extensionCount);
|
||||
for (var i = 0; i < extensionCount; i++)
|
||||
Log.Write("graphics", glGetStringi(GL_EXTENSIONS, (uint)i));
|
||||
}
|
||||
|
||||
public static void CheckGLError()
|
||||
|
||||
@@ -40,16 +40,13 @@ namespace OpenRA.Platforms.Default
|
||||
if (SDL.SDL_GL_MakeCurrent(window.Window, context) < 0)
|
||||
throw new InvalidOperationException($"Can not bind OpenGL context. (Error: {SDL.SDL_GetError()})");
|
||||
|
||||
OpenGL.Initialize(window.GLProfile == GLProfile.Legacy);
|
||||
OpenGL.Initialize();
|
||||
OpenGL.CheckGLError();
|
||||
|
||||
if (OpenGL.Profile != GLProfile.Legacy)
|
||||
{
|
||||
OpenGL.glGenVertexArrays(1, out var vao);
|
||||
OpenGL.CheckGLError();
|
||||
OpenGL.glBindVertexArray(vao);
|
||||
OpenGL.CheckGLError();
|
||||
}
|
||||
OpenGL.glGenVertexArrays(1, out var vao);
|
||||
OpenGL.CheckGLError();
|
||||
OpenGL.glBindVertexArray(vao);
|
||||
OpenGL.CheckGLError();
|
||||
}
|
||||
|
||||
public IVertexBuffer<T> CreateVertexBuffer<T>(int size) where T : struct
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace OpenRA.Platforms.Default
|
||||
static extern IntPtr XFlush(IntPtr display);
|
||||
|
||||
public Sdl2PlatformWindow(Size requestEffectiveWindowSize, WindowMode windowMode,
|
||||
float scaleModifier, int vertexBatchSize, int indexBatchSize, int videoDisplay, GLProfile requestProfile, bool enableLegacyGL)
|
||||
float scaleModifier, int vertexBatchSize, int indexBatchSize, int videoDisplay, GLProfile requestProfile)
|
||||
{
|
||||
// Lock the Window/Surface properties until initialization is complete
|
||||
lock (syncObject)
|
||||
@@ -147,9 +147,6 @@ namespace OpenRA.Platforms.Default
|
||||
// Decide which OpenGL profile to use.
|
||||
// Prefer standard GL over GLES provided by the native driver
|
||||
var testProfiles = new List<GLProfile> { GLProfile.ANGLE, GLProfile.Modern, GLProfile.Embedded };
|
||||
if (enableLegacyGL)
|
||||
testProfiles.Add(GLProfile.Legacy);
|
||||
|
||||
var errorLog = new List<string>();
|
||||
supportedProfiles = testProfiles
|
||||
.Where(profile => CanCreateGLWindow(profile, errorLog))
|
||||
@@ -537,10 +534,6 @@ namespace OpenRA.Platforms.Default
|
||||
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_PROFILE_MASK, (int)SDL.SDL_GLprofile.SDL_GL_CONTEXT_PROFILE_ES);
|
||||
break;
|
||||
case GLProfile.Legacy:
|
||||
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||
SDL.SDL_GL_SetAttribute(SDL.SDL_GLattr.SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace OpenRA.Platforms.Default
|
||||
sealed class Shader : ThreadAffine, IShader
|
||||
{
|
||||
readonly Dictionary<string, int> samplers = new();
|
||||
readonly Dictionary<int, int> legacySizeUniforms = new();
|
||||
readonly Dictionary<string, int> uniformCache = new();
|
||||
readonly Dictionary<int, ITexture> textures = new();
|
||||
readonly Queue<int> unbindTextures = new();
|
||||
@@ -28,8 +27,7 @@ namespace OpenRA.Platforms.Default
|
||||
|
||||
static uint CompileShaderObject(int type, string code, string name)
|
||||
{
|
||||
var version = OpenGL.Profile == GLProfile.Embedded ? "300 es" :
|
||||
OpenGL.Profile == GLProfile.Legacy ? "120" : "140";
|
||||
var version = OpenGL.Profile == GLProfile.Embedded ? "300 es" : "140";
|
||||
|
||||
code = code.Replace("{VERSION}", version);
|
||||
|
||||
@@ -127,14 +125,6 @@ namespace OpenRA.Platforms.Default
|
||||
|
||||
OpenGL.glUniform1i(loc, nextTexUnit);
|
||||
OpenGL.CheckGLError();
|
||||
|
||||
if (OpenGL.Profile == GLProfile.Legacy)
|
||||
{
|
||||
var sizeLoc = OpenGL.glGetUniformLocation(program, sampler + "Size");
|
||||
if (sizeLoc >= 0)
|
||||
legacySizeUniforms.Add(nextTexUnit, sizeLoc);
|
||||
}
|
||||
|
||||
nextTexUnit++;
|
||||
}
|
||||
}
|
||||
@@ -166,13 +156,6 @@ namespace OpenRA.Platforms.Default
|
||||
{
|
||||
OpenGL.glActiveTexture(OpenGL.GL_TEXTURE0 + kv.Key);
|
||||
OpenGL.glBindTexture(OpenGL.GL_TEXTURE_2D, texture.ID);
|
||||
|
||||
// Work around missing textureSize GLSL function by explicitly tracking sizes in a uniform
|
||||
if (OpenGL.Profile == GLProfile.Legacy && legacySizeUniforms.TryGetValue(kv.Key, out var param))
|
||||
{
|
||||
OpenGL.glUniform2f(param, texture.Size.Width, texture.Size.Height);
|
||||
OpenGL.CheckGLError();
|
||||
}
|
||||
}
|
||||
else
|
||||
unbindTextures.Enqueue(kv.Key);
|
||||
|
||||
@@ -19,27 +19,6 @@ uniform vec2 DepthPreviewParams;
|
||||
uniform float DepthTextureScale;
|
||||
uniform float AntialiasPixelsPerTexel;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
varying vec4 vTexCoord;
|
||||
varying vec2 vTexMetadata;
|
||||
varying vec4 vChannelMask;
|
||||
varying vec4 vDepthMask;
|
||||
varying vec2 vTexSampler;
|
||||
|
||||
varying vec4 vColorFraction;
|
||||
varying vec4 vRGBAFraction;
|
||||
varying vec4 vPalettedFraction;
|
||||
varying vec4 vTint;
|
||||
|
||||
uniform vec2 Texture0Size;
|
||||
uniform vec2 Texture1Size;
|
||||
uniform vec2 Texture2Size;
|
||||
uniform vec2 Texture3Size;
|
||||
uniform vec2 Texture4Size;
|
||||
uniform vec2 Texture5Size;
|
||||
uniform vec2 Texture6Size;
|
||||
uniform vec2 Texture7Size;
|
||||
#else
|
||||
in vec4 vColor;
|
||||
|
||||
in vec4 vTexCoord;
|
||||
@@ -54,7 +33,6 @@ in vec4 vPalettedFraction;
|
||||
in vec4 vTint;
|
||||
|
||||
out vec4 fragColor;
|
||||
#endif
|
||||
|
||||
vec3 rgb2hsv(vec3 c)
|
||||
{
|
||||
@@ -99,47 +77,6 @@ vec4 linear2srgb(vec4 c)
|
||||
return c.a * vec4(linear2srgb(c.r / c.a), linear2srgb(c.g / c.a), linear2srgb(c.b / c.a), 1.0f);
|
||||
}
|
||||
|
||||
#if __VERSION__ == 120
|
||||
vec2 Size(float samplerIndex)
|
||||
{
|
||||
if (samplerIndex < 0.5)
|
||||
return Texture0Size;
|
||||
else if (samplerIndex < 1.5)
|
||||
return Texture1Size;
|
||||
else if (samplerIndex < 2.5)
|
||||
return Texture2Size;
|
||||
else if (samplerIndex < 3.5)
|
||||
return Texture3Size;
|
||||
else if (samplerIndex < 4.5)
|
||||
return Texture4Size;
|
||||
else if (samplerIndex < 5.5)
|
||||
return Texture5Size;
|
||||
else if (samplerIndex < 6.5)
|
||||
return Texture6Size;
|
||||
|
||||
return Texture7Size;
|
||||
}
|
||||
|
||||
vec4 Sample(float samplerIndex, vec2 pos)
|
||||
{
|
||||
if (samplerIndex < 0.5)
|
||||
return texture2D(Texture0, pos);
|
||||
else if (samplerIndex < 1.5)
|
||||
return texture2D(Texture1, pos);
|
||||
else if (samplerIndex < 2.5)
|
||||
return texture2D(Texture2, pos);
|
||||
else if (samplerIndex < 3.5)
|
||||
return texture2D(Texture3, pos);
|
||||
else if (samplerIndex < 4.5)
|
||||
return texture2D(Texture4, pos);
|
||||
else if (samplerIndex < 5.5)
|
||||
return texture2D(Texture5, pos);
|
||||
else if (samplerIndex < 6.5)
|
||||
return texture2D(Texture6, pos);
|
||||
|
||||
return texture2D(Texture7, pos);
|
||||
}
|
||||
#else
|
||||
ivec2 Size(float samplerIndex)
|
||||
{
|
||||
if (samplerIndex < 0.5)
|
||||
@@ -179,7 +116,6 @@ vec4 Sample(float samplerIndex, vec2 pos)
|
||||
|
||||
return texture(Texture7, pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
vec4 SamplePalettedBilinear(float samplerIndex, vec2 coords, vec2 textureSize)
|
||||
{
|
||||
@@ -193,30 +129,18 @@ vec4 SamplePalettedBilinear(float samplerIndex, vec2 coords, vec2 textureSize)
|
||||
vec4 x3 = Sample(samplerIndex, tl + vec2(0., px.y));
|
||||
vec4 x4 = Sample(samplerIndex, tl + px);
|
||||
|
||||
#if __VERSION__ == 120
|
||||
vec4 c1 = texture2D(Palette, vec2(dot(x1, vChannelMask), vTexMetadata.s));
|
||||
vec4 c2 = texture2D(Palette, vec2(dot(x2, vChannelMask), vTexMetadata.s));
|
||||
vec4 c3 = texture2D(Palette, vec2(dot(x3, vChannelMask), vTexMetadata.s));
|
||||
vec4 c4 = texture2D(Palette, vec2(dot(x4, vChannelMask), vTexMetadata.s));
|
||||
#else
|
||||
vec4 c1 = texture(Palette, vec2(dot(x1, vChannelMask), vTexMetadata.s));
|
||||
vec4 c2 = texture(Palette, vec2(dot(x2, vChannelMask), vTexMetadata.s));
|
||||
vec4 c3 = texture(Palette, vec2(dot(x3, vChannelMask), vTexMetadata.s));
|
||||
vec4 c4 = texture(Palette, vec2(dot(x4, vChannelMask), vTexMetadata.s));
|
||||
#endif
|
||||
|
||||
return mix(mix(c1, c2, interp.x), mix(c3, c4, interp.x), interp.y);
|
||||
}
|
||||
|
||||
vec4 ColorShift(vec4 c, float p)
|
||||
{
|
||||
#if __VERSION__ == 120
|
||||
vec4 range = texture2D(ColorShifts, vec2(0.25, p));
|
||||
vec4 shift = texture2D(ColorShifts, vec2(0.75, p));
|
||||
#else
|
||||
vec4 range = texture(ColorShifts, vec2(0.25, p));
|
||||
vec4 shift = texture(ColorShifts, vec2(0.75, p));
|
||||
#endif
|
||||
|
||||
vec3 hsv = rgb2hsv(srgb2linear(c).rgb);
|
||||
if (hsv.r > range.r && range.g >= hsv.r)
|
||||
@@ -251,11 +175,7 @@ void main()
|
||||
{
|
||||
vec4 x = Sample(vTexSampler.s, coords);
|
||||
vec2 p = vec2(dot(x, vChannelMask), vTexMetadata.s);
|
||||
#if __VERSION__ == 120
|
||||
c = vPalettedFraction * texture2D(Palette, p) + vRGBAFraction * x + vColorFraction * vTexCoord;
|
||||
#else
|
||||
c = vPalettedFraction * texture(Palette, p) + vRGBAFraction * x + vColorFraction * vTexCoord;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Discard any transparent fragments (both color and depth)
|
||||
@@ -277,12 +197,7 @@ void main()
|
||||
if (EnableDepthPreview)
|
||||
{
|
||||
float intensity = 1.0 - clamp(DepthPreviewParams.x * depth - 0.5 * DepthPreviewParams.x - DepthPreviewParams.y + 0.5, 0.0, 1.0);
|
||||
|
||||
#if __VERSION__ == 120
|
||||
gl_FragColor = vec4(vec3(intensity), 1.0);
|
||||
#else
|
||||
fragColor = vec4(vec3(intensity), 1.0);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -292,10 +207,6 @@ void main()
|
||||
else
|
||||
c *= vTint;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
gl_FragColor = c;
|
||||
#else
|
||||
fragColor = c;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,23 +3,6 @@
|
||||
uniform vec3 Scroll;
|
||||
uniform vec3 p1, p2;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
attribute vec3 aVertexPosition;
|
||||
attribute vec4 aVertexTexCoord;
|
||||
attribute vec2 aVertexTexMetadata;
|
||||
attribute vec4 aVertexTint;
|
||||
|
||||
varying vec4 vTexCoord;
|
||||
varying vec2 vTexMetadata;
|
||||
varying vec4 vChannelMask;
|
||||
varying vec4 vDepthMask;
|
||||
varying vec2 vTexSampler;
|
||||
|
||||
varying vec4 vColorFraction;
|
||||
varying vec4 vRGBAFraction;
|
||||
varying vec4 vPalettedFraction;
|
||||
varying vec4 vTint;
|
||||
#else
|
||||
in vec3 aVertexPosition;
|
||||
in vec4 aVertexTexCoord;
|
||||
in vec2 aVertexTexMetadata;
|
||||
@@ -35,7 +18,6 @@ out vec4 vColorFraction;
|
||||
out vec4 vRGBAFraction;
|
||||
out vec4 vPalettedFraction;
|
||||
out vec4 vTint;
|
||||
#endif
|
||||
|
||||
vec4 UnpackChannelAttributes(float x)
|
||||
{
|
||||
|
||||
@@ -9,30 +9,13 @@ uniform vec2 PaletteRows;
|
||||
uniform vec4 LightDirection;
|
||||
uniform vec3 AmbientLight, DiffuseLight;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
varying vec4 vTexCoord;
|
||||
varying vec4 vChannelMask;
|
||||
varying vec4 vNormalsMask;
|
||||
#else
|
||||
in vec4 vTexCoord;
|
||||
in vec4 vChannelMask;
|
||||
in vec4 vNormalsMask;
|
||||
out vec4 fragColor;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
#if __VERSION__ == 120
|
||||
vec4 x = texture2D(DiffuseTexture, vTexCoord.st);
|
||||
vec4 color = texture2D(Palette, vec2(dot(x, vChannelMask), PaletteRows.x));
|
||||
if (color.a < 0.01)
|
||||
discard;
|
||||
|
||||
vec4 y = texture2D(DiffuseTexture, vTexCoord.pq);
|
||||
vec4 normal = (2.0 * texture2D(Palette, vec2(dot(y, vNormalsMask), PaletteRows.y)) - 1.0);
|
||||
vec3 intensity = AmbientLight + DiffuseLight * max(dot(normal, LightDirection), 0.0);
|
||||
gl_FragColor = vec4(intensity * color.rgb, color.a);
|
||||
#else
|
||||
vec4 x = texture(DiffuseTexture, vTexCoord.st);
|
||||
vec4 color = texture(Palette, vec2(dot(x, vChannelMask), PaletteRows.x));
|
||||
if (color.a < 0.01)
|
||||
@@ -42,5 +25,4 @@ void main()
|
||||
vec4 normal = (2.0 * texture(Palette, vec2(dot(y, vNormalsMask), PaletteRows.y)) - 1.0);
|
||||
vec3 intensity = AmbientLight + DiffuseLight * max(dot(normal, LightDirection), 0.0);
|
||||
fragColor = vec4(intensity * color.rgb, color.a);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -3,21 +3,12 @@
|
||||
uniform mat4 View;
|
||||
uniform mat4 TransformMatrix;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
attribute vec4 aVertexPosition;
|
||||
attribute vec4 aVertexTexCoord;
|
||||
attribute vec2 aVertexTexMetadata;
|
||||
varying vec4 vTexCoord;
|
||||
varying vec4 vChannelMask;
|
||||
varying vec4 vNormalsMask;
|
||||
#else
|
||||
in vec4 aVertexPosition;
|
||||
in vec4 aVertexTexCoord;
|
||||
in vec2 aVertexTexMetadata;
|
||||
out vec4 vTexCoord;
|
||||
out vec4 vChannelMask;
|
||||
out vec4 vNormalsMask;
|
||||
#endif
|
||||
|
||||
vec4 DecodeMask(float x)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
#version {VERSION}
|
||||
|
||||
#if __VERSION__ == 120
|
||||
attribute vec2 aVertexPosition;
|
||||
#else
|
||||
in vec2 aVertexPosition;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -5,27 +5,11 @@ precision mediump float;
|
||||
|
||||
uniform float Blend;
|
||||
uniform sampler2D WorldTexture;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
uniform vec2 WorldTextureSize;
|
||||
#else
|
||||
out vec4 fragColor;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
#if __VERSION__ == 120
|
||||
vec4 c = texture2D(WorldTexture, gl_FragCoord.xy / WorldTextureSize);
|
||||
#else
|
||||
vec4 c = texture(WorldTexture, gl_FragCoord.xy / textureSize(WorldTexture, 0));
|
||||
#endif
|
||||
|
||||
float lum = 0.5 * (min(c.r, min(c.g, c.b)) + max(c.r, max(c.g, c.b)));
|
||||
c = vec4(lum, lum, lum, c.a) * Blend + c * (1.0 - Blend);
|
||||
|
||||
#if __VERSION__ == 120
|
||||
gl_FragColor = c;
|
||||
#else
|
||||
fragColor = c;
|
||||
#endif
|
||||
fragColor = vec4(lum, lum, lum, c.a) * Blend + c * (1.0 - Blend);
|
||||
}
|
||||
|
||||
@@ -6,26 +6,10 @@ precision mediump float;
|
||||
uniform float Blend;
|
||||
uniform vec3 Color;
|
||||
uniform sampler2D WorldTexture;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
uniform vec2 WorldTextureSize;
|
||||
#else
|
||||
out vec4 fragColor;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
#if __VERSION__ == 120
|
||||
vec4 c = texture2D(WorldTexture, gl_FragCoord.xy / WorldTextureSize);
|
||||
#else
|
||||
vec4 c = texture(WorldTexture, gl_FragCoord.xy / textureSize(WorldTexture, 0));
|
||||
#endif
|
||||
|
||||
c = vec4(Color, c.a) * Blend + c * (1.0 - Blend);
|
||||
|
||||
#if __VERSION__ == 120
|
||||
gl_FragColor = c;
|
||||
#else
|
||||
fragColor = c;
|
||||
#endif
|
||||
fragColor = vec4(Color, c.a) * Blend + c * (1.0 - Blend);
|
||||
}
|
||||
|
||||
@@ -7,12 +7,7 @@ uniform float From;
|
||||
uniform float To;
|
||||
uniform float Blend;
|
||||
uniform sampler2D WorldTexture;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
uniform vec2 WorldTextureSize;
|
||||
#else
|
||||
out vec4 fragColor;
|
||||
#endif
|
||||
|
||||
vec4 ColorForEffect(float effect, vec4 c)
|
||||
{
|
||||
@@ -32,16 +27,6 @@ vec4 ColorForEffect(float effect, vec4 c)
|
||||
|
||||
void main()
|
||||
{
|
||||
#if __VERSION__ == 120
|
||||
vec4 c = texture2D(WorldTexture, gl_FragCoord.xy / WorldTextureSize);
|
||||
#else
|
||||
vec4 c = texture(WorldTexture, gl_FragCoord.xy / textureSize(WorldTexture, 0));
|
||||
#endif
|
||||
c = ColorForEffect(From, c) * Blend + ColorForEffect(To, c) * (1.0 - Blend);
|
||||
|
||||
#if __VERSION__ == 120
|
||||
gl_FragColor = c;
|
||||
#else
|
||||
fragColor = c;
|
||||
#endif
|
||||
fragColor = ColorForEffect(From, c) * Blend + ColorForEffect(To, c) * (1.0 - Blend);
|
||||
}
|
||||
|
||||
@@ -5,26 +5,10 @@ precision mediump float;
|
||||
|
||||
uniform vec3 Tint;
|
||||
uniform sampler2D WorldTexture;
|
||||
|
||||
#if __VERSION__ == 120
|
||||
uniform vec2 WorldTextureSize;
|
||||
#else
|
||||
out vec4 fragColor;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
#if __VERSION__ == 120
|
||||
vec4 c = texture2D(WorldTexture, gl_FragCoord.xy / WorldTextureSize);
|
||||
#else
|
||||
vec4 c = texture(WorldTexture, gl_FragCoord.xy / textureSize(WorldTexture, 0));
|
||||
#endif
|
||||
|
||||
c = vec4(min(c.r * Tint.r, 1.0), min(c.g * Tint.g, 1.0), min(c.b * Tint.b, 1.0), c.a);
|
||||
|
||||
#if __VERSION__ == 120
|
||||
gl_FragColor = c;
|
||||
#else
|
||||
fragColor = c;
|
||||
#endif
|
||||
fragColor = vec4(min(c.r * Tint.r, 1.0), min(c.g * Tint.g, 1.0), min(c.b * Tint.b, 1.0), c.a);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user