Initial commit

This commit is contained in:
Stillkill committed 2026-03-08 15:30:46 -05:00
commit c630089742
4782 files changed
+178521

No files matched your search

+125
View File
@@ -0,0 +1,125 @@
// These [aren't but] should be grouped in a way that they require the least amount of updating (world data in one, model data in another, part of model data in another one, etc)
#ifdef USE_STEREO_TEXTURE_ARRAY
Texture2DArray TEXTURE_0 : register ( t0 );
#else
Texture2D TEXTURE_0 : register ( t0 );
#endif
Texture2D TEXTURE_1 : register ( t1 );
Texture2D TEXTURE_2 : register ( t2 );
// Make sure this thing is actually getting bound
sampler TextureSampler0 : register( s0 );
sampler TextureSampler1 : register( s1 );
sampler TextureSampler2 : register( s2 );
#ifdef LOW_PRECISION
#define lpfloat min16float
#define lpfloat2 min16float2
#define lpfloat4 min16float4
#else
#define lpfloat float
#define lpfloat2 float2
#define lpfloat4 float4
#endif
#ifdef MSAA_FRAMEBUFFER_ENABLED
#define TEXCOORD_0_FB_MSAA TEXCOORD_0_centroid
#define TEXCOORD_1_FB_MSAA TEXCOORD_1_centroid
#else
#define TEXCOORD_0_FB_MSAA TEXCOORD_0
#define TEXCOORD_1_FB_MSAA TEXCOORD_1
#endif
cbuffer RenderChunkConstants
{
float4 CHUNK_ORIGIN_AND_SCALE;
}
cbuffer EntityConstants
{
float4 OVERLAY_COLOR;
float4 TILE_LIGHT_COLOR;
float4 CHANGE_COLOR;
float4 GLINT_COLOR;
float2 UV_ANIM;
float2 UV_OFFSET;
float2 UV_ROTATION;
float2 GLINT_UV_SCALE;
}
cbuffer PerFrameConstants
{
float3 VIEW_DIRECTION; // unneeded
float TIME; // unneeded
float3 VIEW_POS;
float FAR_CHUNKS_DISTANCE;
float4 FOG_COLOR;
float2 FOG_CONTROL;
float RENDER_DISTANCE;
}
#if !defined(INSTANCEDSTEREO)
cbuffer WorldConstants
{
float4x4 WORLDVIEWPROJ;
float4x4 WORLD;
float4x4 WORLDVIEW;
float4x4 PROJ;
}
#else
cbuffer WorldConstantsStereographic
{
float4x4 WORLDVIEWPROJ_STEREO[2];
float4x4 WORLD_STEREO;
float4x4 WORLDVIEW_STEREO[2];
float4x4 PROJ_STEREO[2];
}
#endif
cbuffer ShaderConstants
{
float4 CURRENT_COLOR;
float4 DARKEN;
float3 TEXTURE_DIMENSIONS;
}
cbuffer WeatherConstants {
float4 POSITION_OFFSET;
float4 VELOCITY;
float4 ALPHA;
float4 VIEW_POSITION;
float4 SIZE_SCALE;
float4 FORWARD;
float4 UV_INFO;
float4 PARTICLE_BOX;
}
cbuffer HoloConstants
{
float4 TABLE_REVEAL_CENTER;
float4 TABLE_REVEAL_CONSTANTS; // x = Radius
float3 GAZE_DIRECTION;
float4 SKIRT_UVS;
float4 SKIRT_UV_SCALE;
float2 CHUNK_CLIP_MIN;
float2 CHUNK_CLIP_MAX;
float2 CLIP_MIN;
float2 CLIP_MAX;
}
+17
View File
@@ -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;
}
+29
View File
@@ -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
}
+40
View File
@@ -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);
}
}
+46
View File
@@ -0,0 +1,46 @@
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
float4 color : COLOR;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
static const float fogNear = 0.9;
static const float3 inverseLightDirection = float3( 0.62, 0.78, 0.0 );
static const float ambient = 0.7;
void main( in VS_Input VSInput, out PS_Input PSInput )
{
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
PSInput.instanceID = i;
float3 worldPos = mul(WORLD_STEREO, float4(VSInput.position, 1));
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
float3 worldPos = mul(WORLD, float4(VSInput.position, 1));
#endif
PSInput.color = VSInput.color * CURRENT_COLOR;
float depth = length(worldPos) / RENDER_DISTANCE;
float fog = max( depth - fogNear, 0.0 );
PSInput.color.a *= 1.0 - fog;
}
+17
View File
@@ -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;
}
+40
View File
@@ -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);
}
}
+33
View File
@@ -0,0 +1,33 @@
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
float4 color : COLOR;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
void main( in VS_Input VSInput, out PS_Input PSInput )
{
PSInput.color = VSInput.color;
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
#endif
}
+18
View File
@@ -0,0 +1,18 @@
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
PSOutput.color = PSInput.color * CURRENT_COLOR;
}
@@ -0,0 +1,28 @@
#include "ShaderConstants.fxh"
// be sure to change the shader type to pertex shader and shader model to ps_40 (in visual studio)
struct PS_Input {
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
};
struct PS_Output {
float4 color : SV_Target;
};
void main(in PS_Input PSInput, out PS_Output PSOutput) {
float4 diffuse = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
#ifdef ALPHA_TEST
if (diffuse.a < 0.5) {
discard;
}
#endif
float grayscale = (CURRENT_COLOR.r * diffuse.r * 0.3 + CURRENT_COLOR.g * diffuse.g * 0.59 + CURRENT_COLOR.b * diffuse.b * 0.11);
float4 gray_color = float4(grayscale, grayscale, grayscale, CURRENT_COLOR.a * diffuse.a);
PSOutput.color = gray_color;
}
@@ -0,0 +1,83 @@
#include "ShaderConstants.fxh"
float4 glintBlend(float4 dest, float4 source) {
return float4(source.rgb * source.rgb, 0.0) + dest;
}
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
float2 uv : TEXCOORD_0;
#ifdef ENABLE_FOG
float4 fogColor : FOG_COLOR;
#endif
#ifdef GLINT
float2 layer1UV : UV_1;
float2 layer2UV : UV_2;
#endif
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
float4 diffuse = TEXTURE_0.Sample( TextureSampler0, PSInput.uv );
#ifdef ALPHA_TEST
#ifdef ENABLE_VERTEX_TINT_MASK
if( diffuse.a <= 0.0f )
#else
if (diffuse.a <= 0.5f)
#endif
{
discard;
}
#endif
#ifdef ENABLE_VERTEX_TINT_MASK
diffuse.rgb = lerp(diffuse.rgb, diffuse.rgb*PSInput.color.rgb, diffuse.a);
if (PSInput.color.a > 0.0f) {
diffuse.a = diffuse.a > 0.0f ? 1.0f : 0.0f;
}
#endif
#ifdef GLINT
float4 layer1 = TEXTURE_1.Sample(TextureSampler1, frac(PSInput.layer1UV)).rgbr * GLINT_COLOR;
float4 layer2 = TEXTURE_1.Sample(TextureSampler1, frac(PSInput.layer2UV)).rgbr * GLINT_COLOR;
float4 glint = (layer1 + layer2);
#ifdef INVENTORY
diffuse.rgb = glint.rgb;
#else
diffuse.rgb = glintBlend(diffuse, glint).rgb;
#endif
#endif
#ifdef USE_OVERLAY
//use either the diffuse or the OVERLAY_COLOR
diffuse.rgb = lerp( diffuse, OVERLAY_COLOR, OVERLAY_COLOR.a ).rgb;
#endif
#ifdef ENABLE_FOG
diffuse.rgb = lerp(diffuse.rgb, PSInput.fogColor.rgb, PSInput.fogColor.a);
#endif
#ifdef ENABLE_VERTEX_TINT_MASK
PSOutput.color = diffuse;
#else
PSOutput.color = diffuse * PSInput.color;
#endif
#ifdef VR_FEATURE
// On Rift, the transition from 0 brightness to the lowest 8 bit value is abrupt, so clamp to
// the lowest 8 bit value.
PSOutput.color = max(PSOutput.color, 1 / 255.0f);
#endif
}
+66
View File
@@ -0,0 +1,66 @@
#include "ShaderConstants.fxh"
struct GeometryShaderInput
{
float4 pos : SV_POSITION;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
#ifdef ENABLE_FOG
float4 fogColor : FOG_COLOR;
#endif
#ifdef GLINT
float2 layer1UV : UV_1;
float2 layer2UV : UV_2;
#endif
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
// Per-pixel color data passed through the pixel shader.
struct GeometryShaderOutput
{
float4 pos : SV_POSITION;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
#ifdef ENABLE_FOG
float4 fogColor : FOG_COLOR;
#endif
#ifdef GLINT
float2 layer1UV : UV_1;
float2 layer2UV : UV_2;
#endif
#ifdef INSTANCEDSTEREO
uint renTarget_id : SV_RenderTargetArrayIndex;
#endif
};
// passes through the triangles, except changint the viewport id to match the instance
[maxvertexcount(3)]
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
{
GeometryShaderOutput output = (GeometryShaderOutput)0;
#ifdef INSTANCEDSTEREO
int i = input[0].instanceID;
#endif
{
for (int j = 0; j < 3; j++)
{
output.pos = input[j].pos;
output.color = input[j].color;
output.uv0 = input[j].uv0;
#ifdef ENABLE_FOG
output.fogColor = input[j].fogColor;
#endif
#ifdef INSTANCEDSTEREO
output.renTarget_id = i;
#endif
outStream.Append(output);
}
}
}
+70
View File
@@ -0,0 +1,70 @@
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
float4 color : COLOR;
float2 texCoords : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
float2 texCoords : TEXCOORD_0;
#ifdef ENABLE_FOG
float4 fogColor : FOG_COLOR;
#endif
#ifdef GLINT
float2 layer1UV : UV_1;
float2 layer2UV : UV_2;
#endif
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
#ifdef GLINT
float2 calculateLayerUV(float2 origUV, float offset, float rotation) {
float2 uv = origUV;
uv -= 0.5;
float rsin = sin(rotation);
float rcos = cos(rotation);
uv = mul(uv, float2x2(rcos, -rsin, rsin, rcos));
uv.x += offset;
uv += 0.5;
return uv * GLINT_UV_SCALE;
}
#endif
void main( in VS_Input VSInput, out PS_Input PSInput )
{
PSInput.color = VSInput.color;
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
#endif
PSInput.texCoords = VSInput.texCoords;
#ifdef ENABLE_FOG
//fog
PSInput.fogColor.rgb = FOG_COLOR.rgb;
PSInput.fogColor.a = clamp(((PSInput.position.z / RENDER_DISTANCE) - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, 1.0);
#endif
#ifdef GLINT
PSInput.layer1UV = calculateLayerUV(VSInput.texCoords, UV_OFFSET.x, UV_ROTATION.x);
PSInput.layer2UV = calculateLayerUV(VSInput.texCoords, UV_OFFSET.y, UV_ROTATION.y);
#endif
}
@@ -0,0 +1,25 @@
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
};
struct PS_Output
{
float4 color : SV_Target;
#ifdef FORCE_DEPTH_ZERO
float depth : SV_Depth;
#endif
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
PSOutput.color = CURRENT_COLOR;
#ifdef FORCE_DEPTH_ZERO
PSOutput.depth = 0.0;
#endif
}
+118
View File
@@ -0,0 +1,118 @@
#include "ShaderConstants.fxh"
#include "Util.fxh"
struct PS_Input {
float4 position : SV_Position;
float4 light : LIGHT;
float4 fogColor : FOG_COLOR;
#ifdef GLINT
// there is some alignment issue on the Windows Phone 1320 that causes the position
// to get corrupted if this is two floats and last in the struct memory wise
float4 layerUV : GLINT_UVS;
#endif
#ifdef USE_OVERLAY
float4 overlayColor : OVERLAY_COLOR;
#endif
float2 uv : TEXCOORD_0_FB_MSAA;
};
struct PS_Output
{
float4 color : SV_Target;
};
#ifdef USE_EMISSIVE
#define NEEDS_DISCARD(C) (C.a + C.r + C.g + C.b == 0.0)
#else
#ifndef USE_COLOR_MASK
#define NEEDS_DISCARD(C) (C.a < 0.5)
#else
#define NEEDS_DISCARD(C) (C.a <= 0.0)
#endif
#endif
float4 glintBlend(float4 dest, float4 source) {
// glBlendFuncSeparate(GL_SRC_COLOR, GL_ONE, GL_ONE, GL_ZERO)
return float4(source.rgb * source.rgb, source.a) + float4(dest.rgb, 0.0);
}
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
float4 color = float4( 1.0f, 1.0f, 1.0f, 1.0f );
#ifndef NO_TEXTURE
#if !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE) || (VERSION < 0xa000 /*D3D_FEATURE_LEVEL_10_0*/)
color = TEXTURE_0.Sample( TextureSampler0, PSInput.uv );
#else
color = texture2D_AA(TEXTURE_0, TextureSampler0, PSInput.uv);
#endif
#endif
#ifdef ALPHA_TEST
if( NEEDS_DISCARD( color ) )
{
discard;
}
#endif
#ifdef USE_COLOR_MASK
color.rgb = lerp( color, color * CHANGE_COLOR, color.a ).rgb;
color.a = 1.0;
#endif
#ifdef ITEM_IN_HAND
color.rgb = lerp(color, color * CHANGE_COLOR, PSInput.light.a).rgb;
#endif
#ifdef USE_MULTITEXTURE
float4 tex1 = TEXTURE_1.Sample(TextureSampler1, PSInput.uv);
float4 tex2 = TEXTURE_2.Sample(TextureSampler2, PSInput.uv);
color.rgb = lerp(color.rgb, tex1, tex1.a);
#ifdef COLOR_SECOND_TEXTURE
if (tex2.a > 0.0f) {
color.rgb = lerp(tex2.rgb, tex2 * CHANGE_COLOR, tex2.a);
}
#else
color.rgb = lerp(color.rgb, tex2, tex2.a);
#endif
#endif
#ifdef USE_OVERLAY
//use either the diffuse or the OVERLAY_COLOR
color.rgb = lerp( color, PSInput.overlayColor, PSInput.overlayColor.a ).rgb;
#endif
#ifdef USE_EMISSIVE
//make glowy stuff
color *= lerp( float( 1.0 ).xxxx, PSInput.light, color.a );
#else
color *= PSInput.light;
#endif
//apply fog
color.rgb = lerp( color.rgb, PSInput.fogColor.rgb, PSInput.fogColor.a );
#ifdef GLINT
// Applies color mask to glint texture instead and blends with original color
float4 layer1 = TEXTURE_1.Sample(TextureSampler1, frac(PSInput.layerUV.xy)).rgbr * GLINT_COLOR;
float4 layer2 = TEXTURE_1.Sample(TextureSampler1, frac(PSInput.layerUV.zw)).rgbr * GLINT_COLOR;
float4 glint = (layer1 + layer2) * TILE_LIGHT_COLOR;
color = glintBlend(color, glint);
#endif
//WARNING do not refactor this
PSOutput.color = color;
#ifdef VR_FEATURE
// On Rift, the transition from 0 brightness to the lowest 8 bit value is abrupt, so clamp to
// the lowest 8 bit value.
PSOutput.color = max(PSOutput.color, 1 / 255.0f);
#endif
}
+72
View File
@@ -0,0 +1,72 @@
#include "ShaderConstants.fxh"
struct GeometryShaderInput
{
float4 pos : SV_POSITION;
float4 light : LIGHT;
float4 fogColor : FOG_COLOR;
#ifdef GLINT
float4 layerUV : GLINT_UVS;
#endif
#ifdef USE_OVERLAY
float4 overlayColor : OVERLAY_COLOR;
#endif
float2 uv : TEXCOORD_0_FB_MSAA;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
// Per-pixel color data passed through the pixel shader.
struct GeometryShaderOutput
{
float4 pos : SV_POSITION;
float4 light : LIGHT;
float4 fogColor : FOG_COLOR;
#ifdef GLINT
float4 layerUV : GLINT_UVS;
#endif
#ifdef USE_OVERLAY
float4 overlayColor : OVERLAY_COLOR;
#endif
float2 uv : TEXCOORD_0_FB_MSAA;
#ifdef INSTANCEDSTEREO
uint renTarget_id : SV_RenderTargetArrayIndex;
#endif
};
// passes through the triangles, except changint the viewport id to match the instance
[maxvertexcount(3)]
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
{
GeometryShaderOutput output = (GeometryShaderOutput)0;
#ifdef INSTANCEDSTEREO
int i = input[0].instanceID;
#endif
for (int j = 0; j < 3; j++)
{
output.pos = input[j].pos;
#ifndef NO_TEXTURE
output.uv = input[j].uv;
#endif
#ifdef INSTANCEDSTEREO
output.renTarget_id = i;
#endif
output.light = input[j].light;
output.fogColor = input[j].fogColor;
#ifdef USE_OVERLAY
output.overlayColor = input[j].overlayColor;
#endif
#ifdef GLINT
output.layerUV = input[j].layerUV;
#endif
outStream.Append(output);
}
}
+137
View File
@@ -0,0 +1,137 @@
#include "ShaderConstants.fxh"
struct VS_Input {
float3 position : POSITION;
float4 normal : NORMAL;
float2 texCoords : TEXCOORD_0;
#ifdef COLOR_BASED
float4 color : COLOR;
#endif
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input {
float4 position : SV_Position;
float4 light : LIGHT;
float4 fogColor : FOG_COLOR;
#ifdef GLINT
// there is some alignment issue on the Windows Phone 1320 that causes the position
// to get corrupted if this is two floats and last in the struct memory wise
float4 layerUV : GLINT_UVS;
#endif
#ifdef USE_OVERLAY
float4 overlayColor : OVERLAY_COLOR;
#endif
float2 uv : TEXCOORD_0_FB_MSAA;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
static const float AMBIENT = 0.45;
static const float XFAC = -0.1;
static const float ZFAC = 0.1;
float4 TransformRGBA8_SNORM(const float4 RGBA8_SNORM) {
#ifdef R8G8B8A8_SNORM_UNSUPPORTED
return RGBA8_SNORM * float(2.0).xxxx - float(1.0).xxxx;
#else
return RGBA8_SNORM;
#endif
}
float lightIntensity(const float4 position, const float4 normal) {
#ifdef FANCY
#if !defined(INSTANCEDSTEREO)
float3 N = normalize(mul(WORLD, normal)).xyz;
#else
float3 N = normalize(mul(WORLD_STEREO, normal)).xyz;
#endif
N.y *= TILE_LIGHT_COLOR.a;
//take care of double sided polygons on materials without culling
#ifdef FLIP_BACKFACES
#if !defined(INSTANCEDSTEREO)
float3 viewDir = normalize((mul(WORLD, position)).xyz);
#else
float3 viewDir = normalize((mul(WORLD_STEREO, position)).xyz);
#endif
if (dot(N, viewDir) > 0.0) {
N *= -1.0;
}
#endif
float yLight = (1.0 + N.y) * 0.5;
return yLight * (1.0 - AMBIENT) + N.x*N.x * XFAC + N.z*N.z * ZFAC + AMBIENT;
#else
return 1.0;
#endif
}
#ifdef GLINT
float2 calculateLayerUV(float2 origUV, float offset, float rotation) {
float2 uv = origUV;
uv -= 0.5;
float rsin = sin(rotation);
float rcos = cos(rotation);
uv = mul(uv, float2x2(rcos, -rsin, rsin, rcos));
uv.x += offset;
uv += 0.5;
return uv * GLINT_UV_SCALE;
}
#endif
void main(in VS_Input VSInput, out PS_Input PSInput) {
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul(WORLDVIEWPROJ_STEREO[i], float4(VSInput.position, 1));
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
#endif
float4 normal = TransformRGBA8_SNORM(VSInput.normal);
float L = lightIntensity(float4(VSInput.position, 1), normal);
#ifdef USE_OVERLAY
L += OVERLAY_COLOR.a * 0.35;
PSInput.overlayColor = OVERLAY_COLOR;
#endif
PSInput.light = float4(L.xxx * TILE_LIGHT_COLOR.rgb, 1.0);
#ifdef COLOR_BASED
PSInput.light *= VSInput.color;
#endif
#ifndef NO_TEXTURE
PSInput.uv = VSInput.texCoords;
#endif
#ifdef USE_UV_ANIM
PSInput.uv.xy += UV_ANIM.xy;
#endif
#ifdef GLINT
PSInput.layerUV.xy = calculateLayerUV(VSInput.texCoords, UV_OFFSET.x, UV_ROTATION.x);
PSInput.layerUV.zw = calculateLayerUV(VSInput.texCoords, UV_OFFSET.y, UV_ROTATION.y);
#endif
//fog
PSInput.fogColor.rgb = FOG_COLOR.rgb;
PSInput.fogColor.a = clamp(((PSInput.position.z / RENDER_DISTANCE) - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, 1.0);
}
@@ -0,0 +1,16 @@
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
PSOutput.color = float4(1,1,1,1);
}
@@ -0,0 +1,17 @@
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
PSOutput.color = PSInput.color;
}
@@ -0,0 +1,40 @@
#include "ShaderConstants.fxh"
struct GeometryShaderInput
{
float4 pos : SV_POSITION;
float4 color : COLOR;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
// Per-pixel color data passed through the pixel shader.
struct GeometryShaderOutput
{
float4 pos : SV_POSITION;
float4 color : COLOR;
#ifdef INSTANCEDSTEREO
uint renTarget_id : SV_RenderTargetArrayIndex;
#endif
};
// passes through the triangles, except changint the viewport id to match the instance
[maxvertexcount(3)]
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
{
GeometryShaderOutput output = (GeometryShaderOutput)0;
#ifdef INSTANCEDSTEREO
int i = input[0].instanceID;
#endif
for (int j = 0; j < 3; j++)
{
output.pos = input[j].pos;
output.color = input[j].color;
#ifdef INSTANCEDSTEREO
output.renTarget_id = i;
#endif
outStream.Append(output);
}
}
+34
View File
@@ -0,0 +1,34 @@
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
float4 normal : NORMAL;
float4 color : COLOR;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
void main( in VS_Input VSInput, out PS_Input PSInput )
{
PSInput.color = VSInput.color * 0.5f + -0.5f * dot(VSInput.normal, float4(GAZE_DIRECTION, 0.0f));
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1.0f ) );
PSInput.instanceID = i;
#else
PSInput.position = mul( WORLDVIEWPROJ, float4( VSInput.position, 1.0f ) );
#endif
}
@@ -0,0 +1,27 @@
// DO NOT HAVE THIS INCLUDE BE THE FIRST LINE! we need a #define to be respected in the .fxh file
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
float2 uv : TEXCOORD_0; // the stereo texture uses a texture array
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
#ifdef INSTANCEDSTEREO
float3 uvr = float3(PSInput.uv, PSInput.instanceID); // 3rd element selects the texture
#else
int eyeIndex = 0; //TODO: Right now this code will render mono if we were to implement non-instanced stereo rendering
float3 uvr = float3(PSInput.uv, eyeIndex); // 3rd element selects the texture
#endif
PSOutput.color = TEXTURE_0.Sample(TextureSampler0, uvr);
}
@@ -0,0 +1,45 @@
#include "ShaderConstants.fxh"
struct GeometryShaderInput
{
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
// Per-pixel color data passed through the pixel shader.
struct GeometryShaderOutput
{
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
uint renTarget_id : SV_RenderTargetArrayIndex;
#endif
};
// passes through the triangles, except changint the viewport id to match the instance
[maxvertexcount(3)]
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
{
GeometryShaderOutput output = (GeometryShaderOutput)0;
#ifdef INSTANCEDSTEREO
int i = input[0].instanceID;
#endif
{
for (int j = 0; j < 3; j++)
{
output.pos = input[j].pos;
output.uv0 = input[j].uv0;
#ifdef INSTANCEDSTEREO
output.renTarget_id = i;
output.instanceID = i;
#endif
outStream.Append(output);
}
//outStream.RestartStrip();
}
}
@@ -0,0 +1,22 @@
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
float2 uv : TEXCOORD_0;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
float2 uv = PSInput.uv * SKIRT_UV_SCALE.xy;
uv = frac(uv);
uv = uv * SKIRT_UVS.zw + SKIRT_UVS.xy;
PSOutput.color = TEXTURE_0.Sample( TextureSampler0, uv ) * PSInput.color.r;
PSOutput.color.rgb *= TEXTURE_1.Sample(TextureSampler1, PSInput.color.gr).rgb;
}
@@ -0,0 +1,46 @@
#include "ShaderConstants.fxh"
struct GeometryShaderInput
{
float4 pos : SV_POSITION;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
// Per-pixel color data passed through the pixel shader.
struct GeometryShaderOutput
{
float4 pos : SV_POSITION;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint renTarget_id : SV_RenderTargetArrayIndex;
#endif
};
// Takes verts in world space and transforms them by two different view
// proj matrices, on two different viewports.
[maxvertexcount(6)]
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
{
GeometryShaderOutput output = (GeometryShaderOutput)0;
#ifdef INSTANCEDSTEREO
int i = input[0].instanceID;
#endif
{
for (int j = 0; j < 3; j++)
{
output.pos = input[j].pos;
output.color = input[j].color;
output.uv0 = input[j].uv0;
#ifdef INSTANCEDSTEREO
output.renTarget_id = i;
#endif
outStream.Append(output);
}
}
}
@@ -0,0 +1,38 @@
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
float4 color : COLOR;
float2 texCoords : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
float2 texCoords : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
void main( in VS_Input VSInput, out PS_Input PSInput )
{
PSInput.color = VSInput.color;
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
#endif
PSInput.texCoords = VSInput.texCoords;
}
@@ -0,0 +1,24 @@
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
float3 color : COLOR;
float2 uv : TEXCOORD_0;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
float4 diffuse = TEXTURE_0.Sample( TextureSampler0, PSInput.uv );
//diffuse.rgb *= TEXTURE_1.Sample(TextureSampler1, float2(0, PSInput.color.a)).rgb;
//diffuse.rgb *= float3(151.0f/255.0f, 59.0f/255.0f, 224.0f/255.0f);
diffuse.rgb *= PSInput.color.rgb;
PSOutput.color = diffuse;
}
@@ -0,0 +1,45 @@
#include "ShaderConstants.fxh"
struct GeometryShaderInput
{
float4 pos : SV_POSITION;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
// Per-pixel color data passed through the pixel shader.
struct GeometryShaderOutput
{
float4 pos : SV_POSITION;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint renTarget_id : SV_RenderTargetArrayIndex;
#endif
};
// passes through the triangles, except changint the viewport id to match the instance
[maxvertexcount(3)]
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
{
GeometryShaderOutput output = (GeometryShaderOutput)0;
#ifdef INSTANCEDSTEREO
int i = input[0].instanceID;
#endif
{
for (int j = 0; j < 3; j++)
{
output.pos = input[j].pos;
output.color = input[j].color;
output.uv0 = input[j].uv0;
#ifdef INSTANCEDSTEREO
output.renTarget_id = i;
#endif
outStream.Append(output);
}
}
}
@@ -0,0 +1,51 @@
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
float3 normal : NORMAL;
float4 color : COLOR;
float2 texCoords : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
float2 texCoords : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
void main( in VS_Input VSInput, out PS_Input PSInput )
{
PSInput.color = VSInput.color;
float3 position = VSInput.position;
float3 voxelCenter = VSInput.normal * 80.0f - float3(40.0f, 40.0f, 40.0f);
voxelCenter.y = -0.5f;
float2 delta = voxelCenter.xz - TABLE_REVEAL_CENTER.xz;
float lengthSq = dot(delta, delta);
if (lengthSq > (TABLE_REVEAL_CONSTANTS.x * TABLE_REVEAL_CONSTANTS.x)) {
position = float3(0.0f, 0.0f, 0.0f);
}
else if (TABLE_REVEAL_CONSTANTS.y > 0.0f && VSInput.normal.y > 0.0f && lengthSq < (TABLE_REVEAL_CONSTANTS.y * TABLE_REVEAL_CONSTANTS.y)) {
float fallAmount = TABLE_REVEAL_CONSTANTS.y*TABLE_REVEAL_CONSTANTS.y - lengthSq;
position.y -= fallAmount * 0.1f;
}
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( position, 1 ) );
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(position, 1));
#endif
PSInput.texCoords = VSInput.texCoords;
}
@@ -0,0 +1,32 @@
//$ANTCOLONY
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
float4 uv1 : TEXCOORD_1;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main(in PS_Input PSInput, out PS_Output PSOutput)
{
float2 uv = PSInput.uv1.xy + (PSInput.uv0 - floor(PSInput.uv0)) * PSInput.uv1.zw;
float4 diffuse = TEXTURE_0.Sample(TextureSampler0, uv);
float2 lightingUVs = float2(0.0f, 0.9f);
diffuse.rgb *= TEXTURE_1.Sample(TextureSampler1, lightingUVs).rgb;
if (diffuse.a < 0.5f)
{
discard;
}
diffuse *= PSInput.color;
PSOutput.color = diffuse;
}
@@ -0,0 +1,50 @@
#include "ShaderConstants.fxh"
struct GeometryShaderInput
{
float4 pos : SV_POSITION;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
float4 uv1 : TEXCOORD_1;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
// Per-pixel color data passed through the pixel shader.
struct GeometryShaderOutput
{
float4 pos : SV_POSITION;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
float4 uv1 : TEXCOORD_1;
#ifdef INSTANCEDSTEREO
uint renTarget_id : SV_RenderTargetArrayIndex;
#endif
};
// Takes verts in world space and transforms them by two different view
// proj matrices, on two different viewports.
[maxvertexcount(6)]
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
{
GeometryShaderOutput output = (GeometryShaderOutput)0;
#ifdef INSTANCEDSTEREO
int i = input[0].instanceID;
#endif
{
for (int j = 0; j < 3; j++)
{
output.pos = input[j].pos;
output.color = input[j].color;
output.uv0 = input[j].uv0;
output.uv1 = input[j].uv1;
#ifdef INSTANCEDSTEREO
output.renTarget_id = i;
#endif
outStream.Append(output);
}
//outStream.RestartStrip();
}
}
@@ -0,0 +1,48 @@
//$ANTCOLONY
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
float2 uv0 : TEXCOORD_0; // x,y 0-1 based off if voxel texture wasn't in atlas. Can multiply against atlas UV's to get atlas uv's
float2 uv1 : TEXCOORD_1; // x = voxel coord x, y = voxel coord y
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
float4 uvRect : TEXCOORD_1;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
Texture2D<float4> TILE_UV_MAP : register (t1);
void main( in VS_Input VSInput, out PS_Input PSInput )
{
float3 position = VSInput.position.xyz;
int2 tileUVs = int2(0, VSInput.uv1.x * 255.0f);
float4 uvCoords = TEXTURE_1[tileUVs];
tileUVs.x = 4.0f;
float4 colorVal = TEXTURE_1[tileUVs];
PSInput.uv0 = VSInput.uv0 * float2(1.0f, 127.0f);
PSInput.uvRect = uvCoords;
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul(WORLDVIEWPROJ_STEREO[i], float4(position.xyz, 1));
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(position.xyz, 1));
#endif
PSInput.color = colorVal;
}
@@ -0,0 +1,21 @@
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
float4 light : LIGHT;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
float4 color = lerp( float4( 1, 1, 1, 1 ), PSInput.light, PSInput.light.a );
color.rgb = lerp( color, OVERLAY_COLOR, OVERLAY_COLOR.a ).rgb;
PSOutput.color = color;
}
@@ -0,0 +1,34 @@
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
float4 normal : NORMAL;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
void main( in VS_Input VSInput, out PS_Input PSInput )
{
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
#endif
PSInput.color.rgb = ( VSInput.normal.xyz / 2 ) + 0.5;
PSInput.color.a = 1.0;
}
@@ -0,0 +1,43 @@
#include "ShaderConstants.fxh"
struct GeometryShaderInput
{
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
// Per-pixel color data passed through the pixel shader.
struct GeometryShaderOutput
{
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint renTarget_id : SV_RenderTargetArrayIndex;
#endif
};
// Takes verts in world space and transforms them by two different view
// proj matrices, on two different viewports.
[maxvertexcount(3)]
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
{
GeometryShaderOutput output = (GeometryShaderOutput)0;
#ifdef INSTANCEDSTEREO
int i = input[0].instanceID;
#endif
{
for (int j = 0; j < 3; j++)
{
output.pos = input[j].pos;
output.uv0 = input[j].uv0;
#ifdef INSTANCEDSTEREO
output.renTarget_id = i;
#endif
outStream.Append(output);
}
}
}
+46
View File
@@ -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);
}
}
+30
View File
@@ -0,0 +1,30 @@
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
void main( in VS_Input VSInput, out PS_Input PSInput )
{
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
#endif
}
+39
View File
@@ -0,0 +1,39 @@
#include "ShaderConstants.fxh"
struct PS_Input {
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
float4 color : COLOR;
float4 worldPosition : TEXCOORD_1;
float4 fogColor : FOG_COLOR;
};
struct PS_Output {
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput ) {
PSOutput.color = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
PSOutput.color.a *= PSInput.color.a;
float2 uv = PSInput.worldPosition.xz;
float4 occlusionTexture = TEXTURE_1.Sample(TextureSampler1, uv);
// clamp the uvs
if (uv.x >= 0.0f && uv.x <= 1.0f &&
uv.y >= 0.0f && uv.y <= 1.0f &&
PSInput.worldPosition.y < occlusionTexture.a) {
PSOutput.color.a = 0.0f;
}
float mixAmount = saturate((PSInput.worldPosition.y - occlusionTexture.a)*10.0f);
float3 lighting = lerp(occlusionTexture.rgb, PSInput.color.rgb, mixAmount);
PSOutput.color.rgb *= lighting.rgb;
//apply fog
PSOutput.color.rgb = lerp(PSOutput.color.rgb, PSInput.fogColor.rgb, PSInput.fogColor.a);
}
+68
View File
@@ -0,0 +1,68 @@
#include "ShaderConstants.fxh"
struct GeometryShaderInput
{
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
float4 color : COLOR;
float4 worldPosition : TEXCOORD_1;
float4 fogColor : FOG_COLOR;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
// Per-pixel color data passed through the pixel shader.
struct GeometryShaderOutput
{
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
float4 color : COLOR;
float4 worldPosition : TEXCOORD_1;
float4 fogColor : FOG_COLOR;
#ifdef INSTANCEDSTEREO
uint renTarget_id : SV_RenderTargetArrayIndex;
#endif
};
bool inBounds(float3 worldPos)
{
bool inBounds = true;
if (worldPos.x < CLIP_MIN.x ||
worldPos.x > CLIP_MAX.x ||
worldPos.z < CLIP_MIN.y ||
worldPos.z > CLIP_MAX.y)
{
inBounds = false;
}
return inBounds;
}
// passes through the triangles, except changint the viewport id to match the instance
[maxvertexcount(3)]
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
{
GeometryShaderOutput output = (GeometryShaderOutput)0;
#ifdef INSTANCEDSTEREO
int i = input[0].instanceID;
#endif
// if (inBounds(input[0].worldPositionActual) || inBounds(input[1].worldPositionActual) || inBounds(input[2].worldPositionActual)) {
for (int j = 0; j < 3; j++) {
output.position = input[j].position;
output.uv = input[j].uv;
output.color = input[j].color;
output.worldPosition = input[j].worldPosition;
output.fogColor = input[j].fogColor;
#ifdef INSTANCEDSTEREO
output.renTarget_id = i;
#endif
outStream.Append(output);
}
// }
}
+81
View File
@@ -0,0 +1,81 @@
#include "ShaderConstants.fxh"
struct VS_Input {
float3 position : POSITION;
float2 uv0 : TEXCOORD_0;
float4 color : COLOR;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input {
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
float4 color : COLOR;
float4 worldPosition : TEXCOORD_1;
float4 fogColor : FOG_COLOR;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
void main(in VS_Input VSInput, out PS_Input PSInput)
{
float spriteSelector = VSInput.color.x*255.0f;
PSInput.uv = UV_INFO.xy + (VSInput.uv0 * UV_INFO.zw);
PSInput.uv.x += spriteSelector * UV_INFO.z;
float3 position = VSInput.position.xyz;
// subtract the offset then fmod into (0.0f, PARTICLE_BOX)
position.xyz += POSITION_OFFSET.xyz;
position.xyz = fmod(position.xyz, PARTICLE_BOX.xxx);
// centre box on origin
position.xyz -= PARTICLE_BOX.xxx * 0.5f;
// push along view vector so box is positioned more infront of camera
position.xyz += FORWARD.xyz;
// get world position
float4 worldPositionBottom = float4(position.xyz, 1.0f);
float4 worldPositionTop = float4(worldPositionBottom.xyz + (VELOCITY.xyz * SIZE_SCALE.y), 1.0f);
// get projected positions of top and bottom of particle, and top of particle in previous frame
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
float4 bottom = mul(WORLDVIEWPROJ_STEREO[i], worldPositionBottom);
float4 top = mul(WORLDVIEWPROJ_STEREO[i], worldPositionTop);
PSInput.instanceID = i;
#else
float4 bottom = mul(WORLDVIEWPROJ, worldPositionBottom);
float4 top = mul(WORLDVIEWPROJ, worldPositionTop);
#endif
// get 2d vector in screenspace between top and bottom of particle
float2 dir = (top.xy/top.w) - (bottom.xy/bottom.w);
// get 2d vector perpendicular to velocity
float2 dirPerp = normalize(float2(-dir.y, dir.x));
// choose either the top or bottom projected position using uv.y
PSInput.position = lerp(top, bottom, VSInput.uv0.y);
// offset the position of each side of the particle using uv.x
PSInput.position.xy += (0.5f - VSInput.uv0.x) * dirPerp * SIZE_SCALE.x;
// get the final colour including the lighting, distance and length scales, and per instance alpha
PSInput.color = ALPHA;
//fog
PSInput.fogColor.rgb = FOG_COLOR.rgb;
PSInput.fogColor.a = clamp(((PSInput.position.z / RENDER_DISTANCE) - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, 1.0);
worldPositionBottom.xz *= 1.0f / 64.0f; // Scale by 1/TextureDimensions to get values between
worldPositionBottom.xz += 0.5f; // Offset so that center of view is in the center of occlusion texture
worldPositionBottom.y += VIEW_POSITION.y - 0.5f;
worldPositionBottom.y *= 1.0f / 255.0f;
PSInput.worldPosition = worldPositionBottom;
}
@@ -0,0 +1,82 @@
#include "ShaderConstants.fxh"
#include "Util.fxh"
struct PS_Input
{
float4 position : SV_Position;
lpfloat4 color : COLOR;
snorm float2 uv0 : TEXCOORD_0_FB_MSAA;
snorm float2 uv1 : TEXCOORD_1_FB_MSAA;
#ifdef NEAR_WATER
float cameraDist : TEXCOORD_2;
#endif
#ifdef FOG
float4 fogColor : FOG_COLOR;
#endif
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
#if !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE) || (VERSION < 0xa000 /*D3D_FEATURE_LEVEL_10_0*/)
float4 diffuse = TEXTURE_0.Sample(TextureSampler0, PSInput.uv0);
#else
float4 diffuse = texture2D_AA(TEXTURE_0, TextureSampler0, PSInput.uv0 );
#endif
#ifdef SEASONS_FAR
diffuse.a = 1.0f;
PSInput.color.b = 1.0f;
#endif
#ifdef ALPHA_TEST
//If we know that all the verts in a triangle will have the same alpha, we should cull there first.
#ifdef ALPHA_TO_COVERAGE
float alphaThreshold = .05f;
#else
float alphaThreshold = .5f;
#endif
if(diffuse.a < alphaThreshold)
discard;
#endif
diffuse = diffuse * TEXTURE_1.Sample(TextureSampler1, PSInput.uv1);
#ifndef SEASONS
#if !defined(ALPHA_TEST) && !defined(BLEND)
diffuse.a = PSInput.color.a;
#elif defined(BLEND)
diffuse.a *= PSInput.color.a;
#ifdef NEAR_WATER
float alphaFadeOut = saturate(PSInput.cameraDist.x);
diffuse.a = lerp(diffuse.a, 1.0f, alphaFadeOut);
#endif
#endif
diffuse.rgb *= PSInput.color.rgb;
#else
float2 uv = PSInput.color.xy;
diffuse.rgb *= lerp(1.0f, TEXTURE_2.Sample(TextureSampler2, uv).rgb*2.0f, PSInput.color.b);
diffuse.rgb *= PSInput.color.aaa;
diffuse.a = 1.0f;
#endif
#ifdef FOG
diffuse.rgb = lerp( diffuse.rgb, PSInput.fogColor.rgb, PSInput.fogColor.a );
#endif
PSOutput.color = diffuse;
#ifdef VR_FEATURE
// On Rift, the transition from 0 brightness to the lowest 8 bit value is abrupt, so clamp to
// the lowest 8 bit value.
PSOutput.color = max(PSOutput.color, 1 / 255.0f);
#endif
}
@@ -0,0 +1,82 @@
#include "ShaderConstants.fxh"
struct GeometryShaderInput
{
float4 pos : SV_POSITION;
lpfloat4 color : COLOR;
snorm float2 uv0 : TEXCOORD_0;
snorm float2 uv1 : TEXCOORD_1;
#ifdef NEAR_WATER
float cameraDist : TEXCOORD_2;
#endif
#ifdef FOG
float4 fogColor : FOG_COLOR;
#endif
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
// Per-pixel color data passed through the pixel shader.
struct GeometryShaderOutput
{
float4 pos : SV_POSITION;
lpfloat4 color : COLOR;
snorm float2 uv0 : TEXCOORD_0;
snorm float2 uv1 : TEXCOORD_1;
#ifdef NEAR_WATER
float cameraDist : TEXCOORD_2;
#endif
#ifdef FOG
float4 fogColor : FOG_COLOR;
#endif
#ifdef INSTANCEDSTEREO
uint renTarget_id : SV_RenderTargetArrayIndex;
#endif
};
bool inBounds(float3 worldPos)
{
bool inBounds = true;
if (worldPos.x < CHUNK_CLIP_MIN.x ||
worldPos.x > CHUNK_CLIP_MAX.x ||
worldPos.z < CHUNK_CLIP_MIN.y ||
worldPos.z > CHUNK_CLIP_MAX.y)
{
inBounds = false;
}
return inBounds;
}
// passes through the triangles, except changint the viewport id to match the instance
[maxvertexcount(3)]
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
{
GeometryShaderOutput output = (GeometryShaderOutput)0;
#ifdef INSTANCEDSTEREO
int i = input[0].instanceID;
#endif
{
for (int j = 0; j < 3; j++)
{
output.pos = input[j].pos;
output.color = input[j].color;
output.uv0 = input[j].uv0;
output.uv1 = input[j].uv1;
#ifdef NEAR_WATER
output.cameraDist = input[j].cameraDist;
#endif
#ifdef INSTANCEDSTEREO
output.renTarget_id = i;
#endif
#ifdef FOG
output.fogColor = input[j].fogColor;
#endif
outStream.Append(output);
}
}
}
+123
View File
@@ -0,0 +1,123 @@
#include "ShaderConstants.fxh"
struct VS_Input {
float3 position : POSITION;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
float2 uv1 : TEXCOORD_1;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input {
float4 position : SV_Position;
lpfloat4 color : COLOR;
snorm float2 uv0 : TEXCOORD_0_FB_MSAA;
snorm float2 uv1 : TEXCOORD_1_FB_MSAA;
#ifdef NEAR_WATER
float cameraDist : TEXCOORD_2;
#endif
#ifdef FOG
float4 fogColor : FOG_COLOR;
#endif
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
static const float rA = 1.0;
static const float rB = 1.0;
static const float3 UNIT_Y = float3(0, 1, 0);
static const float DIST_DESATURATION = 56.0 / 255.0; //WARNING this value is also hardcoded in the water color, don'tchange
void main(in VS_Input VSInput, out PS_Input PSInput) {
PSInput.uv0 = VSInput.uv0;
PSInput.uv1 = VSInput.uv1;
PSInput.color = VSInput.color;
#ifdef AS_ENTITY_RENDERER
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul(WORLDVIEWPROJ_STEREO[i], float4(VSInput.position, 1));
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
#endif
float3 worldPos = PSInput.position;
#else
float3 worldPos = (VSInput.position.xyz * CHUNK_ORIGIN_AND_SCALE.w) + CHUNK_ORIGIN_AND_SCALE.xyz;
// Transform to view space before projection instead of all at once to avoid floating point errors
// Not required for entities because they are already offset by camera translation before rendering
// World position here is calculated above and can get huge
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul(WORLDVIEW_STEREO[i], float4(worldPos, 1 ));
PSInput.position = mul(PROJ_STEREO[i], PSInput.position);
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEW, float4( worldPos, 1 ));
PSInput.position = mul(PROJ, PSInput.position);
#endif
#endif
///// find distance from the camera
#if defined(FOG) || defined(NEAR_WATER)
#ifdef FANCY
float3 relPos = -worldPos;
float cameraDepth = length(relPos);
#ifdef NEAR_WATER
PSInput.cameraDist = cameraDepth / FAR_CHUNKS_DISTANCE;
#endif
#else
float cameraDepth = PSInput.position.z;
#ifdef NEAR_WATER
float3 relPos = -worldPos;
float cameraDist = length(relPos);
PSInput.cameraDist = cameraDist / FAR_CHUNKS_DISTANCE;
#endif
#endif
#endif
///// apply fog
#ifdef FOG
float len = cameraDepth / RENDER_DISTANCE;
#ifdef ALLOW_FADE
len += CURRENT_COLOR.r;
#endif
PSInput.fogColor.rgb = FOG_COLOR.rgb;
PSInput.fogColor.a = clamp((len - FOG_CONTROL.x) / (FOG_CONTROL.y - FOG_CONTROL.x), 0.0, 1.0);
#endif
///// water magic
#ifdef NEAR_WATER
#ifdef FANCY /////enhance water
float F = dot(normalize(relPos), UNIT_Y);
F = 1.0 - max(F, 0.1);
F = 1.0 - lerp(F*F*F*F, 1.0, min(1.0, cameraDepth / FAR_CHUNKS_DISTANCE));
PSInput.color.rg -= float2(float(F * DIST_DESATURATION).xx);
float4 depthColor = float4(PSInput.color.rgb * 0.5, 1.0);
float4 traspColor = float4(PSInput.color.rgb * 0.45, 0.8);
float4 surfColor = float4(PSInput.color.rgb, 1.0);
float4 nearColor = lerp(traspColor, depthColor, PSInput.color.a);
PSInput.color = lerp(surfColor, nearColor, F);
#else
PSInput.color.a = PSInput.position.z / FAR_CHUNKS_DISTANCE + 0.5;
#endif //FANCY
#endif
}
+40
View File
@@ -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);
}
}
+34
View File
@@ -0,0 +1,34 @@
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
float4 color : COLOR;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
void main( in VS_Input VSInput, out PS_Input PSInput )
{
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
#endif
PSInput.color = lerp( CURRENT_COLOR, FOG_COLOR, VSInput.color.r );
}
+18
View File
@@ -0,0 +1,18 @@
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
PSOutput.color = PSInput.color;
PSOutput.color.rgb *= CURRENT_COLOR.rgb * PSInput.color.a;
}
@@ -0,0 +1,52 @@
#include "ShaderConstants.fxh"
#include "Util.fxh"
#ifndef BLUR_RADIUS
#define BLUR_RADIUS 1 //base size
#endif
//HACK do not build higher res versions on DX9
#if VERSION < 0xa000 && BLUR_RADIUS > 2
#undef BLUR_RADIUS
#define BLUR_RADIUS 2
#endif
struct PS_Input
{
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
float2 pixelSide = float2(1.0 / TEXTURE_DIMENSIONS.xy);
#if BLUR_RADIUS == 1
float4 color = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
#else
float4 color = float4(0, 0, 0, 0);
for(int i = -BLUR_RADIUS / 2; i < BLUR_RADIUS / 2; ++i) {
for(int j = -BLUR_RADIUS / 2; j < BLUR_RADIUS / 2; ++j) {
float2 uv = PSInput.uv + pixelSide * float2(j, i);
uv = fmod(uv, float2(1,1));
color += TEXTURE_0.Sample(TextureSampler0, uv);
}
}
color /= BLUR_RADIUS * BLUR_RADIUS;
#endif
color.rgb = lerp(color.rgb, CURRENT_COLOR.rgb * color.rgb, color.a * CURRENT_COLOR.a);
if(CURRENT_COLOR.a > 0) {
//the alpha in diffuse is a mask
color.a = 1;
}
PSOutput.color = color;
}
+33
View File
@@ -0,0 +1,33 @@
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
float2 uv : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
void main( in VS_Input VSInput, out PS_Input PSInput )
{
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position.x, VSInput.position.y, 0, 1 ) );
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4( VSInput.position.x, VSInput.position.y, 0, 1 ));
#endif
PSInput.uv = VSInput.uv + 2.0 * VSInput.position.z * (VSInput.uv - float2(0.5, 0.5));
}
+28
View File
@@ -0,0 +1,28 @@
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
float4 color : COLOR;
float2 uv : TEXCOORD_0;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
const float4 diffuse = TEXTURE_0.Sample( TextureSampler0, PSInput.uv );
#ifdef ALPHA_TEST
if( diffuse.a < 0.5 )
{
discard;
}
#endif
PSOutput.color = diffuse * PSInput.color * DARKEN;
}
+24
View File
@@ -0,0 +1,24 @@
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
PSOutput.color = TEXTURE_0.Sample( TextureSampler0, PSInput.uv );
#ifdef ALPHA_TEST
if( PSOutput.color.a < 0.5 )
{
discard;
}
#endif
}
@@ -0,0 +1,29 @@
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
float2 uv1 : TEXCOORD_1;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main(in PS_Input PSInput, out PS_Output PSOutput)
{
float4 color = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
float4 color1 = TEXTURE_0.Sample(TextureSampler0, PSInput.uv1);
if (color.a < 0.01f)
{
color = color1;
}
else if (color.b > 0.01f) {
color = lerp(color, color1, CURRENT_COLOR.a);
}
PSOutput.color = color;
}
@@ -0,0 +1,31 @@
#include "ShaderConstants.fxh"
#include "Util.fxh"
struct PS_Input
{
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
#if !defined(TEXEL_AA) || !defined(TEXEL_AA_FEATURE) || (VERSION < 0xa000 /*D3D_FEATURE_LEVEL_10_0*/)
float4 diffuse = TEXTURE_0.Sample(TextureSampler0, PSInput.uv);
#else
float4 diffuse = texture2D_AA(TEXTURE_0, TextureSampler0, PSInput.uv);
#endif
#ifdef ALPHA_TEST
if( diffuse.a < 0.5 )
{
discard;
}
#endif
PSOutput.color = CURRENT_COLOR * diffuse;
}
@@ -0,0 +1,25 @@
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
float4 diffuse = TEXTURE_0.Sample( TextureSampler0, PSInput.uv );
if( diffuse.a < 0.5 )
{
discard;
}
PSOutput.color = CURRENT_COLOR;
}
+54
View File
@@ -0,0 +1,54 @@
float4 texture2D_AA(in Texture2D tex, in sampler texSampler, in float2 uv)
{
// Texture antialiasing
//
// The texture coordinates are modified so that the bilinear filter will be one pixel width wide instead of one texel width.
// Get the UV deltas
float2 dUVdx = ddx(uv) * TEXTURE_DIMENSIONS.xy;
float2 dUVdy = ddy(uv) * TEXTURE_DIMENSIONS.xy;
float2 dU = float2(dUVdx.x, dUVdy.x);
float2 dV = float2(dUVdx.y, dUVdy.y);
float duUV = sqrt(dot(dU, dU));
float dvUV = sqrt(dot(dV, dV));
// Determine mip map LOD
float d = max(dot(dUVdx, dUVdx), dot(dUVdy, dUVdy));
float mipLevel = .5f * log2(d);
mipLevel = mipLevel + .5f; // Mip bias to reduce aliasing
mipLevel = clamp(mipLevel, 0.0f, TEXTURE_DIMENSIONS.z);
float2 uvModified;
if( mipLevel >= 1.0f)
{
uvModified = uv;
}
else
{
// First scale the uv so that each texel has a uv range of [0,1]
float2 texelUV = frac(uv * TEXTURE_DIMENSIONS.xy);
// Initially set uvModified to the floor of the texel position
uvModified = (uv * TEXTURE_DIMENSIONS.xy) - texelUV;
// Modify the texelUV to push the uvs toward the edges.
// | | | |
// | _/ | | / |
// Change | U _/ | to | U ___/ |
// | _/ | | / |
// | / | | / |
// | X | | X |
float scalerU = 1.0f / (duUV);
float scalerV = 1.0f / (dvUV);
float2 scaler = max(float2(scalerU, scalerV), 1.0f);
texelUV = clamp(texelUV * scaler, 0.0f, .5f) + clamp(texelUV*scaler - (scaler - .5f), 0.0f, .5f);
uvModified += texelUV;
uvModified /= TEXTURE_DIMENSIONS.xy;
}
float4 diffuse = tex.Sample(TextureSampler0, uvModified);
return diffuse;
}
+43
View File
@@ -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();
}
}
+33
View File
@@ -0,0 +1,33 @@
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
float2 uv : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
void main( in VS_Input VSInput, out PS_Input PSInput )
{
PSInput.uv = VSInput.uv;
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
#endif
}
@@ -0,0 +1,17 @@
#include "ShaderConstants.fxh"
struct PS_Input
{
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
};
struct PS_Output
{
float4 color : SV_Target;
};
void main( in PS_Input PSInput, out PS_Output PSOutput )
{
PSOutput.color = float4( PSInput.uv.xy, 0, 1 );
}
+46
View File
@@ -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();
}
}
+36
View File
@@ -0,0 +1,36 @@
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
float2 uv : TEXCOORD_0;
float2 uv1 : TEXCOORD_1;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
float2 uv1 : TEXCOORD_1;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
void main(in VS_Input VSInput, out PS_Input PSInput)
{
PSInput.uv = VSInput.uv;
PSInput.uv1 = VSInput.uv1;
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul(WORLDVIEWPROJ_STEREO[i], float4(VSInput.position, 1));
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
#endif
}
+34
View File
@@ -0,0 +1,34 @@
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
float2 uv : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
void main( in VS_Input VSInput, out PS_Input PSInput )
{
PSInput.uv = VSInput.uv * GLINT_UV_SCALE.xy;
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul( WORLDVIEWPROJ_STEREO[i], float4( VSInput.position, 1 ) );
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
#endif
}
@@ -0,0 +1,35 @@
#include "ShaderConstants.fxh"
struct VS_Input
{
float3 position : POSITION;
float2 uv : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input
{
float4 position : SV_Position;
float2 uv : TEXCOORD_0;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
void main( in VS_Input VSInput, out PS_Input PSInput )
{
PSInput.uv = VSInput.uv;
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
float4 pos = mul(WORLDVIEW_STEREO[i], float4(VSInput.position, 1));
PSInput.position = mul(PROJ_STEREO[i], pos);
PSInput.instanceID = i;
#else
float4 pos = mul(WORLDVIEW, float4(VSInput.position, 1));
PSInput.position = mul(PROJ, pos);
#endif
}
+25
View File
@@ -0,0 +1,25 @@
#include "ShaderConstants.fxh"
struct PS_Input {
float4 position : SV_Position;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
float2 uv1 : TEXCOORD_1;
};
struct PS_Output {
float4 color : SV_Target;
};
void main(in PS_Input PSInput, out PS_Output PSOutput)
{
float4 diffuse = TEXTURE_0.Sample(TextureSampler0, PSInput.uv0) * TEXTURE_1.Sample(TextureSampler1, PSInput.uv1);
#ifdef ALPHA_TEST
if(diffuse.a < 0.5)
discard;
#endif
diffuse *= PSInput.color;
PSOutput.color = diffuse;
}
+50
View File
@@ -0,0 +1,50 @@
#include "ShaderConstants.fxh"
struct GeometryShaderInput
{
float4 position : SV_Position;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
float2 uv1 : TEXCOORD_1;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
// Per-pixel color data passed through the pixel shader.
struct GeometryShaderOutput
{
float4 position : SV_Position;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
float2 uv1 : TEXCOORD_1;
#ifdef INSTANCEDSTEREO
uint renTarget_id : SV_RenderTargetArrayIndex;
#endif
};
// passes through the triangles, except changint the viewport id to match the instance
[maxvertexcount(3)]
void main(triangle GeometryShaderInput input[3], inout TriangleStream<GeometryShaderOutput> outStream)
{
GeometryShaderOutput output = (GeometryShaderOutput)0;
#ifdef INSTANCEDSTEREO
int i = input[0].instanceID;
#endif
for (int j = 0; j < 3; j++)
{
output.position = input[j].position;
output.color = input[j].color;
output.uv0 = input[j].uv0;
output.uv1 = input[j].uv1;
#ifdef INSTANCEDSTEREO
output.renTarget_id = i;
#endif
outStream.Append(output);
}
}
+39
View File
@@ -0,0 +1,39 @@
#include "ShaderConstants.fxh"
struct VS_Input {
float3 position : POSITION;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
float2 uv1 : TEXCOORD_1;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
struct PS_Input {
float4 position : SV_Position;
float4 color : COLOR;
float2 uv0 : TEXCOORD_0;
float2 uv1 : TEXCOORD_1;
#ifdef INSTANCEDSTEREO
uint instanceID : SV_InstanceID;
#endif
};
void main(in VS_Input VSInput, out PS_Input PSInput)
{
#ifdef INSTANCEDSTEREO
int i = VSInput.instanceID;
PSInput.position = mul(WORLDVIEWPROJ_STEREO[i], float4(VSInput.position, 1));
PSInput.instanceID = i;
#else
PSInput.position = mul(WORLDVIEWPROJ, float4(VSInput.position, 1));
#endif
PSInput.color = VSInput.color;
PSInput.uv0.x = VSInput.uv0.x*2.0f;
PSInput.uv0.y = VSInput.uv0.y*10.0f;
PSInput.uv1 = VSInput.uv1;
}