mirror of
https://git.stillkill.net/MinecraftLeak/Narration-NoGeneratedLevel-20170216.git
synced 2026-10-22 05:12:18 +01:00
Initial commit
This commit is contained in:
commit
bd6318027f
4937 files changed
+194287
No files matched your search
@@ -0,0 +1,39 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
||||
#define _centroid centroid
|
||||
#else
|
||||
#define _centroid
|
||||
#endif
|
||||
|
||||
_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
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture2D( TEXTURE_0, uv );
|
||||
gl_FragColor = vec4(color.rgb, 0.75);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
#define attribute in
|
||||
#define varying out
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
uniform MAT4 WORLD;
|
||||
uniform float RENDER_DISTANCE;
|
||||
uniform vec4 FOG_COLOR;
|
||||
uniform vec4 CURRENT_COLOR;
|
||||
|
||||
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,36 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
layout(location = 1) out vec4 FragData;
|
||||
#define gl_FragData FragData
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
|
||||
#endif
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
#if __VERSION__ >= 300
|
||||
gl_FragColor = color;
|
||||
gl_FragData = vec4(0.0);
|
||||
#else
|
||||
gl_FragColor = color;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
#define attribute in
|
||||
#define varying out
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec4 COLOR;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
color = COLOR;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
|
||||
#endif
|
||||
|
||||
uniform vec4 CURRENT_COLOR;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = color * CURRENT_COLOR;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
||||
#define _centroid centroid
|
||||
#else
|
||||
#define _centroid
|
||||
#endif
|
||||
|
||||
_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
|
||||
|
||||
uniform vec4 CURRENT_COLOR;
|
||||
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,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
|
||||
#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
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
layout(location = 1) out vec4 FragData;
|
||||
#define gl_FragData FragData
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
varying vec2 uv;
|
||||
|
||||
#endif
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
uniform sampler2D TEXTURE_1;
|
||||
uniform vec4 OVERLAY_COLOR;
|
||||
|
||||
#ifdef ENABLE_VERTEX_TINT_MASK
|
||||
uniform vec4 CHANGE_COLOR;
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
uniform vec4 GLINT_COLOR;
|
||||
#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()
|
||||
{
|
||||
vec4 diffuse = texture2D( TEXTURE_0, uv );
|
||||
|
||||
#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;
|
||||
}
|
||||
#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
|
||||
gl_FragColor = diffuse;
|
||||
#else
|
||||
|
||||
#if __VERSION__ >= 300
|
||||
gl_FragColor = diffuse * color;
|
||||
gl_FragData = diffuse * color;
|
||||
#else
|
||||
gl_FragColor = diffuse * color;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
// __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
|
||||
#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
|
||||
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
uniform MAT4 WORLD;
|
||||
|
||||
uniform vec2 UV_OFFSET;
|
||||
uniform vec2 UV_ROTATION;
|
||||
uniform vec2 GLINT_UV_SCALE;
|
||||
uniform vec4 FOG_COLOR;
|
||||
uniform vec2 FOG_CONTROL;
|
||||
uniform float RENDER_DISTANCE;
|
||||
uniform vec3 PLAYER_POSITION;
|
||||
|
||||
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(((length(PLAYER_POSITION - (WORLD * POSITION).xyz) / RENDER_DISTANCE) - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, FOG_COLOR.a);
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
layer1UV = calculateLayerUV(UV_OFFSET.x, UV_ROTATION.x);
|
||||
layer2UV = calculateLayerUV(UV_OFFSET.y, UV_ROTATION.y);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
||||
#define _centroid centroid
|
||||
#else
|
||||
#define _centroid
|
||||
#endif
|
||||
|
||||
_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
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
|
||||
varying vec3 uBlurIncrement;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 imageCoord = uv;
|
||||
vec4 sum = vec4(0.0);
|
||||
vec2 blurSize = uBlurIncrement.xy * uBlurIncrement.z;
|
||||
|
||||
sum += texture2D(TEXTURE_0, imageCoord - blurSize * 9.0) * 0.0014794516787135662;
|
||||
sum += texture2D(TEXTURE_0, imageCoord - blurSize * 8.0) * 0.003804239018665086;
|
||||
sum += texture2D(TEXTURE_0, imageCoord - blurSize * 7.0) * 0.00875346226514214;
|
||||
sum += texture2D(TEXTURE_0, imageCoord - blurSize * 6.0) * 0.018023411141080636;
|
||||
sum += texture2D(TEXTURE_0, imageCoord - blurSize * 5.0) * 0.03320772876259043;
|
||||
sum += texture2D(TEXTURE_0, imageCoord - blurSize * 4.0) * 0.05475028876252328;
|
||||
sum += texture2D(TEXTURE_0, imageCoord - blurSize * 3.0) * 0.0807753247211904;
|
||||
sum += texture2D(TEXTURE_0, imageCoord - blurSize * 2.0) * 0.10663900118033988;
|
||||
sum += texture2D(TEXTURE_0, imageCoord - blurSize * 1.0) * 0.12597909446198644;
|
||||
sum += texture2D(TEXTURE_0, imageCoord) * 0.1331759960155365;
|
||||
sum += texture2D(TEXTURE_0, imageCoord + blurSize * 1.0) * 0.12597909446198644;
|
||||
sum += texture2D(TEXTURE_0, imageCoord + blurSize * 2.0) * 0.10663900118033988;
|
||||
sum += texture2D(TEXTURE_0, imageCoord + blurSize * 3.0) * 0.0807753247211904;
|
||||
sum += texture2D(TEXTURE_0, imageCoord + blurSize * 4.0) * 0.05475028876252328;
|
||||
sum += texture2D(TEXTURE_0, imageCoord + blurSize * 5.0) * 0.03320772876259043;
|
||||
sum += texture2D(TEXTURE_0, imageCoord + blurSize * 6.0) * 0.018023411141080636;
|
||||
sum += texture2D(TEXTURE_0, imageCoord + blurSize * 7.0) * 0.00875346226514214;
|
||||
sum += texture2D(TEXTURE_0, imageCoord + blurSize * 8.0) * 0.003804239018665086;
|
||||
sum += texture2D(TEXTURE_0, imageCoord + blurSize * 9.0) * 0.0014794516787135662;
|
||||
|
||||
gl_FragColor = sum;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// __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
|
||||
#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
|
||||
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
uniform vec3 BLUR_INCREMENT;
|
||||
|
||||
attribute POS4 POSITION;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
|
||||
varying vec3 uBlurIncrement;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
uv = TEXCOORD_0;
|
||||
uBlurIncrement = BLUR_INCREMENT;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
|
||||
#endif
|
||||
|
||||
uniform vec4 CURRENT_COLOR;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = CURRENT_COLOR;
|
||||
|
||||
#if defined(FORCE_DEPTH_ZERO) && __VERSION__ >= 300
|
||||
gl_FragDepth = 0.0;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
// These [aren't but] should be grouped in a way that they require the least amount of updating (world data in one, model data in another, part of model data in another one, etc)
|
||||
|
||||
#ifdef USE_STEREO_TEXTURE_ARRAY
|
||||
Texture2DArray TEXTURE_0 : register ( t0 );
|
||||
#else
|
||||
Texture2D TEXTURE_0 : register ( t0 );
|
||||
#endif
|
||||
|
||||
Texture2D TEXTURE_1 : register ( t1 );
|
||||
Texture2D TEXTURE_2 : register ( t2 );
|
||||
|
||||
// Make sure this thing is actually getting bound
|
||||
sampler TextureSampler0 : register( s0 );
|
||||
sampler TextureSampler1 : register( s1 );
|
||||
sampler TextureSampler2 : register( s2 );
|
||||
|
||||
#ifdef LOW_PRECISION
|
||||
#define lpfloat min16float
|
||||
#define lpfloat2 min16float2
|
||||
#define lpfloat4 min16float4
|
||||
#else
|
||||
#define lpfloat float
|
||||
#define lpfloat2 float2
|
||||
#define lpfloat4 float4
|
||||
#endif
|
||||
|
||||
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
||||
#define TEXCOORD_0_FB_MSAA TEXCOORD_0_centroid
|
||||
#define TEXCOORD_1_FB_MSAA TEXCOORD_1_centroid
|
||||
#else
|
||||
#define TEXCOORD_0_FB_MSAA TEXCOORD_0
|
||||
#define TEXCOORD_1_FB_MSAA TEXCOORD_1
|
||||
#endif
|
||||
|
||||
|
||||
cbuffer RenderChunkConstants
|
||||
{
|
||||
|
||||
float4 CHUNK_ORIGIN_AND_SCALE;
|
||||
}
|
||||
|
||||
cbuffer EntityConstants
|
||||
{
|
||||
float4 OVERLAY_COLOR;
|
||||
float4 TILE_LIGHT_COLOR;
|
||||
float4 CHANGE_COLOR;
|
||||
float4 GLINT_COLOR;
|
||||
float2 UV_ANIM;
|
||||
float2 UV_OFFSET;
|
||||
float2 UV_ROTATION;
|
||||
float2 GLINT_UV_SCALE;
|
||||
}
|
||||
|
||||
cbuffer PerFrameConstants
|
||||
{
|
||||
float3 VIEW_DIRECTION; // unneeded
|
||||
float TIME; // unneeded
|
||||
|
||||
float3 VIEW_POS;
|
||||
float FAR_CHUNKS_DISTANCE;
|
||||
float4 FOG_COLOR;
|
||||
|
||||
float2 FOG_CONTROL;
|
||||
|
||||
float RENDER_DISTANCE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if !defined(INSTANCEDSTEREO)
|
||||
|
||||
cbuffer WorldConstants
|
||||
{
|
||||
float4x4 WORLDVIEWPROJ;
|
||||
float4x4 WORLD;
|
||||
float4x4 WORLDVIEW;
|
||||
float4x4 PROJ;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
cbuffer WorldConstantsStereographic
|
||||
{
|
||||
float4x4 WORLDVIEWPROJ_STEREO[2];
|
||||
float4x4 WORLD_STEREO;
|
||||
float4x4 WORLDVIEW_STEREO[2];
|
||||
float4x4 PROJ_STEREO[2];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
cbuffer ShaderConstants
|
||||
{
|
||||
float4 CURRENT_COLOR;
|
||||
float4 DARKEN;
|
||||
float3 TEXTURE_DIMENSIONS;
|
||||
}
|
||||
|
||||
cbuffer WeatherConstants {
|
||||
float4 POSITION_OFFSET;
|
||||
float4 VELOCITY;
|
||||
float4 ALPHA;
|
||||
float4 VIEW_POSITION;
|
||||
float4 SIZE_SCALE;
|
||||
float4 FORWARD;
|
||||
float4 UV_INFO;
|
||||
float4 PARTICLE_BOX;
|
||||
}
|
||||
|
||||
cbuffer HoloConstants
|
||||
{
|
||||
float4 TABLE_REVEAL_CENTER;
|
||||
float4 TABLE_REVEAL_CONSTANTS; // x = Radius
|
||||
|
||||
float3 GAZE_DIRECTION;
|
||||
|
||||
float4 SKIRT_UVS;
|
||||
float4 SKIRT_UV_SCALE;
|
||||
|
||||
float2 CHUNK_CLIP_MIN;
|
||||
float2 CHUNK_CLIP_MAX;
|
||||
|
||||
float2 CLIP_MIN;
|
||||
float2 CLIP_MAX;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
PSOutput.color = PSInput.color;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float4 position : POSITION;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
PSInput.color = VSInput.color;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], VSInput.position );
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, VSInput.position);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// passes through the triangles, except changint the viewport id to match the instance
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
output.color = input[j].color;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
static const float fogNear = 0.9;
|
||||
|
||||
static const float3 inverseLightDirection = float3( 0.62, 0.78, 0.0 );
|
||||
static const float ambient = 0.7;
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
|
||||
PSInput.instanceID = i;
|
||||
float3 worldPos = mul(WORLD_STEREO, float4(VSInput.position, 1));
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
float3 worldPos = mul(WORLD, float4(VSInput.position, 1));
|
||||
#endif
|
||||
|
||||
PSInput.color = VSInput.color * CURRENT_COLOR;
|
||||
|
||||
float depth = length(worldPos) / RENDER_DISTANCE;
|
||||
|
||||
float fog = max( depth - fogNear, 0.0 );
|
||||
|
||||
PSInput.color.a *= 1.0 - fog;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
PSOutput.color = PSInput.color;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// passes through the triangles, except changint the viewport id to match the instance
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
output.color = input[j].color;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
PSInput.color = VSInput.color;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
PSOutput.color = PSInput.color * CURRENT_COLOR;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
// be sure to change the shader type to pertex shader and shader model to ps_40 (in visual studio)
|
||||
|
||||
struct PS_Input {
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
};
|
||||
|
||||
struct PS_Output {
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main(in PS_Input PSInput, out PS_Output PSOutput) {
|
||||
float4 diffuse = TEXTURE_0.Sample(TextureSampler0, PSInput.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);
|
||||
float4 gray_color = float4(grayscale, grayscale, grayscale, CURRENT_COLOR.a * diffuse.a);
|
||||
PSOutput.color = gray_color;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
float4 glintBlend(float4 dest, float4 source) {
|
||||
return float4(source.rgb * source.rgb, 0.0) + dest;
|
||||
}
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD_0;
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
float2 layer1UV : UV_1;
|
||||
float2 layer2UV : UV_2;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
float4 diffuse = TEXTURE_0.Sample( TextureSampler0, PSInput.uv );
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
|
||||
#ifdef ENABLE_VERTEX_TINT_MASK
|
||||
if( diffuse.a <= 0.0f )
|
||||
#else
|
||||
if (diffuse.a <= 0.5f)
|
||||
#endif
|
||||
{
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VERTEX_TINT_MASK
|
||||
diffuse.rgb = lerp(diffuse.rgb, diffuse.rgb*PSInput.color.rgb, diffuse.a);
|
||||
if (PSInput.color.a > 0.0f) {
|
||||
diffuse.a = diffuse.a > 0.0f ? 1.0f : 0.0f;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
float4 layer1 = TEXTURE_1.Sample(TextureSampler1, frac(PSInput.layer1UV)).rgbr * GLINT_COLOR;
|
||||
float4 layer2 = TEXTURE_1.Sample(TextureSampler1, frac(PSInput.layer2UV)).rgbr * GLINT_COLOR;
|
||||
float4 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 = lerp( diffuse, OVERLAY_COLOR, OVERLAY_COLOR.a ).rgb;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
diffuse.rgb = lerp(diffuse.rgb, PSInput.fogColor.rgb, PSInput.fogColor.a);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_VERTEX_TINT_MASK
|
||||
PSOutput.color = diffuse;
|
||||
#else
|
||||
PSOutput.color = diffuse * PSInput.color;
|
||||
#endif
|
||||
|
||||
#ifdef VR_FEATURE
|
||||
// On Rift, the transition from 0 brightness to the lowest 8 bit value is abrupt, so clamp to
|
||||
// the lowest 8 bit value.
|
||||
PSOutput.color = max(PSOutput.color, 1 / 255.0f);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
float2 layer1UV : UV_1;
|
||||
float2 layer2UV : UV_2;
|
||||
#endif
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
float2 layer1UV : UV_1;
|
||||
float2 layer2UV : UV_2;
|
||||
#endif
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// passes through the triangles, except changint the viewport id to match the instance
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
output.color = input[j].color;
|
||||
output.uv0 = input[j].uv0;
|
||||
#ifdef ENABLE_FOG
|
||||
output.fogColor = input[j].fogColor;
|
||||
#endif
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texCoords : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 texCoords : TEXCOORD_0;
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
float2 layer1UV : UV_1;
|
||||
float2 layer2UV : UV_2;
|
||||
#endif
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef GLINT
|
||||
float2 calculateLayerUV(float2 origUV, float offset, float rotation) {
|
||||
float2 uv = origUV;
|
||||
uv -= 0.5;
|
||||
float rsin = sin(rotation);
|
||||
float rcos = cos(rotation);
|
||||
uv = mul(uv, float2x2(rcos, -rsin, rsin, rcos));
|
||||
uv.x += offset;
|
||||
uv += 0.5;
|
||||
|
||||
return uv * GLINT_UV_SCALE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
PSInput.color = VSInput.color;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
PSInput.texCoords = VSInput.texCoords;
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
//fog
|
||||
PSInput.fogColor.rgb = FOG_COLOR.rgb;
|
||||
PSInput.fogColor.a = clamp(((PSInput.position.z / RENDER_DISTANCE) - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
PSInput.layer1UV = calculateLayerUV(VSInput.texCoords, UV_OFFSET.x, UV_ROTATION.x);
|
||||
PSInput.layer2UV = calculateLayerUV(VSInput.texCoords, UV_OFFSET.y, UV_ROTATION.y);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
|
||||
#ifdef FORCE_DEPTH_ZERO
|
||||
float depth : SV_Depth;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
PSOutput.color = CURRENT_COLOR;
|
||||
|
||||
#ifdef FORCE_DEPTH_ZERO
|
||||
PSOutput.depth = 0.0;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "Util.fxh"
|
||||
|
||||
struct PS_Input {
|
||||
float4 position : SV_Position;
|
||||
|
||||
float4 light : LIGHT;
|
||||
float4 fogColor : FOG_COLOR;
|
||||
|
||||
#ifdef GLINT
|
||||
// there is some alignment issue on the Windows Phone 1320 that causes the position
|
||||
// to get corrupted if this is two floats and last in the struct memory wise
|
||||
float4 layerUV : GLINT_UVS;
|
||||
#endif
|
||||
|
||||
#ifdef USE_OVERLAY
|
||||
float4 overlayColor : OVERLAY_COLOR;
|
||||
#endif
|
||||
|
||||
float2 uv : TEXCOORD_0_FB_MSAA;
|
||||
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
#ifdef USE_EMISSIVE
|
||||
#define NEEDS_DISCARD(C) (C.a + C.r + C.g + C.b == 0.0)
|
||||
#else
|
||||
#ifndef USE_COLOR_MASK
|
||||
#define NEEDS_DISCARD(C) (C.a < 0.5)
|
||||
#else
|
||||
#define NEEDS_DISCARD(C) (C.a <= 0.0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
float4 glintBlend(float4 dest, float4 source) {
|
||||
// glBlendFuncSeparate(GL_SRC_COLOR, GL_ONE, GL_ONE, GL_ZERO)
|
||||
return float4(source.rgb * source.rgb, source.a) + float4(dest.rgb, 0.0);
|
||||
}
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
float4 color = float4( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
#ifndef NO_TEXTURE
|
||||
|
||||
#if !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE) || (VERSION < 0xa000 /*D3D_FEATURE_LEVEL_10_0*/)
|
||||
color = TEXTURE_0.Sample( TextureSampler0, PSInput.uv );
|
||||
#else
|
||||
color = texture2D_AA(TEXTURE_0, TextureSampler0, PSInput.uv);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if( NEEDS_DISCARD( color ) )
|
||||
{
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_COLOR_MASK
|
||||
color.rgb = lerp( color, color * CHANGE_COLOR, color.a ).rgb;
|
||||
color.a = 1.0;
|
||||
#endif
|
||||
|
||||
#ifdef ITEM_IN_HAND
|
||||
color.rgb = lerp(color, color * CHANGE_COLOR, PSInput.light.a).rgb;
|
||||
#endif
|
||||
|
||||
#ifdef USE_MULTITEXTURE
|
||||
float4 tex1 = TEXTURE_1.Sample(TextureSampler1, PSInput.uv);
|
||||
float4 tex2 = TEXTURE_2.Sample(TextureSampler2, PSInput.uv);
|
||||
color.rgb = lerp(color.rgb, tex1, tex1.a);
|
||||
#ifdef COLOR_SECOND_TEXTURE
|
||||
if (tex2.a > 0.0f) {
|
||||
color.rgb = lerp(tex2.rgb, tex2 * CHANGE_COLOR, tex2.a);
|
||||
}
|
||||
#else
|
||||
color.rgb = lerp(color.rgb, tex2, tex2.a);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_OVERLAY
|
||||
//use either the diffuse or the OVERLAY_COLOR
|
||||
color.rgb = lerp( color, PSInput.overlayColor, PSInput.overlayColor.a ).rgb;
|
||||
#endif
|
||||
|
||||
#ifdef USE_EMISSIVE
|
||||
//make glowy stuff
|
||||
color *= lerp( float( 1.0 ).xxxx, PSInput.light, color.a );
|
||||
#else
|
||||
color *= PSInput.light;
|
||||
#endif
|
||||
|
||||
//apply fog
|
||||
color.rgb = lerp( color.rgb, PSInput.fogColor.rgb, PSInput.fogColor.a );
|
||||
|
||||
#ifdef GLINT
|
||||
// Applies color mask to glint texture instead and blends with original color
|
||||
float4 layer1 = TEXTURE_1.Sample(TextureSampler1, frac(PSInput.layerUV.xy)).rgbr * GLINT_COLOR;
|
||||
float4 layer2 = TEXTURE_1.Sample(TextureSampler1, frac(PSInput.layerUV.zw)).rgbr * GLINT_COLOR;
|
||||
float4 glint = (layer1 + layer2) * TILE_LIGHT_COLOR;
|
||||
color = glintBlend(color, glint);
|
||||
#endif
|
||||
|
||||
//WARNING do not refactor this
|
||||
PSOutput.color = color;
|
||||
|
||||
#ifdef VR_FEATURE
|
||||
// On Rift, the transition from 0 brightness to the lowest 8 bit value is abrupt, so clamp to
|
||||
// the lowest 8 bit value.
|
||||
PSOutput.color = max(PSOutput.color, 1 / 255.0f);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 light : LIGHT;
|
||||
float4 fogColor : FOG_COLOR;
|
||||
|
||||
#ifdef GLINT
|
||||
float4 layerUV : GLINT_UVS;
|
||||
#endif
|
||||
|
||||
#ifdef USE_OVERLAY
|
||||
float4 overlayColor : OVERLAY_COLOR;
|
||||
#endif
|
||||
|
||||
float2 uv : TEXCOORD_0_FB_MSAA;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 light : LIGHT;
|
||||
float4 fogColor : FOG_COLOR;
|
||||
|
||||
#ifdef GLINT
|
||||
float4 layerUV : GLINT_UVS;
|
||||
#endif
|
||||
|
||||
#ifdef USE_OVERLAY
|
||||
float4 overlayColor : OVERLAY_COLOR;
|
||||
#endif
|
||||
|
||||
float2 uv : TEXCOORD_0_FB_MSAA;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// passes through the triangles, except changint the viewport id to match the instance
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
#ifndef NO_TEXTURE
|
||||
output.uv = input[j].uv;
|
||||
#endif
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
output.light = input[j].light;
|
||||
output.fogColor = input[j].fogColor;
|
||||
#ifdef USE_OVERLAY
|
||||
output.overlayColor = input[j].overlayColor;
|
||||
#endif
|
||||
#ifdef GLINT
|
||||
output.layerUV = input[j].layerUV;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input {
|
||||
float3 position : POSITION;
|
||||
float4 normal : NORMAL;
|
||||
float2 texCoords : TEXCOORD_0;
|
||||
#ifdef COLOR_BASED
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input {
|
||||
float4 position : SV_Position;
|
||||
|
||||
float4 light : LIGHT;
|
||||
float4 fogColor : FOG_COLOR;
|
||||
|
||||
#ifdef GLINT
|
||||
// there is some alignment issue on the Windows Phone 1320 that causes the position
|
||||
// to get corrupted if this is two floats and last in the struct memory wise
|
||||
float4 layerUV : GLINT_UVS;
|
||||
#endif
|
||||
|
||||
#ifdef USE_OVERLAY
|
||||
float4 overlayColor : OVERLAY_COLOR;
|
||||
#endif
|
||||
|
||||
float2 uv : TEXCOORD_0_FB_MSAA;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
static const float AMBIENT = 0.45;
|
||||
|
||||
static const float XFAC = -0.1;
|
||||
static const float ZFAC = 0.1;
|
||||
|
||||
|
||||
float4 TransformRGBA8_SNORM(const float4 RGBA8_SNORM) {
|
||||
#ifdef R8G8B8A8_SNORM_UNSUPPORTED
|
||||
return RGBA8_SNORM * float(2.0).xxxx - float(1.0).xxxx;
|
||||
#else
|
||||
return RGBA8_SNORM;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
float lightIntensity(const float4 position, const float4 normal) {
|
||||
#ifdef FANCY
|
||||
|
||||
#if !defined(INSTANCEDSTEREO)
|
||||
float3 N = normalize(mul(WORLD, normal)).xyz;
|
||||
#else
|
||||
float3 N = normalize(mul(WORLD_STEREO, normal)).xyz;
|
||||
#endif
|
||||
|
||||
N.y *= TILE_LIGHT_COLOR.a;
|
||||
|
||||
//take care of double sided polygons on materials without culling
|
||||
#ifdef FLIP_BACKFACES
|
||||
#if !defined(INSTANCEDSTEREO)
|
||||
float3 viewDir = normalize((mul(WORLD, position)).xyz);
|
||||
#else
|
||||
float3 viewDir = normalize((mul(WORLD_STEREO, position)).xyz);
|
||||
#endif
|
||||
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
|
||||
float2 calculateLayerUV(float2 origUV, float offset, float rotation) {
|
||||
float2 uv = origUV;
|
||||
uv -= 0.5;
|
||||
float rsin = sin(rotation);
|
||||
float rcos = cos(rotation);
|
||||
uv = mul(uv, float2x2(rcos, -rsin, rsin, rcos));
|
||||
uv.x += offset;
|
||||
uv += 0.5;
|
||||
|
||||
return uv * GLINT_UV_SCALE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void main(in VS_Input VSInput, out PS_Input PSInput) {
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul(WORLDVIEWPROJ_STEREO[i], float4(VSInput.position, 1));
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
float4 normal = TransformRGBA8_SNORM(VSInput.normal);
|
||||
|
||||
float L = lightIntensity(float4(VSInput.position, 1), normal);
|
||||
|
||||
#ifdef USE_OVERLAY
|
||||
L += OVERLAY_COLOR.a * 0.35;
|
||||
PSInput.overlayColor = OVERLAY_COLOR;
|
||||
#endif
|
||||
|
||||
PSInput.light = float4(L.xxx * TILE_LIGHT_COLOR.rgb, 1.0);
|
||||
|
||||
#ifdef COLOR_BASED
|
||||
PSInput.light *= VSInput.color;
|
||||
#endif
|
||||
#ifndef NO_TEXTURE
|
||||
PSInput.uv = VSInput.texCoords;
|
||||
#endif
|
||||
|
||||
#ifdef USE_UV_ANIM
|
||||
PSInput.uv.xy += UV_ANIM.xy;
|
||||
#endif
|
||||
|
||||
#ifdef GLINT
|
||||
PSInput.layerUV.xy = calculateLayerUV(VSInput.texCoords, UV_OFFSET.x, UV_ROTATION.x);
|
||||
PSInput.layerUV.zw = calculateLayerUV(VSInput.texCoords, UV_OFFSET.y, UV_ROTATION.y);
|
||||
#endif
|
||||
|
||||
//fog
|
||||
PSInput.fogColor.rgb = FOG_COLOR.rgb;
|
||||
PSInput.fogColor.a = clamp(((PSInput.position.z / RENDER_DISTANCE) - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
PSOutput.color = float4(1,1,1,1);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
PSOutput.color = PSInput.color;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// passes through the triangles, except changint the viewport id to match the instance
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
output.color = input[j].color;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float4 normal : NORMAL;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
PSInput.color = VSInput.color * 0.5f + -0.5f * dot(VSInput.normal, float4(GAZE_DIRECTION, 0.0f));
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1.0f ) );
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul( WORLDVIEWPROJ, float4( VSInput.position, 1.0f ) );
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// DO NOT HAVE THIS INCLUDE BE THE FIRST LINE! we need a #define to be respected in the .fxh file
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0; // the stereo texture uses a texture array
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
#ifdef INSTANCEDSTEREO
|
||||
float3 uvr = float3(PSInput.uv, PSInput.instanceID); // 3rd element selects the texture
|
||||
#else
|
||||
int eyeIndex = 0; //TODO: Right now this code will render mono if we were to implement non-instanced stereo rendering
|
||||
float3 uvr = float3(PSInput.uv, eyeIndex); // 3rd element selects the texture
|
||||
#endif
|
||||
PSOutput.color = TEXTURE_0.Sample(TextureSampler0, uvr);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// passes through the triangles, except changint the viewport id to match the instance
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
output.uv0 = input[j].uv0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
output.instanceID = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
//outStream.RestartStrip();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD_0;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
float2 uv = PSInput.uv * SKIRT_UV_SCALE.xy;
|
||||
uv = frac(uv);
|
||||
uv = uv * SKIRT_UVS.zw + SKIRT_UVS.xy;
|
||||
PSOutput.color = TEXTURE_0.Sample( TextureSampler0, uv ) * PSInput.color.r;
|
||||
PSOutput.color.rgb *= TEXTURE_1.Sample(TextureSampler1, PSInput.color.gr).rgb;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Takes verts in world space and transforms them by two different view
|
||||
// proj matrices, on two different viewports.
|
||||
[maxvertexcount(6)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
output.color = input[j].color;
|
||||
output.uv0 = input[j].uv0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texCoords : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 texCoords : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
PSInput.color = VSInput.color;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
PSInput.texCoords = VSInput.texCoords;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float3 color : COLOR;
|
||||
float2 uv : TEXCOORD_0;
|
||||
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
float4 diffuse = TEXTURE_0.Sample( TextureSampler0, PSInput.uv );
|
||||
//diffuse.rgb *= TEXTURE_1.Sample(TextureSampler1, float2(0, PSInput.color.a)).rgb;
|
||||
//diffuse.rgb *= float3(151.0f/255.0f, 59.0f/255.0f, 224.0f/255.0f);
|
||||
diffuse.rgb *= PSInput.color.rgb;
|
||||
|
||||
PSOutput.color = diffuse;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// passes through the triangles, except changint the viewport id to match the instance
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
output.color = input[j].color;
|
||||
output.uv0 = input[j].uv0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
float4 color : COLOR;
|
||||
float2 texCoords : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 texCoords : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
PSInput.color = VSInput.color;
|
||||
float3 position = VSInput.position;
|
||||
float3 voxelCenter = VSInput.normal * 80.0f - float3(40.0f, 40.0f, 40.0f);
|
||||
voxelCenter.y = -0.5f;
|
||||
float2 delta = voxelCenter.xz - TABLE_REVEAL_CENTER.xz;
|
||||
float lengthSq = dot(delta, delta);
|
||||
|
||||
if (lengthSq > (TABLE_REVEAL_CONSTANTS.x * TABLE_REVEAL_CONSTANTS.x)) {
|
||||
position = float3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
else if (TABLE_REVEAL_CONSTANTS.y > 0.0f && VSInput.normal.y > 0.0f && lengthSq < (TABLE_REVEAL_CONSTANTS.y * TABLE_REVEAL_CONSTANTS.y)) {
|
||||
float fallAmount = TABLE_REVEAL_CONSTANTS.y*TABLE_REVEAL_CONSTANTS.y - lengthSq;
|
||||
position.y -= fallAmount * 0.1f;
|
||||
}
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( position, 1 ) );
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(position, 1));
|
||||
#endif
|
||||
PSInput.texCoords = VSInput.texCoords;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
//$ANTCOLONY
|
||||
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
float4 uv1 : TEXCOORD_1;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main(in PS_Input PSInput, out PS_Output PSOutput)
|
||||
{
|
||||
float2 uv = PSInput.uv1.xy + (PSInput.uv0 - floor(PSInput.uv0)) * PSInput.uv1.zw;
|
||||
float4 diffuse = TEXTURE_0.Sample(TextureSampler0, uv);
|
||||
float2 lightingUVs = float2(0.0f, 0.9f);
|
||||
diffuse.rgb *= TEXTURE_1.Sample(TextureSampler1, lightingUVs).rgb;
|
||||
|
||||
if (diffuse.a < 0.5f)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
diffuse *= PSInput.color;
|
||||
PSOutput.color = diffuse;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
float4 uv1 : TEXCOORD_1;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
float4 uv1 : TEXCOORD_1;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Takes verts in world space and transforms them by two different view
|
||||
// proj matrices, on two different viewports.
|
||||
[maxvertexcount(6)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
output.color = input[j].color;
|
||||
output.uv0 = input[j].uv0;
|
||||
output.uv1 = input[j].uv1;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
//outStream.RestartStrip();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
//$ANTCOLONY
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float2 uv0 : TEXCOORD_0; // x,y 0-1 based off if voxel texture wasn't in atlas. Can multiply against atlas UV's to get atlas uv's
|
||||
float2 uv1 : TEXCOORD_1; // x = voxel coord x, y = voxel coord y
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
float4 uvRect : TEXCOORD_1;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
Texture2D<float4> TILE_UV_MAP : register (t1);
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
float3 position = VSInput.position.xyz;
|
||||
|
||||
int2 tileUVs = int2(0, VSInput.uv1.x * 255.0f);
|
||||
float4 uvCoords = TEXTURE_1[tileUVs];
|
||||
|
||||
tileUVs.x = 4.0f;
|
||||
float4 colorVal = TEXTURE_1[tileUVs];
|
||||
|
||||
PSInput.uv0 = VSInput.uv0 * float2(1.0f, 127.0f);
|
||||
PSInput.uvRect = uvCoords;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul(WORLDVIEWPROJ_STEREO[i], float4(position.xyz, 1));
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(position.xyz, 1));
|
||||
#endif
|
||||
PSInput.color = colorVal;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 light : LIGHT;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
float4 color = lerp( float4( 1, 1, 1, 1 ), PSInput.light, PSInput.light.a );
|
||||
|
||||
color.rgb = lerp( color, OVERLAY_COLOR, OVERLAY_COLOR.a ).rgb;
|
||||
|
||||
PSOutput.color = color;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float4 normal : NORMAL;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
PSInput.color.rgb = ( VSInput.normal.xyz / 2 ) + 0.5;
|
||||
PSInput.color.a = 1.0;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Takes verts in world space and transforms them by two different view
|
||||
// proj matrices, on two different viewports.
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
output.uv0 = input[j].uv0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// passes through the triangles, except changint the viewport id to match the instance
|
||||
#ifdef LINE_STRIP
|
||||
[maxvertexcount(2)]
|
||||
void main(line GeometryShaderInput input[2], inout LineStream<GeometryShaderOutput> outStream)
|
||||
#else
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
#endif
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
#ifdef LINE_STRIP
|
||||
for (int j = 0; j < 2; j++)
|
||||
#else
|
||||
for (int j = 0; j < 3; j++)
|
||||
#endif
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input {
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
float4 color : COLOR;
|
||||
float4 worldPosition : TEXCOORD_1;
|
||||
float4 fogColor : FOG_COLOR;
|
||||
};
|
||||
|
||||
struct PS_Output {
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput ) {
|
||||
|
||||
PSOutput.color = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
|
||||
PSOutput.color.a *= PSInput.color.a;
|
||||
|
||||
float2 uv = PSInput.worldPosition.xz;
|
||||
float4 occlusionTexture = TEXTURE_1.Sample(TextureSampler1, uv);
|
||||
|
||||
// clamp the uvs
|
||||
if (uv.x >= 0.0f && uv.x <= 1.0f &&
|
||||
uv.y >= 0.0f && uv.y <= 1.0f &&
|
||||
PSInput.worldPosition.y < occlusionTexture.a) {
|
||||
PSOutput.color.a = 0.0f;
|
||||
}
|
||||
|
||||
float mixAmount = saturate((PSInput.worldPosition.y - occlusionTexture.a)*10.0f);
|
||||
float3 lighting = lerp(occlusionTexture.rgb, PSInput.color.rgb, mixAmount);
|
||||
PSOutput.color.rgb *= lighting.rgb;
|
||||
|
||||
//apply fog
|
||||
PSOutput.color.rgb = lerp(PSOutput.color.rgb, PSInput.fogColor.rgb, PSInput.fogColor.a);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
float4 color : COLOR;
|
||||
float4 worldPosition : TEXCOORD_1;
|
||||
float4 fogColor : FOG_COLOR;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
float4 color : COLOR;
|
||||
float4 worldPosition : TEXCOORD_1;
|
||||
float4 fogColor : FOG_COLOR;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
bool inBounds(float3 worldPos)
|
||||
{
|
||||
bool inBounds = true;
|
||||
if (worldPos.x < CLIP_MIN.x ||
|
||||
worldPos.x > CLIP_MAX.x ||
|
||||
worldPos.z < CLIP_MIN.y ||
|
||||
worldPos.z > CLIP_MAX.y)
|
||||
{
|
||||
inBounds = false;
|
||||
}
|
||||
|
||||
return inBounds;
|
||||
}
|
||||
|
||||
// passes through the triangles, except changint the viewport id to match the instance
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
// if (inBounds(input[0].worldPositionActual) || inBounds(input[1].worldPositionActual) || inBounds(input[2].worldPositionActual)) {
|
||||
|
||||
for (int j = 0; j < 3; j++) {
|
||||
output.position = input[j].position;
|
||||
output.uv = input[j].uv;
|
||||
output.color = input[j].color;
|
||||
output.worldPosition = input[j].worldPosition;
|
||||
output.fogColor = input[j].fogColor;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input {
|
||||
float3 position : POSITION;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct PS_Input {
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
float4 color : COLOR;
|
||||
float4 worldPosition : TEXCOORD_1;
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
void main(in VS_Input VSInput, out PS_Input PSInput)
|
||||
{
|
||||
float spriteSelector = VSInput.color.x*255.0f;
|
||||
PSInput.uv = UV_INFO.xy + (VSInput.uv0 * UV_INFO.zw);
|
||||
PSInput.uv.x += spriteSelector * UV_INFO.z;
|
||||
|
||||
float3 position = VSInput.position.xyz;
|
||||
|
||||
// subtract the offset then fmod into (0.0f, PARTICLE_BOX)
|
||||
position.xyz += POSITION_OFFSET.xyz;
|
||||
position.xyz = fmod(position.xyz, PARTICLE_BOX.xxx);
|
||||
|
||||
// centre box on origin
|
||||
position.xyz -= PARTICLE_BOX.xxx * 0.5f;
|
||||
|
||||
// push along view vector so box is positioned more infront of camera
|
||||
position.xyz += FORWARD.xyz;
|
||||
|
||||
// get world position
|
||||
float4 worldPositionBottom = float4(position.xyz, 1.0f);
|
||||
float4 worldPositionTop = float4(worldPositionBottom.xyz + (VELOCITY.xyz * SIZE_SCALE.y), 1.0f);
|
||||
|
||||
// get projected positions of top and bottom of particle, and top of particle in previous frame
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
float4 bottom = mul(WORLDVIEWPROJ_STEREO[i], worldPositionBottom);
|
||||
float4 top = mul(WORLDVIEWPROJ_STEREO[i], worldPositionTop);
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
float4 bottom = mul(WORLDVIEWPROJ, worldPositionBottom);
|
||||
float4 top = mul(WORLDVIEWPROJ, worldPositionTop);
|
||||
#endif
|
||||
// get 2d vector in screenspace between top and bottom of particle
|
||||
float2 dir = (top.xy/top.w) - (bottom.xy/bottom.w);
|
||||
|
||||
// get 2d vector perpendicular to velocity
|
||||
float2 dirPerp = normalize(float2(-dir.y, dir.x));
|
||||
|
||||
// choose either the top or bottom projected position using uv.y
|
||||
PSInput.position = lerp(top, bottom, VSInput.uv0.y);
|
||||
|
||||
// offset the position of each side of the particle using uv.x
|
||||
PSInput.position.xy += (0.5f - VSInput.uv0.x) * dirPerp * SIZE_SCALE.x;
|
||||
|
||||
// get the final colour including the lighting, distance and length scales, and per instance alpha
|
||||
PSInput.color = ALPHA;
|
||||
|
||||
//fog
|
||||
PSInput.fogColor.rgb = FOG_COLOR.rgb;
|
||||
PSInput.fogColor.a = clamp(((PSInput.position.z / RENDER_DISTANCE) - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, 1.0);
|
||||
|
||||
worldPositionBottom.xz *= 1.0f / 64.0f; // Scale by 1/TextureDimensions to get values between
|
||||
worldPositionBottom.xz += 0.5f; // Offset so that center of view is in the center of occlusion texture
|
||||
worldPositionBottom.y += VIEW_POSITION.y - 0.5f;
|
||||
worldPositionBottom.y *= 1.0f / 255.0f;
|
||||
PSInput.worldPosition = worldPositionBottom;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "Util.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
lpfloat4 color : COLOR;
|
||||
snorm float2 uv0 : TEXCOORD_0_FB_MSAA;
|
||||
snorm float2 uv1 : TEXCOORD_1_FB_MSAA;
|
||||
#ifdef NEAR_WATER
|
||||
float cameraDist : TEXCOORD_2;
|
||||
#endif
|
||||
|
||||
#ifdef FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
#if !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE) || (VERSION < 0xa000 /*D3D_FEATURE_LEVEL_10_0*/)
|
||||
float4 diffuse = TEXTURE_0.Sample(TextureSampler0, PSInput.uv0);
|
||||
#else
|
||||
float4 diffuse = texture2D_AA(TEXTURE_0, TextureSampler0, PSInput.uv0 );
|
||||
#endif
|
||||
|
||||
#ifdef SEASONS_FAR
|
||||
diffuse.a = 1.0f;
|
||||
PSInput.color.b = 1.0f;
|
||||
#endif
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
//If we know that all the verts in a triangle will have the same alpha, we should cull there first.
|
||||
#ifdef ALPHA_TO_COVERAGE
|
||||
float alphaThreshold = .05f;
|
||||
#else
|
||||
float alphaThreshold = .5f;
|
||||
#endif
|
||||
if(diffuse.a < alphaThreshold)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
diffuse = diffuse * TEXTURE_1.Sample(TextureSampler1, PSInput.uv1);
|
||||
|
||||
#ifndef SEASONS
|
||||
|
||||
#if !defined(ALPHA_TEST) && !defined(BLEND)
|
||||
diffuse.a = PSInput.color.a;
|
||||
#elif defined(BLEND)
|
||||
diffuse.a *= PSInput.color.a;
|
||||
|
||||
#ifdef NEAR_WATER
|
||||
float alphaFadeOut = saturate(PSInput.cameraDist.x);
|
||||
diffuse.a = lerp(diffuse.a, 1.0f, alphaFadeOut);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
diffuse.rgb *= PSInput.color.rgb;
|
||||
#else
|
||||
float2 uv = PSInput.color.xy;
|
||||
diffuse.rgb *= lerp(1.0f, TEXTURE_2.Sample(TextureSampler2, uv).rgb*2.0f, PSInput.color.b);
|
||||
diffuse.rgb *= PSInput.color.aaa;
|
||||
diffuse.a = 1.0f;
|
||||
#endif
|
||||
|
||||
#ifdef FOG
|
||||
diffuse.rgb = lerp( diffuse.rgb, PSInput.fogColor.rgb, PSInput.fogColor.a );
|
||||
#endif
|
||||
|
||||
PSOutput.color = diffuse;
|
||||
|
||||
#ifdef VR_FEATURE
|
||||
// On Rift, the transition from 0 brightness to the lowest 8 bit value is abrupt, so clamp to
|
||||
// the lowest 8 bit value.
|
||||
PSOutput.color = max(PSOutput.color, 1 / 255.0f);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
lpfloat4 color : COLOR;
|
||||
snorm float2 uv0 : TEXCOORD_0;
|
||||
snorm float2 uv1 : TEXCOORD_1;
|
||||
#ifdef NEAR_WATER
|
||||
float cameraDist : TEXCOORD_2;
|
||||
#endif
|
||||
#ifdef FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
lpfloat4 color : COLOR;
|
||||
snorm float2 uv0 : TEXCOORD_0;
|
||||
snorm float2 uv1 : TEXCOORD_1;
|
||||
#ifdef NEAR_WATER
|
||||
float cameraDist : TEXCOORD_2;
|
||||
#endif
|
||||
#ifdef FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
bool inBounds(float3 worldPos)
|
||||
{
|
||||
bool inBounds = true;
|
||||
if (worldPos.x < CHUNK_CLIP_MIN.x ||
|
||||
worldPos.x > CHUNK_CLIP_MAX.x ||
|
||||
worldPos.z < CHUNK_CLIP_MIN.y ||
|
||||
worldPos.z > CHUNK_CLIP_MAX.y)
|
||||
{
|
||||
inBounds = false;
|
||||
}
|
||||
|
||||
return inBounds;
|
||||
}
|
||||
|
||||
// passes through the triangles, except changint the viewport id to match the instance
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
output.color = input[j].color;
|
||||
output.uv0 = input[j].uv0;
|
||||
output.uv1 = input[j].uv1;
|
||||
#ifdef NEAR_WATER
|
||||
output.cameraDist = input[j].cameraDist;
|
||||
#endif
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
|
||||
#ifdef FOG
|
||||
output.fogColor = input[j].fogColor;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input {
|
||||
float3 position : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
float2 uv1 : TEXCOORD_1;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input {
|
||||
float4 position : SV_Position;
|
||||
lpfloat4 color : COLOR;
|
||||
snorm float2 uv0 : TEXCOORD_0_FB_MSAA;
|
||||
snorm float2 uv1 : TEXCOORD_1_FB_MSAA;
|
||||
|
||||
#ifdef NEAR_WATER
|
||||
float cameraDist : TEXCOORD_2;
|
||||
#endif
|
||||
|
||||
#ifdef FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
static const float rA = 1.0;
|
||||
static const float rB = 1.0;
|
||||
static const float3 UNIT_Y = float3(0, 1, 0);
|
||||
static const float DIST_DESATURATION = 56.0 / 255.0; //WARNING this value is also hardcoded in the water color, don'tchange
|
||||
|
||||
|
||||
void main(in VS_Input VSInput, out PS_Input PSInput) {
|
||||
PSInput.uv0 = VSInput.uv0;
|
||||
PSInput.uv1 = VSInput.uv1;
|
||||
PSInput.color = VSInput.color;
|
||||
|
||||
#ifdef AS_ENTITY_RENDERER
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul(WORLDVIEWPROJ_STEREO[i], float4(VSInput.position, 1));
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
float3 worldPos = PSInput.position;
|
||||
#else
|
||||
float3 worldPos = (VSInput.position.xyz * CHUNK_ORIGIN_AND_SCALE.w) + CHUNK_ORIGIN_AND_SCALE.xyz;
|
||||
|
||||
// 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
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
|
||||
PSInput.position = mul(WORLDVIEW_STEREO[i], float4(worldPos, 1 ));
|
||||
PSInput.position = mul(PROJ_STEREO[i], PSInput.position);
|
||||
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEW, float4( worldPos, 1 ));
|
||||
PSInput.position = mul(PROJ, PSInput.position);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
///// find distance from the camera
|
||||
|
||||
#if defined(FOG) || defined(NEAR_WATER)
|
||||
#ifdef FANCY
|
||||
float3 relPos = -worldPos;
|
||||
float cameraDepth = length(relPos);
|
||||
#ifdef NEAR_WATER
|
||||
PSInput.cameraDist = cameraDepth / FAR_CHUNKS_DISTANCE;
|
||||
#endif
|
||||
#else
|
||||
float cameraDepth = PSInput.position.z;
|
||||
#ifdef NEAR_WATER
|
||||
float3 relPos = -worldPos;
|
||||
float cameraDist = length(relPos);
|
||||
PSInput.cameraDist = cameraDist / FAR_CHUNKS_DISTANCE;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
///// apply fog
|
||||
|
||||
#ifdef FOG
|
||||
float len = cameraDepth / RENDER_DISTANCE;
|
||||
#ifdef ALLOW_FADE
|
||||
len += CURRENT_COLOR.r;
|
||||
#endif
|
||||
|
||||
PSInput.fogColor.rgb = FOG_COLOR.rgb;
|
||||
PSInput.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);
|
||||
F = 1.0 - lerp(F*F*F*F, 1.0, min(1.0, cameraDepth / FAR_CHUNKS_DISTANCE));
|
||||
|
||||
PSInput.color.rg -= float2(float(F * DIST_DESATURATION).xx);
|
||||
|
||||
float4 depthColor = float4(PSInput.color.rgb * 0.5, 1.0);
|
||||
float4 traspColor = float4(PSInput.color.rgb * 0.45, 0.8);
|
||||
float4 surfColor = float4(PSInput.color.rgb, 1.0);
|
||||
|
||||
float4 nearColor = lerp(traspColor, depthColor, PSInput.color.a);
|
||||
PSInput.color = lerp(surfColor, nearColor, F);
|
||||
#else
|
||||
PSInput.color.a = PSInput.position.z / FAR_CHUNKS_DISTANCE + 0.5;
|
||||
#endif //FANCY
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// passes through the triangles, except changint the viewport id to match the instance
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
output.color = input[j].color;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
PSInput.color = lerp( CURRENT_COLOR, FOG_COLOR, VSInput.color.r );
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
PSOutput.color = PSInput.color;
|
||||
PSOutput.color.rgb *= CURRENT_COLOR.rgb * PSInput.color.a;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "Util.fxh"
|
||||
|
||||
#ifndef BLUR_RADIUS
|
||||
#define BLUR_RADIUS 1 //base size
|
||||
#endif
|
||||
|
||||
//HACK do not build higher res versions on DX9
|
||||
#if VERSION < 0xa000 && BLUR_RADIUS > 2
|
||||
#undef BLUR_RADIUS
|
||||
#define BLUR_RADIUS 2
|
||||
#endif
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
float2 pixelSide = float2(1.0 / TEXTURE_DIMENSIONS.xy);
|
||||
|
||||
#if BLUR_RADIUS == 1
|
||||
float4 color = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
#else
|
||||
float4 color = float4(0, 0, 0, 0);
|
||||
for(int i = -BLUR_RADIUS / 2; i < BLUR_RADIUS / 2; ++i) {
|
||||
for(int j = -BLUR_RADIUS / 2; j < BLUR_RADIUS / 2; ++j) {
|
||||
float2 uv = PSInput.uv + pixelSide * float2(j, i);
|
||||
uv = fmod(uv, float2(1,1));
|
||||
|
||||
color += TEXTURE_0.Sample(TextureSampler0, uv);
|
||||
}
|
||||
}
|
||||
|
||||
color /= BLUR_RADIUS * BLUR_RADIUS;
|
||||
#endif
|
||||
|
||||
color.rgb = lerp(color.rgb, CURRENT_COLOR.rgb * color.rgb, color.a * CURRENT_COLOR.a);
|
||||
if(CURRENT_COLOR.a > 0) {
|
||||
//the alpha in diffuse is a mask
|
||||
color.a = 1;
|
||||
}
|
||||
|
||||
PSOutput.color = color;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float2 uv : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position.x, VSInput.position.y, 0, 1 ) );
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4( VSInput.position.x, VSInput.position.y, 0, 1 ));
|
||||
#endif
|
||||
|
||||
PSInput.uv = VSInput.uv + 2.0 * VSInput.position.z * (VSInput.uv - float2(0.5, 0.5));
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD_0;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
const float4 diffuse = TEXTURE_0.Sample( TextureSampler0, PSInput.uv );
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if( diffuse.a < 0.5 )
|
||||
{
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
PSOutput.color = diffuse * PSInput.color * DARKEN;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
PSOutput.color = TEXTURE_0.Sample( TextureSampler0, PSInput.uv );
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if( PSOutput.color.a < 0.5 )
|
||||
{
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
float2 uv1 : TEXCOORD_1;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main(in PS_Input PSInput, out PS_Output PSOutput)
|
||||
{
|
||||
float4 color = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
float4 color1 = TEXTURE_0.Sample(TextureSampler0, PSInput.uv1);
|
||||
|
||||
if (color.a < 0.01f)
|
||||
{
|
||||
color = color1;
|
||||
}
|
||||
else if (color.b > 0.01f) {
|
||||
color = lerp(color, color1, CURRENT_COLOR.a);
|
||||
}
|
||||
|
||||
PSOutput.color = color;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "Util.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
#if !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE) || (VERSION < 0xa000 /*D3D_FEATURE_LEVEL_10_0*/)
|
||||
float4 diffuse = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
#else
|
||||
float4 diffuse = texture2D_AA(TEXTURE_0, TextureSampler0, PSInput.uv);
|
||||
#endif
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if( diffuse.a < 0.5 )
|
||||
{
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
PSOutput.color = CURRENT_COLOR * diffuse;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
float4 diffuse = TEXTURE_0.Sample( TextureSampler0, PSInput.uv );
|
||||
|
||||
|
||||
if( diffuse.a < 0.5 )
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
PSOutput.color = CURRENT_COLOR;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
|
||||
float4 texture2D_AA(in Texture2D tex, in sampler texSampler, in float2 uv)
|
||||
{
|
||||
// Texture antialiasing
|
||||
//
|
||||
// The texture coordinates are modified so that the bilinear filter will be one pixel width wide instead of one texel width.
|
||||
|
||||
// Get the UV deltas
|
||||
float2 dUVdx = ddx(uv) * TEXTURE_DIMENSIONS.xy;
|
||||
float2 dUVdy = ddy(uv) * TEXTURE_DIMENSIONS.xy;
|
||||
float2 dU = float2(dUVdx.x, dUVdy.x);
|
||||
float2 dV = float2(dUVdx.y, dUVdy.y);
|
||||
|
||||
float duUV = sqrt(dot(dU, dU));
|
||||
float dvUV = sqrt(dot(dV, dV));
|
||||
|
||||
// Determine mip map LOD
|
||||
float d = max(dot(dUVdx, dUVdx), dot(dUVdy, dUVdy));
|
||||
float mipLevel = .5f * log2(d);
|
||||
mipLevel = mipLevel + .5f; // Mip bias to reduce aliasing
|
||||
mipLevel = clamp(mipLevel, 0.0f, TEXTURE_DIMENSIONS.z);
|
||||
|
||||
float2 uvModified;
|
||||
if( mipLevel >= 1.0f)
|
||||
{
|
||||
uvModified = uv;
|
||||
}
|
||||
else
|
||||
{
|
||||
// First scale the uv so that each texel has a uv range of [0,1]
|
||||
float2 texelUV = frac(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 |
|
||||
float scalerU = 1.0f / (duUV);
|
||||
float scalerV = 1.0f / (dvUV);
|
||||
float2 scaler = max(float2(scalerU, scalerV), 1.0f);
|
||||
texelUV = clamp(texelUV * scaler, 0.0f, .5f) + clamp(texelUV*scaler - (scaler - .5f), 0.0f, .5f);
|
||||
uvModified += texelUV;
|
||||
uvModified /= TEXTURE_DIMENSIONS.xy;
|
||||
}
|
||||
float4 diffuse = tex.Sample(TextureSampler0, uvModified);
|
||||
return diffuse;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// passes through the triangles, except changint the viewport id to match the instance
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
output.uv0 = input[j].uv0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
//outStream.RestartStrip();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float2 uv : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
PSInput.uv = VSInput.uv;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
PSOutput.color = float4( PSInput.uv.xy, 0, 1 );
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
float2 uv1 : TEXCOORD_1;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
float2 uv1 : TEXCOORD_1;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// passes through the triangles, except changint the viewport id to match the instance
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.pos = input[j].pos;
|
||||
output.uv0 = input[j].uv0;
|
||||
output.uv1 = input[j].uv1;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
//outStream.RestartStrip();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float2 uv : TEXCOORD_0;
|
||||
float2 uv1 : TEXCOORD_1;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
float2 uv1 : TEXCOORD_1;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void main(in VS_Input VSInput, out PS_Input PSInput)
|
||||
{
|
||||
PSInput.uv = VSInput.uv;
|
||||
PSInput.uv1 = VSInput.uv1;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul(WORLDVIEWPROJ_STEREO[i], float4(VSInput.position, 1));
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float2 uv : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
PSInput.uv = VSInput.uv * GLINT_UV_SCALE.xy;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float2 uv : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
PSInput.uv = VSInput.uv;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
float4 pos = mul(WORLDVIEW_STEREO[i], float4(VSInput.position, 1));
|
||||
PSInput.position = mul(PROJ_STEREO[i], pos);
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
float4 pos = mul(WORLDVIEW, float4(VSInput.position, 1));
|
||||
PSInput.position = mul(PROJ, pos);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input {
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
float2 uv1 : TEXCOORD_1;
|
||||
};
|
||||
|
||||
struct PS_Output {
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main(in PS_Input PSInput, out PS_Output PSOutput)
|
||||
{
|
||||
float4 diffuse = TEXTURE_0.Sample(TextureSampler0, PSInput.uv0) * TEXTURE_1.Sample(TextureSampler1, PSInput.uv1);
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if(diffuse.a < 0.5)
|
||||
discard;
|
||||
#endif
|
||||
diffuse *= PSInput.color;
|
||||
|
||||
PSOutput.color = diffuse;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
float2 uv1 : TEXCOORD_1;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
float2 uv1 : TEXCOORD_1;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
// passes through the triangles, except changint the viewport id to match the instance
|
||||
[maxvertexcount(3)]
|
||||
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
|
||||
{
|
||||
GeometryShaderOutput output = (GeometryShaderOutput)0;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = input[0].instanceID;
|
||||
#endif
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
output.position = input[j].position;
|
||||
output.color = input[j].color;
|
||||
output.uv0 = input[j].uv0;
|
||||
output.uv1 = input[j].uv1;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input {
|
||||
float3 position : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
float2 uv1 : TEXCOORD_1;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct PS_Input {
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
float2 uv1 : TEXCOORD_1;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
void main(in VS_Input VSInput, out PS_Input PSInput)
|
||||
{
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul(WORLDVIEWPROJ_STEREO[i], float4(VSInput.position, 1));
|
||||
PSInput.instanceID = i;
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
PSInput.color = VSInput.color;
|
||||
PSInput.uv0.x = VSInput.uv0.x*2.0f;
|
||||
PSInput.uv0.y = VSInput.uv0.y*10.0f;
|
||||
PSInput.uv1 = VSInput.uv1;
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
// version 300 code
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
layout(location = 1) out vec4 FragData;
|
||||
#define gl_FragData FragData
|
||||
|
||||
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
||||
#define _centroid centroid
|
||||
#else
|
||||
#define _centroid
|
||||
#endif
|
||||
|
||||
#ifndef NO_TEXTURE
|
||||
_centroid in vec2 uv;
|
||||
#endif
|
||||
#else
|
||||
// version 100 code
|
||||
#ifndef NO_TEXTURE
|
||||
#if defined(TEXEL_AA) && defined(TEXEL_AA_FEATURE)
|
||||
varying highp vec2 uv;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "shaders/util.h"
|
||||
|
||||
varying vec4 bloomControl;
|
||||
|
||||
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
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
#ifdef USE_EMISSIVE
|
||||
#define NEEDS_DISCARD(C) (C.a + C.r + C.g + C.b == 0.0)
|
||||
#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
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if(NEEDS_DISCARD(color))
|
||||
discard;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_COLOR_MASK
|
||||
color.rgb = mix(color.rgb, color.rgb*changeColor.rgb, color.a);
|
||||
color.a = 1.0;
|
||||
#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 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
|
||||
|
||||
#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
|
||||
#if __VERSION__ >= 300
|
||||
gl_FragColor = color;
|
||||
vec3 lightCol = pow(mix(light.rgb, light.rgb * color.rgb, 0.8), vec3(bloomControl.x)) * bloomControl.y * 0.5;
|
||||
gl_FragData = vec4(lightCol, 1.0);
|
||||
#else
|
||||
gl_FragColor = color;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
// __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
|
||||
#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
|
||||
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
uniform MAT4 WORLD;
|
||||
uniform vec4 TILE_LIGHT_COLOR;
|
||||
uniform vec4 OVERLAY_COLOR;
|
||||
uniform vec4 CHANGE_COLOR;
|
||||
uniform vec4 GLINT_COLOR;
|
||||
uniform vec4 FOG_COLOR;
|
||||
uniform vec2 FOG_CONTROL;
|
||||
uniform float RENDER_DISTANCE;
|
||||
uniform vec2 UV_ANIM;
|
||||
uniform vec2 UV_OFFSET;
|
||||
uniform vec2 UV_ROTATION;
|
||||
uniform vec2 GLINT_UV_SCALE;
|
||||
uniform vec3 PLAYER_POSITION;
|
||||
|
||||
uniform vec4 BLOOM_CONTROL;
|
||||
varying vec4 bloomControl;
|
||||
|
||||
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
|
||||
|
||||
#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 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
|
||||
}
|
||||
|
||||
#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;
|
||||
|
||||
float L = lightIntensity();
|
||||
|
||||
#ifdef USE_OVERLAY
|
||||
L += OVERLAY_COLOR.a * 0.35;
|
||||
overlayColor = OVERLAY_COLOR;
|
||||
#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);
|
||||
|
||||
bloomControl = BLOOM_CONTROL;
|
||||
float d = length(PLAYER_POSITION - (WORLD * POSITION).xyz) / BLOOM_CONTROL.z; // 0.06 dist
|
||||
d = (1.0 - min(d, 1.0)) * BLOOM_CONTROL.w; // strength
|
||||
light = min(mix(light, light * 2.0, d), vec4(1.0));
|
||||
|
||||
#ifdef COLOR_BASED
|
||||
light *= COLOR;
|
||||
#endif
|
||||
|
||||
#ifndef NO_TEXTURE
|
||||
uv = TEXCOORD_0;
|
||||
#endif
|
||||
|
||||
#ifdef USE_UV_ANIM
|
||||
uv.xy += UV_ANIM.xy;
|
||||
#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(((length(PLAYER_POSITION - (WORLD * POSITION).xyz) / RENDER_DISTANCE) - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, FOG_COLOR.a);
|
||||
}
|
||||
@@ -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,27 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1.0);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// __multiversion__
|
||||
//This file is purely here to let the code compile. It is used only for Hololens, which currently runs only on DX11 compatible devices
|
||||
|
||||
#if __VERSION__ >= 300
|
||||
#define varying in
|
||||
out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
#endif
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// __multiversion__
|
||||
//This file is purely here to let the code compile. It is used only for Hololens, which currently runs only on DX11 compatible devices
|
||||
|
||||
#if __VERSION__ >= 300
|
||||
#define attribute in
|
||||
#define varying out
|
||||
#endif
|
||||
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec4 COLOR;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
color = COLOR;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
|
||||
#endif
|
||||
//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,30 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
|
||||
#endif
|
||||
//This file is purely here to let the code compile. It is used only for Hololens, which currently runs only on DX11 compatible devices
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
#define attribute in
|
||||
#define varying out
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#endif
|
||||
//This file is purely here to let the code compile. It is used only for Hololens, which currently runs only on DX11 compatible devices
|
||||
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec4 COLOR;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
color = COLOR;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
|
||||
#endif
|
||||
//This file is purely here to let the code compile. It is used only for Hololens, which currently runs only on DX11 compatible devices
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
#define attribute in
|
||||
#define varying out
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#endif
|
||||
//This file is purely here to let the code compile. It is used only for Hololens, which currently runs only on DX11 compatible devices
|
||||
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec4 COLOR;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
color = COLOR;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
|
||||
#endif
|
||||
//This file is purely here to let the code compile. It is used only for Hololens, which currently runs only on DX11 compatible devices
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
#define attribute in
|
||||
#define varying out
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#endif
|
||||
//This file is purely here to let the code compile. It is used only for Hololens, which currently runs only on DX11 compatible devices
|
||||
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
|
||||
attribute mediump vec4 POSITION;
|
||||
attribute vec4 COLOR;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = WORLDVIEWPROJ * POSITION;
|
||||
|
||||
color = COLOR;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
layout(location = 1) out vec4 FragData;
|
||||
#define gl_FragData FragData
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
|
||||
#endif
|
||||
|
||||
uniform vec4 OVERLAY_COLOR;
|
||||
uniform vec4 BLOOM_CONTROL;
|
||||
|
||||
varying vec4 light;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = mix(vec4(1), light, light.a );
|
||||
|
||||
color.rgb = mix(color, OVERLAY_COLOR, OVERLAY_COLOR.a).rgb;
|
||||
|
||||
#if __VERSION__ >= 300
|
||||
gl_FragColor = color;
|
||||
vec3 lightCol = pow(light.rgb, vec3(BLOOM_CONTROL.x)) * BLOOM_CONTROL.y * 0.5;
|
||||
gl_FragData = vec4(lightCol, 1.0);
|
||||
#else
|
||||
gl_FragColor = color;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
#define attribute in
|
||||
#define varying out
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
|
||||
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,24 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
#define attribute in
|
||||
#define varying out
|
||||
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
|
||||
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.
|
||||
|
||||
// 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
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
uniform sampler2D TEXTURE_1;
|
||||
|
||||
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);
|
||||
|
||||
// clamp the uvs
|
||||
if ( occlusionUV.x >= 0.0 && occlusionUV.x <= 1.0 &&
|
||||
occlusionUV.y >= 0.0 && occlusionUV.y <= 1.0 &&
|
||||
worldPosition.y < occlusionTexture.a) {
|
||||
albedo.a = 0.0;
|
||||
}
|
||||
|
||||
float mixAmount = clamp ( (worldPosition.y - occlusionTexture.a)*10.0, 0.0, 1.0);
|
||||
vec3 lighting = mix(occlusionTexture.rgb, color.rgb, mixAmount);
|
||||
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,92 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
#define attribute in
|
||||
#define varying out
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
precision highp float;
|
||||
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
uniform vec4 POSITION_OFFSET;
|
||||
uniform vec4 VELOCITY;
|
||||
uniform vec4 ALPHA;
|
||||
uniform vec4 VIEW_POSITION;
|
||||
uniform vec4 SIZE_SCALE;
|
||||
uniform vec4 LIGHTING;
|
||||
uniform vec4 FORWARD;
|
||||
uniform vec4 UV_INFO;
|
||||
uniform vec4 PARTICLE_BOX;
|
||||
uniform vec4 FOG_COLOR;
|
||||
uniform vec2 FOG_CONTROL;
|
||||
uniform float RENDER_DISTANCE;
|
||||
|
||||
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);
|
||||
uv.x += spriteSelector * UV_INFO.z;
|
||||
|
||||
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;
|
||||
|
||||
//fog
|
||||
fogColor.rgb = FOG_COLOR.rgb;
|
||||
fogColor.a = clamp(((bottom.z / RENDER_DISTANCE) - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, FOG_COLOR.a);
|
||||
|
||||
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,121 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
||||
#define _centroid centroid
|
||||
#else
|
||||
#define _centroid
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
layout(location = 1) out vec4 FragData;
|
||||
#define gl_FragData FragData
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
varying vec2 uv0;
|
||||
varying vec2 uv1;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
#ifdef FOG
|
||||
varying vec4 fogColor;
|
||||
#endif
|
||||
|
||||
#ifdef NEAR_WATER
|
||||
varying float cameraDist;
|
||||
#endif
|
||||
|
||||
#include "shaders/util.h"
|
||||
|
||||
varying vec4 bloomControl;
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
uniform sampler2D TEXTURE_1;
|
||||
uniform sampler2D TEXTURE_2;
|
||||
|
||||
void main()
|
||||
{
|
||||
#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
|
||||
|
||||
vec4 lightTex = texture2D( TEXTURE_1, uv1 );
|
||||
diffuse = diffuse * lightTex;
|
||||
|
||||
#ifndef SEASONS
|
||||
|
||||
#if !defined(ALPHA_TEST) && !defined(BLEND)
|
||||
diffuse.a = inColor.a;
|
||||
#elif defined(BLEND)
|
||||
diffuse.a *= inColor.a;
|
||||
#ifdef NEAR_WATER
|
||||
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
|
||||
|
||||
#ifdef FOG
|
||||
diffuse.rgb = mix( diffuse.rgb, fogColor.rgb, fogColor.a );
|
||||
#endif
|
||||
|
||||
#if __VERSION__ >= 300
|
||||
gl_FragColor = diffuse;
|
||||
vec3 lightCol = pow(mix(lightTex.rgb, lightTex.rgb * diffuse.rgb, 0.8), vec3(bloomControl.x)) * bloomControl.y;
|
||||
gl_FragData = vec4(lightCol, 1.0);
|
||||
#else
|
||||
gl_FragColor = diffuse;
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
#define attribute in
|
||||
#define varying out
|
||||
|
||||
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
||||
#define _centroid centroid
|
||||
#else
|
||||
#define _centroid
|
||||
#endif
|
||||
|
||||
_centroid out vec2 uv0;
|
||||
_centroid out vec2 uv1;
|
||||
|
||||
#else
|
||||
|
||||
varying vec2 uv0;
|
||||
varying vec2 uv1;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
varying vec4 color;
|
||||
#ifdef FOG
|
||||
varying vec4 fogColor;
|
||||
#endif
|
||||
|
||||
#ifdef NEAR_WATER
|
||||
varying float cameraDist;
|
||||
#endif
|
||||
|
||||
#ifdef AS_ENTITY_RENDERER
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
#else
|
||||
uniform MAT4 WORLDVIEW;
|
||||
uniform MAT4 PROJ;
|
||||
#endif
|
||||
uniform vec4 FOG_COLOR;
|
||||
uniform vec2 FOG_CONTROL;
|
||||
uniform float RENDER_DISTANCE;
|
||||
uniform vec2 VIEWPORT_DIMENSION;
|
||||
uniform vec4 CURRENT_COLOR; //current color r contains the offset to apply to the fog for the "fade in"
|
||||
uniform POS4 CHUNK_ORIGIN_AND_SCALE;
|
||||
uniform POS3 VIEW_POS;
|
||||
uniform float FAR_CHUNKS_DISTANCE;
|
||||
uniform vec3 PLAYER_POSITION;
|
||||
uniform vec4 BLOOM_CONTROL;
|
||||
varying vec4 bloomControl;
|
||||
|
||||
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()
|
||||
{
|
||||
uv0 = TEXCOORD_0;
|
||||
uv1 = TEXCOORD_1;
|
||||
color = COLOR;
|
||||
|
||||
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
|
||||
gl_Position = pos;
|
||||
|
||||
|
||||
///// find distance from the camera
|
||||
|
||||
#if defined(FOG) || defined(NEAR_WATER)
|
||||
#ifdef FANCY
|
||||
vec3 relPos = -worldPos.xyz;
|
||||
// float cameraDepth = length(relPos);
|
||||
float cameraDepth = length(PLAYER_POSITION - worldPos.xyz);
|
||||
|
||||
#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
|
||||
|
||||
bloomControl = BLOOM_CONTROL;
|
||||
|
||||
#ifdef FOG
|
||||
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, FOG_COLOR.a);
|
||||
|
||||
float d = length(PLAYER_POSITION - worldPos.xyz) / BLOOM_CONTROL.z; // dist
|
||||
d = (1.0 - min(d, 1.0)) * BLOOM_CONTROL.w; // strength
|
||||
uv1 = mix(uv1, vec2(1.0,1.0), d);
|
||||
|
||||
// TODO: Make groundfog configurable
|
||||
// fogColor.a = max(fogColor.a, clamp(-worldPos.y / 10.0, 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);
|
||||
F = 1.0 - mix(F*F*F*F, 1.0, 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,34 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
#define attribute in
|
||||
#define varying out
|
||||
|
||||
#else
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
uniform vec4 FOG_COLOR;
|
||||
uniform vec4 CURRENT_COLOR;
|
||||
|
||||
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,38 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#define varying in
|
||||
#define texture2D texture
|
||||
layout(location = 0) out vec4 FragColor;
|
||||
#define gl_FragColor FragColor
|
||||
layout(location = 1) out vec4 FragData;
|
||||
#define gl_FragData FragData
|
||||
|
||||
#else
|
||||
|
||||
// version 100 code
|
||||
|
||||
#endif
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
uniform vec4 CURRENT_COLOR;
|
||||
|
||||
void main()
|
||||
{
|
||||
#if __VERSION__ >= 300
|
||||
gl_FragColor = vec4(color.rgb * CURRENT_COLOR.rgb * color.a, color.a);
|
||||
gl_FragData = vec4(0.0);
|
||||
#else
|
||||
gl_FragColor = vec4(color.rgb * CURRENT_COLOR.rgb * color.a, color.a);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
||||
#define _centroid centroid
|
||||
#else
|
||||
#define _centroid
|
||||
#endif
|
||||
|
||||
_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
|
||||
|
||||
|
||||
#ifndef BLUR_RADIUS
|
||||
#define BLUR_RADIUS 1 //base size
|
||||
#endif
|
||||
|
||||
//HACK do not build higher res versions on gles2
|
||||
#if __VERSION__ < 300 && BLUR_RADIUS > 2
|
||||
#undef BLUR_RADIUS
|
||||
#define BLUR_RADIUS 2
|
||||
#endif
|
||||
|
||||
const int R = BLUR_RADIUS / 2;
|
||||
|
||||
uniform vec3 TEXTURE_DIMENSIONS;
|
||||
uniform vec4 CURRENT_COLOR;
|
||||
uniform sampler2D TEXTURE_0;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 pixelSide = vec2(1.0 / TEXTURE_DIMENSIONS.xy);
|
||||
|
||||
#if BLUR_RADIUS == 1
|
||||
vec4 color = texture2D( TEXTURE_0, uv);
|
||||
#else
|
||||
vec4 color = vec4(0.0);
|
||||
for(int i = -R; i < R; ++i) {
|
||||
for(int j = -R; j < R; ++j) {
|
||||
vec2 sampleUV = uv + pixelSide * vec2(j, i);
|
||||
sampleUV = mod(sampleUV, vec2(1.0));
|
||||
|
||||
color += texture2D( TEXTURE_0, sampleUV);
|
||||
}
|
||||
}
|
||||
|
||||
color /= float(BLUR_RADIUS * BLUR_RADIUS);
|
||||
#endif
|
||||
|
||||
color.rgb = mix(color.rgb, CURRENT_COLOR.rgb * color.rgb, color.a * CURRENT_COLOR.a);
|
||||
if(CURRENT_COLOR.a > 0.0) {
|
||||
//the alpha in diffuse is a mask
|
||||
color.a = 1.0;
|
||||
}
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// __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
|
||||
#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
|
||||
|
||||
uniform MAT4 WORLDVIEWPROJ;
|
||||
|
||||
attribute POS4 POSITION;
|
||||
attribute vec2 TEXCOORD_0;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 pos = POSITION;
|
||||
pos.z = 0.0;
|
||||
gl_Position = WORLDVIEWPROJ * pos;
|
||||
|
||||
//position Z contains the padding % to apply
|
||||
uv = TEXCOORD_0 + 2.0 * POSITION.z * (TEXCOORD_0 - vec2(0.5, 0.5));
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// __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
|
||||
#if __VERSION__ >= 300
|
||||
|
||||
// version 300 code
|
||||
|
||||
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
||||
#define _centroid centroid
|
||||
#else
|
||||
#define _centroid
|
||||
#endif
|
||||
|
||||
_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
|
||||
|
||||
uniform sampler2D TEXTURE_0;
|
||||
uniform vec4 DARKEN;
|
||||
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 diffuse = texture2D( TEXTURE_0, uv );
|
||||
|
||||
if(diffuse.a < 0.5)
|
||||
discard;
|
||||
|
||||
gl_FragColor = diffuse * color * DARKEN;
|
||||
}
|
||||
Loaded 100 of 4937 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user