mirror of
https://git.stillkill.net/MinecraftLeak/MinecraftLegends.git
synced 2026-10-24 06:02:18 +01:00
Initial commit
This commit is contained in:
commit
86efc669e9
5013 files changed
+237743
No files matched your search
@@ -0,0 +1,175 @@
|
||||
// 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)
|
||||
|
||||
#if (defined(USE_STEREO_TEXTURE_ARRAY) || defined(ARRAY_TEXTURE_0)) && (VERSION >= 0xa000)
|
||||
Texture2DArray TEXTURE_0 : register (t0);
|
||||
#else
|
||||
Texture2DMS<float4> TEXTURE_0_MS : register(t0);
|
||||
Texture2D TEXTURE_0 : register(t0);
|
||||
#endif
|
||||
|
||||
Texture2DMS<float4> TEXTURE_1_MS : register(t1);
|
||||
Texture2D TEXTURE_1 : register(t1);
|
||||
Texture2D TEXTURE_2 : register(t2);
|
||||
#ifndef NO_TEX_3
|
||||
Texture2D TEXTURE_3 : register(t3);
|
||||
sampler TextureSampler3 : register(s3);
|
||||
#endif
|
||||
|
||||
// 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
|
||||
|
||||
#if defined(MSAA_FRAMEBUFFER_ENABLED)
|
||||
#define TEXCOORD_0_FB_MSAA TEXCOORD_0_centroid
|
||||
#define TEXCOORD_1_FB_MSAA TEXCOORD_1_centroid
|
||||
#define TEXCOORD_2_FB_MSAA TEXCOORD_2_centroid
|
||||
#define TEXCOORD_3_FB_MSAA TEXCOORD_3_centroid
|
||||
#else
|
||||
#define TEXCOORD_0_FB_MSAA TEXCOORD_0
|
||||
#define TEXCOORD_1_FB_MSAA TEXCOORD_1
|
||||
#define TEXCOORD_2_FB_MSAA TEXCOORD_2
|
||||
#define TEXCOORD_3_FB_MSAA TEXCOORD_3
|
||||
#endif
|
||||
|
||||
|
||||
cbuffer RenderChunkConstants : register(b0)
|
||||
{
|
||||
float4 CHUNK_ORIGIN_AND_SCALE;
|
||||
float RENDER_CHUNK_FOG_ALPHA;
|
||||
}
|
||||
|
||||
|
||||
cbuffer EntityConstants
|
||||
{
|
||||
float4 OVERLAY_COLOR;
|
||||
float4 TILE_LIGHT_COLOR;
|
||||
float4 CHANGE_COLOR;
|
||||
float4 GLINT_COLOR;
|
||||
float4 TEAM_COLOR;
|
||||
float4 UV_ANIM;
|
||||
float2 UV_OFFSET;
|
||||
float2 UV_ROTATION;
|
||||
float2 GLINT_UV_SCALE;
|
||||
}
|
||||
|
||||
cbuffer PerFrameConstants : register(b2)
|
||||
{
|
||||
|
||||
float3 VIEW_POS;
|
||||
float TIME;
|
||||
|
||||
float4 FOG_COLOR;
|
||||
|
||||
float2 FOG_CONTROL;
|
||||
|
||||
float RENDER_DISTANCE;
|
||||
float FAR_CHUNKS_DISTANCE;
|
||||
}
|
||||
|
||||
|
||||
#if !defined(INSTANCEDSTEREO)
|
||||
|
||||
cbuffer WorldConstants : register(b1)
|
||||
{
|
||||
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 : register(b3)
|
||||
{
|
||||
float4 CURRENT_COLOR;
|
||||
float4 DARKEN;
|
||||
float3 TEXTURE_DIMENSIONS;
|
||||
float1 HUD_OPACITY;
|
||||
float4x4 UV_TRANSFORM;
|
||||
int MSAA_SAMPLECOUNT;
|
||||
}
|
||||
|
||||
cbuffer WeatherConstants
|
||||
{
|
||||
float4 POSITION_OFFSET;
|
||||
float4 VELOCITY;
|
||||
float4 ALPHA;
|
||||
float4 VIEW_POSITION;
|
||||
float4 SIZE_SCALE;
|
||||
float4 FORWARD;
|
||||
float4 UV_INFO;
|
||||
float4 PARTICLE_BOX;
|
||||
}
|
||||
|
||||
cbuffer FlipbookTextureConstants
|
||||
{
|
||||
float1 V_OFFSET;
|
||||
float1 V_BLEND_OFFSET;
|
||||
}
|
||||
|
||||
cbuffer EffectsConstants
|
||||
{
|
||||
float2 EFFECT_UV_OFFSET;
|
||||
}
|
||||
|
||||
cbuffer BannerConstants
|
||||
{
|
||||
float4 BANNER_COLORS[7];
|
||||
float4 BANNER_UV_OFFSETS[7];
|
||||
}
|
||||
|
||||
cbuffer TextConstants
|
||||
{
|
||||
float1 GLYPH_SMOOTH_RADIUS;
|
||||
float1 GLYPH_CUTOFF;
|
||||
float1 OUTLINE_CUTOFF;
|
||||
float4 OUTLINE_COLOR;
|
||||
float1 SHADOW_SMOOTH_RADIUS;
|
||||
float4 SHADOW_COLOR;
|
||||
float2 SHADOW_OFFSET;
|
||||
}
|
||||
cbuffer DebugConstants
|
||||
{
|
||||
float TEXTURE_ARRAY_INDEX_0;
|
||||
};
|
||||
|
||||
cbuffer InterFrameConstants
|
||||
{
|
||||
// in secs. This is reset every 2 mins. so the range is [0, 120)
|
||||
// make sure your shader handles the case when it transitions from 120 to 0
|
||||
float TOTAL_REAL_WORLD_TIME;
|
||||
float4x4 CUBE_MAP_ROTATION;
|
||||
};
|
||||
|
||||
cbuffer PostProcessConstants {
|
||||
int GaussianBlurSize;
|
||||
float DepthOfFieldNearEndDepth;
|
||||
float DepthOfFieldFarStartDepth;
|
||||
float DepthOfFieldFarEndDepth;
|
||||
};
|
||||
|
||||
cbuffer BadgerConstants {
|
||||
int NUM_STRUCTURES;
|
||||
float4 STRUCTURE_DATA[8];
|
||||
float4 STRUCTURE_COLOR[8];
|
||||
}
|
||||
@@ -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,27 @@
|
||||
|
||||
float3 getBadgerInfluenceOverlay(float3 worldPos, float3 diffuse)
|
||||
{
|
||||
float4 overlayColor = float4(0, 0, 0, 0);
|
||||
for (int i = 0; i < NUM_STRUCTURES; ++i)
|
||||
{
|
||||
float3 testPos = worldPos.xyz - float3(0.5, 0.5, 0.5);
|
||||
float3 dist = abs(testPos.xyz - STRUCTURE_DATA[i].xyz);
|
||||
float3 aoe = STRUCTURE_DATA[i].www + float3(0.5, 0.5, 0.5);
|
||||
float3 res = step(dist, aoe);
|
||||
float a = res.x * res.y * res.z;
|
||||
|
||||
const float kNumRings = 5.0;
|
||||
const float kAnimTime = mod(TIME, 2.0) / 2.0;
|
||||
|
||||
float ring = max(dist.x, max(dist.y, dist.z));
|
||||
ring = floor(ring - (kAnimTime * kNumRings));
|
||||
ring = frac(ring / kNumRings);
|
||||
a *= lerp(0.5, 1.0, abs(ring * 2.0 - 1.0));
|
||||
|
||||
overlayColor.rgb += STRUCTURE_COLOR[i].rgb * STRUCTURE_COLOR[i].a * a;
|
||||
}
|
||||
|
||||
diffuse.rgb = saturate(diffuse.rgb + overlayColor.rgb);
|
||||
|
||||
return diffuse;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "Util.fxh"
|
||||
|
||||
struct PS_Input {
|
||||
float4 position : SV_Position;
|
||||
#ifdef ENABLE_LIGHT
|
||||
float4 light : LIGHT;
|
||||
#endif
|
||||
#ifdef ENABLE_FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_TINTING
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
|
||||
float4 texCoords : TEXCOORD_0_FB_MSAA;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
float4 diffuse = TEXTURE_0.Sample(TextureSampler0, PSInput.texCoords.xy);
|
||||
float4 base = TEXTURE_0.Sample(TextureSampler0, PSInput.texCoords.zw);
|
||||
|
||||
#ifndef DISABLE_TINTING
|
||||
base.a = lerp(diffuse.r * diffuse.a, diffuse.a, PSInput.color.a);
|
||||
base.rgb *= PSInput.color.rgb;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_LIGHT
|
||||
base.rgb *= PSInput.light.rgb;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_FOG
|
||||
//apply fog
|
||||
base.rgb = lerp(base.rgb, PSInput.fogColor.rgb, PSInput.fogColor.a );
|
||||
#endif
|
||||
|
||||
//WARNING do not refactor this
|
||||
PSOutput.color = base;
|
||||
|
||||
#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,67 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput {
|
||||
float4 pos : SV_POSITION;
|
||||
#ifdef ENABLE_LIGHT
|
||||
float4 light : LIGHT;
|
||||
#endif
|
||||
#ifdef ENABLE_FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
#ifndef DISABLE_TINTING
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
float4 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;
|
||||
#ifdef ENABLE_LIGHT
|
||||
float4 light : LIGHT;
|
||||
#endif
|
||||
#ifdef ENABLE_FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
#ifndef DISABLE_TINTING
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
float4 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;
|
||||
output.uv = input[j].uv;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
#ifdef ENABLE_LIGHT
|
||||
output.light = input[j].light;
|
||||
#endif
|
||||
#ifdef ENABLE_FOG
|
||||
output.fogColor = input[j].fogColor;
|
||||
#endif
|
||||
#ifndef DISABLE_TINTING
|
||||
output.color = input[j].color;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input {
|
||||
float3 position : POSITION;
|
||||
float4 normal : NORMAL;
|
||||
float2 texCoords : TEXCOORD_0;
|
||||
float4 color : COLOR;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input {
|
||||
float4 position : SV_Position;
|
||||
|
||||
#ifdef ENABLE_LIGHT
|
||||
float4 light : LIGHT;
|
||||
#endif
|
||||
#ifdef ENABLE_FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_TINTING
|
||||
float4 color : COLOR;
|
||||
#endif
|
||||
float4 texCoords : TEXCOORD_0_FB_MSAA;
|
||||
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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
|
||||
}
|
||||
|
||||
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));
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = i;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = i;
|
||||
#endif
|
||||
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_LIGHT
|
||||
float4 normal = TransformRGBA8_SNORM(VSInput.normal);
|
||||
|
||||
float L = lightIntensity(float4(VSInput.position, 1), normal);
|
||||
|
||||
PSInput.light = float4(L.xxx * TILE_LIGHT_COLOR.rgb, 1.0);
|
||||
#endif
|
||||
|
||||
int frameIndex = int(VSInput.color.a * 255.0f);
|
||||
PSInput.texCoords.xy = VSInput.texCoords.xy + BANNER_UV_OFFSETS[frameIndex].xy;
|
||||
PSInput.texCoords.zw = VSInput.texCoords.xy;
|
||||
|
||||
#ifndef DISABLE_TINTING
|
||||
PSInput.color = BANNER_COLORS[frameIndex];
|
||||
PSInput.color.a = 1.0f;
|
||||
if (frameIndex > 0) {
|
||||
PSInput.color.a = 0.0f;
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
}
|
||||
|
||||
@@ -0,0 +1,369 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
#if defined(GAUSSIAN_H) || defined(GAUSSIAN_V)
|
||||
|
||||
//Optimized bilinear Gaussian Filters. The idea is to use to hardware bilinear filter to get "free" lerp between pixels.
|
||||
//Here we calculate the pixel offset such that we get the desire lerp amount between two pixels.
|
||||
//std=1.0
|
||||
#define GAUSSIAN_5_TAB_SUM 1.0
|
||||
#define G5TABS0 0.0625
|
||||
#define G5TABS1 0.25
|
||||
#define G5TABS_CENTER 0.375
|
||||
#define G5TABS_COUNT 1
|
||||
static const float G5Offsets[G5TABS_COUNT] = { (2.0*G5TABS0 + G5TABS1) / (G5TABS0 + G5TABS1) };
|
||||
static const float G5Weights[G5TABS_COUNT] = { G5TABS0 + G5TABS1 };
|
||||
|
||||
|
||||
//std=2.0
|
||||
#define GAUSSIAN_11_TAB_SUM 1.0
|
||||
#define G11TABS0 0.008580797401
|
||||
#define G11TABS1 0.02788759155
|
||||
#define G11TABS2 0.06693021973
|
||||
#define G11TABS3 0.1227054028
|
||||
#define G11TABS4 0.1752934326
|
||||
#define G11TABS_CENTER 0.1972051117
|
||||
#define G11TABS_COUNT 3
|
||||
static const float G11Offsets[G11TABS_COUNT] = { (5.0*G11TABS0 + 4.0*G11TABS1) / (G11TABS0 + G11TABS1), (3.0*G11TABS2 + 2.0*G11TABS3) / (G11TABS2 + G11TABS3), (G11TABS4) / (G11TABS4 + G11TABS_CENTER) };
|
||||
static const float G11Weights[G11TABS_COUNT] = { G11TABS0 + G11TABS1, G11TABS2 + G11TABS3, G11TABS4 + G11TABS_CENTER };
|
||||
|
||||
|
||||
//std=3.0
|
||||
#define GAUSSIAN_15_TAB_SUM 1.0
|
||||
#define G15TABS0 0.008843068404
|
||||
#define G15TABS1 0.01842305918
|
||||
#define G15TABS2 0.03401180156
|
||||
#define G15TABS3 0.05587653113
|
||||
#define G15TABS4 0.08195224565
|
||||
#define G15TABS5 0.1075623224
|
||||
#define G15TABS6 0.1265439087
|
||||
#define G15TABS_CENTER 0.1335741259
|
||||
#define G15TABS_COUNT 4
|
||||
static const float G15Offsets[G15TABS_COUNT] = { (7.0*G15TABS0 + 6.0*G15TABS1) / (G15TABS0 + G15TABS1), (5.0*G15TABS2 + 4.0*G15TABS3) / (G15TABS2 + G15TABS3), (3.0*G15TABS4 + 2.0*G15TABS5) / (G15TABS4 + G15TABS5), (G15TABS6) / (G15TABS6 + G15TABS_CENTER) };
|
||||
static const float G15Weights[G15TABS_COUNT] = { G15TABS0 + G15TABS1, G15TABS2 + G15TABS3, G15TABS4 + G15TABS5, G15TABS6 + G15TABS_CENTER };
|
||||
|
||||
|
||||
//std=4.0
|
||||
#define GAUSSIAN_21_TAB_SUM 1.0
|
||||
#define G21TABS0 0.00439142038
|
||||
#define G21TABS1 0.008019115477
|
||||
#define G21TABS2 0.01369932227
|
||||
#define G21TABS3 0.02191891564
|
||||
#define G21TABS4 0.03287837346
|
||||
#define G21TABS5 0.04627326635
|
||||
#define G21TABS6 0.06114681624
|
||||
#define G21TABS7 0.07590639258
|
||||
#define G21TABS8 0.08855745801
|
||||
#define G21TABS9 0.09712753459
|
||||
#define G21TABS_CENTER 0.10016277
|
||||
#define G21TABS_COUNT 5
|
||||
static const float G21Offsets[G21TABS_COUNT] = { (10.0*G21TABS0 + 9.0*G21TABS1) / (G21TABS0 + G21TABS1), (8.0*G21TABS2 + 7.0*G21TABS3) / (G21TABS2 + G21TABS3), (6.0*G21TABS4 + 5.0*G21TABS5) / (G21TABS4 + G21TABS5), (4.0*G21TABS6 + 3.0*G21TABS7) / (G21TABS6 + G21TABS7), (2.0*G21TABS8 + G21TABS9) / (G21TABS8 + G21TABS9) };
|
||||
static const float G21Weights[G21TABS_COUNT] = { G21TABS0 + G21TABS1, G21TABS2 + G21TABS3, G21TABS4 + G21TABS5, G21TABS6 + G21TABS7, G21TABS8 + G21TABS9 };
|
||||
|
||||
|
||||
//std=5.0
|
||||
#define GAUSSIAN_25_TAB_SUM 1.0
|
||||
#define G25TABS0 0.00452735756
|
||||
#define G25TABS1 0.007197337659
|
||||
#define G25TABS2 0.01097593993
|
||||
#define G25TABS3 0.01606235112
|
||||
#define G25TABS4 0.02256377895
|
||||
#define G25TABS5 0.03043486463
|
||||
#define G25TABS6 0.03942698373
|
||||
#define G25TABS7 0.04906469086
|
||||
#define G25TABS8 0.05866430429
|
||||
#define G25TABS9 0.0674015411
|
||||
#define G25TABS10 0.07442253496
|
||||
#define G25TABS11 0.0789790167
|
||||
#define G25TABS_CENTER 0.08055859703
|
||||
#define G25TABS_COUNT 6
|
||||
static const float G25Offsets[G25TABS_COUNT] = { (12.0*G25TABS0 + 11.0*G25TABS1) / (G25TABS0 + G25TABS1), (10.0*G25TABS2 + 9.0*G25TABS3) / (G25TABS2 + G25TABS3), (8.0*G25TABS4 + 7.0*G25TABS5) / (G25TABS4 + G25TABS5), (6.0*G25TABS6 + 5.0*G25TABS7) / (G25TABS6 + G25TABS7), (4.0*G25TABS8 + 3.0*G25TABS9) / (G25TABS8 + G25TABS9), (2.0*G25TABS10 + G25TABS11) / (G25TABS10 + G25TABS11) };
|
||||
static const float G25Weights[G25TABS_COUNT] = { G25TABS0 + G25TABS1, G25TABS2 + G25TABS3, G25TABS4 + G25TABS5, G25TABS6 + G25TABS7, G25TABS8 + G25TABS9, G25TABS10 + G25TABS11 };
|
||||
|
||||
|
||||
//std=6.0
|
||||
#define GAUSSIAN_29_TAB_SUM 1.0
|
||||
#define G29TABS0 0.004438649238
|
||||
#define G29TABS1 0.006469895499
|
||||
#define G29TABS2 0.00916568529
|
||||
#define G29TABS3 0.01262159942
|
||||
#define G29TABS4 0.01689665728
|
||||
#define G29TABS5 0.02199247456
|
||||
#define G29TABS6 0.02783422561
|
||||
#define G29TABS7 0.03425750845
|
||||
#define G29TABS8 0.0410051995
|
||||
#define G29TABS9 0.04773739644
|
||||
#define G29TABS10 0.05405558126
|
||||
#define G29TABS11 0.05953948081
|
||||
#define G29TABS12 0.06379230087
|
||||
#define G29TABS13 0.0664877502
|
||||
#define G29TABS_CENTER 0.06741119117
|
||||
#define G29TABS_COUNT 7
|
||||
static const float G29Offsets[G29TABS_COUNT] = { (14.0*G29TABS0 + 13.0*G29TABS1) / (G29TABS0 + G29TABS1), (12.0*G29TABS2 + 11.0*G29TABS3) / (G29TABS2 + G29TABS3), (10.0*G29TABS4 + 9.0*G29TABS5) / (G29TABS4 + G29TABS5), (8.0*G29TABS6 + 7.0*G29TABS7) / (G29TABS6 + G29TABS7), (6.0*G29TABS8 + 5.0*G29TABS9) / (G29TABS8 + G29TABS9), (4.0*G29TABS10 + 3.0*G29TABS11) / (G29TABS10 + G29TABS11), (2.0*G29TABS12 + G29TABS13) / (G29TABS12 + G29TABS13) };
|
||||
static const float G29Weights[G29TABS_COUNT] = { G29TABS0 + G29TABS1, G29TABS2 + G29TABS3, G29TABS4 + G29TABS5, G29TABS6 + G29TABS7, G29TABS8 + G29TABS9, G29TABS10 + G29TABS11, G29TABS12 + G29TABS13 };
|
||||
|
||||
|
||||
//std=7.0
|
||||
#define GAUSSIAN_33_TAB_SUM 1.0
|
||||
#define G33TABS0 0.004260871965
|
||||
#define G33TABS1 0.005852281976
|
||||
#define G33TABS2 0.007872712659
|
||||
#define G33TABS3 0.01037345668
|
||||
#define G33TABS4 0.01338899641
|
||||
#define G33TABS5 0.01692861615
|
||||
#define G33TABS6 0.02096839955
|
||||
#define G33TABS7 0.02544479946
|
||||
#define G33TABS8 0.03025103936
|
||||
#define G33TABS9 0.03523747441
|
||||
#define G33TABS10 0.04021668276
|
||||
#define G33TABS11 0.04497349469
|
||||
#define G33TABS12 0.04927946759
|
||||
#define G33TABS13 0.05291058625
|
||||
#define G33TABS14 0.05566634596
|
||||
#define G33TABS15 0.05738798552
|
||||
#define G33TABS_CENTER 0.05797357721
|
||||
#define G33TABS_COUNT 8
|
||||
static const float G33Offsets[G33TABS_COUNT] = { (16.0*G33TABS0 + 15.0*G33TABS1) / (G33TABS0 + G33TABS1), (14.0*G33TABS2 + 13.0*G33TABS3) / (G33TABS2 + G33TABS3), (12.0*G33TABS4 + 11.0*G33TABS5) / (G33TABS4 + G33TABS5), (10.0*G33TABS6 + 9.0*G33TABS7) / (G33TABS6 + G33TABS7), (8.0*G33TABS8 + 7.0*G33TABS9) / (G33TABS8 + G33TABS9), (6.0*G33TABS10 + 5.0*G33TABS11) / (G33TABS10 + G33TABS11), (4.0*G33TABS12 + 3.0*G33TABS13) / (G33TABS12 + G33TABS13), (2.0*G33TABS14 + G33TABS15) / (G33TABS14 + G33TABS15) };
|
||||
static const float G33Weights[G33TABS_COUNT] = { G33TABS0 + G33TABS1, G33TABS2 + G33TABS3, G33TABS4 + G33TABS5, G33TABS6 + G33TABS7, G33TABS8 + G33TABS9, G33TABS10 + G33TABS11, G33TABS12 + G33TABS13, G33TABS14 + G33TABS15 };
|
||||
|
||||
|
||||
//std=8.0
|
||||
#define GAUSSIAN_37_TAB_SUM 1.0
|
||||
#define G37TABS0 0.004053106611
|
||||
#define G37TABS1 0.0053311132
|
||||
#define G37TABS2 0.006901887625
|
||||
#define G37TABS3 0.008795325822
|
||||
#define G37TABS4 0.01103273327
|
||||
#define G37TABS5 0.01362302717
|
||||
#define G37TABS6 0.0165590244
|
||||
#define G37TABS7 0.01981421723
|
||||
#define G37TABS8 0.02334047623
|
||||
#define G37TABS9 0.02706710689
|
||||
#define G37TABS10 0.0309016137
|
||||
#define G37TABS11 0.03473239226
|
||||
#define G37TABS12 0.03843338487
|
||||
#define G37TABS13 0.04187051685
|
||||
#define G37TABS14 0.04490950598
|
||||
#define G37TABS15 0.04742443831
|
||||
#define G37TABS16 0.04930636047
|
||||
#define G37TABS17 0.05047107765
|
||||
#define G37TABS_CENTER 0.05086538294
|
||||
#define G37TABS_COUNT 9
|
||||
static const float G37Offsets[G37TABS_COUNT] = { (18.0*G37TABS0 + 17.0*G37TABS1) / (G37TABS0 + G37TABS1), (16.0*G37TABS2 + 15.0*G37TABS3) / (G37TABS2 + G37TABS3), (14.0*G37TABS4 + 13.0*G37TABS5) / (G37TABS4 + G37TABS5), (12.0*G37TABS6 + 11.0*G37TABS7) / (G37TABS6 + G37TABS7), (10.0*G37TABS8 + 9.0*G37TABS9) / (G37TABS8 + G37TABS9), (8.0*G37TABS10 + 7.0*G37TABS11) / (G37TABS10 + G37TABS11), (6.0*G37TABS12 + 5.0*G37TABS13) / (G37TABS12 + G37TABS13), (4.0*G37TABS14 + 3.0*G37TABS15) / (G37TABS14 + G37TABS15), (2.0*G37TABS16 + G37TABS17) / (G37TABS16 + G37TABS17) };
|
||||
static const float G37Weights[G37TABS_COUNT] = { G37TABS0 + G37TABS1, G37TABS2 + G37TABS3, G37TABS4 + G37TABS5, G37TABS6 + G37TABS7, G37TABS8 + G37TABS9, G37TABS10 + G37TABS11, G37TABS12 + G37TABS13, G37TABS14 + G37TABS15, G37TABS16 + G37TABS17 };
|
||||
|
||||
|
||||
//std=9.0
|
||||
#define GAUSSIAN_39_TAB_SUM 1.0
|
||||
#define G39TABS0 0.00492716991
|
||||
#define G39TABS1 0.006193178845
|
||||
#define G39TABS2 0.007688084084
|
||||
#define G39TABS3 0.009425801719
|
||||
#define G39TABS4 0.01141355582
|
||||
#define G39TABS5 0.01364999582
|
||||
#define G39TABS6 0.01612348499
|
||||
#define G39TABS7 0.01881073249
|
||||
#define G39TABS8 0.0216759434
|
||||
#define G39TABS9 0.0246706461
|
||||
#define G39TABS10 0.02773432111
|
||||
#define G39TABS11 0.03079590201
|
||||
#define G39TABS12 0.03377615059
|
||||
#define G39TABS13 0.03659082981
|
||||
#define G39TABS14 0.03915451852
|
||||
#define G39TABS15 0.0413848392
|
||||
#define G39TABS16 0.04320681325
|
||||
#define G39TABS17 0.04455702616
|
||||
#define G39TABS18 0.04538728131
|
||||
#define G39TABS_CENTER 0.04566744971
|
||||
#define G39TABS_COUNT 10
|
||||
static const float G39Offsets[G39TABS_COUNT] = { (19.0*G39TABS0 + 18.0*G39TABS1) / (G39TABS0 + G39TABS1), (17.0*G39TABS2 + 16.0*G39TABS3) / (G39TABS2 + G39TABS3), (15.0*G39TABS4 + 14.0*G39TABS5) / (G39TABS4 + G39TABS5), (13.0*G39TABS6 + 12.0*G39TABS7) / (G39TABS6 + G39TABS7), (11.0*G39TABS8 + 10.0*G39TABS9) / (G39TABS8 + G39TABS9), (9.0*G39TABS10 + 8.0*G39TABS11) / (G39TABS10 + G39TABS11), (7.0*G39TABS12 + 6.0*G39TABS13) / (G39TABS12 + G39TABS13), (5.0*G39TABS14 + 4.0*G39TABS15) / (G39TABS14 + G39TABS15), (3.0*G39TABS16 + 2.0*G39TABS17) / (G39TABS16 + G39TABS17), (G39TABS18) / (G39TABS18 + G39TABS_CENTER) };
|
||||
static const float G39Weights[G39TABS_COUNT] = { G39TABS0 + G39TABS1, G39TABS2 + G39TABS3, G39TABS4 + G39TABS5, G39TABS6 + G39TABS7, G39TABS8 + G39TABS9, G39TABS10 + G39TABS11, G39TABS12 + G39TABS13, G39TABS14 + G39TABS15, G39TABS16 + G39TABS17, G39TABS18 + G39TABS_CENTER };
|
||||
|
||||
|
||||
//std=10.0
|
||||
#define GAUSSIAN_43_TAB_SUM 1.0
|
||||
#define G43TABS0 0.004544882447
|
||||
#define G43TABS1 0.005580105671
|
||||
#define G43TABS2 0.006782448882
|
||||
#define G43TABS3 0.00816129838
|
||||
#define G43TABS4 0.009722202442
|
||||
#define G43TABS5 0.01146585831
|
||||
#define G43TABS6 0.0133871643
|
||||
#define G43TABS7 0.01547441035
|
||||
#define G43TABS8 0.0177086835
|
||||
#define G43TABS9 0.02006356163
|
||||
#define G43TABS10 0.02250515907
|
||||
#define G43TABS11 0.02499257139
|
||||
#define G43TABS12 0.02747874342
|
||||
#define G43TABS13 0.02991175716
|
||||
#define G43TABS14 0.03223650512
|
||||
#define G43TABS15 0.0343966833
|
||||
#define G43TABS16 0.03633700902
|
||||
#define G43TABS17 0.03800554515
|
||||
#define G43TABS18 0.039355996
|
||||
#define G43TABS19 0.04034983428
|
||||
#define G43TABS20 0.04095812324
|
||||
#define G43TABS_CENTER 0.04116291385
|
||||
#define G43TABS_COUNT 11
|
||||
static const float G43Offsets[G43TABS_COUNT] = { (21.0*G43TABS0 + 20.0*G43TABS1) / (G43TABS0 + G43TABS1), (19.0*G43TABS2 + 18.0*G43TABS3) / (G43TABS2 + G43TABS3), (17.0*G43TABS4 + 16.0*G43TABS5) / (G43TABS4 + G43TABS5), (15.0*G43TABS6 + 14.0*G43TABS7) / (G43TABS6 + G43TABS7), (13.0*G43TABS8 + 12.0*G43TABS9) / (G43TABS8 + G43TABS9), (11.0*G43TABS10 + 10.0*G43TABS11) / (G43TABS10 + G43TABS11), (9.0*G43TABS12 + 8.0*G43TABS13) / (G43TABS12 + G43TABS13), (7.0*G43TABS14 + 6.0*G43TABS15) / (G43TABS14 + G43TABS15), (5.0*G43TABS16 + 4.0*G43TABS17) / (G43TABS16 + G43TABS17), (3.0*G43TABS18 + 2.0*G43TABS19) / (G43TABS18 + G43TABS19), (G43TABS20) / (G43TABS20 + G43TABS_CENTER) };
|
||||
static const float G43Weights[G43TABS_COUNT] = { G43TABS0 + G43TABS1, G43TABS2 + G43TABS3, G43TABS4 + G43TABS5, G43TABS6 + G43TABS7, G43TABS8 + G43TABS9, G43TABS10 + G43TABS11, G43TABS12 + G43TABS13, G43TABS14 + G43TABS15, G43TABS16 + G43TABS17, G43TABS18 + G43TABS19, G43TABS20 + G43TABS_CENTER };
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
struct PS_Input {
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0_FB_MSAA;
|
||||
};
|
||||
|
||||
struct PS_Output {
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
|
||||
void main(in PS_Input PSInput, out PS_Output PSOutput) {
|
||||
|
||||
#if defined(GAUSSIAN_H) || defined(GAUSSIAN_V)
|
||||
|
||||
#ifdef GAUSSIAN_H
|
||||
float2 texOffset = float2(1.0f, 0.0f) / TEXTURE_DIMENSIONS.xy;
|
||||
#else //GAUSSIAN_V
|
||||
float2 texOffset = float2(0.0f, 1.0f) / TEXTURE_DIMENSIONS.xy;
|
||||
#endif
|
||||
|
||||
if (GaussianBlurSize == 1) { //Total 3 texture samples per fragment
|
||||
//Start with the center Guassian number
|
||||
float4 color = G5TABS_CENTER * TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
//Add the other ones
|
||||
[unroll(G5TABS_COUNT)]
|
||||
for (int i = 0; i < G5TABS_COUNT; ++i) {
|
||||
color += G5Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv - texOffset * G5Offsets[i]);
|
||||
color += G5Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv + texOffset * G5Offsets[i]);
|
||||
}
|
||||
//No need to divide by total weight as gaussianFilter adds up to 1.0
|
||||
PSOutput.color = color;
|
||||
}
|
||||
else if (GaussianBlurSize == 2) { //Total 7 texture samples per fragment
|
||||
//Start with the center Guassian number. This is negative because we are including the center as
|
||||
//the bilinear calculation below. It will be double counted if we don't first offset it by negative amount
|
||||
float4 color = -(G11TABS_CENTER * TEXTURE_0.Sample(TextureSampler0, PSInput.uv));
|
||||
//Add the other ones
|
||||
[unroll(G11TABS_COUNT)]
|
||||
for (int i = 0; i < G11TABS_COUNT; ++i) {
|
||||
color += G11Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv - texOffset * G11Offsets[i]);
|
||||
color += G11Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv + texOffset * G11Offsets[i]);
|
||||
}
|
||||
//No need to divide by total weight as gaussianFilter adds up to 1.0
|
||||
PSOutput.color = color;
|
||||
}
|
||||
else if (GaussianBlurSize == 3) { //Total 9 texture samples per fragment
|
||||
//Start with the center Guassian number. This is negative because we are including the center as
|
||||
//the bilinear calculation below. It will be double counted if we don't first offset it by negative amount
|
||||
float4 color = -(G15TABS_CENTER * TEXTURE_0.Sample(TextureSampler0, PSInput.uv));
|
||||
//Add the other ones
|
||||
[unroll(G15TABS_COUNT)]
|
||||
for (int i = 0; i < G15TABS_COUNT; ++i) {
|
||||
color += G15Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv - texOffset * G15Offsets[i]);
|
||||
color += G15Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv + texOffset * G15Offsets[i]);
|
||||
}
|
||||
//No need to divide by total weight as gaussianFilter adds up to 1.0
|
||||
PSOutput.color = color;
|
||||
}
|
||||
else if (GaussianBlurSize == 4) { //Total 11 texture samples per fragment
|
||||
//Start with the center Guassian number.
|
||||
float4 color = G21TABS_CENTER * TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
//Add the other ones
|
||||
[unroll(G21TABS_COUNT)]
|
||||
for (int i = 0; i < G21TABS_COUNT; ++i) {
|
||||
color += G21Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv - texOffset * G21Offsets[i]);
|
||||
color += G21Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv + texOffset * G21Offsets[i]);
|
||||
}
|
||||
//No need to divide by total weight as gaussianFilter adds up to 1.0
|
||||
PSOutput.color = color;
|
||||
}
|
||||
else if (GaussianBlurSize == 5) { //Total 13 texture samples per fragment
|
||||
//Start with the center Guassian number
|
||||
float4 color = G25TABS_CENTER * TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
//Add the other ones
|
||||
[unroll(G25TABS_COUNT)]
|
||||
for (int i = 0; i < G25TABS_COUNT; ++i) {
|
||||
color += G25Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv - texOffset * G25Offsets[i]);
|
||||
color += G25Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv + texOffset * G25Offsets[i]);
|
||||
}
|
||||
//No need to divide by total weight as gaussianFilter adds up to 1.0
|
||||
PSOutput.color = color;
|
||||
}
|
||||
else if (GaussianBlurSize == 6) { //Total 15 texture samples per fragment
|
||||
// Start with the center Guassian number
|
||||
float4 color = G29TABS_CENTER * TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
//Add the other ones
|
||||
[unroll(G29TABS_COUNT)]
|
||||
for (int i = 0; i < G29TABS_COUNT; ++i) {
|
||||
color += G29Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv - texOffset * G29Offsets[i]);
|
||||
color += G29Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv + texOffset * G29Offsets[i]);
|
||||
}
|
||||
//No need to divide by total weight as gaussianFilter adds up to 1.0
|
||||
PSOutput.color = color;
|
||||
}
|
||||
else if (GaussianBlurSize == 7) { //Total 17 texture samples per fragment
|
||||
//Start with the center Guassian number. This is negative because we are including the center as
|
||||
float4 color = G33TABS_CENTER * TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
//Add the other ones
|
||||
[unroll(G33TABS_COUNT)]
|
||||
for (int i = 0; i < G33TABS_COUNT; ++i) {
|
||||
color += G33Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv - texOffset * G33Offsets[i]);
|
||||
color += G33Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv + texOffset * G33Offsets[i]);
|
||||
}
|
||||
//No need to divide by total weight as gaussianFilter adds up to 1.0
|
||||
PSOutput.color = color;
|
||||
}
|
||||
else if (GaussianBlurSize == 8) { //Total 19 texture samples per fragment
|
||||
//Start with the center Guassian number. This is negative because we are including the center as
|
||||
float4 color = G37TABS_CENTER * TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
//Add the other ones
|
||||
[unroll(G37TABS_COUNT)]
|
||||
for (int i = 0; i < G37TABS_COUNT; ++i) {
|
||||
color += G37Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv - texOffset * G37Offsets[i]);
|
||||
color += G37Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv + texOffset * G37Offsets[i]);
|
||||
}
|
||||
//No need to divide by total weight as gaussianFilter adds up to 1.0
|
||||
PSOutput.color = color;
|
||||
}
|
||||
else if (GaussianBlurSize == 9) { //Total 21 texture samples per fragment
|
||||
//Start with the center Guassian number. This is negative because we are including the center as
|
||||
//the bilinear calculation below. It will be double counted if we don't first offset it by negative amount
|
||||
float4 color = -(G39TABS_CENTER * TEXTURE_0.Sample(TextureSampler0, PSInput.uv));
|
||||
//Add the other ones
|
||||
[unroll(G39TABS_COUNT)]
|
||||
for (int i = 0; i < G39TABS_COUNT; ++i) {
|
||||
color += G39Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv - texOffset * G39Offsets[i]);
|
||||
color += G39Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv + texOffset * G39Offsets[i]);
|
||||
}
|
||||
//No need to divide by total weight as gaussianFilter adds up to 1.0
|
||||
PSOutput.color = color;
|
||||
}
|
||||
else if (GaussianBlurSize == 10) { //Total 23 texture samples per fragment
|
||||
//Start with the center Guassian number. This is negative because we are including the center as
|
||||
//the bilinear calculation below. It will be double counted if we don't first offset it by negative amount
|
||||
float4 color = -(G43TABS_CENTER * TEXTURE_0.Sample(TextureSampler0, PSInput.uv));
|
||||
//Add the other ones
|
||||
[unroll(G43TABS_COUNT)]
|
||||
for (int i = 0; i < G43TABS_COUNT; ++i) {
|
||||
color += G43Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv - texOffset * G43Offsets[i]);
|
||||
color += G43Weights[i] * TEXTURE_0.Sample(TextureSampler0, PSInput.uv + texOffset * G43Offsets[i]);
|
||||
}
|
||||
//No need to divide by total weight as gaussianFilter adds up to 1.0
|
||||
PSOutput.color = color;
|
||||
}
|
||||
//This should never happen ...
|
||||
else {
|
||||
PSOutput.color = float4(1.0, 0.0, 0.0, 1.0); //Red to indicate it's wrong
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//default to not blur anything
|
||||
PSOutput.color = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
|
||||
#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,54 @@
|
||||
#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 GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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 ) );
|
||||
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
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#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,41 @@
|
||||
#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 GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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 ) );
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#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,47 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "util.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float4 color : COLOR;
|
||||
float4 weights : WEIGHTS;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
PSInput.color = VSInput.color;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
#endif
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
PSInput.position = mul(WORLDVIEWPROJ_STEREO[i], float4(VSInput.position.xyz, 1));
|
||||
PSInput.position.xy += computeScreenOffsets(VSInput.position.xyz, VSInput.weights, WORLDVIEWPROJ_STEREO[i][i]);
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position.xyz, 1));
|
||||
PSInput.position.xy += computeScreenOffsets(VSInput.position.xyz, VSInput.weights, WORLDVIEWPROJ);
|
||||
#endif
|
||||
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = i;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = i;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
#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 )
|
||||
{
|
||||
#ifdef EFFECTS_OFFSET
|
||||
float4 diffuse = TEXTURE_0.Sample(TextureSampler0, PSInput.uv + EFFECT_UV_OFFSET);
|
||||
#else
|
||||
float4 diffuse = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
#endif
|
||||
|
||||
#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; // This line is needed for horse armour icon and dyed leather to work properly
|
||||
}
|
||||
#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
|
||||
|
||||
#ifdef ENABLE_CURRENT_ALPHA_MULTIPLY
|
||||
PSOutput.color = diffuse * float4(1.0, 1.0, 1.0, HUD_OPACITY);
|
||||
#else
|
||||
PSOutput.color = diffuse;
|
||||
#endif
|
||||
|
||||
#else
|
||||
PSOutput.color = diffuse * PSInput.color;
|
||||
#endif
|
||||
|
||||
#ifdef VR_MODE
|
||||
// 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 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 GLINT
|
||||
output.layer1UV = input[j].layer1UV;
|
||||
output.layer2UV = input[j].layer2UV;
|
||||
#endif
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
#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 GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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 ) );
|
||||
#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 USE_LIGHTING
|
||||
PSInput.color *= float4(TILE_LIGHT_COLOR.rgb, 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
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#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,43 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0_FB_MSAA;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main(in PS_Input PSInput, out PS_Output PSOutput)
|
||||
{
|
||||
PSOutput.color = float4(0.0, 0.0, 0.0, 1.0); //If we don't initialize this, compiler complaints :(
|
||||
#if (VERSION >= 0xa100 /*D3D_FEATURE_LEVEL_10_1*/)
|
||||
|
||||
float4 samples = TEXTURE_0.Gather(TextureSampler0, PSInput.uv);
|
||||
PSOutput.color.r = min(min(samples.x, samples.y), min(samples.z, samples.w));
|
||||
|
||||
// Don't reflect things that are too close to the player. IE ignore all low depth values ( the player's hands model for example ). We do this by pushing them to the far plane in the HiZ down sampling.
|
||||
// If color.r is smaller than 0.1, force it to be 1.0
|
||||
const float NEAR_TOLERANCE = 0.1;
|
||||
PSOutput.color.r = lerp(1.0, PSOutput.color.r, sign(saturate(PSOutput.color.r - NEAR_TOLERANCE)));
|
||||
|
||||
#else
|
||||
|
||||
//Also works, but slower than using the gather command. Can be used for backward compatibility with older shaders. NOTE: GLSL also has a gather equivalent.
|
||||
|
||||
// Take minimum values.
|
||||
float x_off = 0.5 / TEXTURE_DIMENSIONS.x;
|
||||
float y_off = 0.5 / TEXTURE_DIMENSIONS.y;
|
||||
|
||||
float2 uv = PSInput.uv;
|
||||
float depth0 = TEXTURE_0.Sample(TextureSampler0, uv + float2(-x_off, -y_off)).r;
|
||||
float depth1 = TEXTURE_0.Sample(TextureSampler0, uv + float2(x_off, -y_off)).r;
|
||||
float depth2 = TEXTURE_0.Sample(TextureSampler0, uv + float2(-x_off, y_off)).r;
|
||||
float depth3 = TEXTURE_0.Sample(TextureSampler0, uv + float2(x_off, y_off)).r;
|
||||
PSOutput.color.r = min(min(depth0, depth1), min(depth2, depth3));
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "util.fxh"
|
||||
|
||||
#define FAR_PLANE_DEPTH 1.0f
|
||||
#define GAUSSIAN_DOF
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0_FB_MSAA;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main(in PS_Input PSInput, out PS_Output PSOutput)
|
||||
{
|
||||
#ifdef GAUSSIAN_DOF
|
||||
|
||||
const float centerDepth = MakeDepthLinear(TEXTURE_1.Sample(TextureSampler1, float2(0.5f, 0.5f)).r, 0.025f, FAR_CHUNKS_DISTANCE, false);
|
||||
const float depth = MakeDepthLinear(TEXTURE_1.Sample(TextureSampler1, PSInput.uv).r, 0.025f, FAR_CHUNKS_DISTANCE, false);
|
||||
float4 color = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
|
||||
if ((centerDepth > DepthOfFieldNearEndDepth || depth >= DepthOfFieldFarStartDepth) && depth > 0.01f) {
|
||||
|
||||
const float nearBlurPlaneEnd = clamp(DepthOfFieldNearEndDepth, 0, DepthOfFieldFarStartDepth); //Can only go up to where the far plane starts
|
||||
const float farPlaneStart = clamp(DepthOfFieldFarStartDepth, DepthOfFieldNearEndDepth, DepthOfFieldFarEndDepth);
|
||||
const float farPlaneEnd = clamp(DepthOfFieldFarEndDepth, DepthOfFieldFarStartDepth, FAR_PLANE_DEPTH);
|
||||
float4 baseColor = float4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
float4 blurColor = float4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
if (depth >= farPlaneEnd) { //We are beyound max blur ... so always pick the blurry one
|
||||
color = TEXTURE_3.Sample(TextureSampler3, PSInput.uv); //Far blur
|
||||
//color = float4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
else if (depth < nearBlurPlaneEnd) {
|
||||
float lerpRatio = depth / nearBlurPlaneEnd;
|
||||
blurColor = TEXTURE_2.Sample(TextureSampler2, PSInput.uv); //Near blur
|
||||
baseColor = TEXTURE_0.Sample(TextureSampler0, PSInput.uv); //Clear color
|
||||
//blurColor = float4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
//baseColor = float4(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
color = lerp(blurColor, baseColor, lerpRatio);
|
||||
}
|
||||
else if (depth > farPlaneStart) {
|
||||
float lerpRatio = (depth - farPlaneStart) / (farPlaneEnd - farPlaneStart);
|
||||
blurColor = TEXTURE_3.Sample(TextureSampler3, PSInput.uv); //Far blur
|
||||
baseColor = TEXTURE_0.Sample(TextureSampler0, PSInput.uv); //Clear color
|
||||
//blurColor = float4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
//baseColor = float4(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
color = lerp(baseColor, blurColor, lerpRatio);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PSOutput.color = color;
|
||||
|
||||
#else
|
||||
|
||||
//Default to no depth of field
|
||||
PSOutput.color = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "util.fxh"
|
||||
|
||||
struct PS_Input {
|
||||
float4 position : SV_Position;
|
||||
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
snorm float2 colorLookupUV : TEXCOORD_0_FB_MSAA;
|
||||
float2 parallaxUV : TEXCOORD_1_FB_MSAA;
|
||||
float4 encodedPlane : PLANE_INFO;
|
||||
#ifdef FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct PS_Output {
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
static const float MAX_LAYER_DEPTH = 32.0;
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput ) {
|
||||
#ifdef BYPASS_PIXEL_SHADER
|
||||
PSOutput.color = float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
#else
|
||||
///// Decode Input Values
|
||||
// Decode parallax plane data
|
||||
// Using round() because normals should all be in the standard basis
|
||||
const float planeDistance = PSInput.encodedPlane.a * MAX_LAYER_DEPTH;
|
||||
|
||||
///// Color Assembly
|
||||
float4 colorSample = TEXTURE_1.Sample(TextureSampler1, PSInput.colorLookupUV);
|
||||
float4 textureSample = TEXTURE_0.Sample(TextureSampler0, PSInput.parallaxUV);
|
||||
const float3 brightness = textureSample.rgb * (1.0 - PSInput.encodedPlane.w);
|
||||
colorSample.rgb *= brightness;
|
||||
|
||||
// Look for hard-coded value to clear the portal first
|
||||
#ifdef FOG
|
||||
if(planeDistance > MAX_LAYER_DEPTH - 1.0) {
|
||||
PSOutput.color = float4(PSInput.fogColor.rgb * PSInput.fogColor.a, 0.0f);
|
||||
}
|
||||
else {
|
||||
PSOutput.color = float4(colorSample.rgb * (1.0 - PSInput.fogColor.a), 1.0f);
|
||||
}
|
||||
#else
|
||||
if(planeDistance > MAX_LAYER_DEPTH - 1.0) {
|
||||
PSOutput.color = float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
else {
|
||||
PSOutput.color = float4(colorSample.rgb, 1);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
snorm float2 colorLookupUV : TEXCOORD_0_FB_MSAA;
|
||||
float2 parallaxUV : TEXCOORD_1_FB_MSAA;
|
||||
float4 encodedPlane : PLANE_INFO;
|
||||
#ifdef FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Per-pixel color data passed through the pixel shader.
|
||||
struct GeometryShaderOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
snorm float2 colorLookupUV : TEXCOORD_0;
|
||||
float2 parallaxUV : TEXCOORD_1_FB_MSAA;
|
||||
float4 encodedPlane : PLANE_INFO;
|
||||
#ifdef FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
#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;
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
output.colorLookupUV = input[j].colorLookupUV;
|
||||
output.parallaxUV = input[j].parallaxUV;
|
||||
output.encodedPlane = input[j].encodedPlane;
|
||||
#ifdef FOG
|
||||
output.fogColor = input[j].fogColor;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
output.renTarget_id = i;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
#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;
|
||||
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
snorm float2 colorLookupUV : TEXCOORD_0_FB_MSAA;
|
||||
float2 parallaxUV : TEXCOORD_1_FB_MSAA;
|
||||
float4 encodedPlane : PLANE_INFO;
|
||||
|
||||
// lpfloat4 color : COLOR;
|
||||
|
||||
// float3 eyePositionInWorld : EYE_POS;
|
||||
// float3 surfacePositionInWorld : SURFACE_POS;
|
||||
|
||||
#ifdef FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
static const float DIST_DESATURATION = 56.0 / 255.0; //WARNING this value is also hardcoded in the water color, don'tchange
|
||||
|
||||
static const float MAX_LAYER_DEPTH = 32.0;
|
||||
|
||||
void main(in VS_Input VSInput, out PS_Input PSInput) {
|
||||
///// Vertex Transformation
|
||||
float3 worldPos = (VSInput.position.xyz * CHUNK_ORIGIN_AND_SCALE.w) + CHUNK_ORIGIN_AND_SCALE.xyz;
|
||||
float3 viewRay = worldPos.xyz;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
|
||||
PSInput.position = mul(WORLDVIEW_STEREO[i], float4(worldPos, 1 ));
|
||||
PSInput.position = mul(PROJ_STEREO[i], PSInput.position);
|
||||
|
||||
viewRay -= WORLDVIEW_STEREO[i]._m30_m31_m32;
|
||||
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEW, float4( worldPos, 1 ));
|
||||
PSInput.position = mul(PROJ, PSInput.position);
|
||||
#endif
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#endif
|
||||
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
PSInput.encodedPlane = VSInput.color;
|
||||
PSInput.colorLookupUV = VSInput.uv0;
|
||||
|
||||
///// Decode Input Values
|
||||
// Decode parallax plane data
|
||||
const float4 planeData = (PSInput.encodedPlane - float4(0.5, 0.5, 0.5, 0.0)) * float4(2.0, 2.0, 2.0, MAX_LAYER_DEPTH);
|
||||
const float3 planeNormal = planeData.rgb;
|
||||
const float planeDistance = planeData.a;
|
||||
|
||||
|
||||
///// Ray-cast for parallax-offset UV
|
||||
// Perform ray-plane intersection to find the position on the parallax plane
|
||||
float t = dot(viewRay - (planeNormal * planeDistance), planeNormal) / dot(viewRay, planeNormal);
|
||||
float3 parallaxPositionInWorld = (t * viewRay) + VIEW_POS;
|
||||
|
||||
///// Ridiculous UV-remapping
|
||||
const float3 normalMask = abs(planeNormal);
|
||||
// Since all normals are orthonormal on <x,y,z>, mask out the correct uv result
|
||||
float2 raycastUV = parallaxPositionInWorld.yz * normalMask[0];
|
||||
raycastUV += parallaxPositionInWorld.xz * normalMask[1];
|
||||
raycastUV += parallaxPositionInWorld.xy * normalMask[2];
|
||||
// Scale the UVs to Minecraft pixel size
|
||||
raycastUV = raycastUV / 16.0;
|
||||
|
||||
///// Color Lookup
|
||||
const float rotor = 3.1415926535897 * (5.0 / 7.0);
|
||||
float rotS = sin(planeDistance * rotor);
|
||||
float rotC = cos(planeDistance * rotor);
|
||||
|
||||
PSInput.parallaxUV = mul(float2x2(float2(rotC, rotS), float2(-rotS, rotC)), raycastUV);
|
||||
|
||||
///// UV Scrolling
|
||||
// Offset rotation based on a value unique to the layer
|
||||
PSInput.parallaxUV += float2(rotC, rotS) * planeDistance;
|
||||
PSInput.parallaxUV.y += TIME / 256.0;
|
||||
|
||||
const float modVal = 64.0;
|
||||
PSInput.parallaxUV = fmod(PSInput.parallaxUV, modVal);
|
||||
|
||||
///// Fog
|
||||
#ifdef FOG
|
||||
#ifdef FANCY
|
||||
float3 relPos = -worldPos;
|
||||
float cameraDepth = length(relPos);
|
||||
#else
|
||||
float cameraDepth = PSInput.position.z;
|
||||
#endif
|
||||
float len = cameraDepth / RENDER_DISTANCE;
|
||||
#ifdef ALLOW_FADE
|
||||
len += RENDER_CHUNK_FOG_ALPHA.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
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
#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
|
||||
|
||||
float4 teamColor : TEAM_COLOR;
|
||||
|
||||
#ifdef TINTED_ALPHA_TEST
|
||||
float4 alphaTestMultiplier : ALPHA_MULTIPLIER;
|
||||
#endif
|
||||
|
||||
float2 uv : TEXCOORD_0_FB_MSAA;
|
||||
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
#ifdef USE_EMISSIVE
|
||||
#ifdef USE_ONLY_EMISSIVE
|
||||
#define NEEDS_DISCARD(C) (C.a == 0.0f ||C.a == 1.0f )
|
||||
#else
|
||||
#define NEEDS_DISCARD(C) (C.a + C.r + C.g + C.b == 0.0)
|
||||
#endif
|
||||
#else
|
||||
#ifndef USE_COLOR_MASK
|
||||
#define NEEDS_DISCARD(C) (C.a < 0.5)
|
||||
#else
|
||||
#define NEEDS_DISCARD(C) (C.a == 0.0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
float3 blendTeamColor(float3 base, float3 blend, float alpha, float4 mask)
|
||||
{
|
||||
float3 clr = base;
|
||||
|
||||
// mask textures should have an alpha of 1, the _nomask texture has an alpha of 0
|
||||
if (mask.a < 0.5f)
|
||||
{
|
||||
clr += blend * alpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
clr = lerp(clr, base * blend, mask.r); // mask.r = multiply
|
||||
clr = clr + (blend * mask.g); // mark.g = additive
|
||||
clr = lerp(clr, blend, mask.b); // mask.b = linear blend
|
||||
}
|
||||
|
||||
return clr;
|
||||
}
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
float4 color = float4( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
float4 teamMask = float4(0.f, 0.f, 0.f, 0.f);
|
||||
|
||||
#if( !defined(NO_TEXTURE) || !defined(COLOR_BASED) || defined(USE_COLOR_BLEND) )
|
||||
|
||||
#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
|
||||
|
||||
teamMask = TEXTURE_3.Sample(TextureSampler0, PSInput.uv);
|
||||
|
||||
#if defined(ALPHA_TEST) && !defined(USE_MULTITEXTURE)
|
||||
if( NEEDS_DISCARD( color ) )
|
||||
{
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TINTED_ALPHA_TEST
|
||||
float4 testColor = color;
|
||||
testColor.a = testColor.a * PSInput.alphaTestMultiplier.r;
|
||||
if( NEEDS_DISCARD( testColor ) )
|
||||
{
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef USE_COLOR_MASK
|
||||
color.rgb = lerp( color, color * CHANGE_COLOR, color.a ).rgb;
|
||||
color.a *= CHANGE_COLOR.a;
|
||||
#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 ALPHA_TEST
|
||||
if (color.a < 0.5f && tex1.a == 0.0f) {
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
color.rgb = blendTeamColor(color.rgb, PSInput.teamColor.rgb, PSInput.teamColor.a, teamMask);
|
||||
|
||||
#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_MODE
|
||||
// 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,88 @@
|
||||
#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
|
||||
|
||||
float4 teamColor : TEAM_COLOR;
|
||||
|
||||
#ifdef TINTED_ALPHA_TEST
|
||||
float4 alphaTestMultiplier : ALPHA_MULTIPLIER;
|
||||
#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
|
||||
|
||||
float4 teamColor : TEAM_COLOR;
|
||||
|
||||
#ifdef TINTED_ALPHA_TEST
|
||||
float4 alphaTestMultiplier : ALPHA_MULTIPLIER;
|
||||
#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
|
||||
output.teamColor = input[j].teamColor;
|
||||
#ifdef TINTED_ALPHA_TEST
|
||||
output.alphaTestMultiplier = input[j].alphaTestMultiplier;
|
||||
#endif
|
||||
#ifdef GLINT
|
||||
output.layerUV = input[j].layerUV;
|
||||
#endif
|
||||
outStream.Append(output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
#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
|
||||
|
||||
//#ifdef USE_TEAMCOLOR
|
||||
float4 teamColor : TEAM_COLOR;
|
||||
//#endif
|
||||
|
||||
#ifdef TINTED_ALPHA_TEST
|
||||
// With MSAA Enabled, making this field a float results in a DX11 internal compiler error
|
||||
// We assume it is trying to pack the single float with the centroid-interpolated UV coordinates, which it can't do
|
||||
float4 alphaTestMultiplier : ALPHA_MULTIPLIER;
|
||||
#endif
|
||||
|
||||
float2 uv : TEXCOORD_0_FB_MSAA;
|
||||
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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 teamColorIntensity(const float3 pos, const float3 normal)
|
||||
{
|
||||
return saturate(pos.y / 16.f);
|
||||
}
|
||||
|
||||
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));
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#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
|
||||
|
||||
float intensity = teamColorIntensity(VSInput.position, normal);
|
||||
PSInput.teamColor = float4(TEAM_COLOR.rgb, intensity);
|
||||
|
||||
#ifdef TINTED_ALPHA_TEST
|
||||
PSInput.alphaTestMultiplier = OVERLAY_COLOR.aaaa;
|
||||
#endif
|
||||
|
||||
PSInput.light = float4(L.xxx * TILE_LIGHT_COLOR.rgb, 1.0);
|
||||
|
||||
#ifdef COLOR_BASED
|
||||
PSInput.light *= VSInput.color;
|
||||
#endif
|
||||
|
||||
#if( !defined(NO_TEXTURE) || !defined(COLOR_BASED) || defined(USE_COLOR_BLEND) )
|
||||
PSInput.uv = VSInput.texCoords;
|
||||
#endif
|
||||
|
||||
#ifdef USE_UV_ANIM
|
||||
PSInput.uv.xy = UV_ANIM.xy + (PSInput.uv.xy * UV_ANIM.zw);
|
||||
#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,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,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,23 @@
|
||||
#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 )
|
||||
{
|
||||
// when copying the levelstage texture for the rift overlay, we need to ensure alpha is 1, and
|
||||
// convert from linear space to SRGB
|
||||
|
||||
PSOutput.color = TEXTURE_0.Sample( TextureSampler0, PSInput.uv );
|
||||
PSOutput.color.a = 1.0;
|
||||
PSOutput.color = pow(PSOutput.color, 2.2); // conversion to srgb
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#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 GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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 ) );
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#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,38 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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 ) );
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#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 )
|
||||
{
|
||||
float a = abs(PSInput.uv.x);
|
||||
float4 clr = PSInput.color;
|
||||
clr.a *= 1.f - a;
|
||||
PSOutput.color = clr;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "util.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float4 color : COLOR;
|
||||
float4 weights : WEIGHTS;
|
||||
float2 texCoords : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD_0;
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
PSInput.color = VSInput.color;
|
||||
PSInput.uv = float2(VSInput.texCoords.x * 2.f - 1.f, 0.f);
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
#endif
|
||||
|
||||
float3 pos = VSInput.position.xyz;
|
||||
float3 up = normalize(VSInput.weights.xyz);
|
||||
float dir = VSInput.weights.w;
|
||||
|
||||
pos += up * dir;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
PSInput.position = mul(WORLDVIEWPROJ_STEREO[i], float4(pos.xyz, 1));
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(pos.xyz, 1));
|
||||
#endif
|
||||
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = i;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = i;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#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);
|
||||
|
||||
#ifndef FLIP_OCCLUSION
|
||||
#define OCCLUSION_OPERATOR <
|
||||
#else
|
||||
#define OCCLUSION_OPERATOR >
|
||||
#endif
|
||||
|
||||
#ifdef SNOW
|
||||
#define OCCLUSION_HEIGHT occlusionTexture.g
|
||||
#define OCCLUSION_LUMINANCE occlusionTexture.r
|
||||
#else
|
||||
#define OCCLUSION_HEIGHT occlusionTexture.a
|
||||
#define OCCLUSION_LUMINANCE occlusionTexture.b
|
||||
#endif
|
||||
|
||||
// clamp the uvs
|
||||
if (uv.x >= 0.0f && uv.x <= 1.0f &&
|
||||
uv.y >= 0.0f && uv.y <= 1.0f &&
|
||||
PSInput.worldPosition.y OCCLUSION_OPERATOR OCCLUSION_HEIGHT) {
|
||||
PSOutput.color.a = 0.0f;
|
||||
}
|
||||
|
||||
float mixAmount = (PSInput.worldPosition.y - OCCLUSION_HEIGHT)*25.0f;
|
||||
float2 lightingUVs = float2(OCCLUSION_LUMINANCE, 1.0f);
|
||||
lightingUVs.x = lerp(lightingUVs.x, 0.0f, mixAmount);
|
||||
|
||||
float3 lighting = TEXTURE_2.Sample(TextureSampler2, lightingUVs);
|
||||
PSOutput.color.rgb *= lighting.rgb;
|
||||
|
||||
//apply fog
|
||||
PSOutput.color.rgb = lerp(PSOutput.color.rgb, PSInput.fogColor.rgb, PSInput.fogColor.a);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#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
|
||||
};
|
||||
|
||||
// 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.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,97 @@
|
||||
#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 GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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);
|
||||
#ifndef NO_VARIETY
|
||||
PSInput.uv.x += spriteSelector * UV_INFO.z;
|
||||
#endif
|
||||
|
||||
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);
|
||||
#else
|
||||
float4 bottom = mul(WORLDVIEWPROJ, worldPositionBottom);
|
||||
float4 top = mul(WORLDVIEWPROJ, worldPositionTop);
|
||||
#endif
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#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;
|
||||
|
||||
#if defined(COMFORT_MODE) && defined(VR_MODE)
|
||||
if (PSInput.position.z < 2.0f) {
|
||||
PSInput.color.a = clamp((PSInput.position.z - 1.2f)/0.8f, 0.0f, 1.0f);
|
||||
}
|
||||
#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);
|
||||
|
||||
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,99 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "util.fxh"
|
||||
#include "badger_util.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float3 worldPos : WORLD_POS;
|
||||
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
lpfloat4 color : COLOR;
|
||||
snorm float2 uv0 : TEXCOORD_0_FB_MSAA;
|
||||
snorm float2 uv1 : TEXCOORD_1_FB_MSAA;
|
||||
#endif
|
||||
|
||||
#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 )
|
||||
{
|
||||
#ifdef BYPASS_PIXEL_SHADER
|
||||
PSOutput.color = float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
return;
|
||||
#else
|
||||
|
||||
#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
|
||||
|
||||
#if !defined(ALWAYS_LIT)
|
||||
diffuse = diffuse * TEXTURE_1.Sample(TextureSampler1, PSInput.uv1);
|
||||
#endif
|
||||
|
||||
#ifndef SEASONS
|
||||
|
||||
#if !defined(ALPHA_TEST) && !defined(BLEND)
|
||||
diffuse.a = PSInput.color.a;
|
||||
#elif defined(BLEND)
|
||||
#ifdef NEAR_WATER
|
||||
diffuse.a *= PSInput.color.a;
|
||||
|
||||
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
|
||||
|
||||
diffuse.rgb = getBadgerInfluenceOverlay(PSInput.worldPos.xyz, diffuse.rgb);
|
||||
|
||||
#ifdef FOG
|
||||
diffuse.rgb = lerp( diffuse.rgb, PSInput.fogColor.rgb, PSInput.fogColor.a );
|
||||
#endif
|
||||
|
||||
PSOutput.color = diffuse;
|
||||
|
||||
#ifdef VR_MODE
|
||||
// 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
|
||||
|
||||
#endif // BYPASS_PIXEL_SHADER
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct GeometryShaderInput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
lpfloat4 color : COLOR;
|
||||
snorm float2 uv0 : TEXCOORD_0;
|
||||
snorm float2 uv1 : TEXCOORD_1;
|
||||
#endif
|
||||
#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;
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
lpfloat4 color : COLOR;
|
||||
snorm float2 uv0 : TEXCOORD_0;
|
||||
snorm float2 uv1 : TEXCOORD_1;
|
||||
#endif
|
||||
#ifdef NEAR_WATER
|
||||
float cameraDist : TEXCOORD_2;
|
||||
#endif
|
||||
#ifdef FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#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;
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
output.color = input[j].color;
|
||||
output.uv0 = input[j].uv0;
|
||||
output.uv1 = input[j].uv1;
|
||||
#endif
|
||||
#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,140 @@
|
||||
#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;
|
||||
float3 worldPos : WORLD_POS;
|
||||
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
lpfloat4 color : COLOR;
|
||||
snorm float2 uv0 : TEXCOORD_0_FB_MSAA;
|
||||
snorm float2 uv1 : TEXCOORD_1_FB_MSAA;
|
||||
#endif
|
||||
|
||||
#ifdef NEAR_WATER
|
||||
float cameraDist : TEXCOORD_2;
|
||||
#endif
|
||||
|
||||
#ifdef FOG
|
||||
float4 fogColor : FOG_COLOR;
|
||||
#endif
|
||||
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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) {
|
||||
|
||||
#ifndef BYPASS_PIXEL_SHADER
|
||||
PSInput.uv0 = VSInput.uv0;
|
||||
PSInput.uv1 = VSInput.uv1;
|
||||
PSInput.color = VSInput.color;
|
||||
#endif
|
||||
|
||||
#ifdef AS_ENTITY_RENDERER
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul(WORLDVIEWPROJ_STEREO[i], float4(VSInput.position, 1));
|
||||
#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);
|
||||
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEW, float4( worldPos, 1 ));
|
||||
PSInput.position = mul(PROJ, PSInput.position);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#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 += RENDER_CHUNK_FOG_ALPHA.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
|
||||
|
||||
PSInput.worldPos = worldPos;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0_FB_MSAA;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float depth : SV_Depth;
|
||||
#if (VERSION <= 0xa000 /*D3D_FEATURE_LEVEL_10_0*/)
|
||||
float4 dx9dummy : SV_Target;
|
||||
#endif
|
||||
};
|
||||
|
||||
void main( in PS_Input PSInput, out PS_Output PSOutput )
|
||||
{
|
||||
#ifdef MSAA_FRAMEBUFFER_ENABLED
|
||||
float depth = 0.0f;
|
||||
int sampleCount = MSAA_SAMPLECOUNT;
|
||||
for (int i = 0; i < sampleCount; ++i )
|
||||
{
|
||||
depth += TEXTURE_0_MS.Load(PSInput.position.xy, i);
|
||||
}
|
||||
depth /= sampleCount;
|
||||
|
||||
PSOutput.depth = depth;
|
||||
#else
|
||||
PSOutput.depth = 0.0;
|
||||
#endif
|
||||
|
||||
#if (VERSION <= 0xa000 /*D3D_FEATURE_LEVEL_10_0*/)
|
||||
PSOutput.dx9dummy = float4(0, 0, 0, 0);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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 ) );
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = i;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = i;
|
||||
#endif
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
|
||||
//this is to make it come closer to the camera and avoid z-fighting
|
||||
PSInput.position.z -= 0.0001;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "util.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float4 weights : WEIGHTS;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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.position.xy += computeScreenOffsets(VSInput.position.xyz, VSInput.weights, WORLDVIEWPROJ_STEREO[i]);
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = i;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = i;
|
||||
#endif
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
PSInput.position.xy += computeScreenOffsets(VSInput.position.xyz, VSInput.weights, WORLDVIEWPROJ);
|
||||
#endif
|
||||
|
||||
//this is to make it come closer to the camera and avoid z-fighting
|
||||
PSInput.position.z -= 0.0001;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#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.rgb = lerp(PSInput.color.rgb, CURRENT_COLOR.rgb, PSInput.color.a);
|
||||
PSOutput.color.a = 1;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
#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 = CURRENT_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,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,42 @@
|
||||
#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 GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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 ) );
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#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,28 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "util.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
};
|
||||
|
||||
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 )
|
||||
{
|
||||
float4 color = CURRENT_COLOR;
|
||||
PSOutput.color = color;
|
||||
|
||||
#ifdef FORCE_DEPTH_ZERO
|
||||
PSOutput.depth = 0.0;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "util.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
};
|
||||
|
||||
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 )
|
||||
{
|
||||
float4 color = CURRENT_COLOR;
|
||||
|
||||
const float cycleTime = 1.f;
|
||||
const float cutoff = cycleTime * 0.75f;
|
||||
|
||||
float a = mod(TIME, cycleTime) / cutoff;
|
||||
a = 1.f - smoothstep(saturate(a - 0.1f), a, PSInput.uv.x);
|
||||
if (a > 0.f) {
|
||||
color = lerp(float4(1, 1, 1, 1), color, a);
|
||||
a = 1.f;
|
||||
}
|
||||
color.a = a;
|
||||
|
||||
PSOutput.color = color;
|
||||
|
||||
#ifdef FORCE_DEPTH_ZERO
|
||||
PSOutput.depth = 0.0;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct VS_Input
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float2 uv0 : TEXCOORD_0;
|
||||
#ifdef INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0;
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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 ) );
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = i;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = i;
|
||||
#endif
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
|
||||
PSInput.uv = VSInput.uv0;
|
||||
|
||||
//this is to make it come closer to the camera and avoid z-fighting
|
||||
PSInput.position.z -= 0.0001;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float4 color : COLOR;
|
||||
float2 uv : TEXCOORD_0_FB_MSAA;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
float median(float a, float b, float c) {
|
||||
return max(min(a, b), min(max(a, b), c));
|
||||
}
|
||||
|
||||
static const float GLYPH_UV_SIZE = 1.0 / 16.0;
|
||||
|
||||
void main(in PS_Input PSInput, out PS_Output PSOutput)
|
||||
{
|
||||
float4 diffuse = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
|
||||
#ifdef SMOOTH
|
||||
const float center = 0.4f;
|
||||
const float radius = 0.1f;
|
||||
|
||||
diffuse = smoothstep(center - radius, center + radius, diffuse);
|
||||
#endif
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if (diffuse.a < 0.5)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MSDF
|
||||
float4 resultColor = PSInput.color;
|
||||
|
||||
const float sampleDistance = median(diffuse.r, diffuse.g, diffuse.b);
|
||||
|
||||
const float innerEdgeAlpha = smoothstep(max(0.0, GLYPH_CUTOFF - GLYPH_SMOOTH_RADIUS), min(1.0, GLYPH_CUTOFF + GLYPH_SMOOTH_RADIUS), sampleDistance);
|
||||
// Apply fill cutoff
|
||||
resultColor = lerp(OUTLINE_COLOR, resultColor, innerEdgeAlpha);
|
||||
|
||||
const float outerEdgeAlpha = smoothstep(max(0.0, OUTLINE_CUTOFF - GLYPH_SMOOTH_RADIUS), min(1.0, OUTLINE_CUTOFF + GLYPH_SMOOTH_RADIUS), sampleDistance);
|
||||
// Apply stroke (outline) cutoff
|
||||
resultColor = float4(resultColor.rgb, resultColor.a * outerEdgeAlpha);
|
||||
|
||||
const float2 topLeft = floor(PSInput.uv / GLYPH_UV_SIZE) * GLYPH_UV_SIZE;
|
||||
const float2 bottomRight = floor(PSInput.uv / GLYPH_UV_SIZE) * GLYPH_UV_SIZE + GLYPH_UV_SIZE;
|
||||
|
||||
const float4 shadowSample = TEXTURE_0.Sample(TextureSampler0, clamp(PSInput.uv - SHADOW_OFFSET, topLeft, bottomRight));
|
||||
const float shadowDistance = shadowSample.a;
|
||||
const float shadowAlpha = smoothstep(max(0.0, OUTLINE_CUTOFF - SHADOW_SMOOTH_RADIUS), min(1.0, OUTLINE_CUTOFF + SHADOW_SMOOTH_RADIUS), shadowDistance);
|
||||
// Apply shadow past the stroke
|
||||
resultColor = lerp(float4(SHADOW_COLOR.rgb, SHADOW_COLOR.a * shadowAlpha), resultColor, outerEdgeAlpha);
|
||||
|
||||
diffuse = resultColor;
|
||||
#else
|
||||
diffuse *= PSInput.color;
|
||||
#endif
|
||||
|
||||
PSOutput.color = diffuse * DARKEN;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0_FB_MSAA;
|
||||
};
|
||||
|
||||
struct PS_Output
|
||||
{
|
||||
float4 color : SV_Target;
|
||||
};
|
||||
|
||||
void main(in PS_Input PSInput, out PS_Output PSOutput)
|
||||
{
|
||||
#ifdef STEREO_LEFT_EYE_ONLY
|
||||
PSOutput.color = TEXTURE_0.Sample(TextureSampler0, float3(PSInput.uv, 0.0f));
|
||||
#elif defined(DEPTH_TEXTURE)
|
||||
PSOutput.color.a = 1.0;
|
||||
#if defined(ARRAY_TEXTURE_0)
|
||||
PSOutput.color.rgb = TEXTURE_0.Sample(TextureSampler0, float3(PSInput.uv, TEXTURE_ARRAY_INDEX_0)).r;
|
||||
#else
|
||||
PSOutput.color.rgb = TEXTURE_0.Sample(TextureSampler0, PSInput.uv).r;
|
||||
#endif
|
||||
#else
|
||||
#if defined(ARRAY_TEXTURE_0)
|
||||
PSOutput.color = TEXTURE_0.Sample(TextureSampler0, float3(PSInput.uv, TEXTURE_ARRAY_INDEX_0));
|
||||
#else
|
||||
PSOutput.color = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ALPHA_TEST
|
||||
if( PSOutput.color.a < 0.5 )
|
||||
{
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NO_ALPHA
|
||||
PSOutput.color.a = 1.f;
|
||||
#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,40 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "util.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0_FB_MSAA;
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
#ifdef IGNORE_CURRENTCOLOR
|
||||
PSOutput.color = diffuse;
|
||||
#else
|
||||
PSOutput.color = CURRENT_COLOR * diffuse;
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWSMR_MAGICALPHA
|
||||
// Set the magic MR value alpha value so that this content pops over layers
|
||||
PSOutput.color.a = 133.0f / 255.0f;
|
||||
#endif
|
||||
}
|
||||
@@ -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,31 @@
|
||||
#include "ShaderConstants.fxh"
|
||||
#include "util.fxh"
|
||||
|
||||
struct PS_Input
|
||||
{
|
||||
float4 position : SV_Position;
|
||||
float2 uv : TEXCOORD_0_FB_MSAA;
|
||||
};
|
||||
|
||||
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.0625 )
|
||||
{
|
||||
discard;
|
||||
}
|
||||
#endif
|
||||
|
||||
PSOutput.color = diffuse;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
|
||||
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.
|
||||
|
||||
if (tex.CalculateLevelOfDetailUnclamped(TextureSampler0, uv) < -0.5f)
|
||||
{
|
||||
// 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));
|
||||
|
||||
// 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
|
||||
float2 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;
|
||||
|
||||
// Update uv
|
||||
uv = uvModified;
|
||||
}
|
||||
|
||||
return tex.Sample(TextureSampler0, uv);
|
||||
}
|
||||
|
||||
float MakeDepthLinear(float z, float n, float f, bool scaleZ)
|
||||
{
|
||||
//Remaps z from [0, 1] to [-1, 1].
|
||||
if (scaleZ) {
|
||||
z = 2.f * z - 1.f;
|
||||
}
|
||||
return (2.f * n) / (f + n - z * (f - n));
|
||||
}
|
||||
|
||||
float2 computeScreenOffsets(in float3 pos, in float4 data, in float4x4 worldViewProj)
|
||||
{
|
||||
float3 normal = data.xyz;
|
||||
float width = length(normal);
|
||||
float pixelScale = abs(data.w);
|
||||
float dir = (data.w < 0) ? -1.f : 1.f;
|
||||
|
||||
float4 pos0 = float4(pos, 1.f);
|
||||
float4 pos1 = float4(pos + normal, 1.f);
|
||||
|
||||
pos0 = mul(worldViewProj, pos0);
|
||||
pos1 = mul(worldViewProj, pos1);
|
||||
|
||||
float2 screenNormal = (pos1.xy / pos1.w) - (pos0.xy / pos0.w);
|
||||
screenNormal = normalize(float2(-screenNormal.y, screenNormal.x));
|
||||
|
||||
float w = dot(worldViewProj[3], float4(pos, 1.f));
|
||||
|
||||
float pixelRadius = w * pixelScale;
|
||||
return screenNormal * (dir * width * pixelRadius);
|
||||
}
|
||||
|
||||
// modulo that behaves like glsl (aka: like we actually expect)
|
||||
float mod(float x, float y)
|
||||
{
|
||||
return x - y * floor(x / y);
|
||||
}
|
||||
@@ -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,41 @@
|
||||
#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 GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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 ) );
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#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,45 @@
|
||||
#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 GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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));
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#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;
|
||||
float2 uv1 : TEXCOORD_1;
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void main(in VS_Input VSInput, out PS_Input PSInput) {
|
||||
PSInput.uv = VSInput.uv;
|
||||
PSInput.uv.y += V_OFFSET;
|
||||
PSInput.uv1 = VSInput.uv;
|
||||
PSInput.uv1.y += V_BLEND_OFFSET;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul(WORLDVIEWPROJ_STEREO[i], float4(VSInput.position, 1));
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#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 GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void main( in VS_Input VSInput, out PS_Input PSInput )
|
||||
{
|
||||
float4 transformedUV = mul(UV_TRANSFORM, float4(VSInput.uv, 0, 1));
|
||||
PSInput.uv = transformedUV.xy;
|
||||
|
||||
#ifdef INSTANCEDSTEREO
|
||||
int i = VSInput.instanceID;
|
||||
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#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 GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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 ) );
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
|
||||
#endif
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#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 GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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);
|
||||
#else
|
||||
float4 pos = mul(WORLDVIEW, float4(VSInput.position, 1));
|
||||
PSInput.position = mul(PROJ, pos);
|
||||
#endif
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = VSInput.instanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = VSInput.instanceID;
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#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 GEOMETRY_INSTANCEDSTEREO
|
||||
uint instanceID : SV_InstanceID;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
uint renTarget_id : SV_RenderTargetArrayIndex;
|
||||
#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], mul(CUBE_MAP_ROTATION, float4( VSInput.position, 1 )));
|
||||
#ifdef GEOMETRY_INSTANCEDSTEREO
|
||||
PSInput.instanceID = i;
|
||||
#endif
|
||||
#ifdef VERTEXSHADER_INSTANCEDSTEREO
|
||||
PSInput.renTarget_id = i;
|
||||
#endif
|
||||
#else
|
||||
PSInput.position = mul(WORLDVIEWPROJ, mul(CUBE_MAP_ROTATION, float4(VSInput.position, 1)));
|
||||
#endif
|
||||
}
|
||||
Reference in new issue
Block a user