22// scene, using tweakable intensity levels and saturation.
33// This is the final step in applying a bloom postprocess.
44
5- sampler BloomSampler : register (s0);
6- sampler BaseSampler : register (s1);
5+ #if OPENGL
6+ #define SV_POSITION POSITION
7+ #define VS_SHADERMODEL vs_3_0
8+ #define PS_SHADERMODEL ps_3_0
9+ #else
10+ #define VS_SHADERMODEL vs_4_0_level_9_1
11+ #define PS_SHADERMODEL ps_4_0_level_9_1
12+ #endif
13+
14+ texture BloomTexture;
15+ texture BaseTexture;
16+
17+ sampler2D BloomSampler = sampler_state
18+ {
19+ Texture = <BloomTexture>;
20+ Filter = Linear;
21+ AddressU = clamp ;
22+ AddressV = clamp ;
23+ };
24+
25+ sampler2D BaseSampler = sampler_state
26+ {
27+ Texture = <BaseTexture>;
28+ Filter = Linear;
29+ AddressU = clamp ;
30+ AddressV = clamp ;
31+ };
732
833float BloomIntensity;
934float BaseIntensity;
1035
1136float BloomSaturation;
1237float BaseSaturation;
1338
39+ struct VS_OUTPUT
40+ {
41+ float4 Position : SV_POSITION0;
42+ float2 TexCoord : TEXCOORD0 ;
43+ };
1444
1545// Helper for modifying the saturation of a color.
1646float4 AdjustSaturation (float4 color, float saturation)
@@ -23,11 +53,11 @@ float4 AdjustSaturation(float4 color, float saturation)
2353}
2454
2555
26- float4 PixelShaderFunction (float2 texCoord : TEXCOORD0 ) : COLOR0
56+ float4 PixelShaderFunction (VS_OUTPUT input ) : SV_TARGET0
2757{
2858 // Look up the bloom and original base image colors.
29- float4 bloom = tex2D (BloomSampler, texCoord );
30- float4 base = tex2D (BaseSampler, texCoord );
59+ float4 bloom = tex2D (BloomSampler, input.TexCoord );
60+ float4 base = tex2D (BaseSampler, input.TexCoord );
3161
3262 // Adjust color saturation and intensity.
3363 bloom = AdjustSaturation (bloom, BloomSaturation) * BloomIntensity;
@@ -46,10 +76,6 @@ technique BloomCombine
4676{
4777 pass Pass1
4878 {
49- #if SM4
50- PixelShader = compile ps_4_0_level_9_1 PixelShaderFunction ();
51- #else
52- PixelShader = compile ps_2_0 PixelShaderFunction ();
53- #endif
79+ PixelShader = compile PS_SHADERMODEL PixelShaderFunction ();
5480 }
5581}
0 commit comments