Migrate rendering to OpenGL 3.2 / OpenGL ES 3.0.
This commit is contained in:
committed by
RoosterDragon
parent
91c63034d3
commit
ce8112fb5a
@@ -1,3 +1,10 @@
|
||||
#version {VERSION}
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
in vec4 vColor;
|
||||
|
||||
uniform sampler2D Texture0;
|
||||
uniform sampler2D Texture1;
|
||||
uniform sampler2D Texture2;
|
||||
@@ -10,15 +17,17 @@ uniform sampler2D Palette;
|
||||
uniform bool EnableDepthPreview;
|
||||
uniform float DepthTextureScale;
|
||||
|
||||
varying vec4 vTexCoord;
|
||||
varying vec2 vTexMetadata;
|
||||
varying vec4 vChannelMask;
|
||||
varying vec4 vDepthMask;
|
||||
varying vec2 vTexSampler;
|
||||
in vec4 vTexCoord;
|
||||
in vec2 vTexMetadata;
|
||||
in vec4 vChannelMask;
|
||||
in vec4 vDepthMask;
|
||||
in vec2 vTexSampler;
|
||||
|
||||
varying vec4 vColorFraction;
|
||||
varying vec4 vRGBAFraction;
|
||||
varying vec4 vPalettedFraction;
|
||||
in vec4 vColorFraction;
|
||||
in vec4 vRGBAFraction;
|
||||
in vec4 vPalettedFraction;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
float jet_r(float x)
|
||||
{
|
||||
@@ -38,26 +47,26 @@ float jet_b(float x)
|
||||
vec4 Sample(float samplerIndex, vec2 pos)
|
||||
{
|
||||
if (samplerIndex < 0.5)
|
||||
return texture2D(Texture0, pos);
|
||||
return texture(Texture0, pos);
|
||||
else if (samplerIndex < 1.5)
|
||||
return texture2D(Texture1, pos);
|
||||
return texture(Texture1, pos);
|
||||
else if (samplerIndex < 2.5)
|
||||
return texture2D(Texture2, pos);
|
||||
return texture(Texture2, pos);
|
||||
else if (samplerIndex < 3.5)
|
||||
return texture2D(Texture3, pos);
|
||||
return texture(Texture3, pos);
|
||||
else if (samplerIndex < 4.5)
|
||||
return texture2D(Texture4, pos);
|
||||
return texture(Texture4, pos);
|
||||
else if (samplerIndex < 5.5)
|
||||
return texture2D(Texture5, pos);
|
||||
return texture(Texture5, pos);
|
||||
|
||||
return texture2D(Texture6, pos);
|
||||
return texture(Texture6, pos);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 x = Sample(vTexSampler.s, vTexCoord.st);
|
||||
vec2 p = vec2(dot(x, vChannelMask), vTexMetadata.s);
|
||||
vec4 c = vPalettedFraction * texture2D(Palette, p) + vRGBAFraction * x + vColorFraction * vTexCoord;
|
||||
vec4 c = vPalettedFraction * texture(Palette, p) + vRGBAFraction * x + vColorFraction * vTexCoord;
|
||||
|
||||
// Discard any transparent fragments (both color and depth)
|
||||
if (c.a == 0.0)
|
||||
@@ -79,8 +88,8 @@ void main()
|
||||
float r = clamp(jet_r(x), 0.0, 1.0);
|
||||
float g = clamp(jet_g(x), 0.0, 1.0);
|
||||
float b = clamp(jet_b(x), 0.0, 1.0);
|
||||
gl_FragColor = vec4(r, g, b, 1.0);
|
||||
fragColor = vec4(r, g, b, 1.0);
|
||||
}
|
||||
else
|
||||
gl_FragColor = c;
|
||||
fragColor = c;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
#version {VERSION}
|
||||
|
||||
uniform vec3 Scroll;
|
||||
uniform vec3 r1, r2;
|
||||
|
||||
attribute vec4 aVertexPosition;
|
||||
attribute vec4 aVertexTexCoord;
|
||||
attribute vec2 aVertexTexMetadata;
|
||||
in vec4 aVertexPosition;
|
||||
in vec4 aVertexTexCoord;
|
||||
in vec2 aVertexTexMetadata;
|
||||
|
||||
varying vec4 vTexCoord;
|
||||
varying vec2 vTexMetadata;
|
||||
varying vec4 vChannelMask;
|
||||
varying vec4 vDepthMask;
|
||||
varying vec2 vTexSampler;
|
||||
out vec4 vTexCoord;
|
||||
out vec2 vTexMetadata;
|
||||
out vec4 vChannelMask;
|
||||
out vec4 vDepthMask;
|
||||
out vec2 vTexSampler;
|
||||
|
||||
varying vec4 vColorFraction;
|
||||
varying vec4 vRGBAFraction;
|
||||
varying vec4 vPalettedFraction;
|
||||
out vec4 vColorFraction;
|
||||
out vec4 vRGBAFraction;
|
||||
out vec4 vPalettedFraction;
|
||||
|
||||
vec4 UnpackChannelAttributes(float x)
|
||||
{
|
||||
|
||||
@@ -1,22 +1,28 @@
|
||||
#version {VERSION}
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform sampler2D Palette, DiffuseTexture;
|
||||
uniform vec2 PaletteRows;
|
||||
|
||||
uniform vec4 LightDirection;
|
||||
uniform vec3 AmbientLight, DiffuseLight;
|
||||
|
||||
varying vec4 vTexCoord;
|
||||
varying vec4 vChannelMask;
|
||||
varying vec4 vNormalsMask;
|
||||
in vec4 vTexCoord;
|
||||
in vec4 vChannelMask;
|
||||
in vec4 vNormalsMask;
|
||||
out vec4 fragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 x = texture2D(DiffuseTexture, vTexCoord.st);
|
||||
vec4 color = texture2D(Palette, vec2(dot(x, vChannelMask), PaletteRows.x));
|
||||
vec4 x = texture(DiffuseTexture, vTexCoord.st);
|
||||
vec4 color = texture(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);
|
||||
vec4 y = texture(DiffuseTexture, vTexCoord.pq);
|
||||
vec4 normal = (2.0 * texture(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);
|
||||
fragColor = vec4(intensity * color.rgb, color.a);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
#version {VERSION}
|
||||
|
||||
uniform mat4 View;
|
||||
uniform mat4 TransformMatrix;
|
||||
|
||||
attribute vec4 aVertexPosition;
|
||||
attribute vec4 aVertexTexCoord;
|
||||
attribute vec2 aVertexTexMetadata;
|
||||
varying vec4 vTexCoord;
|
||||
varying vec4 vChannelMask;
|
||||
varying vec4 vNormalsMask;
|
||||
in vec4 aVertexPosition;
|
||||
in vec4 aVertexTexCoord;
|
||||
in vec2 aVertexTexMetadata;
|
||||
out vec4 vTexCoord;
|
||||
out vec4 vChannelMask;
|
||||
out vec4 vNormalsMask;
|
||||
|
||||
vec4 DecodeMask(float x)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user