trunk/hlsl/post.fx
| r26926 | r26927 | |
| 6 | 6 | |
| 7 | 7 | sampler DiffuseSampler = sampler_state |
| 8 | 8 | { |
| 9 | | Texture = <DiffuseTexture>; |
| 10 | | MipFilter = LINEAR; |
| 11 | | MinFilter = LINEAR; |
| 12 | | MagFilter = LINEAR; |
| 13 | | AddressU = CLAMP; |
| 14 | | AddressV = CLAMP; |
| 15 | | AddressW = CLAMP; |
| 9 | Texture = <DiffuseTexture>; |
| 10 | MipFilter = LINEAR; |
| 11 | MinFilter = LINEAR; |
| 12 | MagFilter = LINEAR; |
| 13 | AddressU = CLAMP; |
| 14 | AddressV = CLAMP; |
| 15 | AddressW = CLAMP; |
| 16 | 16 | }; |
| 17 | 17 | |
| 18 | 18 | texture ShadowTexture; |
| 19 | 19 | |
| 20 | 20 | sampler ShadowSampler = sampler_state |
| 21 | 21 | { |
| 22 | | Texture = <ShadowTexture>; |
| 23 | | MipFilter = LINEAR; |
| 24 | | MinFilter = LINEAR; |
| 25 | | MagFilter = LINEAR; |
| 26 | | AddressU = WRAP; |
| 27 | | AddressV = WRAP; |
| 28 | | AddressW = WRAP; |
| 22 | Texture = <ShadowTexture>; |
| 23 | MipFilter = LINEAR; |
| 24 | MinFilter = LINEAR; |
| 25 | MagFilter = LINEAR; |
| 26 | AddressU = WRAP; |
| 27 | AddressV = WRAP; |
| 28 | AddressW = WRAP; |
| 29 | 29 | }; |
| 30 | 30 | |
| 31 | 31 | //----------------------------------------------------------------------------- |
| r26926 | r26927 | |
| 34 | 34 | |
| 35 | 35 | struct VS_OUTPUT |
| 36 | 36 | { |
| 37 | | float4 Position : POSITION; |
| 38 | | float4 Color : COLOR0; |
| 39 | | float2 TexCoord : TEXCOORD0; |
| 37 | float4 Position : POSITION; |
| 38 | float4 Color : COLOR0; |
| 39 | float2 TexCoord : TEXCOORD0; |
| 40 | 40 | }; |
| 41 | 41 | |
| 42 | 42 | struct VS_INPUT |
| 43 | 43 | { |
| 44 | | float4 Position : POSITION; |
| 45 | | float4 Color : COLOR0; |
| 46 | | float2 TexCoord : TEXCOORD0; |
| 47 | | float2 Unused : TEXCOORD1; |
| 44 | float4 Position : POSITION; |
| 45 | float4 Color : COLOR0; |
| 46 | float2 TexCoord : TEXCOORD0; |
| 47 | float2 Unused : TEXCOORD1; |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | 50 | struct PS_INPUT |
| 51 | 51 | { |
| 52 | | float4 Color : COLOR0; |
| 53 | | float2 TexCoord : TEXCOORD0; |
| 52 | float4 Color : COLOR0; |
| 53 | float2 TexCoord : TEXCOORD0; |
| 54 | 54 | }; |
| 55 | 55 | |
| 56 | 56 | //----------------------------------------------------------------------------- |
| r26926 | r26927 | |
| 63 | 63 | |
| 64 | 64 | VS_OUTPUT vs_main(VS_INPUT Input) |
| 65 | 65 | { |
| 66 | | VS_OUTPUT Output = (VS_OUTPUT)0; |
| 67 | | |
| 68 | | Output.Position = float4(Input.Position.xyz, 1.0f); |
| 69 | | Output.Position.xy /= ScreenDims; |
| 70 | | Output.Position.y = 1.0f - Output.Position.y; |
| 71 | | Output.Position.xy -= 0.5f; |
| 72 | | Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f); |
| 73 | | Output.Color = Input.Color; |
| 74 | | Output.TexCoord = Input.TexCoord + 0.5f / SourceDims; |
| 66 | VS_OUTPUT Output = (VS_OUTPUT)0; |
| 67 | |
| 68 | Output.Position = float4(Input.Position.xyz, 1.0f); |
| 69 | Output.Position.xy /= ScreenDims; |
| 70 | Output.Position.y = 1.0f - Output.Position.y; |
| 71 | Output.Position.xy -= 0.5f; |
| 72 | Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f); |
| 73 | Output.Color = Input.Color; |
| 74 | Output.TexCoord = Input.TexCoord + 0.5f / SourceDims; |
| 75 | 75 | |
| 76 | | return Output; |
| 76 | return Output; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | //----------------------------------------------------------------------------- |
| r26926 | r26927 | |
| 102 | 102 | |
| 103 | 103 | float4 ps_main(PS_INPUT Input) : COLOR |
| 104 | 104 | { |
| 105 | | float2 UsedArea = 1.0f / SourceRect; |
| 106 | | float2 HalfRect = SourceRect * 0.5f; |
| 107 | | float2 R2 = 1.0f / pow(length(UsedArea), 2.0f); |
| 108 | | // -- Screen Pincushion Calculation -- |
| 109 | | float2 PinUnitCoord = Input.TexCoord * UsedArea * 2.0f - 1.0f; |
| 110 | | float PincushionR2 = pow(length(PinUnitCoord), 2.0f) * R2; |
| 111 | | float2 PincushionCurve = PinUnitCoord * PincushionAmount * PincushionR2; |
| 112 | | float2 BaseCoord = Input.TexCoord; |
| 113 | | float2 ScanCoord = BaseCoord - 0.5f / ScreenDims; |
| 114 | | |
| 115 | | BaseCoord -= HalfRect; |
| 116 | | BaseCoord *= 1.0f - PincushionAmount * UsedArea * 0.2f; // Warning: Magic constant |
| 117 | | BaseCoord += HalfRect; |
| 118 | | BaseCoord += PincushionCurve; |
| 105 | float2 UsedArea = 1.0f / SourceRect; |
| 106 | float2 HalfRect = SourceRect * 0.5f; |
| 107 | float2 R2 = 1.0f / pow(length(UsedArea), 2.0f); |
| 108 | // -- Screen Pincushion Calculation -- |
| 109 | float2 PinUnitCoord = Input.TexCoord * UsedArea * 2.0f - 1.0f; |
| 110 | float PincushionR2 = pow(length(PinUnitCoord), 2.0f) * R2; |
| 111 | float2 PincushionCurve = PinUnitCoord * PincushionAmount * PincushionR2; |
| 112 | float2 BaseCoord = Input.TexCoord; |
| 113 | float2 ScanCoord = BaseCoord - 0.5f / ScreenDims; |
| 114 | |
| 115 | BaseCoord -= HalfRect; |
| 116 | BaseCoord *= 1.0f - PincushionAmount * UsedArea * 0.2f; // Warning: Magic constant |
| 117 | BaseCoord += HalfRect; |
| 118 | BaseCoord += PincushionCurve; |
| 119 | 119 | |
| 120 | | ScanCoord -= HalfRect; |
| 121 | | ScanCoord *= 1.0f - PincushionAmount * UsedArea * 0.2f; // Warning: Magic constant |
| 122 | | ScanCoord += HalfRect; |
| 123 | | ScanCoord += PincushionCurve; |
| 120 | ScanCoord -= HalfRect; |
| 121 | ScanCoord *= 1.0f - PincushionAmount * UsedArea * 0.2f; // Warning: Magic constant |
| 122 | ScanCoord += HalfRect; |
| 123 | ScanCoord += PincushionCurve; |
| 124 | 124 | |
| 125 | | float2 CurveClipUnitCoord = Input.TexCoord * UsedArea * 2.0f - 1.0f; |
| 126 | | float CurvatureClipR2 = pow(length(CurveClipUnitCoord), 2.0f) * R2; |
| 127 | | float2 CurvatureClipCurve = CurveClipUnitCoord * CurvatureAmount * CurvatureClipR2; |
| 128 | | float2 ScreenClipCoord = Input.TexCoord; |
| 129 | | ScreenClipCoord -= HalfRect; |
| 130 | | ScreenClipCoord *= 1.0f - CurvatureAmount * UsedArea * 0.2f; // Warning: Magic constant |
| 131 | | ScreenClipCoord += HalfRect; |
| 132 | | ScreenClipCoord += CurvatureClipCurve; |
| 125 | float2 CurveClipUnitCoord = Input.TexCoord * UsedArea * 2.0f - 1.0f; |
| 126 | float CurvatureClipR2 = pow(length(CurveClipUnitCoord), 2.0f) * R2; |
| 127 | float2 CurvatureClipCurve = CurveClipUnitCoord * CurvatureAmount * CurvatureClipR2; |
| 128 | float2 ScreenClipCoord = Input.TexCoord; |
| 129 | ScreenClipCoord -= HalfRect; |
| 130 | ScreenClipCoord *= 1.0f - CurvatureAmount * UsedArea * 0.2f; // Warning: Magic constant |
| 131 | ScreenClipCoord += HalfRect; |
| 132 | ScreenClipCoord += CurvatureClipCurve; |
| 133 | 133 | |
| 134 | | // RGB Pincushion Calculation |
| 135 | | float3 PincushionCurveX = PinUnitCoord.x * PincushionAmount * PincushionR2; |
| 136 | | float3 PincushionCurveY = PinUnitCoord.y * PincushionAmount * PincushionR2; |
| 134 | // RGB Pincushion Calculation |
| 135 | float3 PincushionCurveX = PinUnitCoord.x * PincushionAmount * PincushionR2; |
| 136 | float3 PincushionCurveY = PinUnitCoord.y * PincushionAmount * PincushionR2; |
| 137 | 137 | |
| 138 | | float4 BaseTexel = tex2D(DiffuseSampler, BaseCoord); |
| 138 | float4 BaseTexel = tex2D(DiffuseSampler, BaseCoord); |
| 139 | 139 | |
| 140 | | // -- Alpha Clipping (1px border in drawd3d does not work for some reason) -- |
| 141 | | clip((BaseCoord < 1.0f / SourceDims) ? -1 : 1); |
| 142 | | clip((BaseCoord > (SourceRect + 1.0f / SourceDims)) ? -1 : 1); |
| 140 | // -- Alpha Clipping (1px border in drawd3d does not work for some reason) -- |
| 141 | clip((BaseCoord < 1.0f / SourceDims) ? -1 : 1); |
| 142 | clip((BaseCoord > (SourceRect + 1.0f / SourceDims)) ? -1 : 1); |
| 143 | 143 | |
| 144 | | // -- Scanline Simulation -- |
| 145 | | float InnerSine = ScanCoord.y * SourceDims.y * ScanlineScale; |
| 146 | | float ScanBrightMod = sin(InnerSine * PI + ScanlineOffset * SourceDims.y); |
| 147 | | float3 ScanBrightness = lerp(1.0f, (pow(ScanBrightMod * ScanBrightMod, ScanlineHeight) * ScanlineBrightScale + 1.0f) * 0.5f, ScanlineAlpha); |
| 148 | | float3 Scanned = BaseTexel.rgb * ScanBrightness; |
| 144 | // -- Scanline Simulation -- |
| 145 | float InnerSine = ScanCoord.y * SourceDims.y * ScanlineScale; |
| 146 | float ScanBrightMod = sin(InnerSine * PI + ScanlineOffset * SourceDims.y); |
| 147 | float3 ScanBrightness = lerp(1.0f, (pow(ScanBrightMod * ScanBrightMod, ScanlineHeight) * ScanlineBrightScale + 1.0f) * 0.5f, ScanlineAlpha); |
| 148 | float3 Scanned = BaseTexel.rgb * ScanBrightness; |
| 149 | 149 | |
| 150 | | // -- Color Compression (increasing the floor of the signal without affecting the ceiling) -- |
| 151 | | Scanned = Floor + (1.0f - Floor) * Scanned; |
| 150 | // -- Color Compression (increasing the floor of the signal without affecting the ceiling) -- |
| 151 | Scanned = Floor + (1.0f - Floor) * Scanned; |
| 152 | 152 | |
| 153 | | // Shadow mask |
| 154 | | // Note: This is broken right now and needs fixed |
| 155 | | float2 ShadowFrac = frac(BaseCoord * ShadowCount); |
| 156 | | float2 ShadowCoord = ShadowFrac * ShadowUV + 0.5f / ShadowDims; |
| 157 | | float3 ShadowTexel = lerp(1.0f, tex2D(ShadowSampler, ShadowCoord).rgb, ShadowAlpha); |
| 158 | | |
| 159 | | // -- Final Pixel -- |
| 160 | | float4 Output = float4(Scanned * ShadowTexel, BaseTexel.a) * Input.Color; |
| 161 | | |
| 162 | | Output.r = pow(Output.r, Power.r); |
| 163 | | Output.g = pow(Output.g, Power.g); |
| 164 | | Output.b = pow(Output.b, Power.b); |
| 165 | | Output.a = 1.0f; |
| 153 | // Shadow mask |
| 154 | // Note: This is broken right now and needs fixed |
| 155 | float2 ShadowFrac = frac(BaseCoord * ShadowCount); |
| 156 | float2 ShadowCoord = ShadowFrac * ShadowUV + 0.5f / ShadowDims; |
| 157 | float3 ShadowTexel = lerp(1.0f, tex2D(ShadowSampler, ShadowCoord).rgb, ShadowAlpha); |
| 158 | |
| 159 | // -- Final Pixel -- |
| 160 | float4 Output = float4(Scanned * ShadowTexel, BaseTexel.a) * Input.Color; |
| 161 | |
| 162 | Output.r = pow(Output.r, Power.r); |
| 163 | Output.g = pow(Output.g, Power.g); |
| 164 | Output.b = pow(Output.b, Power.b); |
| 165 | Output.a = 1.0f; |
| 166 | 166 | |
| 167 | | return Output; |
| 167 | return Output; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | //----------------------------------------------------------------------------- |
| r26926 | r26927 | |
| 173 | 173 | |
| 174 | 174 | technique ScanMaskTechnique |
| 175 | 175 | { |
| 176 | | pass Pass0 |
| 177 | | { |
| 178 | | Lighting = FALSE; |
| 176 | pass Pass0 |
| 177 | { |
| 178 | Lighting = FALSE; |
| 179 | 179 | |
| 180 | | //Sampler[0] = <DiffuseSampler>; |
| 180 | //Sampler[0] = <DiffuseSampler>; |
| 181 | 181 | |
| 182 | | VertexShader = compile vs_3_0 vs_main(); |
| 183 | | PixelShader = compile ps_3_0 ps_main(); |
| 184 | | } |
| 182 | VertexShader = compile vs_3_0 vs_main(); |
| 183 | PixelShader = compile ps_3_0 ps_main(); |
| 184 | } |
| 185 | 185 | } |
trunk/hlsl/bloom.fx
| r26926 | r26927 | |
| 16 | 16 | |
| 17 | 17 | sampler DiffuseSampler0 = sampler_state |
| 18 | 18 | { |
| 19 | | Texture = <DiffuseA>; |
| 20 | | MipFilter = LINEAR; |
| 21 | | MinFilter = LINEAR; |
| 22 | | MagFilter = LINEAR; |
| 23 | | AddressU = CLAMP; |
| 24 | | AddressV = CLAMP; |
| 25 | | AddressW = CLAMP; |
| 19 | Texture = <DiffuseA>; |
| 20 | MipFilter = NONE; |
| 21 | MinFilter = NONE; |
| 22 | MagFilter = NONE; |
| 23 | AddressU = CLAMP; |
| 24 | AddressV = CLAMP; |
| 25 | AddressW = CLAMP; |
| 26 | 26 | }; |
| 27 | 27 | |
| 28 | 28 | sampler DiffuseSampler1 = sampler_state |
| 29 | 29 | { |
| 30 | | Texture = <DiffuseB>; |
| 31 | | MipFilter = LINEAR; |
| 32 | | MinFilter = LINEAR; |
| 33 | | MagFilter = LINEAR; |
| 34 | | AddressU = CLAMP; |
| 35 | | AddressV = CLAMP; |
| 36 | | AddressW = CLAMP; |
| 30 | Texture = <DiffuseB>; |
| 31 | MipFilter = LINEAR; |
| 32 | MinFilter = LINEAR; |
| 33 | MagFilter = LINEAR; |
| 34 | AddressU = CLAMP; |
| 35 | AddressV = CLAMP; |
| 36 | AddressW = CLAMP; |
| 37 | 37 | }; |
| 38 | 38 | |
| 39 | 39 | sampler DiffuseSampler2 = sampler_state |
| 40 | 40 | { |
| 41 | | Texture = <DiffuseC>; |
| 42 | | MipFilter = LINEAR; |
| 43 | | MinFilter = LINEAR; |
| 44 | | MagFilter = LINEAR; |
| 45 | | AddressU = CLAMP; |
| 46 | | AddressV = CLAMP; |
| 47 | | AddressW = CLAMP; |
| 41 | Texture = <DiffuseC>; |
| 42 | MipFilter = LINEAR; |
| 43 | MinFilter = LINEAR; |
| 44 | MagFilter = LINEAR; |
| 45 | AddressU = CLAMP; |
| 46 | AddressV = CLAMP; |
| 47 | AddressW = CLAMP; |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | 50 | sampler DiffuseSampler3 = sampler_state |
| 51 | 51 | { |
| 52 | | Texture = <DiffuseD>; |
| 53 | | MipFilter = LINEAR; |
| 54 | | MinFilter = LINEAR; |
| 55 | | MagFilter = LINEAR; |
| 56 | | AddressU = CLAMP; |
| 57 | | AddressV = CLAMP; |
| 58 | | AddressW = CLAMP; |
| 52 | Texture = <DiffuseD>; |
| 53 | MipFilter = LINEAR; |
| 54 | MinFilter = LINEAR; |
| 55 | MagFilter = LINEAR; |
| 56 | AddressU = CLAMP; |
| 57 | AddressV = CLAMP; |
| 58 | AddressW = CLAMP; |
| 59 | 59 | }; |
| 60 | 60 | |
| 61 | 61 | sampler DiffuseSampler4 = sampler_state |
| 62 | 62 | { |
| 63 | | Texture = <DiffuseE>; |
| 64 | | MipFilter = LINEAR; |
| 65 | | MinFilter = LINEAR; |
| 66 | | MagFilter = LINEAR; |
| 67 | | AddressU = CLAMP; |
| 68 | | AddressV = CLAMP; |
| 69 | | AddressW = CLAMP; |
| 63 | Texture = <DiffuseE>; |
| 64 | MipFilter = LINEAR; |
| 65 | MinFilter = LINEAR; |
| 66 | MagFilter = LINEAR; |
| 67 | AddressU = CLAMP; |
| 68 | AddressV = CLAMP; |
| 69 | AddressW = CLAMP; |
| 70 | 70 | }; |
| 71 | 71 | |
| 72 | 72 | sampler DiffuseSampler5 = sampler_state |
| 73 | 73 | { |
| 74 | | Texture = <DiffuseF>; |
| 75 | | MipFilter = LINEAR; |
| 76 | | MinFilter = LINEAR; |
| 77 | | MagFilter = LINEAR; |
| 78 | | AddressU = CLAMP; |
| 79 | | AddressV = CLAMP; |
| 80 | | AddressW = CLAMP; |
| 74 | Texture = <DiffuseF>; |
| 75 | MipFilter = LINEAR; |
| 76 | MinFilter = LINEAR; |
| 77 | MagFilter = LINEAR; |
| 78 | AddressU = CLAMP; |
| 79 | AddressV = CLAMP; |
| 80 | AddressW = CLAMP; |
| 81 | 81 | }; |
| 82 | 82 | |
| 83 | 83 | sampler DiffuseSampler6 = sampler_state |
| 84 | 84 | { |
| 85 | | Texture = <DiffuseG>; |
| 86 | | MipFilter = LINEAR; |
| 87 | | MinFilter = LINEAR; |
| 88 | | MagFilter = LINEAR; |
| 89 | | AddressU = CLAMP; |
| 90 | | AddressV = CLAMP; |
| 91 | | AddressW = CLAMP; |
| 85 | Texture = <DiffuseG>; |
| 86 | MipFilter = LINEAR; |
| 87 | MinFilter = LINEAR; |
| 88 | MagFilter = LINEAR; |
| 89 | AddressU = CLAMP; |
| 90 | AddressV = CLAMP; |
| 91 | AddressW = CLAMP; |
| 92 | 92 | }; |
| 93 | 93 | |
| 94 | 94 | sampler DiffuseSampler7 = sampler_state |
| 95 | 95 | { |
| 96 | | Texture = <DiffuseH>; |
| 97 | | MipFilter = LINEAR; |
| 98 | | MinFilter = LINEAR; |
| 99 | | MagFilter = LINEAR; |
| 100 | | AddressU = CLAMP; |
| 101 | | AddressV = CLAMP; |
| 102 | | AddressW = CLAMP; |
| 96 | Texture = <DiffuseH>; |
| 97 | MipFilter = LINEAR; |
| 98 | MinFilter = LINEAR; |
| 99 | MagFilter = LINEAR; |
| 100 | AddressU = CLAMP; |
| 101 | AddressV = CLAMP; |
| 102 | AddressW = CLAMP; |
| 103 | 103 | }; |
| 104 | 104 | |
| 105 | 105 | sampler DiffuseSampler8 = sampler_state |
| 106 | 106 | { |
| 107 | | Texture = <DiffuseI>; |
| 108 | | MipFilter = LINEAR; |
| 109 | | MinFilter = LINEAR; |
| 110 | | MagFilter = LINEAR; |
| 111 | | AddressU = CLAMP; |
| 112 | | AddressV = CLAMP; |
| 113 | | AddressW = CLAMP; |
| 107 | Texture = <DiffuseI>; |
| 108 | MipFilter = LINEAR; |
| 109 | MinFilter = LINEAR; |
| 110 | MagFilter = LINEAR; |
| 111 | AddressU = CLAMP; |
| 112 | AddressV = CLAMP; |
| 113 | AddressW = CLAMP; |
| 114 | 114 | }; |
| 115 | 115 | |
| 116 | 116 | sampler DiffuseSampler9 = sampler_state |
| 117 | 117 | { |
| 118 | | Texture = <DiffuseJ>; |
| 119 | | MipFilter = LINEAR; |
| 120 | | MinFilter = LINEAR; |
| 121 | | MagFilter = LINEAR; |
| 122 | | AddressU = CLAMP; |
| 123 | | AddressV = CLAMP; |
| 124 | | AddressW = CLAMP; |
| 118 | Texture = <DiffuseJ>; |
| 119 | MipFilter = LINEAR; |
| 120 | MinFilter = LINEAR; |
| 121 | MagFilter = LINEAR; |
| 122 | AddressU = CLAMP; |
| 123 | AddressV = CLAMP; |
| 124 | AddressW = CLAMP; |
| 125 | 125 | }; |
| 126 | 126 | |
| 127 | 127 | sampler DiffuseSamplerA = sampler_state |
| 128 | 128 | { |
| 129 | | Texture = <DiffuseK>; |
| 130 | | MipFilter = LINEAR; |
| 131 | | MinFilter = LINEAR; |
| 132 | | MagFilter = LINEAR; |
| 133 | | AddressU = CLAMP; |
| 134 | | AddressV = CLAMP; |
| 135 | | AddressW = CLAMP; |
| 129 | Texture = <DiffuseK>; |
| 130 | MipFilter = LINEAR; |
| 131 | MinFilter = LINEAR; |
| 132 | MagFilter = LINEAR; |
| 133 | AddressU = CLAMP; |
| 134 | AddressV = CLAMP; |
| 135 | AddressW = CLAMP; |
| 136 | 136 | }; |
| 137 | 137 | |
| 138 | 138 | //----------------------------------------------------------------------------- |
| r26926 | r26927 | |
| 141 | 141 | |
| 142 | 142 | struct VS_OUTPUT |
| 143 | 143 | { |
| 144 | | float4 Position : POSITION; |
| 145 | | float4 Color : COLOR0; |
| 146 | | float2 TexCoord : TEXCOORD0; |
| 144 | float4 Position : POSITION; |
| 145 | float4 Color : COLOR0; |
| 146 | float2 TexCoord : TEXCOORD0; |
| 147 | 147 | }; |
| 148 | 148 | |
| 149 | 149 | struct VS_INPUT |
| 150 | 150 | { |
| 151 | | float3 Position : POSITION; |
| 152 | | float4 Color : COLOR0; |
| 153 | | float2 TexCoord : TEXCOORD0; |
| 154 | | float2 Unused : TEXCOORD1; |
| 151 | float3 Position : POSITION; |
| 152 | float4 Color : COLOR0; |
| 153 | float2 TexCoord : TEXCOORD0; |
| 154 | float2 Unused : TEXCOORD1; |
| 155 | 155 | }; |
| 156 | 156 | |
| 157 | 157 | struct PS_INPUT |
| 158 | 158 | { |
| 159 | | float4 Color : COLOR0; |
| 160 | | float2 TexCoord : TEXCOORD0; |
| 159 | float4 Color : COLOR0; |
| 160 | float2 TexCoord : TEXCOORD0; |
| 161 | 161 | }; |
| 162 | 162 | |
| 163 | 163 | //----------------------------------------------------------------------------- |
| 164 | 164 | // Bloom Vertex Shader |
| 165 | 165 | //----------------------------------------------------------------------------- |
| 166 | 166 | |
| 167 | | uniform float2 TargetSize; |
| 167 | uniform float2 ScreenSize; |
| 168 | uniform float2 TextureSize; |
| 168 | 169 | |
| 169 | 170 | VS_OUTPUT vs_main(VS_INPUT Input) |
| 170 | 171 | { |
| 171 | | VS_OUTPUT Output = (VS_OUTPUT)0; |
| 172 | | |
| 173 | | Output.Position = float4(Input.Position.xyz, 1.0f); |
| 174 | | Output.Position.xy /= TargetSize; |
| 175 | | Output.Position.y = 1.0f - Output.Position.y; |
| 176 | | Output.Position.xy -= float2(0.5f, 0.5f); |
| 177 | | Output.Position.xy *= float2(2.0f, 2.0f); |
| 178 | | Output.Color = Input.Color; |
| 179 | | Output.TexCoord = (Input.Position.xy + 0.5f) / TargetSize; |
| 172 | VS_OUTPUT Output = (VS_OUTPUT)0; |
| 173 | |
| 174 | Output.Position = float4(Input.Position.xyz, 1.0f); |
| 175 | Output.Position.xy /= ScreenSize; |
| 176 | Output.Position.y = 1.0f - Output.Position.y; |
| 177 | Output.Position.xy -= float2(0.5f, 0.5f); |
| 178 | Output.Position.xy *= float2(2.0f, 2.0f); |
| 179 | Output.Color = Input.Color; |
| 180 | Output.TexCoord = (Input.Position.xy + 0.5f) / ScreenSize; |
| 180 | 181 | |
| 181 | | return Output; |
| 182 | return Output; |
| 182 | 183 | } |
| 183 | 184 | |
| 184 | 185 | //----------------------------------------------------------------------------- |
| r26926 | r26927 | |
| 191 | 192 | |
| 192 | 193 | float4 ps_main(PS_INPUT Input) : COLOR |
| 193 | 194 | { |
| 194 | | float3 texel0 = tex2D(DiffuseSampler0, Input.TexCoord).rgb; |
| 195 | | float3 texel1 = tex2D(DiffuseSampler1, Input.TexCoord).rgb; |
| 196 | | float3 texel2 = tex2D(DiffuseSampler2, Input.TexCoord).rgb; |
| 197 | | float3 texel3 = tex2D(DiffuseSampler3, Input.TexCoord).rgb; |
| 198 | | float3 texel4 = tex2D(DiffuseSampler4, Input.TexCoord).rgb; |
| 199 | | float3 texel5 = tex2D(DiffuseSampler5, Input.TexCoord).rgb; |
| 200 | | float3 texel6 = tex2D(DiffuseSampler6, Input.TexCoord).rgb; |
| 201 | | float3 texel7 = tex2D(DiffuseSampler7, Input.TexCoord).rgb; |
| 202 | | float3 texel8 = tex2D(DiffuseSampler8, Input.TexCoord).rgb; |
| 203 | | float3 texel9 = tex2D(DiffuseSampler9, Input.TexCoord).rgb; |
| 204 | | float3 texelA = tex2D(DiffuseSamplerA, Input.TexCoord).rgb; |
| 195 | float3 texel0 = tex2D(DiffuseSampler0, Input.TexCoord).rgb; |
| 196 | float3 texel1 = tex2D(DiffuseSampler1, Input.TexCoord).rgb; |
| 197 | float3 texel2 = tex2D(DiffuseSampler2, Input.TexCoord).rgb; |
| 198 | float3 texel3 = tex2D(DiffuseSampler3, Input.TexCoord).rgb; |
| 199 | float3 texel4 = tex2D(DiffuseSampler4, Input.TexCoord).rgb; |
| 200 | float3 texel5 = tex2D(DiffuseSampler5, Input.TexCoord).rgb; |
| 201 | float3 texel6 = tex2D(DiffuseSampler6, Input.TexCoord).rgb; |
| 202 | float3 texel7 = tex2D(DiffuseSampler7, Input.TexCoord).rgb; |
| 203 | float3 texel8 = tex2D(DiffuseSampler8, Input.TexCoord).rgb; |
| 204 | float3 texel9 = tex2D(DiffuseSampler9, Input.TexCoord).rgb; |
| 205 | float3 texelA = tex2D(DiffuseSamplerA, Input.TexCoord).rgb; |
| 205 | 206 | |
| 206 | | texel0 = texel0 * Level0123Weight.x; |
| 207 | | texel1 = texel1 * Level0123Weight.y; |
| 208 | | texel2 = texel2 * Level0123Weight.z; |
| 209 | | texel3 = texel3 * Level0123Weight.w; |
| 210 | | texel4 = texel4 * Level4567Weight.x; |
| 211 | | texel5 = texel5 * Level4567Weight.y; |
| 212 | | texel6 = texel6 * Level4567Weight.z; |
| 213 | | texel7 = texel7 * Level4567Weight.w; |
| 214 | | texel8 = texel8 * Level89AWeight.x; |
| 215 | | texel9 = texel9 * Level89AWeight.y; |
| 216 | | texelA = texelA * Level89AWeight.z; |
| 207 | texel0 = texel0 * Level0123Weight.x; |
| 208 | texel1 = texel1 * Level0123Weight.y; |
| 209 | texel2 = texel2 * Level0123Weight.z; |
| 210 | texel3 = texel3 * Level0123Weight.w; |
| 211 | texel4 = texel4 * Level4567Weight.x; |
| 212 | texel5 = texel5 * Level4567Weight.y; |
| 213 | texel6 = texel6 * Level4567Weight.z; |
| 214 | texel7 = texel7 * Level4567Weight.w; |
| 215 | texel8 = texel8 * Level89AWeight.x; |
| 216 | texel9 = texel9 * Level89AWeight.y; |
| 217 | texelA = texelA * Level89AWeight.z; |
| 217 | 218 | |
| 218 | | float4 sum = float4(texel0 + texel1 + texel2 + texel3 + texel4 + |
| 219 | | texel5 + texel6 + texel7 + texel8 + texel9 + texelA, 1.0f); |
| 220 | | return sum; |
| 219 | float4 sum = float4(texel0 + texel1 + texel2 + texel3 + texel4 + |
| 220 | texel5 + texel6 + texel7 + texel8 + texel9 + texelA, 1.0f); |
| 221 | return sum; |
| 221 | 222 | } |
| 222 | 223 | |
| 223 | 224 | //----------------------------------------------------------------------------- |
| r26926 | r26927 | |
| 226 | 227 | |
| 227 | 228 | technique TestTechnique |
| 228 | 229 | { |
| 229 | | pass Pass0 |
| 230 | | { |
| 231 | | Lighting = FALSE; |
| 230 | pass Pass0 |
| 231 | { |
| 232 | Lighting = FALSE; |
| 232 | 233 | |
| 233 | | Sampler[0] = <DiffuseSampler0>; // 2048x2048 |
| 234 | | Sampler[1] = <DiffuseSampler1>; // 1024x1024 |
| 235 | | Sampler[2] = <DiffuseSampler2>; // 512x512 |
| 236 | | Sampler[3] = <DiffuseSampler3>; // 256x256 |
| 237 | | Sampler[4] = <DiffuseSampler4>; // 128x128 |
| 238 | | Sampler[5] = <DiffuseSampler5>; // 64x64 |
| 239 | | Sampler[6] = <DiffuseSampler6>; // 32x32 |
| 240 | | Sampler[7] = <DiffuseSampler7>; // 16x16 |
| 241 | | Sampler[8] = <DiffuseSampler8>; // 8x8 |
| 242 | | Sampler[9] = <DiffuseSampler9>; // 4x4 |
| 243 | | Sampler[10] = <DiffuseSamplerA>; // 2x2 |
| 234 | Sampler[0] = <DiffuseSampler0>; // 2048x2048 |
| 235 | Sampler[1] = <DiffuseSampler1>; // 1024x1024 |
| 236 | Sampler[2] = <DiffuseSampler2>; // 512x512 |
| 237 | Sampler[3] = <DiffuseSampler3>; // 256x256 |
| 238 | Sampler[4] = <DiffuseSampler4>; // 128x128 |
| 239 | Sampler[5] = <DiffuseSampler5>; // 64x64 |
| 240 | Sampler[6] = <DiffuseSampler6>; // 32x32 |
| 241 | Sampler[7] = <DiffuseSampler7>; // 16x16 |
| 242 | Sampler[8] = <DiffuseSampler8>; // 8x8 |
| 243 | Sampler[9] = <DiffuseSampler9>; // 4x4 |
| 244 | Sampler[10] = <DiffuseSamplerA>; // 2x2 |
| 244 | 245 | |
| 245 | | VertexShader = compile vs_3_0 vs_main(); |
| 246 | | PixelShader = compile ps_3_0 ps_main(); |
| 247 | | } |
| 246 | VertexShader = compile vs_3_0 vs_main(); |
| 247 | PixelShader = compile ps_3_0 ps_main(); |
| 248 | } |
| 248 | 249 | } |
trunk/src/osd/windows/d3dhlsl.c
| r26926 | r26927 | |
| 1051 | 1051 | post_effect->add_uniform("Power", uniform::UT_VEC3, uniform::CU_POST_POWER); |
| 1052 | 1052 | post_effect->add_uniform("Floor", uniform::UT_VEC3, uniform::CU_POST_FLOOR); |
| 1053 | 1053 | |
| 1054 | bloom_effect->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT); |
| 1055 | |
| 1054 | 1056 | initialized = true; |
| 1055 | 1057 | |
| 1056 | 1058 | return 0; |
| r26926 | r26927 | |
| 1629 | 1631 | |
| 1630 | 1632 | HRESULT result = (*d3dintf->device.set_render_target)(d3d->get_device(), 0, rt->target[2]); |
| 1631 | 1633 | |
| 1632 | | result = (*d3dintf->device.clear)(d3d->get_device(), 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(1,0,0,0), 0, 0); |
| 1634 | result = (*d3dintf->device.clear)(d3d->get_device(), 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0); |
| 1633 | 1635 | if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result); |
| 1634 | 1636 | |
| 1635 | 1637 | curr_effect->begin(&num_passes, 0); |
| r26926 | r26927 | |
| 1697 | 1699 | } |
| 1698 | 1700 | |
| 1699 | 1701 | curr_effect = bloom_effect; |
| 1702 | curr_effect->update_uniforms(); |
| 1700 | 1703 | |
| 1701 | 1704 | float weight0123[4] = { options->bloom_level0_weight, options->bloom_level1_weight, options->bloom_level2_weight, options->bloom_level3_weight }; |
| 1702 | 1705 | float weight4567[4] = { options->bloom_level4_weight, options->bloom_level5_weight, options->bloom_level6_weight, options->bloom_level7_weight }; |
| 1703 | 1706 | float weight89A[3] = { options->bloom_level8_weight, options->bloom_level9_weight, options->bloom_level10_weight }; |
| 1707 | float temp0[2] = { 1024.0f, 512.0f }; |
| 1704 | 1708 | curr_effect->set_vector("Level0123Weight", 4, weight0123); |
| 1705 | 1709 | curr_effect->set_vector("Level4567Weight", 4, weight4567); |
| 1706 | 1710 | curr_effect->set_vector("Level89AWeight", 3, weight89A); |
| 1707 | | curr_effect->set_vector("TargetSize", 2, &screendims.c.x); |
| 1711 | curr_effect->set_vector("ScreenSize", 2, &screendims.c.x); |
| 1712 | curr_effect->set_vector("TextureSize", 2, temp0); |
| 1708 | 1713 | |
| 1709 | 1714 | curr_effect->set_texture("DiffuseA", rt->render_texture[2]); |
| 1710 | 1715 | |