mirror of
https://git.stillkill.net/MinecraftLeak/MinecraftLegends.git
synced 2026-10-22 13:22:20 +01:00
Initial commit
This commit is contained in:
commit
86efc669e9
5013 files changed
+237743
No files matched your search
@@ -0,0 +1,27 @@
|
||||
|
||||
vec3 getBadgerInfluenceOverlay(vec3 worldPos, vec3 diffuse)
|
||||
{
|
||||
vec4 overlayColor = vec4(0, 0, 0, 0);
|
||||
for (int i = 0; i < NUM_STRUCTURES; ++i)
|
||||
{
|
||||
vec3 testPos = worldPos.xyz - vec3(0.5, 0.5, 0.5);
|
||||
vec3 dist = abs(testPos.xyz - STRUCTURE_DATA[i].xyz);
|
||||
vec3 aoe = STRUCTURE_DATA[i].www + vec3(0.5, 0.5, 0.5);
|
||||
vec3 res = step(dist, aoe);
|
||||
float a = res.x * res.y * res.z;
|
||||
|
||||
float kNumRings = 5.0;
|
||||
float kAnimTime = mod(TIME, 2.0) / 2.0;
|
||||
|
||||
float ring = max(dist.x, max(dist.y, dist.z));
|
||||
ring = floor(ring - (kAnimTime * kNumRings));
|
||||
ring = fract(ring / kNumRings);
|
||||
a *= mix(0.5, 1.0, abs(ring * 2.0 - 1.0));
|
||||
|
||||
overlayColor.rgb += STRUCTURE_COLOR[i].rgb * STRUCTURE_COLOR[i].a * a;
|
||||
}
|
||||
|
||||
diffuse.rgb = clamp(diffuse.rgb + overlayColor.rgb, vec3(0,0,0), vec3(1,1,1));
|
||||
|
||||
return diffuse;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroid.h"
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
|
||||
#if __VERSION__ >= 300
|
||||
_centroid varying vec4 uv;
|
||||
#else
|
||||
varying vec4 uv;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
varying vec4 fogColor;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_LIGHT
|
||||
varying vec4 light;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_TINTING
|
||||
varying vec4 color;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 diffuse = texture2D(TEXTURE_0, uv.xy);
|
||||
vec4 base = texture2D(TEXTURE_0, uv.zw);
|
||||
|
||||
#ifndef DISABLE_TINTING
|
||||
base.a = mix(diffuse.r * diffuse.a, diffuse.a, color.a);
|
||||
base.rgb *= color.rgb;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_LIGHT
|
||||
base.rgb *= light.rgb;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
//apply fog
|
||||
base.rgb = mix( base.rgb, fogColor.rgb, fogColor.a );
|
||||
#endif
|
||||
|
||||
gl_FragColor = base;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionCentroid.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/uniformEntityConstants.h"
|
||||
#include "shaders/uniformPerFrameConstants.h"
|
||||
#include "shaders/uniformBannerConstants.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
attribute vec4 NORMAL;
|
||||
attribute vec4 COLOR;
|
||||
|
||||
#if __VERSION__ >= 300
|
||||
_centroid varying vec4 uv;
|
||||
#else
|
||||
varying vec4 uv;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
varying vec4 fogColor;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_LIGHT
|
||||
varying vec4 light;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_TINTING
|
||||
varying vec4 color;
|
||||
#endif
|
||||
|
||||
const float AMBIENT = 0.45;
|
||||
|
||||
const float XFAC = -0.1;
|
||||
const float ZFAC = 0.1;
|
||||
|
||||
float lightIntensity() {
|
||||
#ifdef FANCY
|
||||
vec3 N = normalize( WORLD * NORMAL ).xyz;
|
||||
|
||||
N.y *= TILE_LIGHT_COLOR.w; //TILE_LIGHT_COLOR.w contains the direction of the light
|
||||
|
||||
//take care of double sided polygons on materials without culling
|
||||
#ifdef FLIP_BACKFACES
|
||||
vec3 viewDir = normalize((WORLD * POSITION).xyz);
|
||||
if( dot(N, viewDir) > 0.0 )
|
||||
N *= -1.0;
|
||||
#endif
|
||||
|
||||
float yLight = (1.0+N.y) * 0.5;
|
||||
return yLight * (1.0-AMBIENT) + N.x*N.x * XFAC + N.z*N.z * ZFAC + AMBIENT;
|
||||
#else
|
||||
return 1.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
POS4 pos = WORLDVIEWPROJ * POSITION;
|
||||
gl_Position = pos;
|
||||
|
||||
#ifdef ENABLE_LIGHT
|
||||
float L = lightIntensity();
|
||||
light = vec4(vec3(L) * TILE_LIGHT_COLOR.xyz, 1.0);
|
||||
#endif
|
||||
|
||||
int frameIndex = int((COLOR.a * 255.0) + 0.5);
|
||||
uv.xy = TEXCOORD_0.xy + BANNER_UV_OFFSETS[frameIndex].xy;
|
||||
uv.zw = TEXCOORD_0.xy;
|
||||
|
||||
#ifndef DISABLE_TINTING
|
||||
color = BANNER_COLORS[frameIndex];
|
||||
color.a = 1.0;
|
||||
if (frameIndex > 0) {
|
||||
color.a = 0.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
//fog
|
||||
fogColor.rgb = FOG_COLOR.rgb;
|
||||
fogColor.a = clamp(((pos.z / RENDER_DISTANCE) - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, 1.0);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroidUV.h"
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
|
||||
|
||||
void main() {
|
||||
//TODO: Implement
|
||||
//default to not blur anything
|
||||
gl_FragColor = texture2D(TEXTURE_0, uv);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/uniformPerFrameConstants.h"
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec4 COLOR;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
const float fogNear = 0.9;
|
||||
|
||||
const vec3 inverseLightDirection = vec3(0.62, 0.78, 0.0);
|
||||
const float ambient = 0.7;
|
||||
|
||||
void main()
|
||||
{
|
||||
POS4 pos = WORLDVIEWPROJ * POSITION;
|
||||
POS4 worldPos = WORLD * POSITION;
|
||||
gl_Position = pos;
|
||||
|
||||
color = COLOR * CURRENT_COLOR;
|
||||
|
||||
float depth = length(worldPos.xyz) / RENDER_DISTANCE;
|
||||
float fog = max(depth - fogNear, 0.0);
|
||||
|
||||
color.a *= 1.0 - fog;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionSimple.h"
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec4 COLOR;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
color = COLOR;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = color * CURRENT_COLOR;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroidUV.h"
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 diffuse = texture2D( TEXTURE_0, uv );
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if(diffuse.a < 0.5)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
float grayscale = (CURRENT_COLOR.r * diffuse.r * 0.3 + CURRENT_COLOR.g * diffuse.g * 0.59 + CURRENT_COLOR.b * diffuse.b * 0.11);
|
||||
vec4 gray_color = vec4(grayscale, grayscale, grayscale, CURRENT_COLOR.a * diffuse.a);
|
||||
gl_FragColor = gray_color;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/util_vertex.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec4 COLOR;
|
||||
attribute vec4 WEIGHTS;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
gl_Position.xy += computeScreenOffsets(POSITION.xyz, WEIGHTS, WORLDVIEWPROJ);
|
||||
|
||||
color = COLOR;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroidUV.h"
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
uniform sampler2D TEXTURE_1;
|
||||
|
||||
#include "shaders/uniformEntityConstants.h"
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
|
||||
#ifdef EFFECTS_OFFSET
|
||||
#include "shaders/uniformEffectsConstants.h"
|
||||
#endif
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
varying vec4 fogColor;
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
varying vec2 layer1UV;
|
||||
varying vec2 layer2UV;
|
||||
|
||||
vec4 glintBlend(vec4 dest, vec4 source) {
|
||||
return vec4(source.rgb * source.rgb, 0.0) + dest;
|
||||
}
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
#ifdef EFFECTS_OFFSET
|
||||
vec4 diffuse = texture2D( TEXTURE_0, uv + EFFECT_UV_OFFSET);
|
||||
#else
|
||||
vec4 diffuse = texture2D( TEXTURE_0, uv );
|
||||
#endif
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
#ifdef ENABLE_VERTEX_TINT_MASK
|
||||
if(diffuse.a <= 0.0)
|
||||
#else
|
||||
if(diffuse.a < 0.5)
|
||||
#endif
|
||||
discard;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VERTEX_TINT_MASK
|
||||
diffuse.rgb = mix(diffuse.rgb, diffuse.rgb*color.rgb, diffuse.a);
|
||||
if (color.a > 0.0) {
|
||||
diffuse.a = (diffuse.a > 0.0) ? 1.0 : 0.0; // This line is needed for horse armour icon and dyed leather to work properly
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
vec4 layer1 = texture2D(TEXTURE_1, fract(layer1UV)).rgbr * GLINT_COLOR;
|
||||
vec4 layer2 = texture2D(TEXTURE_1, fract(layer2UV)).rgbr * GLINT_COLOR;
|
||||
vec4 glint = (layer1 + layer2);
|
||||
|
||||
#ifdef INVENTORY
|
||||
diffuse.rgb = glint.rgb;
|
||||
#else
|
||||
diffuse.rgb = glintBlend(diffuse, glint).rgb;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_OVERLAY
|
||||
//use either the diffuse or the OVERLAY_COLOR
|
||||
diffuse.rgb = mix(diffuse, OVERLAY_COLOR, OVERLAY_COLOR.a).rgb;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
//apply fog
|
||||
diffuse.rgb = mix( diffuse.rgb, fogColor.rgb, fogColor.a );
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VERTEX_TINT_MASK
|
||||
|
||||
#ifdef ENABLE_CURRENT_ALPHA_MULTIPLY
|
||||
gl_FragColor = diffuse * vec4(1.0,1.0,1.0,HUD_OPACITY);
|
||||
#else
|
||||
gl_FragColor = diffuse;
|
||||
#endif
|
||||
|
||||
#else
|
||||
gl_FragColor = diffuse * color;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionCentroidUV.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/uniformEntityConstants.h"
|
||||
#include "shaders/uniformPerFrameConstants.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec4 COLOR;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
varying vec4 fogColor;
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
varying vec2 layer1UV;
|
||||
varying vec2 layer2UV;
|
||||
|
||||
vec2 calculateLayerUV(float offset, float rotation) {
|
||||
vec2 uv = TEXCOORD_0;
|
||||
uv -= 0.5;
|
||||
float rsin = sin(rotation);
|
||||
float rcos = cos(rotation);
|
||||
uv = mat2(rcos, -rsin, rsin, rcos) * uv;
|
||||
uv.x += offset;
|
||||
uv += 0.5;
|
||||
|
||||
return uv * GLINT_UV_SCALE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
color = COLOR;
|
||||
uv = TEXCOORD_0;
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
//fog
|
||||
fogColor.rgb = FOG_COLOR.rgb;
|
||||
fogColor.a = clamp(((gl_Position.z / RENDER_DISTANCE) - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
#ifdef USE_LIGHTING
|
||||
color *= vec4(TILE_LIGHT_COLOR.xyz, 1.0);
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
layer1UV = calculateLayerUV(UV_OFFSET.x, UV_ROTATION.x);
|
||||
layer2UV = calculateLayerUV(UV_OFFSET.y, UV_ROTATION.y);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = CURRENT_COLOR;
|
||||
|
||||
#if defined(FORCE_DEPTH_ZERO) && __VERSION__ >= 300
|
||||
gl_FragDepth = 0.0;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
// To use centroid sampling we need to have version 300 es shaders, which requires changing:
|
||||
// attribute to in
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroidUV.h"
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
//TODO: Implement
|
||||
gl_FragColor = texture2D(TEXTURE_0, uv);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroidUV.h"
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
|
||||
void main()
|
||||
{
|
||||
//TODO: Implement
|
||||
//Default to no depth of field
|
||||
gl_FragColor = texture2D(TEXTURE_0, uv);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroid.h"
|
||||
|
||||
#if __VERSION__ >= 300
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
#if defined(TEXEL_AA) && defined(TEXEL_AA_FEATURE)
|
||||
_centroid in highp vec2 colorLookupUV;
|
||||
_centroid in highp vec2 parallaxUV;
|
||||
#else
|
||||
_centroid in vec2 colorLookupUV;
|
||||
_centroid in highp vec2 parallaxUV;
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
varying vec2 colorLookupUV;
|
||||
varying highp vec2 parallaxUV;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
varying lowp vec4 encodedPlane;
|
||||
#ifdef FOG
|
||||
varying vec4 fogColor;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
uniform sampler2D TEXTURE_1;
|
||||
|
||||
const float MAX_LAYER_DEPTH = 32.0;
|
||||
|
||||
void main()
|
||||
{
|
||||
#ifdef BYPASS_PIXEL_SHADER
|
||||
gl_FragColor = vec4(0, 0, 0, 0);
|
||||
#else
|
||||
|
||||
///// Color Assembly
|
||||
vec4 colorSample = texture2D(TEXTURE_1, colorLookupUV);
|
||||
vec4 textureSample = texture2D(TEXTURE_0, parallaxUV);
|
||||
float brightness = 1.0 - (encodedPlane.w);
|
||||
vec3 result = textureSample.rgb * colorSample.rgb * brightness;
|
||||
|
||||
#ifdef FOG
|
||||
if(encodedPlane.w * MAX_LAYER_DEPTH > MAX_LAYER_DEPTH - 1.0) {
|
||||
gl_FragColor = vec4(mix(vec3(0,0,0), fogColor.rgb, fogColor.a), 0);
|
||||
}
|
||||
else {
|
||||
gl_FragColor = vec4(result * (1.0 - fogColor.a), 1);
|
||||
}
|
||||
#else
|
||||
// Look for hard-coded value to clear the portal first
|
||||
if(encodedPlane.w * MAX_LAYER_DEPTH > MAX_LAYER_DEPTH - 1.0) {
|
||||
gl_FragColor = vec4(0, 0, 0, 0);
|
||||
}
|
||||
else {
|
||||
gl_FragColor = vec4(result, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
// To use centroid sampling we need to have version 300 es shaders, which requires changing:
|
||||
// attribute to in
|
||||
// varying to out when in vertex shaders or in when in fragment shaders
|
||||
// defining an out vec4 FragColor and replacing uses of gl_FragColor with FragColor
|
||||
// texture2D to texture
|
||||
|
||||
precision highp float;
|
||||
|
||||
#include "shaders/vertexVersionCentroid.h"
|
||||
|
||||
#if __VERSION__ >= 300
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
_centroid out vec2 colorLookupUV;
|
||||
_centroid out vec2 parallaxUV;
|
||||
#endif
|
||||
#else
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
varying vec2 colorLookupUV;
|
||||
varying vec2 parallaxUV;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
varying lowp vec4 encodedPlane;
|
||||
#ifdef FOG
|
||||
varying vec4 fogColor;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/uniformPerFrameConstants.h"
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
#include "shaders/uniformRenderChunkConstants.h"
|
||||
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
attribute POS4 POSITION;
|
||||
attribute vec4 COLOR;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
attribute vec2 TEXCOORD_1;
|
||||
#endif
|
||||
|
||||
const float MAX_LAYER_DEPTH = 32.0;
|
||||
|
||||
void main() {
|
||||
///// Vertex Transformation
|
||||
POS4 worldPos = vec4((POSITION.xyz * CHUNK_ORIGIN_AND_SCALE.w) + CHUNK_ORIGIN_AND_SCALE.xyz, 1);
|
||||
POS4 pos = PROJ * (WORLDVIEW * worldPos);
|
||||
gl_Position = pos;
|
||||
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
///// End Portal Data
|
||||
colorLookupUV = TEXCOORD_0;
|
||||
encodedPlane = COLOR; // Color value is used to encode the starfield plane
|
||||
|
||||
vec3 planeNormal = (encodedPlane.xyz - vec3(0.5,0.5,0.5)) * 2.0;
|
||||
float planeDistance = encodedPlane.w * MAX_LAYER_DEPTH;
|
||||
|
||||
// Calculate view direction from the surface position and the eye position
|
||||
POS3 viewRay = worldPos.xyz;
|
||||
|
||||
///// Ray-cast for parallax-offset UV
|
||||
// Perform ray-plane intersection to find the position on the parallax plane
|
||||
float t = (dot(viewRay - (planeDistance * planeNormal), planeNormal)) / dot(viewRay, planeNormal);
|
||||
POS3 parallaxPositionInWorld = (t * viewRay) + VIEW_POS;
|
||||
|
||||
///// Ridiculous UV-remapping
|
||||
// Create a mask with a 1 wherever the normal would have a non-zero value
|
||||
// All normals are orthonormal on <x,y,z>, so there should be two 0's and a 1
|
||||
vec3 normalMask = floor(abs(planeNormal) + vec3(0.5,0.5,0.5));
|
||||
// Mask out the correct uv result
|
||||
vec2 raycastUV = parallaxPositionInWorld.yz * normalMask[0] + parallaxPositionInWorld.xz * normalMask[1] + parallaxPositionInWorld.xy * normalMask[2];
|
||||
|
||||
// Scale the UVs to Minecraft pixel size
|
||||
raycastUV = raycastUV / 16.0; // TODO: Use TEXTURE_DIMENSIONS
|
||||
|
||||
const float rotor = 3.1415926535897 * (5.0 / 7.0);
|
||||
float rotS = sin(planeDistance * rotor);
|
||||
float rotC = cos(planeDistance * rotor);
|
||||
|
||||
parallaxUV = mat2(vec2(rotC, rotS), vec2(-rotS, rotC)) * raycastUV;
|
||||
|
||||
parallaxUV += vec2(rotC, rotS) * planeDistance;
|
||||
parallaxUV.y += TIME / 256.0;
|
||||
|
||||
const float modVal = 64.0;
|
||||
parallaxUV = vec2(mod(parallaxUV.x, modVal), mod(parallaxUV.y, modVal));
|
||||
|
||||
///// Fog
|
||||
#ifdef FOG
|
||||
#ifdef FANCY
|
||||
vec3 relPos = -worldPos.xyz;
|
||||
float cameraDepth = length(relPos);
|
||||
#ifdef NEAR_WATER
|
||||
cameraDist = cameraDepth / FAR_CHUNKS_DISTANCE;
|
||||
#endif
|
||||
#else
|
||||
float cameraDepth = pos.z;
|
||||
#ifdef NEAR_WATER
|
||||
vec3 relPos = -worldPos.xyz;
|
||||
float camDist = length(relPos);
|
||||
cameraDist = camDist / FAR_CHUNKS_DISTANCE;
|
||||
#endif
|
||||
#endif
|
||||
float len = cameraDepth / RENDER_DISTANCE;
|
||||
#ifdef ALLOW_FADE
|
||||
len += CURRENT_COLOR.r;
|
||||
#endif
|
||||
fogColor.rgb = FOG_COLOR.rgb;
|
||||
fogColor.a = clamp((len - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, 1.0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroidUV.h"
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
#include "shaders/util.h"
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
uniform sampler2D TEXTURE_1;
|
||||
|
||||
#ifdef USE_MULTITEXTURE
|
||||
uniform sampler2D TEXTURE_2;
|
||||
#endif
|
||||
|
||||
varying vec4 light;
|
||||
varying vec4 fogColor;
|
||||
|
||||
#ifdef USE_OVERLAY
|
||||
varying vec4 overlayColor;
|
||||
#endif
|
||||
|
||||
varying vec4 teamColor;
|
||||
|
||||
#ifdef TINTED_ALPHA_TEST
|
||||
varying float alphaTestMultiplier;
|
||||
#endif
|
||||
|
||||
#if defined(USE_COLOR_MASK) || defined(ITEM_IN_HAND) || defined(COLOR_SECOND_TEXTURE)
|
||||
varying vec4 changeColor;
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
varying vec2 layer1UV;
|
||||
varying vec2 layer2UV;
|
||||
varying vec4 tileLightColor;
|
||||
varying vec4 glintColor;
|
||||
#endif
|
||||
|
||||
vec4 glintBlend(vec4 dest, vec4 source) {
|
||||
// glBlendFuncSeparate(GL_SRC_COLOR, GL_ONE, GL_ONE, GL_ZERO)
|
||||
return vec4(source.rgb * source.rgb, source.a) + vec4(dest.rgb, 0.0);
|
||||
}
|
||||
|
||||
vec3 blendTeamColor(vec3 base, vec3 blend, float amt)
|
||||
{
|
||||
return base + (blend * amt);
|
||||
}
|
||||
|
||||
#ifdef USE_EMISSIVE
|
||||
#ifdef USE_ONLY_EMISSIVE
|
||||
#define NEEDS_DISCARD(C) (C.a == 0.0 || C.a == 1.0 )
|
||||
#else
|
||||
#define NEEDS_DISCARD(C) (C.a + C.r + C.g + C.b == 0.0)
|
||||
#endif
|
||||
#else
|
||||
#ifndef USE_COLOR_MASK
|
||||
#define NEEDS_DISCARD(C) (C.a < 0.5)
|
||||
#else
|
||||
#define NEEDS_DISCARD(C) (C.a == 0.0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = vec4(1.0);
|
||||
|
||||
#ifndef NO_TEXTURE
|
||||
#if !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE)
|
||||
color = texture2D( TEXTURE_0, uv );
|
||||
#else
|
||||
color = texture2D_AA(TEXTURE_0, uv);
|
||||
#endif // !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE)
|
||||
|
||||
#if defined(ALPHA_TEST) && !defined(USE_MULTITEXTURE)
|
||||
if(NEEDS_DISCARD(color))
|
||||
discard;
|
||||
#endif // ALPHA_TEST
|
||||
|
||||
#ifdef TINTED_ALPHA_TEST
|
||||
vec4 testColor = color;
|
||||
testColor.a *= alphaTestMultiplier;
|
||||
if(NEEDS_DISCARD(testColor))
|
||||
discard;
|
||||
#endif // TINTED_ALPHA_TEST
|
||||
#endif // NO_TEXTURE
|
||||
|
||||
#ifdef USE_COLOR_MASK
|
||||
color.rgb = mix(color.rgb, color.rgb*changeColor.rgb, color.a);
|
||||
color.a *= changeColor.a;
|
||||
#endif
|
||||
|
||||
#ifdef ITEM_IN_HAND
|
||||
color.rgb = mix(color.rgb, color.rgb*changeColor.rgb, light.a);
|
||||
#endif
|
||||
|
||||
#ifdef USE_MULTITEXTURE
|
||||
vec4 tex1 = texture2D( TEXTURE_1, uv );
|
||||
vec4 tex2 = texture2D( TEXTURE_2, uv );
|
||||
color.rgb = mix(color.rgb, tex1.rgb, tex1.a);
|
||||
#ifdef ALPHA_TEST
|
||||
if (color.a < 0.5 && tex1.a == 0.0) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COLOR_SECOND_TEXTURE
|
||||
if (tex2.a > 0.0) {
|
||||
color.rgb = tex2.rgb + (tex2.rgb * changeColor.rgb - tex2.rgb)*tex2.a;//lerp(tex2.rgb, tex2 * changeColor.rgb, tex2.a)
|
||||
}
|
||||
#else
|
||||
color.rgb = mix(color.rgb, tex2.rgb, tex2.a);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_OVERLAY
|
||||
//use either the diffuse or the OVERLAY_COLOR
|
||||
color.rgb = mix(color, overlayColor, overlayColor.a).rgb;
|
||||
#endif
|
||||
|
||||
color.rgb = blendTeamColor(color.rgb, teamColor.rgb, teamColor.a);
|
||||
|
||||
#ifdef USE_EMISSIVE
|
||||
//make glowy stuff
|
||||
color *= mix(vec4(1.0), light, color.a );
|
||||
#else
|
||||
color *= light;
|
||||
#endif
|
||||
|
||||
//apply fog
|
||||
color.rgb = mix( color.rgb, fogColor.rgb, fogColor.a );
|
||||
|
||||
#ifdef GLINT
|
||||
// Applies color mask to glint texture instead and blends with original color
|
||||
vec4 layer1 = texture2D(TEXTURE_1, fract(layer1UV)).rgbr * glintColor;
|
||||
vec4 layer2 = texture2D(TEXTURE_1, fract(layer2UV)).rgbr * glintColor;
|
||||
vec4 glint = (layer1 + layer2) * tileLightColor;
|
||||
|
||||
color = glintBlend(color, glint);
|
||||
#endif
|
||||
|
||||
//WARNING do not refactor this
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionCentroidUV.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/uniformEntityConstants.h"
|
||||
#include "shaders/uniformPerFrameConstants.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
attribute vec4 NORMAL;
|
||||
|
||||
#ifdef COLOR_BASED
|
||||
attribute vec4 COLOR;
|
||||
#endif
|
||||
|
||||
varying vec4 light;
|
||||
varying vec4 fogColor;
|
||||
|
||||
#ifdef USE_OVERLAY
|
||||
varying vec4 overlayColor;
|
||||
#endif
|
||||
|
||||
varying vec4 teamColor;
|
||||
|
||||
#ifdef TINTED_ALPHA_TEST
|
||||
varying float alphaTestMultiplier;
|
||||
#endif
|
||||
|
||||
#if defined(USE_COLOR_MASK) || defined(ITEM_IN_HAND) || defined(COLOR_SECOND_TEXTURE)
|
||||
varying vec4 changeColor;
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
varying vec2 layer1UV;
|
||||
varying vec2 layer2UV;
|
||||
varying vec4 tileLightColor;
|
||||
varying vec4 glintColor;
|
||||
#endif
|
||||
|
||||
const float AMBIENT = 0.45;
|
||||
|
||||
const float XFAC = -0.1;
|
||||
const float ZFAC = 0.1;
|
||||
|
||||
float teamColorIntensity(vec3 pos, vec3 normal)
|
||||
{
|
||||
#if 1
|
||||
float amt = clamp(pos.y / 16.f, 0, 1);
|
||||
return amt;
|
||||
#else
|
||||
vec3 lightDir = normalize(vec3(1, 0, 1));
|
||||
vec3 N = normalize(normal * mat3(WORLDVIEW)).xyz;
|
||||
return clamp(dot(N, lightDir), 0, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
float lightIntensity(vec3 N) {
|
||||
#ifdef FANCY
|
||||
N.y *= TILE_LIGHT_COLOR.w; //TILE_LIGHT_COLOR.w contains the direction of the light
|
||||
|
||||
//take care of double sided polygons on materials without culling
|
||||
#ifdef FLIP_BACKFACES
|
||||
vec3 viewDir = normalize((WORLD * POSITION).xyz);
|
||||
if( dot(N, viewDir) > 0.0 )
|
||||
N *= -1.0;
|
||||
#endif
|
||||
|
||||
float yLight = (1.0+N.y) * 0.5;
|
||||
return yLight * (1.0-AMBIENT) + N.x*N.x * XFAC + N.z*N.z * ZFAC + AMBIENT;
|
||||
#else
|
||||
return 1.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef GLINT
|
||||
vec2 calculateLayerUV(float offset, float rotation) {
|
||||
vec2 uv = TEXCOORD_0;
|
||||
uv -= 0.5;
|
||||
float rsin = sin(rotation);
|
||||
float rcos = cos(rotation);
|
||||
uv = mat2(rcos, -rsin, rsin, rcos) * uv;
|
||||
uv.x += offset;
|
||||
uv += 0.5;
|
||||
|
||||
return uv * GLINT_UV_SCALE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
POS4 pos = WORLDVIEWPROJ * POSITION;
|
||||
gl_Position = pos;
|
||||
|
||||
vec3 N = normalize( WORLD * NORMAL ).xyz;
|
||||
|
||||
float L = lightIntensity(N);
|
||||
|
||||
#ifdef USE_OVERLAY
|
||||
L += OVERLAY_COLOR.a * 0.35;
|
||||
overlayColor = OVERLAY_COLOR;
|
||||
#endif
|
||||
|
||||
float intensity = teamColorIntensity(POSITION.xyz, N.xyz);
|
||||
teamColor = vec4(TEAM_COLOR.rgb, intensity * TEAM_COLOR.a);
|
||||
|
||||
#ifdef TINTED_ALPHA_TEST
|
||||
alphaTestMultiplier = OVERLAY_COLOR.a;
|
||||
#endif
|
||||
|
||||
#if defined(USE_COLOR_MASK) || defined(ITEM_IN_HAND) || defined(COLOR_SECOND_TEXTURE)
|
||||
changeColor = CHANGE_COLOR;
|
||||
#endif
|
||||
|
||||
light = vec4(vec3(L) * TILE_LIGHT_COLOR.xyz, 1.0);
|
||||
|
||||
#ifdef COLOR_BASED
|
||||
light *= COLOR;
|
||||
#endif
|
||||
|
||||
#ifndef NO_TEXTURE
|
||||
uv = TEXCOORD_0;
|
||||
#endif
|
||||
|
||||
#ifdef USE_UV_ANIM
|
||||
uv.xy = UV_ANIM.xy + (uv.xy * UV_ANIM.zw);
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
glintColor = GLINT_COLOR;
|
||||
layer1UV = calculateLayerUV(UV_OFFSET.x, UV_ROTATION.x);
|
||||
layer2UV = calculateLayerUV(UV_OFFSET.y, UV_ROTATION.y);
|
||||
tileLightColor = TILE_LIGHT_COLOR;
|
||||
#endif
|
||||
|
||||
|
||||
//fog
|
||||
fogColor.rgb = FOG_COLOR.rgb;
|
||||
fogColor.a = clamp(((pos.z / RENDER_DISTANCE) - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
#version 100
|
||||
uniform sampler2D TEXTURE_0;
|
||||
uniform sampler2D TEXTURE_1;
|
||||
uniform sampler2D TEXTURE_2;
|
||||
|
||||
varying vec4 light;
|
||||
varying vec4 fogColor;
|
||||
|
||||
#ifndef COLOR_BASED
|
||||
varying vec2 uv;
|
||||
#endif
|
||||
#ifdef USE_OVERLAY
|
||||
varying vec4 overlayColor;
|
||||
#endif
|
||||
|
||||
#ifdef USE_EMISSIVE
|
||||
#define NEEDS_DISCARD(C) (C.a + C.r + C.g + C.b == 0.0)
|
||||
#else
|
||||
#define NEEDS_DISCARD(C) (C.a < 0.5)
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = vec4(1.0);
|
||||
#ifndef COLOR_BASED
|
||||
color = texture2D( TEXTURE_0, uv );
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if(NEEDS_DISCARD(color))
|
||||
discard;
|
||||
#endif
|
||||
|
||||
vec4 markings = texture2D( TEXTURE_1, uv );
|
||||
vec4 armor = texture2D( TEXTURE_2, uv );
|
||||
|
||||
color.rgb = mix(color, markings, markings.a).rgb;
|
||||
color.rgb = mix(color, armor, armor.a).rgb;
|
||||
#endif
|
||||
|
||||
#ifdef USE_OVERLAY
|
||||
//use either the diffuse or the OVERLAY_COLOR
|
||||
color.rgb = mix(color, overlayColor, overlayColor.a).rgb;
|
||||
#endif
|
||||
|
||||
#ifdef USE_EMISSIVE
|
||||
//make glowy stuff
|
||||
color *= mix(vec4(1.0), light, color.a );
|
||||
#else
|
||||
color *= light;
|
||||
#endif
|
||||
|
||||
//apply fog
|
||||
color.rgb = mix( color.rgb, fogColor.rgb, fogColor.a );
|
||||
|
||||
//WARNING do not refactor this
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionSimple.h"
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1.0);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// To use centroid sampling we need to have version 300 es shaders, which requires changing:
|
||||
// attribute to in
|
||||
// varying to out when in vertex shaders or in when in fragment shaders
|
||||
// defining an out vec4 FragColor and replacing uses of gl_FragColor with FragColor
|
||||
// texture2D to texture
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
||||
#define _centroid centroid
|
||||
#else
|
||||
#define _centroid
|
||||
#endif
|
||||
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
// To use centroid sampling we need to have version 300 es shaders, which requires changing:
|
||||
// attribute to in
|
||||
// varying to out when in vertex shaders or in when in fragment shaders
|
||||
// defining an out vec4 FragColor and replacing uses of gl_FragColor with FragColor
|
||||
// texture2D to texture
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
||||
#define _centroid centroid
|
||||
#else
|
||||
#define _centroid
|
||||
#endif
|
||||
|
||||
// version 300 code
|
||||
_centroid in vec2 uv;
|
||||
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
varying vec2 uv;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
// To use centroid sampling we need to have version 300 es shaders, which requires changing:
|
||||
// attribute to in
|
||||
// varying to out when in vertex shaders or in when in fragment shaders
|
||||
// defining an out vec4 FragColor and replacing uses of gl_FragColor with FragColor
|
||||
// texture2D to texture
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroidUV.h"
|
||||
|
||||
//This file is purely here to let the code compile. It is used only for HoloWall, which currently runs only on DX11 compatible devices
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1,0,1,1);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformEntityConstants.h"
|
||||
|
||||
varying vec4 light;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = mix(vec4(1), light, light.a );
|
||||
|
||||
color.rgb = mix(color, OVERLAY_COLOR, OVERLAY_COLOR.a).rgb;
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroidUV.h"
|
||||
|
||||
// This shader isn't actually used in OGL, we have to have an OGL shader since a material refers to the DX version
|
||||
// and thus this also needs to exist on the OGL side.
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec4 NORMAL;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
color.rgb = (NORMAL.xyz / 2) + 0.5;
|
||||
color.a = 1.0;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#define MCPE_PLATFORM_NX
|
||||
|
||||
//#if __VERSION__ >= 300
|
||||
#define MAT4 highp mat4
|
||||
#define POS4 highp vec4
|
||||
#define POS3 highp vec3
|
||||
precision highp float;
|
||||
//#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
#version 430
|
||||
|
||||
#include "nvn.h"
|
||||
@@ -0,0 +1,3 @@
|
||||
#version 430
|
||||
|
||||
#include "nvn.h"
|
||||
@@ -0,0 +1,8 @@
|
||||
#version 430
|
||||
|
||||
#include "nvn.h"
|
||||
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
};
|
||||
@@ -0,0 +1,9 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionSimple.h"
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1,1,1,1);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionSimple.h"
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
uniform sampler2D TEXTURE_1;
|
||||
uniform sampler2D TEXTURE_2;
|
||||
|
||||
varying vec2 uv;
|
||||
varying vec4 color;
|
||||
varying vec4 worldPosition;
|
||||
varying vec4 fogColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 albedo = texture2D( TEXTURE_0, uv);
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if (albedo.a < 0.5)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
albedo.a *= color.a;
|
||||
|
||||
vec2 occlusionUV = worldPosition.xz;
|
||||
vec4 occlusionTexture = texture2D( TEXTURE_1, occlusionUV);
|
||||
|
||||
#ifndef FLIP_OCCLUSION
|
||||
#define OCCLUSION_OPERATOR <
|
||||
#else
|
||||
#define OCCLUSION_OPERATOR >
|
||||
#endif
|
||||
|
||||
#ifdef SNOW
|
||||
#define OCCLUSION_HEIGHT occlusionTexture.g
|
||||
#define OCCLUSION_LUMINANCE occlusionTexture.r
|
||||
#else
|
||||
#define OCCLUSION_HEIGHT occlusionTexture.a
|
||||
#define OCCLUSION_LUMINANCE occlusionTexture.b
|
||||
#endif
|
||||
|
||||
// clamp the uvs
|
||||
if ( occlusionUV.x >= 0.0 && occlusionUV.x <= 1.0 &&
|
||||
occlusionUV.y >= 0.0 && occlusionUV.y <= 1.0 &&
|
||||
worldPosition.y OCCLUSION_OPERATOR OCCLUSION_HEIGHT) {
|
||||
albedo.a = 0.0;
|
||||
}
|
||||
|
||||
float mixAmount = (worldPosition.y - OCCLUSION_HEIGHT)*25.0;
|
||||
vec2 lightingUVs = vec2(OCCLUSION_LUMINANCE, 1.0);
|
||||
lightingUVs.x = mix(lightingUVs.x, 0.0, mixAmount);
|
||||
|
||||
vec3 lighting = texture2D( TEXTURE_2, lightingUVs ).rgb;
|
||||
vec4 finalOutput = albedo;
|
||||
finalOutput.rgb *= lighting.rgb;
|
||||
|
||||
//apply fog
|
||||
gl_FragColor.rgb = mix( finalOutput.rgb, fogColor.rgb, fogColor.a );
|
||||
gl_FragColor.a = finalOutput.a;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionSimple.h"
|
||||
|
||||
precision highp float;
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/uniformWeatherConstants.h"
|
||||
#include "shaders/uniformPerFrameConstants.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
attribute vec4 COLOR;
|
||||
|
||||
varying vec2 uv;
|
||||
varying vec4 color;
|
||||
varying vec4 worldPosition;
|
||||
varying vec4 fogColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
float spriteSelector = COLOR.x*255.0;
|
||||
uv = UV_INFO.xy + (TEXCOORD_0 * UV_INFO.zw);
|
||||
#ifndef NO_VARIETY
|
||||
uv.x += spriteSelector * UV_INFO.z;
|
||||
#endif
|
||||
|
||||
vec3 pos = POSITION.xyz;
|
||||
|
||||
// subtract the offset then fmod into (0.0f, PARTICLE_BOX)
|
||||
pos.xyz += POSITION_OFFSET.xyz;
|
||||
pos.xyz = mod(pos.xyz, PARTICLE_BOX.xyz);
|
||||
|
||||
// centre box on origin
|
||||
pos.xyz -= PARTICLE_BOX.xyz * 0.5;
|
||||
|
||||
// push along view vector so box is positioned more infront of camera
|
||||
pos.xyz += FORWARD.xyz;
|
||||
|
||||
// get world position
|
||||
vec4 worldPositionBottom = vec4(pos.xyz, 1.0);
|
||||
vec4 worldPositionTop = vec4(worldPositionBottom.xyz + (VELOCITY.xyz * SIZE_SCALE.y), 1.0);
|
||||
|
||||
// get projected positions of top and bottom of particle, and top of particle in previous frame
|
||||
vec4 bottom = WORLDVIEWPROJ * worldPositionBottom;
|
||||
vec4 top = WORLDVIEWPROJ * worldPositionTop;
|
||||
|
||||
// get 2d vector in screenspace between top and bottom of particle
|
||||
vec2 dir = normalize((top.xy/top.w) - (bottom.xy/bottom.w));
|
||||
|
||||
// get 2d vector perpendicular to velocity
|
||||
vec2 dirPerp = normalize(vec2(-dir.y, dir.x));
|
||||
|
||||
// choose either the top or bottom projected position using uv.y
|
||||
gl_Position = mix(top, bottom, TEXCOORD_0.y);
|
||||
|
||||
// offset the position of each side of the particle using uv.x
|
||||
gl_Position.xy += (0.5 - TEXCOORD_0.x) * dirPerp * SIZE_SCALE.x;
|
||||
|
||||
color = ALPHA.rgba;
|
||||
|
||||
#if defined(COMFORT_MODE) && defined(VR_MODE)
|
||||
if (gl_Position.z < 2.0) {
|
||||
color.a = clamp((gl_Position.z - 1.2)/0.8, 0.0, 1.0);
|
||||
}
|
||||
#endif
|
||||
|
||||
//fog
|
||||
fogColor.rgb = FOG_COLOR.rgb;
|
||||
fogColor.a = clamp(((bottom.z / RENDER_DISTANCE) - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, 1.0);
|
||||
|
||||
worldPositionBottom.xz *= 1.0 / 64.0; // Scale by 1/TextureDimensions to get values between
|
||||
worldPositionBottom.xz += 0.5; // Offset so that center of view is in the center of occlusion texture
|
||||
worldPositionBottom.y += VIEW_POSITION.y - 0.5;
|
||||
worldPositionBottom.y *= 1.0/255.0;
|
||||
worldPosition = worldPositionBottom;
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroid.h"
|
||||
|
||||
varying vec3 worldPosition;
|
||||
|
||||
#if __VERSION__ >= 300
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
#if defined(TEXEL_AA) && defined(TEXEL_AA_FEATURE)
|
||||
_centroid in highp vec2 uv0;
|
||||
_centroid in highp vec2 uv1;
|
||||
#else
|
||||
_centroid in vec2 uv0;
|
||||
_centroid in vec2 uv1;
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
varying vec2 uv0;
|
||||
varying vec2 uv1;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef FOG
|
||||
varying vec4 fogColor;
|
||||
#endif
|
||||
|
||||
#ifdef NEAR_WATER
|
||||
varying float cameraDist;
|
||||
#endif
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
#include "shaders/uniformPerFrameConstants.h"
|
||||
#include "shaders/uniformBadgerConstants.h"
|
||||
#include "shaders/util.h"
|
||||
#include "shaders/badger_util.h"
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
uniform sampler2D TEXTURE_1;
|
||||
uniform sampler2D TEXTURE_2;
|
||||
|
||||
void main()
|
||||
{
|
||||
#ifdef BYPASS_PIXEL_SHADER
|
||||
gl_FragColor = vec4(0, 0, 0, 0);
|
||||
return;
|
||||
#else
|
||||
|
||||
#if !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE)
|
||||
vec4 diffuse = texture2D( TEXTURE_0, uv0 );
|
||||
#else
|
||||
vec4 diffuse = texture2D_AA(TEXTURE_0, uv0 );
|
||||
#endif
|
||||
|
||||
vec4 inColor = color;
|
||||
|
||||
#ifdef SEASONS_FAR
|
||||
diffuse.a = 1.0;
|
||||
inColor.b = 1.0;
|
||||
#endif
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
#ifdef ALPHA_TO_COVERAGE
|
||||
float alphaThreshold = .05;
|
||||
#else
|
||||
float alphaThreshold = .5;
|
||||
#endif
|
||||
if(diffuse.a < alphaThreshold)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
#if !defined(ALWAYS_LIT)
|
||||
diffuse = diffuse * texture2D( TEXTURE_1, uv1 );
|
||||
#endif
|
||||
|
||||
#ifndef SEASONS
|
||||
|
||||
#if !defined(ALPHA_TEST) && !defined(BLEND)
|
||||
diffuse.a = inColor.a;
|
||||
#elif defined(BLEND)
|
||||
#ifdef NEAR_WATER
|
||||
diffuse.a *= inColor.a;
|
||||
float alphaFadeOut = clamp(cameraDist, 0.0, 1.0);
|
||||
diffuse.a = mix(diffuse.a, 1.0, alphaFadeOut);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
diffuse.rgb *= inColor.rgb;
|
||||
#else
|
||||
vec2 uv = inColor.xy;
|
||||
diffuse.rgb *= mix(vec3(1.0,1.0,1.0), texture2D( TEXTURE_2, uv).rgb*2.0, inColor.b);
|
||||
diffuse.rgb *= inColor.aaa;
|
||||
diffuse.a = 1.0;
|
||||
#endif
|
||||
|
||||
diffuse.rgb = getBadgerInfluenceOverlay(worldPosition.xyz, diffuse.rgb);
|
||||
|
||||
#ifdef FOG
|
||||
diffuse.rgb = mix( diffuse.rgb, fogColor.rgb, fogColor.a );
|
||||
#endif
|
||||
|
||||
gl_FragColor = diffuse;
|
||||
|
||||
#endif // BYPASS_PIXEL_SHADER
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
varying vec3 worldPosition;
|
||||
|
||||
#include "shaders/vertexVersionCentroid.h"
|
||||
#if __VERSION__ >= 300
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
_centroid out vec2 uv0;
|
||||
_centroid out vec2 uv1;
|
||||
#endif
|
||||
#else
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
varying vec2 uv0;
|
||||
varying vec2 uv1;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
varying vec4 color;
|
||||
#endif
|
||||
|
||||
#ifdef FOG
|
||||
varying vec4 fogColor;
|
||||
#endif
|
||||
|
||||
#ifdef NEAR_WATER
|
||||
varying float cameraDist;
|
||||
#endif
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/uniformPerFrameConstants.h"
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
#include "shaders/uniformRenderChunkConstants.h"
|
||||
|
||||
attribute POS4 POSITION;
|
||||
attribute vec4 COLOR;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
attribute vec2 TEXCOORD_1;
|
||||
|
||||
const float rA = 1.0;
|
||||
const float rB = 1.0;
|
||||
const vec3 UNIT_Y = vec3(0,1,0);
|
||||
const float DIST_DESATURATION = 56.0 / 255.0; //WARNING this value is also hardcoded in the water color, don'tchange
|
||||
|
||||
void main()
|
||||
{
|
||||
POS4 worldPos;
|
||||
#ifdef AS_ENTITY_RENDERER
|
||||
POS4 pos = WORLDVIEWPROJ * POSITION;
|
||||
worldPos = pos;
|
||||
#else
|
||||
worldPos.xyz = (POSITION.xyz * CHUNK_ORIGIN_AND_SCALE.w) + CHUNK_ORIGIN_AND_SCALE.xyz;
|
||||
worldPos.w = 1.0;
|
||||
|
||||
// Transform to view space before projection instead of all at once to avoid floating point errors
|
||||
// Not required for entities because they are already offset by camera translation before rendering
|
||||
// World position here is calculated above and can get huge
|
||||
POS4 pos = WORLDVIEW * worldPos;
|
||||
pos = PROJ * pos;
|
||||
#endif
|
||||
|
||||
worldPosition = worldPos.xyz;
|
||||
gl_Position = pos;
|
||||
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
uv0 = TEXCOORD_0;
|
||||
uv1 = TEXCOORD_1;
|
||||
color = COLOR;
|
||||
#endif
|
||||
|
||||
///// find distance from the camera
|
||||
|
||||
#if defined(FOG) || defined(NEAR_WATER)
|
||||
#ifdef FANCY
|
||||
vec3 relPos = -worldPos.xyz;
|
||||
float cameraDepth = length(relPos);
|
||||
#ifdef NEAR_WATER
|
||||
cameraDist = cameraDepth / FAR_CHUNKS_DISTANCE;
|
||||
#endif
|
||||
#else
|
||||
float cameraDepth = pos.z;
|
||||
#ifdef NEAR_WATER
|
||||
vec3 relPos = -worldPos.xyz;
|
||||
float camDist = length(relPos);
|
||||
cameraDist = camDist / FAR_CHUNKS_DISTANCE;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
///// apply fog
|
||||
|
||||
#ifdef FOG
|
||||
float len = cameraDepth / RENDER_DISTANCE;
|
||||
#ifdef ALLOW_FADE
|
||||
len += RENDER_CHUNK_FOG_ALPHA;
|
||||
#endif
|
||||
|
||||
fogColor.rgb = FOG_COLOR.rgb;
|
||||
fogColor.a = clamp((len - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
///// water magic
|
||||
#ifdef NEAR_WATER
|
||||
#ifdef FANCY /////enhance water
|
||||
float F = dot(normalize(relPos), UNIT_Y);
|
||||
F = 1.0 - max(F, 0.1);
|
||||
// Nvidia Tegra 2 and Xoom (maybe the combination) have some bug where "min" returns a highp float
|
||||
// in some cases even though the input are lowp floats. This together with the devices/drivers
|
||||
// inability to figure out what to do with that causes it to fail due to an ambiguous call to mix.
|
||||
F = 1.0 - mix(F*F*F*F, 1.0, float(min(1.0, cameraDepth / FAR_CHUNKS_DISTANCE)));
|
||||
|
||||
color.rg -= vec2(F * DIST_DESATURATION);
|
||||
|
||||
vec4 depthColor = vec4(color.rgb * 0.5, 1.0);
|
||||
vec4 traspColor = vec4(color.rgb * 0.45, 0.8);
|
||||
vec4 surfColor = vec4(color.rgb, 1.0);
|
||||
|
||||
vec4 nearColor = mix(traspColor, depthColor, color.a);
|
||||
color = mix(surfColor, nearColor, F);
|
||||
#else
|
||||
// Completely insane, but if I don't have these two lines in here, the water doesn't render on a Nexus 6
|
||||
vec4 surfColor = vec4(color.rgb, 1.0);
|
||||
color = surfColor;
|
||||
color.a = pos.z / FAR_CHUNKS_DISTANCE + 0.5;
|
||||
#endif //FANCY
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionSimple.h"
|
||||
|
||||
void main()
|
||||
{
|
||||
// TODO: implement this for multisampling
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
//this is to make it come closer to the camera and avoid z-fighting
|
||||
gl_Position.z -= 0.0001;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionSimple.h"
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/util_vertex.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec4 WEIGHTS;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
gl_Position.xy += computeScreenOffsets(POSITION.xyz, WEIGHTS, WORLDVIEWPROJ);
|
||||
|
||||
//this is to make it come closer to the camera and avoid z-fighting
|
||||
gl_Position.z -= 0.0001;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor.rgb = mix(color.rgb, CURRENT_COLOR.rgb, color.a);
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
color = CURRENT_COLOR;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/uniformPerFrameConstants.h"
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec4 COLOR;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
const float fogNear = 0.3;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
color = mix( CURRENT_COLOR, FOG_COLOR, COLOR.r );
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(color.rgb * CURRENT_COLOR.rgb * color.a, color.a);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
#include "shaders/uniformPerFrameConstants.h"
|
||||
|
||||
varying vec2 uv0;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = CURRENT_COLOR;
|
||||
color.a = 0.1;
|
||||
|
||||
gl_FragColor = color;
|
||||
|
||||
#if defined(FORCE_DEPTH_ZERO) && __VERSION__ >= 300
|
||||
gl_FragDepth = 0.0;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
#include "shaders/uniformPerFrameConstants.h"
|
||||
#include "shaders/util.h"
|
||||
|
||||
varying vec2 uv0;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = CURRENT_COLOR;
|
||||
|
||||
const float cycleTime = 1.f;
|
||||
const float cutoff = cycleTime * 0.75f;
|
||||
|
||||
float a = mod(TIME, cycleTime) / cutoff;
|
||||
a = 1.f - smoothstep(clamp(a - 0.1f, 0, 1), a, uv0.x);
|
||||
if (a > 0.f) {
|
||||
color = mix(vec4(1, 1, 1, 1), color, a);
|
||||
a = 1.f;
|
||||
}
|
||||
color.a = a;
|
||||
|
||||
gl_FragColor = color;
|
||||
|
||||
#if defined(FORCE_DEPTH_ZERO) && __VERSION__ >= 300
|
||||
gl_FragDepth = 0.0;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionSimple.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
|
||||
varying vec2 uv0;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
uv0 = TEXCOORD_0;
|
||||
|
||||
//this is to make it come closer to the camera and avoid z-fighting
|
||||
gl_Position.z -= 0.0001;
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroidUV.h"
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
float median(float a, float b, float c) {
|
||||
return max(min(a, b), min(max(a, b), c));
|
||||
}
|
||||
|
||||
#include "shaders/uniformTextConstants.h"
|
||||
|
||||
const float GLYPH_UV_SIZE = 1.0 / 16.0;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 diffuse = texture2D( TEXTURE_0, uv );
|
||||
|
||||
#ifdef SMOOTH
|
||||
const float center = 0.4;
|
||||
const float radius = 0.1;
|
||||
|
||||
diffuse = smoothstep(center - radius, center + radius, diffuse);
|
||||
#endif
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if(diffuse.a < 0.5) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MSDF
|
||||
vec4 resultColor = color;
|
||||
|
||||
float sampleDistance = median(diffuse.r, diffuse.g, diffuse.b);
|
||||
|
||||
float innerEdgeAlpha = smoothstep(max(0.0, GLYPH_CUTOFF - GLYPH_SMOOTH_RADIUS), min(1.0, GLYPH_CUTOFF + GLYPH_SMOOTH_RADIUS), sampleDistance);
|
||||
// Apply fill cutoff
|
||||
resultColor = mix(OUTLINE_COLOR, resultColor, innerEdgeAlpha);
|
||||
|
||||
float outerEdgeAlpha = smoothstep(max(0.0, OUTLINE_CUTOFF - GLYPH_SMOOTH_RADIUS), min(1.0, OUTLINE_CUTOFF + GLYPH_SMOOTH_RADIUS), sampleDistance);
|
||||
// Apply stroke (outline) cutoff
|
||||
resultColor = vec4(resultColor.rgb, resultColor.a * outerEdgeAlpha);
|
||||
|
||||
vec2 topLeft = floor(uv);
|
||||
vec2 bottomRight = floor(uv + vec2(GLYPH_UV_SIZE, GLYPH_UV_SIZE));
|
||||
|
||||
vec4 shadowSample = texture2D(TEXTURE_0, clamp(uv - SHADOW_OFFSET, topLeft, bottomRight));
|
||||
float shadowDistance = shadowSample.a;
|
||||
float shadowAlpha = smoothstep(max(0.0, OUTLINE_CUTOFF - SHADOW_SMOOTH_RADIUS), min(1.0, OUTLINE_CUTOFF + SHADOW_SMOOTH_RADIUS), shadowDistance);
|
||||
// Apply shadow past the stroke
|
||||
resultColor = mix(vec4(SHADOW_COLOR.rgb, SHADOW_COLOR.a * shadowAlpha), resultColor, outerEdgeAlpha);
|
||||
|
||||
diffuse = resultColor;
|
||||
#else
|
||||
diffuse *= color;
|
||||
#endif
|
||||
|
||||
gl_FragColor = diffuse * DARKEN;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroidUV.h"
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture2D( TEXTURE_0, uv );
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if(color.a < 0.5)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroid.h"
|
||||
|
||||
#if __VERSION__ >= 300
|
||||
_centroid in vec2 uv;
|
||||
_centroid in vec2 uv1;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
varying vec2 uv1;
|
||||
#endif
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture2D( TEXTURE_0, uv );
|
||||
vec4 color1 = texture2D( TEXTURE_0, uv1 );
|
||||
|
||||
if (color.a < 0.01)
|
||||
{
|
||||
color = color1;
|
||||
}
|
||||
else if (color.b > 0.01) {
|
||||
color = mix(color, color1, CURRENT_COLOR.a);
|
||||
}
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroid.h"
|
||||
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
#if defined(TEXEL_AA) && defined(TEXEL_AA_FEATURE)
|
||||
_centroid in highp vec2 uv;
|
||||
#else
|
||||
_centroid in vec2 uv;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
varying vec2 uv;
|
||||
|
||||
#endif
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
#include "shaders/util.h"
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
|
||||
void main()
|
||||
{
|
||||
#if !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE)
|
||||
vec4 diffuse = texture2D( TEXTURE_0, uv );
|
||||
#else
|
||||
vec4 diffuse = texture2D_AA(TEXTURE_0, uv );
|
||||
#endif
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if(diffuse.a < 0.5)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
gl_FragColor = CURRENT_COLOR * diffuse;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroidUV.h"
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 diffuse = texture2D( TEXTURE_0, uv );
|
||||
if(diffuse.a < 0.5)
|
||||
discard;
|
||||
|
||||
gl_FragColor = CURRENT_COLOR;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionCentroid.h"
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
#if defined(TEXEL_AA) && defined(TEXEL_AA_FEATURE)
|
||||
_centroid in highp vec2 uv;
|
||||
#else
|
||||
_centroid in vec2 uv;
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
varying vec2 uv;
|
||||
|
||||
#endif
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
#include "shaders/util.h"
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
|
||||
void main()
|
||||
{
|
||||
#if !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE)
|
||||
vec4 diffuse = texture2D( TEXTURE_0, uv );
|
||||
#else
|
||||
vec4 diffuse = texture2D_AA(TEXTURE_0, uv );
|
||||
#endif
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if(diffuse.a < 0.0625)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
gl_FragColor = diffuse;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef _UNIFORM_BADGER_CONSTANTS_H
|
||||
#define _UNIFORM_BADGER_CONSTANTS_H
|
||||
|
||||
#include "shaders/uniformMacro.h"
|
||||
|
||||
#ifdef MCPE_PLATFORM_NX
|
||||
#extension GL_ARB_enhanced_layouts : enable
|
||||
uniform BadgerConstants {
|
||||
#endif
|
||||
UNIFORM int NUM_STRUCTURES;
|
||||
UNIFORM vec4 STRUCTURE_DATA[8];
|
||||
UNIFORM vec4 STRUCTURE_COLOR[8];
|
||||
END_UNIFORM_BLOCK
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef _UNIFORM_BANNER_CONSTANTS_H
|
||||
#define _UNIFORM_BANNER_CONSTANTS_H
|
||||
|
||||
#include "shaders/uniformMacro.h"
|
||||
|
||||
#ifdef MCPE_PLATFORM_NX
|
||||
uniform BannerConstants {
|
||||
#endif
|
||||
// BEGIN_UNIFORM_BLOCK(BannerConstants) - unfortunately this macro does not work on old Amazon platforms so using above 3 lines instead
|
||||
UNIFORM vec4 BANNER_COLORS[7];
|
||||
UNIFORM vec4 BANNER_UV_OFFSETS[7];
|
||||
END_UNIFORM_BLOCK
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef _UNIFORM_DEBUG_CONSTANTS_H
|
||||
#define _UNIFORM_DEBUG_CONSTANTS_H
|
||||
|
||||
#include "shaders/uniformMacro.h"
|
||||
|
||||
#ifdef MCPE_PLATFORM_NX
|
||||
uniform DebugConstants {
|
||||
#endif
|
||||
// BEGIN_UNIFORM_BLOCK(DebugConstants) - unfortunately this macro does not work on old Amazon platforms so using above 3 lines instead
|
||||
UNIFORM float TEXTURE_ARRAY_INDEX_0;
|
||||
END_UNIFORM_BLOCK
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef _UNIFORM_EFFECTS_CONSTANTS_H
|
||||
#define _UNIFORM_EFFECTS_CONSTANTS_H
|
||||
|
||||
#include "shaders/uniformMacro.h"
|
||||
|
||||
#ifdef MCPE_PLATFORM_NX
|
||||
uniform EffectsConstants {
|
||||
#endif
|
||||
// BEGIN_UNIFORM_BLOCK(EffectsConstants) - unfortunately this macro does not work on old Amazon platforms so using above 3 lines instead
|
||||
UNIFORM vec2 EFFECT_UV_OFFSET;
|
||||
END_UNIFORM_BLOCK
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef _UNIFORM_ENTITY_CONSTANTS_H
|
||||
#define _UNIFORM_ENTITY_CONSTANTS_H
|
||||
|
||||
#include "shaders/uniformMacro.h"
|
||||
|
||||
#ifdef MCPE_PLATFORM_NX
|
||||
uniform EntityConstants {
|
||||
#endif
|
||||
// BEGIN_UNIFORM_BLOCK(EntityConstants) - unfortunately this macro does not work on old Amazon platforms so using above 3 lines instead
|
||||
UNIFORM vec4 OVERLAY_COLOR;
|
||||
UNIFORM vec4 TILE_LIGHT_COLOR;
|
||||
UNIFORM vec4 CHANGE_COLOR;
|
||||
UNIFORM vec4 GLINT_COLOR;
|
||||
UNIFORM vec4 TEAM_COLOR;
|
||||
UNIFORM vec4 UV_ANIM;
|
||||
UNIFORM vec2 UV_OFFSET;
|
||||
UNIFORM vec2 UV_ROTATION;
|
||||
UNIFORM vec2 GLINT_UV_SCALE;
|
||||
END_UNIFORM_BLOCK
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef _UNIFORM_FLIPBOOK_TEXTURE_CONSTANTS_H
|
||||
#define _UNIFORM_FLIPBOOK_TEXTURE_CONSTANTS_H
|
||||
|
||||
#include "shaders/uniformMacro.h"
|
||||
|
||||
#ifdef MCPE_PLATFORM_NX
|
||||
uniform FlipbookTextureConstants {
|
||||
#endif
|
||||
// BEGIN_UNIFORM_BLOCK(FlipbookTextureConstants) - unfortunately this macro does not work on old Amazon platforms so using above 3 lines instead
|
||||
UNIFORM float V_OFFSET;
|
||||
UNIFORM float V_BLEND_OFFSET;
|
||||
END_UNIFORM_BLOCK
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef _UNIFORM_INTER_FRAME_CONSTANTS_H
|
||||
#define _UNIFORM_INTER_FRAME_CONSTANTS_H
|
||||
|
||||
#include "shaders/uniformMacro.h"
|
||||
|
||||
#ifdef MCPE_PLATFORM_NX
|
||||
uniform InterFrameConstants {
|
||||
#endif
|
||||
// BEGIN_UNIFORM_BLOCK(InterFrameConstants) - unfortunately this macro does not work on old Amazon platforms so using above 3 lines instead
|
||||
// in secs. This is reset every 1 hour. so the range is [0, 3600]
|
||||
// make sure your shader handles the case when it transitions from 3600 to 0
|
||||
UNIFORM float TOTAL_REAL_WORLD_TIME;
|
||||
UNIFORM MAT4 CUBE_MAP_ROTATION;
|
||||
END_UNIFORM_BLOCK
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef _UNIFORM_MACRO_H
|
||||
#define _UNIFORM_MACRO_H
|
||||
|
||||
#ifdef MCPE_PLATFORM_NX
|
||||
// Unfortunately this macro does not work on old Amazon platforms #define BEGIN_UNIFORM_BLOCK(x) uniform x {
|
||||
#define END_UNIFORM_BLOCK };
|
||||
#define UNIFORM
|
||||
#else
|
||||
// Unfortunately this macro does not work on old Amazon platforms #define BEGIN_UNIFORM_BLOCK(x)
|
||||
#define END_UNIFORM_BLOCK
|
||||
#define UNIFORM uniform
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef _UNIFORM_PER_FRAME_CONSTANTS_H
|
||||
#define _UNIFORM_PER_FRAME_CONSTANTS_H
|
||||
|
||||
#include "shaders/uniformMacro.h"
|
||||
|
||||
#ifdef MCPE_PLATFORM_NX
|
||||
#extension GL_ARB_enhanced_layouts : enable
|
||||
layout(binding = 2) uniform PerFrameConstants {
|
||||
#endif
|
||||
// BEGIN_UNIFORM_BLOCK(PerFrameConstants) - unfortunately this macro does not work on old Amazon platforms so using above 3 lines instead
|
||||
UNIFORM vec3 VIEW_POS;
|
||||
UNIFORM float TIME;
|
||||
UNIFORM vec4 FOG_COLOR;
|
||||
UNIFORM vec2 FOG_CONTROL;
|
||||
UNIFORM float RENDER_DISTANCE;
|
||||
UNIFORM float FAR_CHUNKS_DISTANCE;
|
||||
END_UNIFORM_BLOCK
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef _UNIFORM_RENDER_CHUNK_CONSTANTS_H
|
||||
#define _UNIFORM_RENDER_CHUNK_CONSTANTS_H
|
||||
|
||||
#include "shaders/uniformMacro.h"
|
||||
|
||||
#ifdef MCPE_PLATFORM_NX
|
||||
#extension GL_ARB_enhanced_layouts : enable
|
||||
layout(binding = 0) uniform RenderChunkConstants {
|
||||
#endif
|
||||
// BEGIN_UNIFORM_BLOCK(RenderChunkConstants) - unfortunately this macro does not work on old Amazon platforms so using above 3 lines instead
|
||||
UNIFORM POS4 CHUNK_ORIGIN_AND_SCALE;
|
||||
UNIFORM float RENDER_CHUNK_FOG_ALPHA;
|
||||
END_UNIFORM_BLOCK
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef _UNIFORM_SHADER_CONSTANTS_H
|
||||
#define _UNIFORM_SHADER_CONSTANTS_H
|
||||
|
||||
#include "shaders/uniformMacro.h"
|
||||
|
||||
#ifdef MCPE_PLATFORM_NX
|
||||
#extension GL_ARB_enhanced_layouts : enable
|
||||
layout(binding = 3) uniform ShaderConstants {
|
||||
#endif
|
||||
// BEGIN_UNIFORM_BLOCK(ShaderConstants) - unfortunately this macro does not work on old Amazon platforms so using above 3 lines instead
|
||||
UNIFORM vec4 CURRENT_COLOR;
|
||||
UNIFORM vec4 DARKEN;
|
||||
UNIFORM vec3 TEXTURE_DIMENSIONS;
|
||||
UNIFORM float HUD_OPACITY;
|
||||
UNIFORM MAT4 UV_TRANSFORM;
|
||||
END_UNIFORM_BLOCK
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef _UNIFORM_TEXT_CONSTANTS_H
|
||||
#define _UNIFORM_TEXT_CONSTANTS_H
|
||||
|
||||
#include "shaders/uniformMacro.h"
|
||||
|
||||
#ifdef MCPE_PLATFORM_NX
|
||||
uniform TextConstants {
|
||||
#endif
|
||||
// BEGIN_UNIFORM_BLOCK(TextConstants) - unfortunately this macro does not work on old Amazon platforms so using above 3 lines instead
|
||||
UNIFORM float GLYPH_SMOOTH_RADIUS;
|
||||
UNIFORM float GLYPH_CUTOFF;
|
||||
UNIFORM float OUTLINE_CUTOFF;
|
||||
UNIFORM vec4 OUTLINE_COLOR;
|
||||
UNIFORM float SHADOW_SMOOTH_RADIUS;
|
||||
UNIFORM vec4 SHADOW_COLOR;
|
||||
UNIFORM vec2 SHADOW_OFFSET;
|
||||
END_UNIFORM_BLOCK
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef _UNIFORM_WEATHER_CONSTANTS_H
|
||||
#define _UNIFORM_WEATHER_CONSTANTS_H
|
||||
|
||||
#include "shaders/uniformMacro.h"
|
||||
|
||||
#ifdef MCPE_PLATFORM_NX
|
||||
uniform WeatherConstants {
|
||||
#endif
|
||||
// BEGIN_UNIFORM_BLOCK(WeatherConstants) - unfortunately this macro does not work on old Amazon platforms so using above 3 lines instead
|
||||
UNIFORM vec4 POSITION_OFFSET;
|
||||
UNIFORM vec4 VELOCITY;
|
||||
UNIFORM vec4 ALPHA;
|
||||
UNIFORM vec4 VIEW_POSITION;
|
||||
UNIFORM vec4 SIZE_SCALE;
|
||||
UNIFORM vec4 FORWARD;
|
||||
UNIFORM vec4 UV_INFO;
|
||||
UNIFORM vec4 PARTICLE_BOX;
|
||||
END_UNIFORM_BLOCK
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef _UNIFORM_WORLD_CONSTANTS_H
|
||||
#define _UNIFORM_WORLD_CONSTANTS_H
|
||||
|
||||
#include "shaders/uniformMacro.h"
|
||||
|
||||
#ifdef MCPE_PLATFORM_NX
|
||||
#extension GL_ARB_enhanced_layouts : enable
|
||||
layout(binding = 1) uniform WorldConstants {
|
||||
#endif
|
||||
// BEGIN_UNIFORM_BLOCK(WorldConstants) - unfortunately this macro does not work on old Amazon platforms so using above 3 lines instead
|
||||
UNIFORM MAT4 WORLDVIEWPROJ;
|
||||
UNIFORM MAT4 WORLD;
|
||||
UNIFORM MAT4 WORLDVIEW;
|
||||
UNIFORM MAT4 PROJ;
|
||||
END_UNIFORM_BLOCK
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
|
||||
vec4 texture2D_AA(in sampler2D tex, in highp vec2 uv)
|
||||
{
|
||||
// Texture antialiasing
|
||||
//
|
||||
// The texture coordinates are modified so that the bilinear filter will be one pixel wide instead of one texel wide.
|
||||
|
||||
// Get the UV deltas
|
||||
highp vec2 dUVdx = dFdx(uv) * TEXTURE_DIMENSIONS.xy;
|
||||
highp vec2 dUVdy = dFdy(uv) * TEXTURE_DIMENSIONS.xy;
|
||||
highp vec2 dU = vec2(dUVdx.x, dUVdy.x);
|
||||
highp vec2 dV = vec2(dUVdx.y, dUVdy.y);
|
||||
|
||||
highp float duUV = sqrt(dot(dU, dU));
|
||||
highp float dvUV = sqrt(dot(dV, dV));
|
||||
|
||||
// Determine mip map LOD
|
||||
highp float d = max(dot(dUVdx, dUVdx), dot(dUVdy, dUVdy));
|
||||
highp float mipLevel = .5 * log2(d);
|
||||
mipLevel = mipLevel + .5; // Mip bias to reduce aliasing
|
||||
mipLevel = clamp(mipLevel, 0.0, TEXTURE_DIMENSIONS.z);
|
||||
|
||||
highp vec2 uvModified;
|
||||
if( mipLevel >= 1.0)
|
||||
{
|
||||
uvModified = uv;
|
||||
}
|
||||
else
|
||||
{
|
||||
// First scale the uv so that each texel has a uv range of [0,1]
|
||||
highp vec2 texelUV = fract(uv * TEXTURE_DIMENSIONS.xy);
|
||||
|
||||
// Initially set uvModified to the floor of the texel position
|
||||
uvModified = (uv * TEXTURE_DIMENSIONS.xy) - texelUV;
|
||||
|
||||
// Modify the texelUV to push the uvs toward the edges.
|
||||
// | | | |
|
||||
// | _/ | | / |
|
||||
// Change | U _/ | to | U ___/ |
|
||||
// | _/ | | / |
|
||||
// | / | | / |
|
||||
// | X | | X |
|
||||
highp float scalerU = 1.0 / (duUV);
|
||||
highp float scalerV = 1.0 / (dvUV);
|
||||
highp vec2 scaler = max(vec2(scalerU, scalerV), 1.0);
|
||||
texelUV = clamp(texelUV * scaler, 0.0, .5) + clamp(texelUV*scaler - (scaler - .5), 0.0, .5);
|
||||
uvModified += texelUV;
|
||||
uvModified /= TEXTURE_DIMENSIONS.xy;
|
||||
}
|
||||
vec4 diffuse = texture2D(tex, uvModified);
|
||||
return diffuse;
|
||||
|
||||
}
|
||||
|
||||
#endif //__VERSION__ >= 300
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
vec2 computeScreenOffsets(vec3 pos, vec4 data, mat4 worldViewProj)
|
||||
{
|
||||
vec3 normal = data.xyz;
|
||||
float width = length(normal);
|
||||
float pixelScale = abs(data.w);
|
||||
float dir = (data.w < 0) ? -1.f : 1.f;
|
||||
|
||||
vec4 pos0 = vec4(pos, 1.f);
|
||||
vec4 pos1 = vec4(pos + normal, 1.f);
|
||||
|
||||
pos0 = pos0 * worldViewProj;
|
||||
pos1 = pos1 * worldViewProj;
|
||||
|
||||
vec2 screenNormal = (pos1.xy / pos1.w) - (pos0.xy / pos0.w);
|
||||
screenNormal = normalize(vec2(-screenNormal.y, screenNormal.x));
|
||||
|
||||
float w = dot(worldViewProj[3], vec4(pos, 1.f));
|
||||
|
||||
float pixelRadius = w * pixelScale;
|
||||
|
||||
return screenNormal * (dir * width * pixelRadius);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionCentroidUV.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
|
||||
attribute POS4 POSITION;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
uv = TEXCOORD_0;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/fragmentVersionSimple.h"
|
||||
|
||||
varying vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(uv.x, uv.y,0.0,1.0);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionCentroid.h"
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
_centroid out vec2 uv;
|
||||
_centroid out vec2 uv1;
|
||||
|
||||
#else
|
||||
|
||||
varying vec2 uv;
|
||||
varying vec2 uv1;
|
||||
|
||||
#endif
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
|
||||
attribute POS4 POSITION;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
attribute vec2 TEXCOORD_1;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
uv = TEXCOORD_0;
|
||||
uv1 = TEXCOORD_1;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionCentroid.h"
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
_centroid out vec2 uv;
|
||||
_centroid out vec2 uv1;
|
||||
|
||||
#else
|
||||
|
||||
varying vec2 uv;
|
||||
varying vec2 uv1;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/uniformFlipbookTextureConstants.h"
|
||||
|
||||
attribute POS4 POSITION;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
uv = TEXCOORD_0;
|
||||
uv.y += V_OFFSET;
|
||||
uv1 = TEXCOORD_0;
|
||||
uv1.y += V_BLEND_OFFSET;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionCentroidUV.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/uniformShaderConstants.h"
|
||||
|
||||
attribute POS4 POSITION;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
uv = (UV_TRANSFORM * vec4(TEXCOORD_0, 0, 1)).xy;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionCentroidUV.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/uniformEntityConstants.h"
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
uv = TEXCOORD_0 * GLINT_UV_SCALE.xy;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionCentroidUV.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
|
||||
attribute POS4 POSITION;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
POS4 pos = WORLDVIEW * POSITION;
|
||||
gl_Position = PROJ * pos;
|
||||
|
||||
uv = TEXCOORD_0;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// __multiversion__
|
||||
// This signals the loading code to prepend either #version 100 or #version 300 es as apropriate.
|
||||
|
||||
#include "shaders/vertexVersionCentroidUV.h"
|
||||
|
||||
#include "shaders/uniformWorldConstants.h"
|
||||
#include "shaders/uniformInterFrameConstants.h"
|
||||
|
||||
attribute POS4 POSITION;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
|
||||
|
||||
void main() {
|
||||
gl_Position = WORLDVIEWPROJ * CUBE_MAP_ROTATION * POSITION;
|
||||
|
||||
uv = TEXCOORD_0;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// To use centroid sampling we need to have version 300 es shaders, which requires changing:
|
||||
// attribute to in
|
||||
// varying to out when in vertex shaders or in when in fragment shaders
|
||||
// defining an out vec4 FragColor and replacing uses of gl_FragColor with FragColor
|
||||
// texture2D to texture
|
||||
#if __VERSION__ >= 300
|
||||
#define attribute in
|
||||
#define varying out
|
||||
|
||||
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
||||
#define _centroid centroid
|
||||
#else
|
||||
#define _centroid
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// To use centroid sampling we need to have version 300 es shaders, which requires changing:
|
||||
// attribute to in
|
||||
// varying to out when in vertex shaders or in when in fragment shaders
|
||||
// defining an out vec4 FragColor and replacing uses of gl_FragColor with FragColor
|
||||
// texture2D to texture
|
||||
#if __VERSION__ >= 300
|
||||
#define attribute in
|
||||
#define varying out
|
||||
|
||||
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
||||
#define _centroid centroid
|
||||
#else
|
||||
#define _centroid
|
||||
#endif
|
||||
|
||||
_centroid out vec2 uv;
|
||||
|
||||
#else
|
||||
|
||||
varying vec2 uv;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// To use centroid sampling we need to have version 300 es shaders, which requires changing:
|
||||
// attribute to in
|
||||
// varying to out when in vertex shaders or in when in fragment shaders
|
||||
// defining an out vec4 FragColor and replacing uses of gl_FragColor with FragColor
|
||||
// texture2D to texture
|
||||
|
||||
#if __VERSION__ >= 300
|
||||
#define attribute in
|
||||
#define varying out
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user