mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Templates changes for OpenGL shaders.
This commit is contained in:
parent
c354f59b72
commit
5bcd1458c4
140 changed files with 9210 additions and 6 deletions
|
|
@ -0,0 +1,81 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// An implementation of "Practical Morphological Anti-Aliasing" from
|
||||
// GPU Pro 2 by Jorge Jimenez, Belen Masia, Jose I. Echevarria,
|
||||
// Fernando Navarro, and Diego Gutierrez.
|
||||
//
|
||||
// http://www.iryoku.com/mlaa/
|
||||
|
||||
#include "../../../gl/hlslCompat.glsl"
|
||||
|
||||
in vec2 texcoord;
|
||||
|
||||
uniform sampler2D edgesMap;
|
||||
uniform sampler2D edgesMapL;
|
||||
uniform sampler2D areaMap;
|
||||
|
||||
#include "./functions.glsl"
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 areas = vec4(0.0);
|
||||
|
||||
vec2 e = texture(edgesMap, texcoord).rg;
|
||||
|
||||
//[branch]
|
||||
if (bool(e.g)) // Edge at north
|
||||
{
|
||||
// Search distances to the left and to the right:
|
||||
vec2 d = vec2(SearchXLeft(texcoord), SearchXRight(texcoord));
|
||||
|
||||
// Now fetch the crossing edges. Instead of sampling between edgels, we
|
||||
// sample at -0.25, to be able to discern what value has each edgel:
|
||||
vec4 coords = mad(vec4(d.x, -0.25, d.y + 1.0, -0.25),
|
||||
PIXEL_SIZE.xyxy, texcoord.xyxy);
|
||||
float e1 = tex2Dlevel0(edgesMapL, coords.xy).r;
|
||||
float e2 = tex2Dlevel0(edgesMapL, coords.zw).r;
|
||||
|
||||
// Ok, we know how this pattern looks like, now it is time for getting
|
||||
// the actual area:
|
||||
areas.rg = Area(abs(d), e1, e2);
|
||||
}
|
||||
|
||||
//[branch]
|
||||
if (bool(e.r)) // Edge at west
|
||||
{
|
||||
// Search distances to the top and to the bottom:
|
||||
vec2 d = vec2(SearchYUp(texcoord), SearchYDown(texcoord));
|
||||
|
||||
// Now fetch the crossing edges (yet again):
|
||||
vec4 coords = mad(vec4(-0.25, d.x, -0.25, d.y + 1.0),
|
||||
PIXEL_SIZE.xyxy, texcoord.xyxy);
|
||||
float e1 = tex2Dlevel0(edgesMapL, coords.xy).g;
|
||||
float e2 = tex2Dlevel0(edgesMapL, coords.zw).g;
|
||||
|
||||
// Get the area for this direction:
|
||||
areas.ba = Area(abs(d), e1, e2);
|
||||
}
|
||||
|
||||
OUT_FragColor0 = areas;
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// An implementation of "Practical Morphological Anti-Aliasing" from
|
||||
// GPU Pro 2 by Jorge Jimenez, Belen Masia, Jose I. Echevarria,
|
||||
// Fernando Navarro, and Diego Gutierrez.
|
||||
//
|
||||
// http://www.iryoku.com/mlaa/
|
||||
|
||||
#include "../../../gl/hlslCompat.glsl"
|
||||
#include "shadergen:/autogenConditioners.h"
|
||||
|
||||
uniform sampler2D colorMapG;
|
||||
uniform sampler2D prepassMap;
|
||||
|
||||
uniform vec3 lumaCoefficients;
|
||||
uniform float threshold;
|
||||
uniform float depthThreshold;
|
||||
|
||||
in vec2 texcoord;
|
||||
in vec4 offset[2];
|
||||
|
||||
void main()
|
||||
{
|
||||
// Luma calculation requires gamma-corrected colors (texture 'colorMapG').
|
||||
//
|
||||
// Note that there is a lot of overlapped luma calculations; performance
|
||||
// can be improved if this luma calculation is performed in the main pass,
|
||||
// which may give you an edge if used in conjunction with a z prepass.
|
||||
|
||||
float L = dot(texture(colorMapG, texcoord).rgb, lumaCoefficients);
|
||||
|
||||
float Lleft = dot(texture(colorMapG, offset[0].xy).rgb, lumaCoefficients);
|
||||
float Ltop = dot(texture(colorMapG, offset[0].zw).rgb, lumaCoefficients);
|
||||
float Lright = dot(texture(colorMapG, offset[1].xy).rgb, lumaCoefficients);
|
||||
float Lbottom = dot(texture(colorMapG, offset[1].zw).rgb, lumaCoefficients);
|
||||
|
||||
vec4 delta = abs(vec4(L) - vec4(Lleft, Ltop, Lright, Lbottom));
|
||||
vec4 edges = step(threshold, delta);
|
||||
|
||||
// Add depth edges to color edges
|
||||
float D = prepassUncondition(prepassMap, texcoord).w;
|
||||
float Dleft = prepassUncondition(prepassMap, offset[0].xy).w;
|
||||
float Dtop = prepassUncondition(prepassMap, offset[0].zw).w;
|
||||
float Dright = prepassUncondition(prepassMap, offset[1].xy).w;
|
||||
float Dbottom = prepassUncondition(prepassMap, offset[1].zw).w;
|
||||
|
||||
delta = abs(vec4(D) - vec4(Dleft, Dtop, Dright, Dbottom));
|
||||
edges += step(depthThreshold, delta);
|
||||
|
||||
if (dot(edges, vec4(1.0)) == 0.0)
|
||||
discard;
|
||||
|
||||
OUT_FragColor0 = edges;
|
||||
}
|
||||
145
Templates/Full/game/shaders/common/postFx/mlaa/gl/functions.glsl
Normal file
145
Templates/Full/game/shaders/common/postFx/mlaa/gl/functions.glsl
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// An implementation of "Practical Morphological Anti-Aliasing" from
|
||||
// GPU Pro 2 by Jorge Jimenez, Belen Masia, Jose I. Echevarria,
|
||||
// Fernando Navarro, and Diego Gutierrez.
|
||||
//
|
||||
// http://www.iryoku.com/mlaa/
|
||||
|
||||
|
||||
uniform vec2 texSize0;
|
||||
|
||||
#if !defined(PIXEL_SIZE)
|
||||
#define PIXEL_SIZE (1.0 / texSize0)
|
||||
#define MAX_SEARCH_STEPS 8
|
||||
#define MAX_DISTANCE 33
|
||||
#endif
|
||||
|
||||
// Typical Multiply-Add operation to ease translation to assembly code.
|
||||
|
||||
vec4 mad(vec4 m, vec4 a, vec4 b)
|
||||
{
|
||||
#if defined(XBOX)
|
||||
vec4 result;
|
||||
asm {
|
||||
mad result, m, a, b
|
||||
};
|
||||
return result;
|
||||
#else
|
||||
return m * a + b;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// This one just returns the first level of a mip map chain, which allow us to
|
||||
// avoid the nasty ddx/ddy warnings, even improving the performance a little
|
||||
// bit.
|
||||
vec4 tex2Dlevel0(sampler2D map, vec2 texcoord)
|
||||
{
|
||||
return tex2Dlod(map, vec4(texcoord, 0.0, 0.0));
|
||||
}
|
||||
|
||||
|
||||
// Same as above, this eases translation to assembly code;
|
||||
vec4 tex2Doffset(sampler2D map, vec2 texcoord, vec2 offset)
|
||||
{
|
||||
#if defined(XBOX) && MAX_SEARCH_STEPS < 6
|
||||
vec4 result;
|
||||
float x = offset.x;
|
||||
float y = offset.y;
|
||||
asm {
|
||||
tfetch2D result, texcoord, map, OffsetX = x, OffsetY = y
|
||||
};
|
||||
return result;
|
||||
#else
|
||||
return tex2Dlevel0(map, texcoord + PIXEL_SIZE * offset);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Ok, we have the distance and both crossing edges, can you please return
|
||||
// the vec2 blending weights?
|
||||
vec2 Area(vec2 distance, float e1, float e2)
|
||||
{
|
||||
// * By dividing by areaSize - 1.0 below we are implicitely offsetting to
|
||||
// always fall inside of a pixel
|
||||
// * Rounding prevents bilinear access precision problems
|
||||
float areaSize = MAX_DISTANCE * 5.0;
|
||||
vec2 pixcoord = MAX_DISTANCE * round(4.0 * vec2(e1, e2)) + distance;
|
||||
vec2 texcoord = pixcoord / (areaSize - 1.0);
|
||||
return tex2Dlevel0(areaMap, texcoord).rg;
|
||||
}
|
||||
|
||||
|
||||
// Search functions for the 2nd pass.
|
||||
float SearchXLeft(vec2 texcoord)
|
||||
{
|
||||
// We compare with 0.9 to prevent bilinear access precision problems.
|
||||
float i;
|
||||
float e = 0.0;
|
||||
for (i = -1.5; i > -2.0 * MAX_SEARCH_STEPS; i -= 2.0)
|
||||
{
|
||||
e = tex2Doffset(edgesMapL, texcoord, vec2(i, 0.0)).g;
|
||||
/*[flatten]*/ if (e < 0.9) break;
|
||||
}
|
||||
return max(i + 1.5 - 2.0 * e, -2.0 * MAX_SEARCH_STEPS);
|
||||
}
|
||||
|
||||
// Search functions for the 2nd pass.
|
||||
float SearchXRight(vec2 texcoord)
|
||||
{
|
||||
float i;
|
||||
float e = 0.0;
|
||||
for (i = 1.5; i < 2.0 * MAX_SEARCH_STEPS; i += 2.0)
|
||||
{
|
||||
e = tex2Doffset(edgesMapL, texcoord, vec2(i, 0.0)).g;
|
||||
/*[flatten]*/ if (e < 0.9) break;
|
||||
}
|
||||
return min(i - 1.5 + 2.0 * e, 2.0 * MAX_SEARCH_STEPS);
|
||||
}
|
||||
|
||||
// Search functions for the 2nd pass.
|
||||
float SearchYUp(vec2 texcoord)
|
||||
{
|
||||
float i;
|
||||
float e = 0.0;
|
||||
for (i = -1.5; i > -2.0 * MAX_SEARCH_STEPS; i -= 2.0)
|
||||
{
|
||||
e = tex2Doffset(edgesMapL, texcoord, vec2(i, 0.0).yx).r;
|
||||
/*[flatten]*/ if (e < 0.9) break;
|
||||
}
|
||||
return max(i + 1.5 - 2.0 * e, -2.0 * MAX_SEARCH_STEPS);
|
||||
}
|
||||
|
||||
// Search functions for the 2nd pass.
|
||||
float SearchYDown(vec2 texcoord)
|
||||
{
|
||||
float i;
|
||||
float e = 0.0;
|
||||
for (i = 1.5; i < 2.0 * MAX_SEARCH_STEPS; i += 2.0)
|
||||
{
|
||||
e = tex2Doffset(edgesMapL, texcoord, vec2(i, 0.0).yx).r;
|
||||
/*[flatten]*/ if (e < 0.9) break;
|
||||
}
|
||||
return min(i - 1.5 + 2.0 * e, 2.0 * MAX_SEARCH_STEPS);
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// An implementation of "Practical Morphological Anti-Aliasing" from
|
||||
// GPU Pro 2 by Jorge Jimenez, Belen Masia, Jose I. Echevarria,
|
||||
// Fernando Navarro, and Diego Gutierrez.
|
||||
//
|
||||
// http://www.iryoku.com/mlaa/
|
||||
|
||||
#include "../../../gl/hlslCompat.glsl"
|
||||
|
||||
in vec2 texcoord;
|
||||
in vec4 offset[2];
|
||||
|
||||
uniform sampler2D blendMap;
|
||||
uniform sampler2D colorMapL;
|
||||
uniform sampler2D colorMap;
|
||||
|
||||
// Dummy sampers to please include.
|
||||
uniform sampler2D areaMap;
|
||||
uniform sampler2D edgesMapL;
|
||||
#include "./functions.glsl"
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
// Fetch the blending weights for current pixel:
|
||||
vec4 topLeft = texture(blendMap, texcoord);
|
||||
float bottom = texture(blendMap, offset[1].zw).g;
|
||||
float right = texture(blendMap, offset[1].xy).a;
|
||||
vec4 a = vec4(topLeft.r, bottom, topLeft.b, right);
|
||||
|
||||
// Up to 4 lines can be crossing a pixel (one in each edge). So, we perform
|
||||
// a weighted average, where the weight of each line is 'a' cubed, which
|
||||
// favors blending and works well in practice.
|
||||
vec4 w = a * a * a;
|
||||
|
||||
// There is some blending weight with a value greater than 0.0?
|
||||
float sum = dot(w, vec4(1.0));
|
||||
if (sum < 1e-5)
|
||||
discard;
|
||||
|
||||
vec4 color = vec4(0.0);
|
||||
|
||||
// Add the contributions of the possible 4 lines that can cross this pixel:
|
||||
#ifdef BILINEAR_FILTER_TRICK
|
||||
vec4 coords = mad(vec4( 0.0, -a.r, 0.0, a.g), PIXEL_SIZE.yyyy, texcoord.xyxy);
|
||||
color = mad(texture(colorMapL, coords.xy), vec4(w.r), color);
|
||||
color = mad(texture(colorMapL, coords.zw), vec4(w.g), color);
|
||||
|
||||
coords = mad(vec4(-a.b, 0.0, a.a, 0.0), PIXEL_SIZE.xxxx, texcoord.xyxy);
|
||||
color = mad(texture(colorMapL, coords.xy), vec4(w.b), color);
|
||||
color = mad(texture(colorMapL, coords.zw), vec4(w.a), color);
|
||||
#else
|
||||
vec4 C = texture(colorMap, texcoord);
|
||||
vec4 Cleft = texture(colorMap, offset[0].xy);
|
||||
vec4 Ctop = texture(colorMap, offset[0].zw);
|
||||
vec4 Cright = texture(colorMap, offset[1].xy);
|
||||
vec4 Cbottom = texture(colorMap, offset[1].zw);
|
||||
color = mad(mix(C, Ctop, a.r), vec4(w.r), color);
|
||||
color = mad(mix(C, Cbottom, a.g), vec4(w.g), color);
|
||||
color = mad(mix(C, Cleft, a.b), vec4(w.b), color);
|
||||
color = mad(mix(C, Cright, a.a), vec4(w.a), color);
|
||||
#endif
|
||||
|
||||
// Normalize the resulting color and we are finished!
|
||||
OUT_FragColor0 = color / sum;
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// An implementation of "Practical Morphological Anti-Aliasing" from
|
||||
// GPU Pro 2 by Jorge Jimenez, Belen Masia, Jose I. Echevarria,
|
||||
// Fernando Navarro, and Diego Gutierrez.
|
||||
//
|
||||
// http://www.iryoku.com/mlaa/
|
||||
|
||||
#include "../../../gl/hlslCompat.glsl"
|
||||
|
||||
in vec4 vPosition;
|
||||
in vec2 vTexCoord0;
|
||||
|
||||
#define IN_position vPosition
|
||||
#define IN_texcoord vTexCoord0
|
||||
|
||||
#define OUT_position gl_Position
|
||||
out vec2 texcoord;
|
||||
#define OUT_texcoord texcoord
|
||||
out vec4 offset[2];
|
||||
#define OUT_offset offset
|
||||
|
||||
uniform vec2 texSize0;
|
||||
|
||||
void main()
|
||||
{
|
||||
OUT_position = IN_position;
|
||||
vec2 PIXEL_SIZE = 1.0 / texSize0;
|
||||
|
||||
OUT_texcoord = IN_texcoord;
|
||||
OUT_texcoord.xy += PIXEL_SIZE * 0.5;
|
||||
|
||||
OUT_offset[0] = OUT_texcoord.xyxy + PIXEL_SIZE.xyxy * vec4(-1.0, 0.0, 0.0, -1.0);
|
||||
OUT_offset[1] = OUT_texcoord.xyxy + PIXEL_SIZE.xyxy * vec4( 1.0, 0.0, 0.0, 1.0);
|
||||
|
||||
correctSSP(gl_Position);
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
// deal in the Software without restriction, including without limitation the
|
||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
// sell copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// An implementation of "Practical Morphological Anti-Aliasing" from
|
||||
// GPU Pro 2 by Jorge Jimenez, Belen Masia, Jose I. Echevarria,
|
||||
// Fernando Navarro, and Diego Gutierrez.
|
||||
//
|
||||
// http://www.iryoku.com/mlaa/
|
||||
|
||||
#include "../../../gl/hlslCompat.glsl"
|
||||
|
||||
in vec4 vPosition;
|
||||
in vec2 vTexCoord0;
|
||||
|
||||
#define IN_position vPosition
|
||||
#define IN_texcoord vTexCoord0
|
||||
|
||||
#define OUT_position gl_Position
|
||||
out vec2 texcoord;
|
||||
#define OUT_texcoord texcoord
|
||||
|
||||
uniform vec2 texSize0;
|
||||
|
||||
void main()
|
||||
{
|
||||
OUT_position = IN_position;
|
||||
vec2 PIXEL_SIZE = 1.0 / texSize0;
|
||||
|
||||
OUT_texcoord = IN_texcoord;
|
||||
texcoord.xy += PIXEL_SIZE * 0.5;
|
||||
|
||||
correctSSP(gl_Position);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue