Render lines using SpriteRenderer without breaking the batch.
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
varying vec4 vColor;
|
||||
uniform bool EnableDepthPreview;
|
||||
|
||||
float jet_r(float x)
|
||||
{
|
||||
return x < 0.7 ? 4.0 * x - 1.5 : -4.0 * x + 4.5;
|
||||
}
|
||||
|
||||
float jet_g(float x)
|
||||
{
|
||||
return x < 0.5 ? 4.0 * x - 0.5 : -4.0 * x + 3.5;
|
||||
}
|
||||
|
||||
float jet_b(float x)
|
||||
{
|
||||
return x < 0.3 ? 4.0 * x + 0.5 : -4.0 * x + 2.5;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
float depth = gl_FragCoord.z;
|
||||
|
||||
// Convert to window coords
|
||||
gl_FragDepth = 0.5 * depth + 0.5;
|
||||
|
||||
if (EnableDepthPreview)
|
||||
{
|
||||
float x = 1.0 - gl_FragDepth;
|
||||
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);
|
||||
}
|
||||
else
|
||||
gl_FragColor = vColor;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
uniform vec3 Scroll;
|
||||
uniform vec3 r1, r2;
|
||||
|
||||
attribute vec4 aVertexPosition;
|
||||
attribute vec4 aVertexTexCoord;
|
||||
varying vec4 vColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4((aVertexPosition.xyz - Scroll.xyz) * r1 + r2, 1);
|
||||
vColor = aVertexTexCoord;
|
||||
}
|
||||
@@ -7,6 +7,7 @@ varying vec4 vTexCoord;
|
||||
varying vec2 vTexMetadata;
|
||||
varying vec4 vChannelMask;
|
||||
varying vec4 vDepthMask;
|
||||
varying vec4 vColorFraction;
|
||||
|
||||
float jet_r(float x)
|
||||
{
|
||||
@@ -27,7 +28,7 @@ void main()
|
||||
{
|
||||
vec4 x = texture2D(DiffuseTexture, vTexCoord.st);
|
||||
vec2 p = vec2(dot(x, vChannelMask), vTexMetadata.s);
|
||||
vec4 c = texture2D(Palette, p);
|
||||
vec4 c = (vec4(1, 1, 1, 1) - vColorFraction) * texture2D(Palette, p) + vColorFraction * vTexCoord;
|
||||
|
||||
// Discard any transparent fragments (both color and depth)
|
||||
if (c.a == 0.0)
|
||||
|
||||
@@ -8,6 +8,7 @@ varying vec4 vTexCoord;
|
||||
varying vec2 vTexMetadata;
|
||||
varying vec4 vChannelMask;
|
||||
varying vec4 vDepthMask;
|
||||
varying vec4 vColorFraction;
|
||||
|
||||
vec4 DecodeChannelMask(float x)
|
||||
{
|
||||
@@ -17,8 +18,18 @@ vec4 DecodeChannelMask(float x)
|
||||
return vec4(0,0,1,0);
|
||||
if (x > 0.3)
|
||||
return vec4(0,1,0,0);
|
||||
else
|
||||
if (x > 0.0)
|
||||
return vec4(1,0,0,0);
|
||||
|
||||
return vec4(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
vec4 DecodeColorFraction(float x)
|
||||
{
|
||||
if (x > 0.0)
|
||||
return vec4(0, 0, 0, 0);
|
||||
else
|
||||
return vec4(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
void main()
|
||||
@@ -27,6 +38,7 @@ void main()
|
||||
vTexCoord = aVertexTexCoord;
|
||||
vTexMetadata = aVertexTexMetadata;
|
||||
vChannelMask = DecodeChannelMask(abs(aVertexTexMetadata.t));
|
||||
vColorFraction = DecodeColorFraction(abs(aVertexTexMetadata.t));
|
||||
if (aVertexTexMetadata.t < 0.0)
|
||||
{
|
||||
float x = -aVertexTexMetadata.t * 10.0;
|
||||
|
||||
Reference in New Issue
Block a user