Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <renderer/RenderSetup.hlsl>
- struct VS_INPUT
- {
- float3 ssPosition : POSITION;
- float2 texCoord : TEXCOORD0;
- float4 color : COLOR0;
- };
- struct VS_OUTPUT
- {
- float2 texCoord : TEXCOORD0;
- float4 color : COLOR0;
- float4 ssPosition : SV_POSITION;
- };
- struct PS_INPUT
- {
- float2 texCoord : TEXCOORD0;
- float4 color : COLOR0;
- };
- sampler2D baseTexture;
- sampler2D depthTexture;
- sampler2D normalTexture;
- cbuffer LayerConstants
- {
- float startTime;
- float amount;
- };
- /**
- * Vertex shader.
- */
- VS_OUTPUT SFXBasicVS(VS_INPUT input)
- {
- VS_OUTPUT output;
- output.ssPosition = float4(input.ssPosition, 1);
- output.texCoord = input.texCoord + texelCenter;
- output.color = input.color;
- return output;
- }
- float2 clamp_tex2D( sampler2D tex, float2 coord )
- {
- // TODO: remove this and fix sampler using wrapped instead of clamped addressing for depthTexture
- return tex2D( tex, clamp( coord, float2( 0.001, 0.001 ), float2( 0.999, 0.999 ) ) );
- }
- //old colors
- //const float4 edgeColorBlue = float4(-0.02, 0.5, 1, 0) * 3.0;
- //const float4 edgeColorDarkBlue = float4(0.07, 0.05, 1, 0) * 1.5;
- //const float4 edgeColorOrange = float4(1.0, 0.25, 0.0, 0);
- //const float4 edgeColorDarkOrange = float4(1.0, 0.1, 0, 0);
- //const float4 edgeColorDarkRed = float4(1.0, 0.01, 0, 0);
- //const float4 edgeColorGreen = float4(0.2, 0.7, 0.00, 0);
- //const float4 edgeColorDarkGreen = float4(0.07, 0.7, 0.00, 0);
- const float4 edgeColorDark = float4 (0.01, 0.01, 0.01, 0);
- // my colors
- const float4 edgeColorMarines = float4 (0.0, 1, 0, 0) * 10;
- const float4 edgeColorMarineStructures = float4 (1, 0, 0, 0) * 10;
- const float4 edgeColorAliens = float4 (0, 1, 3, 0) * 10;
- const float4 edgeColorGorges = float4 (0, 0.7, 0, 0) * 10;
- const float4 edgeColorAlienStructures = float4 (0, 1, 0.5, 0) * 3;
- const float4 edgeColorBorder = float4 (0.3, 0, 0, 0) * 0.1;
- float4 SFXDarkVisionPS(PS_INPUT input) : COLOR0
- {
- float2 texCoord = input.texCoord;
- float4 inputPixel = tex2D(baseTexture, texCoord);
- if (amount == 0)
- {
- return inputPixel;
- }
- float2 depth1 = tex2D(depthTexture, input.texCoord).rg;
- float fadeout = min(1, pow(2.0, 0.5 - depth1.r*.4));
- // Flashlight on
- float offset = 0.0002 * (0.5 + depth1.g) * max(fadeout, 0.33); // thicker edge around entities, especially nearby
- float depth2 = clamp_tex2D(depthTexture, texCoord + float2(-offset, -offset)).r;
- float depth3 = clamp_tex2D(depthTexture, texCoord + float2(-offset, offset)).r;
- float depth4 = clamp_tex2D(depthTexture, texCoord + float2( offset, -offset)).r;
- float depth5 = clamp_tex2D(depthTexture, texCoord + float2( offset, offset)).r;
- float4 baseColor=float4(.9,0.9,.9,0);
- float edge =
- abs(depth2 - depth1.r) +
- abs(depth3 - depth1.r) +
- abs(depth4 - depth1.r) +
- abs(depth5 - depth1.r);
- edge = min(1.2, edge);
- if (depth1.g > 0.5) // entities
- {
- float min_intensity = 0.5; // entity colouring base intensity
- edge = (edge + min_intensity);
- if ( depth1.g > 0.99 ) // marines 1
- {
- return lerp(inputPixel, edgeColorMarines * edge, amount * (0.1 + edge) * 0.3);
- }
- else if ( depth1.g > 0.97 ) // marine structures 0.98
- {
- return lerp(inputPixel, edgeColorMarineStructures * edge, amount * (0.1 + edge) * 0.3);
- }
- else if ( depth1.g > 0.95 ) // alien players 0.96
- {
- return lerp( inputPixel, edgeColorAliens * edge, amount * (0.1 + edge) * 0.1);
- }
- else if ( depth1.g > 0.93 ) // gorges 0.94
- {
- return lerp( inputPixel, edgeColorAliens * edge, amount * (0.1 + edge) * 0.1);
- }
- else { // targets and world ents 0.9
- return lerp( inputPixel, edgeColorAlienStructures * edge, amount * (0.1 + edge) * 0.15);
- }
- } else // world geometry
- {
- float fog = 0.04 * pow(3, depth1.r * 0.1);
- edge = pow(edge, 0.5) * step( depth1.r, 100 ); // no edges for skyboxes
- float maxStrength = 0.95;
- float brightness = inputPixel.r + inputPixel.g * 1.5 + inputPixel.b;
- float4 edgeColor2 = float4(0.3 - depth1.r * 0.005 + brightness * 0.1, fog * 0.02, brightness * 0.3 + fog, 0);
- return lerp(inputPixel * (5 - 4 * amount), edgeColor2 * (edge + brightness * 0.15) * max(1, fog), min(maxStrength, amount));
- //return saturate (inputPixel + edgeColorDark * 0.1 * amount * edge );
- //return lerp(inputPixel, (edgeColor2 * edge), 0.01 * amount);
- }
- }
Add Comment
Please, Sign In to add comment