summaryrefslogtreecommitdiff
path: root/materialsystem/stdshaders/emissive_scroll_blended_pass_ps2x.fxc
blob: 0a0c6fdb8c1913b6f230c9a50022d4491b35b54c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//========= Copyright � 1996-2006, Valve Corporation, All rights reserved. ============//

// Includes =======================================================================================
// STATIC: "CONVERT_TO_SRGB" "0..1"	[ps20b][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
// STATIC: "CONVERT_TO_SRGB" "0..1"	[ps30][= g_pHardwareConfig->NeedsShaderSRGBConversion()] [PC]
// STATIC: "CONVERT_TO_SRGB" "0..0"	[= 0] [XBOX]
#include "common_vertexlitgeneric_dx9.h"

// Texture Samplers ===============================================================================
sampler g_tBaseSampler		: register( s0 );
sampler g_tFlowSampler		: register( s1 );
sampler g_tSelfIllumSampler	: register( s2 );

// Shaders Constants and Globals ==================================================================
const float4 g_vPackedConst0 : register( c0 );
#define g_flBlendStrength   g_vPackedConst0.x
#define g_flTime			g_vPackedConst0.y

const float2 g_vEmissiveScrollVector : register( c1 );
const float3 g_cSelfIllumTint : register( c2 );

// Interpolated values ============================================================================
struct PS_INPUT
{
	float2 vTexCoord0 : TEXCOORD0;
};

// Main ===========================================================================================
//float4 main( PS_INPUT i ) : COLOR // Non-HDR for debugging
float4 main( PS_INPUT i ) : COLOR
{
	// Color texture
	float4 cBaseColor = tex2D( g_tBaseSampler, i.vTexCoord0.xy );

	// Fetch from dudv map and then fetch from emissive texture with new uv's & scroll
	float4 vFlowValue = tex2D( g_tFlowSampler, i.vTexCoord0.xy );
	float2 vEmissiveTexCoord = vFlowValue.xy + ( g_vEmissiveScrollVector.xy * g_flTime );
	float4 cEmissiveColor = tex2D( g_tSelfIllumSampler, vEmissiveTexCoord.xy );

	//===============//
	// Combine terms //
	//===============//
	float4 result;
	result.rgb = cBaseColor.rgb * cEmissiveColor.rgb * g_cSelfIllumTint.rgb;
	result.rgb *= g_flBlendStrength;

	// Set alpha to 0.0f so it doesn't change dest alpha (I should probably disable dest alpha writes)
	result.a = 0.0f;

	return FinalOutput( result, 0, PIXEL_FOG_TYPE_NONE, TONEMAP_SCALE_LINEAR );
}