Previous 15994 Revisions Next

r11576 Wednesday 18th May, 2011 at 02:16:10 UTC by MooglyGuy
HLSL Updates [Ryan Holtz, Bat Country Entertainment]
- Potential fix for some crashing reported by users
- Split color convolution and deconvergence into separate shaders for potential GPU savings down the line
- Added light and heavy variants of the color convolution shader, the former with YIQ colorspace removed
- Re-worked defocus to occur prior to shadow mask application, as it would be on a real monitor.
- Removed Edge Detection, as it was just for fun and can easily be added in by users if desired.
- Split "pincushion" into "Pincushion" and "Screen Curvature", the former affecting the only the displayed image and the latter only affecting the shadow mask.
[hlsl]color.fx* color_heavy.fx* color_light.fx* deconverge.fx* focus.fx post.fx
[src/osd/windows]drawd3d.c winmain.c winmain.h

hlsl/color_light.fx
r0r11576
1//-----------------------------------------------------------------------------
2// Color-Convolution Effect
3//-----------------------------------------------------------------------------
4
5texture Diffuse;
6
7sampler DiffuseSampler = sampler_state
8{
9   Texture   = <Diffuse>;
10   MipFilter = LINEAR;
11   MinFilter = LINEAR;
12   MagFilter = LINEAR;
13   AddressU = CLAMP;
14   AddressV = CLAMP;
15   AddressW = CLAMP;
16};
17
18//-----------------------------------------------------------------------------
19// Vertex Definitions
20//-----------------------------------------------------------------------------
21
22struct VS_OUTPUT
23{
24   float4 Position : POSITION;
25   float4 Color : COLOR0;
26   float2 TexCoord : TEXCOORD0;
27   float2 ExtraInfo : TEXCOORD1;
28};
29
30struct VS_INPUT
31{
32   float4 Position : POSITION;
33   float4 Color : COLOR0;
34   float2 TexCoord : TEXCOORD0;
35   float2 ExtraInfo : TEXCOORD1;
36};
37
38struct PS_INPUT
39{
40   float4 Color : COLOR0;
41   float2 TexCoord : TEXCOORD0;
42   float2 ExtraInfo : TEXCOORD1;
43};
44
45//-----------------------------------------------------------------------------
46// Post-Processing Vertex Shader
47//-----------------------------------------------------------------------------
48
49uniform float TargetWidth;
50uniform float TargetHeight;
51
52uniform float RawWidth;
53uniform float RawHeight;
54
55uniform float WidthRatio;
56uniform float HeightRatio;
57
58VS_OUTPUT vs_main(VS_INPUT Input)
59{
60   VS_OUTPUT Output = (VS_OUTPUT)0;
61   
62   Output.Position = float4(Input.Position.xyz, 1.0f);
63   Output.Position.x /= TargetWidth;
64   Output.Position.y /= TargetHeight;
65   Output.Position.y = 1.0f - Output.Position.y;
66   Output.Position.x -= 0.5f;
67   Output.Position.y -= 0.5f;
68   Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
69   Output.Color = Input.Color;
70   Output.TexCoord = Input.TexCoord;//(Input.TexCoord - float2(0.5f, 0.5f)) / 8.0f + float2(0.25f, 0.25f);
71   Output.ExtraInfo = Input.ExtraInfo;
72
73   return Output;
74}
75
76//-----------------------------------------------------------------------------
77// Post-Processing Pixel Shader
78//-----------------------------------------------------------------------------
79
80uniform float RedFromRed = 1.0f;
81uniform float RedFromGrn = 0.0f;
82uniform float RedFromBlu = 0.0f;
83uniform float GrnFromRed = 0.0f;
84uniform float GrnFromGrn = 1.0f;
85uniform float GrnFromBlu = 0.0f;
86uniform float BluFromRed = 0.0f;
87uniform float BluFromGrn = 0.0f;
88uniform float BluFromBlu = 1.0f;
89
90uniform float RedOffset = 0.0f;
91uniform float GrnOffset = 0.0f;
92uniform float BluOffset = 0.0f;
93
94uniform float RedScale = 1.0f;
95uniform float GrnScale = 1.0f;
96uniform float BluScale = 1.0f;
97
98uniform float RedFloor = 0.0f;
99uniform float GrnFloor = 0.0f;
100uniform float BluFloor = 0.0f;
101
102uniform float Saturation = 1.0f;
103
104uniform float RedPower = 2.2f;
105uniform float GrnPower = 2.2f;
106uniform float BluPower = 2.2f;
107
108float4 ps_main(PS_INPUT Input) : COLOR
109{
110   float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
111   
112   // -- RGB Tint & Shift --
113   float ShiftedRed = dot(BaseTexel, float3(RedFromRed, RedFromGrn, RedFromBlu));
114   float ShiftedGrn = dot(BaseTexel, float3(GrnFromRed, GrnFromGrn, GrnFromBlu));
115   float ShiftedBlu = dot(BaseTexel, float3(BluFromRed, BluFromGrn, BluFromBlu));
116   
117   // -- RGB Offset & Scale --
118   float3 RGBScale = float3(RedScale, GrnScale, BluScale);
119   float3 RGBShift = float3(RedOffset, GrnOffset, BluOffset);
120   float3 OutTexel = float3(ShiftedRed, ShiftedGrn, ShiftedBlu) * RGBScale + RGBShift;
121   
122   // -- Saturation --
123   float3 Gray = float3(0.3f, 0.59f, 0.11f);
124   float OutLuma = dot(OutTexel, Gray);
125   float3 OutChroma = OutTexel - OutLuma;
126   float3 OutRGB = OutLuma + OutChroma * Saturation;
127   
128   OutRGB.r = pow(OutRGB.r, RedPower);
129   OutRGB.g = pow(OutRGB.g, GrnPower);
130   OutRGB.b = pow(OutRGB.b, BluPower);
131
132   // -- Color Compression (increasing the floor of the signal without affecting the ceiling) --
133   OutRGB = float3(RedFloor + (1.0f - RedFloor) * OutRGB.r, GrnFloor + (1.0f - GrnFloor) * OutRGB.g, BluFloor + (1.0f - BluFloor) * OutRGB.b);
134
135   // -- Final Pixel --
136   float4 Output = lerp(Input.Color, float4(OutRGB, BaseTexel.a) * Input.Color, Input.ExtraInfo.x);
137   
138   return BaseTexel;
139}
140
141//-----------------------------------------------------------------------------
142// Color-Convolution Technique
143//-----------------------------------------------------------------------------
144
145technique ColorTechnique
146{
147   pass Pass0
148   {
149      Lighting = FALSE;
150
151      VertexShader = compile vs_3_0 vs_main();
152      PixelShader  = compile ps_3_0 ps_main();
153   }
154}
hlsl/post.fx
r11575r11576
11//-----------------------------------------------------------------------------
2// Post-Processing Effect
2// Scanline & Shadowmask Effect
33//-----------------------------------------------------------------------------
44
55texture Diffuse;
r11575r11576
3838   float4 Color : COLOR0;
3939   float2 TexCoord : TEXCOORD0;
4040   float2 ExtraInfo : TEXCOORD1;
41   float3 CoordX : TEXCOORD2;
42   float3 CoordY : TEXCOORD3;
43   float2 ShadowCoord : TEXCOORD4;
4441};
4542
4643struct VS_INPUT
r11575r11576
5653   float4 Color : COLOR0;
5754   float2 TexCoord : TEXCOORD0;
5855   float2 ExtraInfo : TEXCOORD1;
59   float3 CoordX : TEXCOORD2;
60   float3 CoordY : TEXCOORD3;
61   float2 ShadowCoord : TEXCOORD4;
6256};
6357
6458//-----------------------------------------------------------------------------
65// Post-Processing Vertex Shader
59// Scanline & Shadowmask Vertex Shader
6660//-----------------------------------------------------------------------------
6761
68uniform float RedConvergeX;
69uniform float RedConvergeY;
70uniform float GrnConvergeX;
71uniform float GrnConvergeY;
72uniform float BluConvergeX;
73uniform float BluConvergeY;
74
7562uniform float TargetWidth;
7663uniform float TargetHeight;
7764
r11575r11576
8168uniform float WidthRatio;
8269uniform float HeightRatio;
8370
84uniform float RedRadialConvergeX;
85uniform float RedRadialConvergeY;
86uniform float GrnRadialConvergeX;
87uniform float GrnRadialConvergeY;
88uniform float BluRadialConvergeX;
89uniform float BluRadialConvergeY;
90
9171VS_OUTPUT vs_main(VS_INPUT Input)
9272{
9373   VS_OUTPUT Output = (VS_OUTPUT)0;
9474   
95   float2 invDims = float2(1.0f / RawWidth, 1.0f / RawHeight);
96   float2 Ratios = float2(1.0f / WidthRatio, 1.0f / HeightRatio);
9775   Output.Position = float4(Input.Position.xyz, 1.0f);
9876   Output.Position.x /= TargetWidth;
9977   Output.Position.y /= TargetHeight;
r11575r11576
10280   Output.Position.y -= 0.5f;
10381   Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
10482   Output.Color = Input.Color;
105   Output.TexCoord = Input.TexCoord;//(Input.TexCoord - float2(0.5f, 0.5f)) / 8.0f + float2(0.25f, 0.25f);
83   float2 InvTexSize = float2(1.0f / TargetWidth, 1.0f / TargetHeight);
84   float2 TexCoord = (Input.Position.xy * InvTexSize) / float2(WidthRatio, HeightRatio);
85   Output.TexCoord = TexCoord;//(Input.TexCoord - float2(0.5f, 0.5f)) / 8.0f + float2(0.25f, 0.25f);
10686   Output.ExtraInfo = Input.ExtraInfo;
10787   
108   Output.CoordX.x = ((((Output.TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + RedRadialConvergeX / RawWidth) + 0.5f) * Ratios.x + RedConvergeX * invDims.x;
109   Output.CoordX.y = ((((Output.TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + GrnRadialConvergeX / RawWidth) + 0.5f) * Ratios.x + GrnConvergeX * invDims.x;
110   Output.CoordX.z = ((((Output.TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + BluRadialConvergeX / RawWidth) + 0.5f) * Ratios.x + GrnConvergeX * invDims.x;
111   
112   Output.CoordY.x = ((((Output.TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + RedRadialConvergeY / RawHeight) + 0.5f) * Ratios.y + RedConvergeY * invDims.y;
113   Output.CoordY.y = ((((Output.TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + GrnRadialConvergeY / RawHeight) + 0.5f) * Ratios.y + BluConvergeY * invDims.y;
114   Output.CoordY.z = ((((Output.TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + BluRadialConvergeY / RawHeight) + 0.5f) * Ratios.y + BluConvergeY * invDims.y;
115   
116   Output.ShadowCoord = Output.TexCoord * float2(RawWidth, RawHeight);
11788   return Output;
11889}
11990
r11575r11576
12394
12495uniform float PI = 3.14159265f;
12596
126uniform float PincushionAmountX = 0.1f;
127uniform float PincushionAmountY = 0.1f;
97uniform float PincushionAmount = 0.00f;
98uniform float CurvatureAmount = 0.08f;
12899
129100uniform float ScanlineAmount = 1.0f;
130101uniform float ScanlineScale = 1.0f;
r11575r11576
132103uniform float ScanlineBrightOffset = 1.0f;
133104uniform float ScanlineOffset = 1.0f;
134105
135uniform float RedFromRed = 1.0f;
136uniform float RedFromGrn = 0.0f;
137uniform float RedFromBlu = 0.0f;
138uniform float GrnFromRed = 0.0f;
139uniform float GrnFromGrn = 1.0f;
140uniform float GrnFromBlu = 0.0f;
141uniform float BluFromRed = 0.0f;
142uniform float BluFromGrn = 0.0f;
143uniform float BluFromBlu = 1.0f;
144
145uniform float YfromY = 1.0f;
146uniform float YfromI = 0.0f;
147uniform float YfromQ = 0.0f;
148uniform float IfromY = 0.0f;
149uniform float IfromI = 1.0f;
150uniform float IfromQ = 0.0f;
151uniform float QfromY = 0.0f;
152uniform float QfromI = 0.0f;
153uniform float QfromQ = 1.0f;
154
155uniform float RedOffset = 0.0f;
156uniform float GrnOffset = 0.0f;
157uniform float BluOffset = 0.0f;
158
159uniform float RedScale = 1.0f;
160uniform float GrnScale = 1.0f;
161uniform float BluScale = 1.0f;
162
163uniform float RedFloor = 0.0f;
164uniform float GrnFloor = 0.0f;
165uniform float BluFloor = 0.0f;
166
167uniform float Saturation = 1.0f;
168
169uniform float YScale = 1.0f;
170uniform float IScale = 1.0f;
171uniform float QScale = 1.0f;
172uniform float YOffset = 0.0f;
173uniform float IOffset = 0.0f;
174uniform float QOffset = 0.0f;
175
176uniform float RedPower = 2.2f;
177uniform float GrnPower = 2.2f;
178uniform float BluPower = 2.2f;
179
180uniform float EdgeDetectScale = 1.0f;
181uniform float EdgeToBaseRatio = 0.0f;
182
183uniform float SubsampleLength = 3.0f;
184
185uniform float CurrFrame = 0.0f;
186uniform float CrawlWidth = 3.0f;
187uniform float CrawlHeight = 3.0f;
188uniform float CrawlRate = 3.0f;
189
190106uniform float UseShadow = 0.0f;
191107uniform float ShadowBrightness = 1.0f;
192108uniform float ShadowPixelSizeX = 3.0f;
193109uniform float ShadowPixelSizeY = 3.0f;
110uniform float ShadowMaskSizeX = 3.0f;
111uniform float ShadowMaskSizeY = 3.0f;
194112uniform float ShadowU = 0.375f;
195113uniform float ShadowV = 0.375f;
196114uniform float ShadowWidth = 8.0f;
r11575r11576
201119   float2 Ratios = float2(WidthRatio, HeightRatio);
202120
203121   // -- Screen Pincushion Calculation --
204   float2 UnitCoord = Input.TexCoord * Ratios * 2.0f - 1.0f;
122   float2 PinViewpointOffset = float2(0.0f, 0.0f);
123   float2 PinUnitCoord = (Input.TexCoord + PinViewpointOffset) * Ratios * 2.0f - 1.0f;
124   float PincushionR2 = pow(length(PinUnitCoord), 2.0f) / pow(length(Ratios), 2.0f);
125   float2 PincushionCurve = PinUnitCoord * PincushionAmount * PincushionR2;
126   float2 BaseCoord = Input.TexCoord;
127   BaseCoord -= 0.5f / Ratios;
128   BaseCoord *= 1.0f - PincushionAmount * Ratios * 0.2f; // Warning: Magic constant
129   BaseCoord += 0.5f / Ratios;
130   BaseCoord += PincushionCurve;
205131
206   float PincushionR2 = pow(length(UnitCoord),2.0f) / pow(length(Ratios), 2.0f);
207   float2 PincushionCurve = UnitCoord * PincushionAmountX * PincushionR2;
208   float2 BaseCoord = Input.TexCoord + PincushionCurve;
132   float2 CurveViewpointOffset = float2(0.2f, 0.0f);
133   float2 CurveUnitCoord = (Input.TexCoord + CurveViewpointOffset) * 2.0f - 1.0f;
134   float CurvatureR2 = pow(length(CurveUnitCoord),2.0f) / pow(length(Ratios), 2.0f);
135   float2 CurvatureCurve = CurveUnitCoord * CurvatureAmount * CurvatureR2;
136   float2 ScreenCurveCoord = Input.TexCoord + CurvatureCurve;
209137
138   float2 CurveClipUnitCoord = Input.TexCoord * Ratios * 2.0f - 1.0f;
139   float CurvatureClipR2 = pow(length(CurveClipUnitCoord),2.0f) / pow(length(Ratios), 2.0f);
140   float2 CurvatureClipCurve = CurveClipUnitCoord * CurvatureAmount * CurvatureClipR2;
141   float2 ScreenClipCoord = Input.TexCoord;
142   ScreenClipCoord -= 0.5f / Ratios;
143   ScreenClipCoord *= 1.0f - CurvatureAmount * Ratios * 0.2f; // Warning: Magic constant
144   ScreenClipCoord += 0.5f / Ratios;
145   ScreenClipCoord += CurvatureClipCurve;
146
210147   // RGB Pincushion Calculation
211   float3 PincushionCurveX = UnitCoord.x * PincushionAmountX * PincushionR2;
212   float3 PincushionCurveY = UnitCoord.y * PincushionAmountX * PincushionR2;
148   float3 PincushionCurveX = PinUnitCoord.x * PincushionAmount * PincushionR2;
149   float3 PincushionCurveY = PinUnitCoord.y * PincushionAmount * PincushionR2;
213150
214   float4 BaseTexel = tex2D(DiffuseSampler, BaseCoord);
151   float4 BaseTexel = tex2D(DiffuseSampler, BaseCoord * Ratios);
215152
216153   // -- Alpha Clipping (1px border in drawd3d does not work for some reason) --
217   clip((BaseCoord.x < 1.0f / TargetWidth) ? -1 : 1);
218   clip((BaseCoord.y < 3.0f / TargetHeight) ? -1 : 1);
219   clip((BaseCoord.x > 1.0f / WidthRatio) ? -1 : 1);
220   clip((BaseCoord.y > 1.0f / HeightRatio) ? -1 : 1);
154   clip((ScreenClipCoord.x < 1.0f / TargetWidth) ? -1 : 1);
155   clip((ScreenClipCoord.y < 3.0f / TargetHeight) ? -1 : 1);
156   clip((ScreenClipCoord.x > 1.0f / WidthRatio) ? -1 : 1);
157   clip((ScreenClipCoord.y > 1.0f / HeightRatio) ? -1 : 1);
221158
222   // -- Chroma Subsampling & RGB Deconvergence --
223   float3 CoordX = Input.CoordX + PincushionCurveX;
224   float3 CoordY = Input.CoordY + PincushionCurveY;
225   float RedTexel = tex2D(DiffuseSampler, float2(CoordX.x, CoordY.x)).r;
226   float GrnTexel = tex2D(DiffuseSampler, float2(CoordX.y, CoordY.y)).g;
227   float BluTexel = tex2D(DiffuseSampler, float2(CoordX.z, CoordY.z)).b;
228
229   float ChromaSubsampleWidth = RawWidth / SubsampleLength;
230   float LumaSubsampleWidth = RawWidth / SubsampleLength; // For now
231   float3 YFrac = frac((CoordY * RawHeight) / CrawlHeight);
232   float3 CrawlPercent = frac(CurrFrame / CrawlRate + (YFrac - frac(YFrac * CrawlWidth) / CrawlWidth)) * CrawlWidth;
233   float3 ChromaCoordX = Input.CoordX + CrawlPercent / RawWidth;
234   float3 ChannelFrac = frac((ChromaCoordX + PincushionCurveX) * ChromaSubsampleWidth);
235   ChromaCoordX = ((ChromaCoordX + PincushionCurveX) * ChromaSubsampleWidth - ChannelFrac) / ChromaSubsampleWidth + ChannelFrac / (ChromaSubsampleWidth * 2.0f);
236   float3 ChromaCoordY = Input.CoordY + PincushionCurveY;
237
238   float3 BaseTexelRight = tex2D(DiffuseSampler, BaseCoord + float2(1.0f / TargetWidth, 0.0f)).rgb;
239   float3 BaseTexelUpper = tex2D(DiffuseSampler, BaseCoord + float2(0.0f, 1.0f / TargetHeight)).rgb;
240
241   float3 UpperDifference = abs(BaseTexel.rgb - BaseTexelUpper);
242   float3 RightDifference = abs(BaseTexel.rgb - BaseTexelRight);
243   float3 EdgeDifference = (UpperDifference + RightDifference) * EdgeDetectScale;
244
245   float RedChromaTexel = tex2D(DiffuseSampler, float2(ChromaCoordX.x, ChromaCoordY.x)).r;
246   float GrnChromaTexel = tex2D(DiffuseSampler, float2(ChromaCoordX.y, ChromaCoordY.y)).g;
247   float BluChromaTexel = tex2D(DiffuseSampler, float2(ChromaCoordX.z, ChromaCoordY.z)).b;
248
249   float3 LumaTexel = float3(RedTexel, GrnTexel, BluTexel);
250   float3 ChromaTexel = lerp(float3(RedChromaTexel, GrnChromaTexel, BluChromaTexel), LumaTexel, ChannelFrac);
251
252   // -- RGB Tint & Shift --
253   float ShiftedRed = dot(LumaTexel, float3(RedFromRed, RedFromGrn, RedFromBlu));
254   float ShiftedGrn = dot(LumaTexel, float3(GrnFromRed, GrnFromGrn, GrnFromBlu));
255   float ShiftedBlu = dot(LumaTexel, float3(BluFromRed, BluFromGrn, BluFromBlu));
256   float ShiftedRedChroma = dot(ChromaTexel, float3(RedFromRed, RedFromGrn, RedFromBlu));
257   float ShiftedGrnChroma = dot(ChromaTexel, float3(GrnFromRed, GrnFromGrn, GrnFromBlu));
258   float ShiftedBluChroma = dot(ChromaTexel, float3(BluFromRed, BluFromGrn, BluFromBlu));
259   float EdgeRed = dot(EdgeDifference, float3(RedFromRed, RedFromGrn, RedFromBlu));
260   float EdgeGrn = dot(EdgeDifference, float3(GrnFromRed, GrnFromGrn, GrnFromBlu));
261   float EdgeBlu = dot(EdgeDifference, float3(BluFromRed, BluFromGrn, BluFromBlu));
262   
263   // -- RGB Offset & Scale --
264   float3 OutTexelLuma = float3(ShiftedRed, ShiftedGrn, ShiftedBlu) * float3(RedScale, GrnScale, BluScale) + float3(RedOffset, GrnOffset, BluOffset);
265   float3 OutTexelChroma = float3(ShiftedRedChroma, ShiftedGrnChroma, ShiftedBluChroma) * float3(RedScale, GrnScale, BluScale) + float3(RedOffset, GrnOffset, BluOffset);
266   
267   // -- Saturation --
268   float OutLumaLuma = dot(OutTexelLuma, float3(0.3f, 0.59f, 0.11f));
269   float3 OutChromaLuma = OutTexelLuma - float3(OutLumaLuma, OutLumaLuma, OutLumaLuma);
270   float3 SaturatedLuma = OutLumaLuma + OutChromaLuma * Saturation;
271   
272   float OutLumaChroma = dot(OutTexelChroma, float3(0.3f, 0.59f, 0.11f));
273   float3 OutChromaChroma = OutTexelChroma  - float3(OutLumaChroma, OutLumaChroma, OutLumaChroma);
274   float3 SaturatedChroma = OutLumaChroma + OutChromaChroma * Saturation;
275   
276   // -- YIQ Convolution --
277   float Y = dot(SaturatedLuma, float3(0.299f, 0.587f, 0.114f));
278   float I = dot(SaturatedChroma, float3(0.595716f, -0.274453f, -0.321263f));
279   float Q = dot(SaturatedChroma, float3(0.211456f, -0.522591f, 0.311135f));
280   Y = dot(float3(Y, I, Q), float3(YfromY, YfromI, YfromQ));
281   I = dot(float3(Y, I, Q), float3(IfromY, IfromI, IfromQ));
282   Q = dot(float3(Y, I, Q), float3(QfromY, QfromI, QfromQ));
283   float3 OutYIQ = float3(Y, I, Q) * float3(YScale, IScale, QScale) + float3(YOffset, IOffset, QOffset);
284   float3 OutRGB = float3(dot(OutYIQ, float3(1.0f, 0.9563f, 0.6210f)), dot(OutYIQ, float3(1.0f, -0.2721f, -0.6474f)), dot(OutYIQ, float3(1.0f, -1.1070f, 1.7046f)));
285
286   OutRGB = lerp(OutRGB, float3(EdgeRed, EdgeGrn, EdgeBlu), EdgeToBaseRatio);
287
288   OutRGB.r = pow(OutRGB.r, RedPower);
289   OutRGB.g = pow(OutRGB.g, GrnPower);
290   OutRGB.b = pow(OutRGB.b, BluPower);
291
292   // -- Color Compression (increasing the floor of the signal without affecting the ceiling) --
293   OutRGB = float3(RedFloor + (1.0f - RedFloor) * OutRGB.r, GrnFloor + (1.0f - GrnFloor) * OutRGB.g, BluFloor + (1.0f - BluFloor) * OutRGB.b);
294
295159   // -- Scanline Simulation --
296   float3 ScanBrightness = lerp(1.0f, abs(sin(((CoordY * RawHeight * ScanlineScale) * PI + ScanlineOffset * RawHeight))) * ScanlineBrightScale + ScanlineBrightOffset, ScanlineAmount);
297   float3 Scanned = OutRGB * ScanBrightness;
160   float3 ScanBrightness = lerp(1.0f, abs(sin(((BaseCoord.y * Ratios.y * RawHeight * ScanlineScale) * PI + ScanlineOffset * RawHeight))) * ScanlineBrightScale + ScanlineBrightOffset, ScanlineAmount);
161   float3 Scanned = BaseTexel.rgb * ScanBrightness;
298162
299   float2 ShadowCoord = BaseCoord * float2(RawWidth, RawHeight);
300   float ShadowCoordX = frac(ShadowCoord.x / ShadowPixelSizeX) * ShadowU + 0.5f / (ShadowWidth * ShadowU);
301   float ShadowCoordY = frac(ShadowCoord.y / ShadowPixelSizeY) * ShadowV + 0.5f / (ShadowHeight * ShadowV);
302   float3 ShadowTexel = lerp(1.0f, tex2D(ShadowSampler, float2(ShadowCoordX, ShadowCoordY)), UseShadow);
163   float2 ShadowDims = float2(ShadowWidth, ShadowHeight);
164   float2 ShadowUV = float2(ShadowU, ShadowV);
165   float2 ShadowMaskSize = float2(ShadowMaskSizeX, ShadowMaskSizeY);
166   float2 ShadowFrac = frac(ScreenCurveCoord * ShadowMaskSize * Ratios * 0.5f);
167   float2 ShadowCoord = ShadowFrac * ShadowUV + 2.5f / ShadowDims;
168   float3 ShadowTexel = lerp(1.0f, tex2D(ShadowSampler, ShadowCoord), UseShadow);
303169   
304170   // -- Final Pixel --
305171   float4 Output = lerp(Input.Color, float4(Scanned * lerp(1.0f, ShadowTexel * 1.25f, ShadowBrightness), BaseTexel.a) * Input.Color, Input.ExtraInfo.x);
r11575r11576
308174}
309175
310176//-----------------------------------------------------------------------------
311// Post-Processing Effect
177// Scanline & Shadowmask Effect
312178//-----------------------------------------------------------------------------
313179
314technique TestTechnique
180technique ScanMaskTechnique
315181{
316182   pass Pass0
317183   {
hlsl/color_heavy.fx
r0r11576
1//-----------------------------------------------------------------------------
2// Color-Convolution Effect
3//-----------------------------------------------------------------------------
4
5texture Diffuse;
6
7sampler DiffuseSampler = sampler_state
8{
9   Texture   = <Diffuse>;
10   MipFilter = LINEAR;
11   MinFilter = LINEAR;
12   MagFilter = LINEAR;
13   AddressU = CLAMP;
14   AddressV = CLAMP;
15   AddressW = CLAMP;
16};
17
18//-----------------------------------------------------------------------------
19// Vertex Definitions
20//-----------------------------------------------------------------------------
21
22struct VS_OUTPUT
23{
24   float4 Position : POSITION;
25   float4 Color : COLOR0;
26   float2 TexCoord : TEXCOORD0;
27   float2 ExtraInfo : TEXCOORD1;
28};
29
30struct VS_INPUT
31{
32   float4 Position : POSITION;
33   float4 Color : COLOR0;
34   float2 TexCoord : TEXCOORD0;
35   float2 ExtraInfo : TEXCOORD1;
36};
37
38struct PS_INPUT
39{
40   float4 Color : COLOR0;
41   float2 TexCoord : TEXCOORD0;
42   float2 ExtraInfo : TEXCOORD1;
43};
44
45//-----------------------------------------------------------------------------
46// Post-Processing Vertex Shader
47//-----------------------------------------------------------------------------
48
49uniform float TargetWidth;
50uniform float TargetHeight;
51
52uniform float RawWidth;
53uniform float RawHeight;
54
55uniform float WidthRatio;
56uniform float HeightRatio;
57
58VS_OUTPUT vs_main(VS_INPUT Input)
59{
60   VS_OUTPUT Output = (VS_OUTPUT)0;
61   
62   Output.Position = float4(Input.Position.xyz, 1.0f);
63   Output.Position.x /= TargetWidth;
64   Output.Position.y /= TargetHeight;
65   Output.Position.y = 1.0f - Output.Position.y;
66   Output.Position.x -= 0.5f;
67   Output.Position.y -= 0.5f;
68   Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
69   Output.Color = Input.Color;
70   Output.TexCoord = Input.TexCoord;//(Input.TexCoord - float2(0.5f, 0.5f)) / 8.0f + float2(0.25f, 0.25f);
71   Output.ExtraInfo = Input.ExtraInfo;
72
73   return Output;
74}
75
76//-----------------------------------------------------------------------------
77// Post-Processing Pixel Shader
78//-----------------------------------------------------------------------------
79
80uniform float RedFromRed = 1.0f;
81uniform float RedFromGrn = 0.0f;
82uniform float RedFromBlu = 0.0f;
83uniform float GrnFromRed = 0.0f;
84uniform float GrnFromGrn = 1.0f;
85uniform float GrnFromBlu = 0.0f;
86uniform float BluFromRed = 0.0f;
87uniform float BluFromGrn = 0.0f;
88uniform float BluFromBlu = 1.0f;
89
90uniform float YfromY = 1.0f;
91uniform float YfromI = 0.0f;
92uniform float YfromQ = 0.0f;
93uniform float IfromY = 0.0f;
94uniform float IfromI = 1.0f;
95uniform float IfromQ = 0.0f;
96uniform float QfromY = 0.0f;
97uniform float QfromI = 0.0f;
98uniform float QfromQ = 1.0f;
99
100uniform float RedOffset = 0.0f;
101uniform float GrnOffset = 0.0f;
102uniform float BluOffset = 0.0f;
103
104uniform float RedScale = 1.0f;
105uniform float GrnScale = 1.0f;
106uniform float BluScale = 1.0f;
107
108uniform float RedFloor = 0.0f;
109uniform float GrnFloor = 0.0f;
110uniform float BluFloor = 0.0f;
111
112uniform float Saturation = 1.0f;
113
114uniform float YScale = 1.0f;
115uniform float IScale = 1.0f;
116uniform float QScale = 1.0f;
117uniform float YOffset = 0.0f;
118uniform float IOffset = 0.0f;
119uniform float QOffset = 0.0f;
120
121uniform float RedPower = 2.2f;
122uniform float GrnPower = 2.2f;
123uniform float BluPower = 2.2f;
124
125uniform float YSubsampleLength = 3.0f;
126uniform float ISubsampleLength = 3.0f;
127uniform float QSubsampleLength = 3.0f;
128
129float4 ps_main(PS_INPUT Input) : COLOR
130{
131   // -- Bandwidth Subsampling --
132   float YSubsampleWidth = (RawWidth * 2.0f) / YSubsampleLength;
133   float ISubsampleWidth = (RawWidth * 2.0f) / ISubsampleLength;
134   float QSubsampleWidth = (RawWidth * 2.0f) / QSubsampleLength;
135   float3 SubsampleWidth = float3(YSubsampleWidth, ISubsampleWidth, QSubsampleWidth);
136   float3 SubsampleFrac = frac(Input.TexCoord.x * SubsampleWidth);
137   float3 SubsampleCoord = (Input.TexCoord.x * SubsampleWidth - SubsampleFrac) / SubsampleWidth + SubsampleFrac / (SubsampleWidth * 2.0f);
138
139   float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
140   
141   float3 YTexel = tex2D(DiffuseSampler, float2(SubsampleCoord.x, Input.TexCoord.y)).rgb;
142   float3 ITexel = tex2D(DiffuseSampler, float2(SubsampleCoord.y, Input.TexCoord.y)).rgb;
143   float3 QTexel = tex2D(DiffuseSampler, float2(SubsampleCoord.z, Input.TexCoord.y)).rgb;
144   
145   float3 LastYTexel = tex2D(DiffuseSampler, float2(SubsampleCoord.x - SubsampleFrac.x / RawWidth, Input.TexCoord.y)).rgb;
146   float3 LastITexel = tex2D(DiffuseSampler, float2(SubsampleCoord.y - SubsampleFrac.y / RawWidth, Input.TexCoord.y)).rgb;
147   float3 LastQTexel = tex2D(DiffuseSampler, float2(SubsampleCoord.z - SubsampleFrac.z / RawWidth, Input.TexCoord.y)).rgb;
148   
149   YTexel = lerp(LastYTexel, YTexel, SubsampleFrac.x);
150   ITexel = lerp(LastITexel, ITexel, SubsampleFrac.y);
151   QTexel = lerp(LastQTexel, QTexel, SubsampleFrac.z);
152
153   // -- RGB Tint & Shift --
154   float ShiftedRedY = dot(YTexel, float3(RedFromRed, RedFromGrn, RedFromBlu));
155   float ShiftedGrnY = dot(YTexel, float3(GrnFromRed, GrnFromGrn, GrnFromBlu));
156   float ShiftedBluY = dot(YTexel, float3(BluFromRed, BluFromGrn, BluFromBlu));
157   float ShiftedRedI = dot(ITexel, float3(RedFromRed, RedFromGrn, RedFromBlu));
158   float ShiftedGrnI = dot(ITexel, float3(GrnFromRed, GrnFromGrn, GrnFromBlu));
159   float ShiftedBluI = dot(ITexel, float3(BluFromRed, BluFromGrn, BluFromBlu));
160   float ShiftedRedQ = dot(QTexel, float3(RedFromRed, RedFromGrn, RedFromBlu));
161   float ShiftedGrnQ = dot(QTexel, float3(GrnFromRed, GrnFromGrn, GrnFromBlu));
162   float ShiftedBluQ = dot(QTexel, float3(BluFromRed, BluFromGrn, BluFromBlu));
163   
164   // -- RGB Offset & Scale --
165   float3 RGBScale = float3(RedScale, GrnScale, BluScale);
166   float3 RGBShift = float3(RedOffset, GrnOffset, BluOffset);
167   float3 OutTexelY = float3(ShiftedRedY, ShiftedGrnY, ShiftedBluY) * RGBScale + RGBShift;
168   float3 OutTexelI = float3(ShiftedRedI, ShiftedGrnI, ShiftedBluI) * RGBScale + RGBShift;
169   float3 OutTexelQ = float3(ShiftedRedQ, ShiftedGrnQ, ShiftedBluQ) * RGBScale + RGBShift;
170   
171   // -- Saturation --
172   float3 Gray = float3(0.3f, 0.59f, 0.11f);
173   float OutLumaY = dot(OutTexelY, Gray);
174   float OutLumaI = dot(OutTexelI, Gray);
175   float OutLumaQ = dot(OutTexelQ, Gray);
176   float3 OutChromaY = OutTexelY - OutLumaY;
177   float3 OutChromaI = OutTexelI - OutLumaI;
178   float3 OutChromaQ = OutTexelQ - OutLumaQ;
179   float3 SaturatedY = OutLumaY + OutChromaY * Saturation;
180   float3 SaturatedI = OutLumaI + OutChromaI * Saturation;
181   float3 SaturatedQ = OutLumaQ + OutChromaQ * Saturation;
182   
183   // -- YIQ Convolution --
184   float Y = dot(SaturatedY, float3(0.299f, 0.587f, 0.114f));
185   float I = dot(SaturatedI, float3(0.595716f, -0.274453f, -0.321263f));
186   float Q = dot(SaturatedQ, float3(0.211456f, -0.522591f, 0.311135f));
187   Y = dot(float3(Y, I, Q), float3(YfromY, YfromI, YfromQ));
188   I = dot(float3(Y, I, Q), float3(IfromY, IfromI, IfromQ));
189   Q = dot(float3(Y, I, Q), float3(QfromY, QfromI, QfromQ));
190   float3 OutYIQ = float3(Y, I, Q) * float3(YScale, IScale, QScale) + float3(YOffset, IOffset, QOffset);
191   float3 OutRGB = float3(dot(OutYIQ, float3(1.0f, 0.9563f, 0.6210f)), dot(OutYIQ, float3(1.0f, -0.2721f, -0.6474f)), dot(OutYIQ, float3(1.0f, -1.1070f, 1.7046f)));
192
193   OutRGB.r = pow(OutRGB.r, RedPower);
194   OutRGB.g = pow(OutRGB.g, GrnPower);
195   OutRGB.b = pow(OutRGB.b, BluPower);
196
197   // -- Color Compression (increasing the floor of the signal without affecting the ceiling) --
198   OutRGB = float3(RedFloor + (1.0f - RedFloor) * OutRGB.r, GrnFloor + (1.0f - GrnFloor) * OutRGB.g, BluFloor + (1.0f - BluFloor) * OutRGB.b);
199
200   // -- Final Pixel --
201   float4 Output = lerp(Input.Color, float4(OutRGB, BaseTexel.a) * Input.Color, Input.ExtraInfo.x);
202   
203   return BaseTexel;
204}
205
206//-----------------------------------------------------------------------------
207// Color-Convolution Technique
208//-----------------------------------------------------------------------------
209
210technique ColorTechnique
211{
212   pass Pass0
213   {
214      Lighting = FALSE;
215
216      VertexShader = compile vs_3_0 vs_main();
217      PixelShader  = compile ps_3_0 ps_main();
218   }
219}
hlsl/color.fx
r0r11576
1//-----------------------------------------------------------------------------
2// Color-Convolution Effect
3//-----------------------------------------------------------------------------
4
5texture Diffuse;
6
7sampler DiffuseSampler = sampler_state
8{
9   Texture   = <Diffuse>;
10   MipFilter = LINEAR;
11   MinFilter = LINEAR;
12   MagFilter = LINEAR;
13   AddressU = CLAMP;
14   AddressV = CLAMP;
15   AddressW = CLAMP;
16};
17
18//-----------------------------------------------------------------------------
19// Vertex Definitions
20//-----------------------------------------------------------------------------
21
22struct VS_OUTPUT
23{
24   float4 Position : POSITION;
25   float4 Color : COLOR0;
26   float2 TexCoord : TEXCOORD0;
27   float2 ExtraInfo : TEXCOORD1;
28};
29
30struct VS_INPUT
31{
32   float4 Position : POSITION;
33   float4 Color : COLOR0;
34   float2 TexCoord : TEXCOORD0;
35   float2 ExtraInfo : TEXCOORD1;
36};
37
38struct PS_INPUT
39{
40   float4 Color : COLOR0;
41   float2 TexCoord : TEXCOORD0;
42   float2 ExtraInfo : TEXCOORD1;
43};
44
45//-----------------------------------------------------------------------------
46// Post-Processing Vertex Shader
47//-----------------------------------------------------------------------------
48
49uniform float TargetWidth;
50uniform float TargetHeight;
51
52uniform float RawWidth;
53uniform float RawHeight;
54
55uniform float WidthRatio;
56uniform float HeightRatio;
57
58VS_OUTPUT vs_main(VS_INPUT Input)
59{
60   VS_OUTPUT Output = (VS_OUTPUT)0;
61   
62   Output.Position = float4(Input.Position.xyz, 1.0f);
63   Output.Position.x /= TargetWidth;
64   Output.Position.y /= TargetHeight;
65   Output.Position.y = 1.0f - Output.Position.y;
66   Output.Position.x -= 0.5f;
67   Output.Position.y -= 0.5f;
68   Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
69   Output.Color = Input.Color;
70   Output.TexCoord = Input.TexCoord;//(Input.TexCoord - float2(0.5f, 0.5f)) / 8.0f + float2(0.25f, 0.25f);
71   Output.ExtraInfo = Input.ExtraInfo;
72
73   return Output;
74}
75
76//-----------------------------------------------------------------------------
77// Post-Processing Pixel Shader
78//-----------------------------------------------------------------------------
79
80uniform float RedFromRed = 1.0f;
81uniform float RedFromGrn = 0.0f;
82uniform float RedFromBlu = 0.0f;
83uniform float GrnFromRed = 0.0f;
84uniform float GrnFromGrn = 1.0f;
85uniform float GrnFromBlu = 0.0f;
86uniform float BluFromRed = 0.0f;
87uniform float BluFromGrn = 0.0f;
88uniform float BluFromBlu = 1.0f;
89
90uniform float YfromY = 1.0f;
91uniform float YfromI = 0.0f;
92uniform float YfromQ = 0.0f;
93uniform float IfromY = 0.0f;
94uniform float IfromI = 1.0f;
95uniform float IfromQ = 0.0f;
96uniform float QfromY = 0.0f;
97uniform float QfromI = 0.0f;
98uniform float QfromQ = 1.0f;
99
100uniform float RedOffset = 0.0f;
101uniform float GrnOffset = 0.0f;
102uniform float BluOffset = 0.0f;
103
104uniform float RedScale = 1.0f;
105uniform float GrnScale = 1.0f;
106uniform float BluScale = 1.0f;
107
108uniform float RedFloor = 0.0f;
109uniform float GrnFloor = 0.0f;
110uniform float BluFloor = 0.0f;
111
112uniform float Saturation = 1.0f;
113
114uniform float YScale = 1.0f;
115uniform float IScale = 1.0f;
116uniform float QScale = 1.0f;
117uniform float YOffset = 0.0f;
118uniform float IOffset = 0.0f;
119uniform float QOffset = 0.0f;
120
121uniform float RedPower = 2.2f;
122uniform float GrnPower = 2.2f;
123uniform float BluPower = 2.2f;
124
125uniform float YSubsampleLength = 3.0f;
126uniform float ISubsampleLength = 3.0f;
127uniform float QSubsampleLength = 3.0f;
128
129float4 ps_main(PS_INPUT Input) : COLOR
130{
131   // -- Bandwidth Subsampling --
132   float3 SubsampleWidth = float3(YSubsampleLength, ISubsampleLength, QSubsampleLength);
133   SubsampleWidth = (RawWidth * 2.0f) / SubsampleWidth;
134   float3 SubsampleCoord = Input.TexCoord.x;
135   float3 SubsampleFrac = frac(SubsampleCoord * SubsampleWidth); // Fraction is in subsample width units!
136   SubsampleCoord = (SubsampleCoord * SubsampleWidth - SubsampleFrac) / SubsampleWidth;
137   
138   float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
139   
140   float3 YTexel = tex2D(DiffuseSampler, float2(SubsampleCoord.x, Input.TexCoord.y)).rgb;
141   float3 ITexel = tex2D(DiffuseSampler, float2(SubsampleCoord.y, Input.TexCoord.y)).rgb;
142   float3 QTexel = tex2D(DiffuseSampler, float2(SubsampleCoord.z, Input.TexCoord.y)).rgb;
143   
144   float3 LastYTexel = tex2D(DiffuseSampler, float2(SubsampleCoord.x + YSubsampleLength / (RawWidth * 2.0f), Input.TexCoord.y)).rgb;
145   float3 LastITexel = tex2D(DiffuseSampler, float2(SubsampleCoord.y + ISubsampleLength / (RawWidth * 2.0f), Input.TexCoord.y)).rgb;
146   float3 LastQTexel = tex2D(DiffuseSampler, float2(SubsampleCoord.z + QSubsampleLength / (RawWidth * 2.0f), Input.TexCoord.y)).rgb;
147   
148   YTexel = lerp(YTexel, LastYTexel, SubsampleFrac.x);
149   ITexel = lerp(ITexel, LastITexel, SubsampleFrac.y);
150   QTexel = lerp(QTexel, LastQTexel, SubsampleFrac.z);
151
152   // -- RGB Tint & Shift --
153   float ShiftedRedY = dot(YTexel, float3(RedFromRed, RedFromGrn, RedFromBlu));
154   float ShiftedGrnY = dot(YTexel, float3(GrnFromRed, GrnFromGrn, GrnFromBlu));
155   float ShiftedBluY = dot(YTexel, float3(BluFromRed, BluFromGrn, BluFromBlu));
156   float ShiftedRedI = dot(ITexel, float3(RedFromRed, RedFromGrn, RedFromBlu));
157   float ShiftedGrnI = dot(ITexel, float3(GrnFromRed, GrnFromGrn, GrnFromBlu));
158   float ShiftedBluI = dot(ITexel, float3(BluFromRed, BluFromGrn, BluFromBlu));
159   float ShiftedRedQ = dot(QTexel, float3(RedFromRed, RedFromGrn, RedFromBlu));
160   float ShiftedGrnQ = dot(QTexel, float3(GrnFromRed, GrnFromGrn, GrnFromBlu));
161   float ShiftedBluQ = dot(QTexel, float3(BluFromRed, BluFromGrn, BluFromBlu));
162   
163   // -- RGB Offset & Scale --
164   float3 RGBScale = float3(RedScale, GrnScale, BluScale);
165   float3 RGBShift = float3(RedOffset, GrnOffset, BluOffset);
166   float3 OutTexelY = float3(ShiftedRedY, ShiftedGrnY, ShiftedBluY) * RGBScale + RGBShift;
167   float3 OutTexelI = float3(ShiftedRedI, ShiftedGrnI, ShiftedBluI) * RGBScale + RGBShift;
168   float3 OutTexelQ = float3(ShiftedRedQ, ShiftedGrnQ, ShiftedBluQ) * RGBScale + RGBShift;
169   
170   // -- Saturation --
171   float3 Gray = float3(0.3f, 0.59f, 0.11f);
172   float OutLumaY = dot(OutTexelY, Gray);
173   float OutLumaI = dot(OutTexelI, Gray);
174   float OutLumaQ = dot(OutTexelQ, Gray);
175   float3 OutChromaY = OutTexelY - OutLumaY;
176   float3 OutChromaI = OutTexelI - OutLumaI;
177   float3 OutChromaQ = OutTexelQ - OutLumaQ;
178   float3 SaturatedY = OutLumaY + OutChromaY * Saturation;
179   float3 SaturatedI = OutLumaI + OutChromaI * Saturation;
180   float3 SaturatedQ = OutLumaQ + OutChromaQ * Saturation;
181   
182   // -- YIQ Convolution --
183   float Y = dot(SaturatedY, float3(0.299f, 0.587f, 0.114f));
184   float I = dot(SaturatedI, float3(0.595716f, -0.274453f, -0.321263f));
185   float Q = dot(SaturatedQ, float3(0.211456f, -0.522591f, 0.311135f));
186   Y = dot(float3(Y, I, Q), float3(YfromY, YfromI, YfromQ));
187   I = dot(float3(Y, I, Q), float3(IfromY, IfromI, IfromQ));
188   Q = dot(float3(Y, I, Q), float3(QfromY, QfromI, QfromQ));
189   float3 OutYIQ = float3(Y, I, Q) * float3(YScale, IScale, QScale) + float3(YOffset, IOffset, QOffset);
190   float3 OutRGB = float3(dot(OutYIQ, float3(1.0f, 0.9563f, 0.6210f)), dot(OutYIQ, float3(1.0f, -0.2721f, -0.6474f)), dot(OutYIQ, float3(1.0f, -1.1070f, 1.7046f)));
191
192   OutRGB.r = pow(OutRGB.r, RedPower);
193   OutRGB.g = pow(OutRGB.g, GrnPower);
194   OutRGB.b = pow(OutRGB.b, BluPower);
195
196   // -- Color Compression (increasing the floor of the signal without affecting the ceiling) --
197   OutRGB = float3(RedFloor + (1.0f - RedFloor) * OutRGB.r, GrnFloor + (1.0f - GrnFloor) * OutRGB.g, BluFloor + (1.0f - BluFloor) * OutRGB.b);
198
199   // -- Final Pixel --
200   float4 Output = lerp(Input.Color, float4(OutRGB, BaseTexel.a) * Input.Color, Input.ExtraInfo.x);
201
202   return Output;
203}
204
205//-----------------------------------------------------------------------------
206// Color-Convolution Technique
207//-----------------------------------------------------------------------------
208
209technique ColorTechnique
210{
211   pass Pass0
212   {
213      Lighting = FALSE;
214
215      VertexShader = compile vs_3_0 vs_main();
216      PixelShader  = compile ps_3_0 ps_main();
217   }
218}
hlsl/focus.fx
r11575r11576
6060
6161uniform float TargetWidth;
6262uniform float TargetHeight;
63
64uniform float WidthRatio;
65uniform float HeightRatio;
66
6367uniform float DefocusX;
6468uniform float DefocusY;
6569uniform float FocusEnable;
r11575r11576
8791   Output.Color = Input.Color;
8892   
8993   float2 InvTexSize = float2(1.0f / TargetWidth, 1.0f / TargetHeight);
90   float2 TexCoord = Input.Position.xy * InvTexSize;
94   float2 TexCoord = (Input.Position.xy * InvTexSize);
9195   float2 DefocusVal = float2(DefocusX, DefocusY);
9296   Output.TexCoord0 = TexCoord + Coord0Offset * InvTexSize * DefocusVal;
9397   Output.TexCoord1 = TexCoord + Coord1Offset * InvTexSize * DefocusVal;
r11575r11576
118122
119123   float3 blurred = (d0 + d1 + d2 + d3 + d4 + d5 + d6 + d7) / 8.0f;
120124
121   blurred = lerp(d0, blurred, FocusEnable);
125   blurred = lerp(d0, blurred, 1.0f);
122126   return float4(blurred, 1.0f);
123127}
124128
hlsl/deconverge.fx
r0r11576
1//-----------------------------------------------------------------------------
2// Deconvergence Effect
3//-----------------------------------------------------------------------------
4
5texture Diffuse;
6
7sampler DiffuseSampler = sampler_state
8{
9   Texture   = <Diffuse>;
10   MipFilter = LINEAR;
11   MinFilter = LINEAR;
12   MagFilter = LINEAR;
13   AddressU = CLAMP;
14   AddressV = CLAMP;
15   AddressW = CLAMP;
16};
17
18//-----------------------------------------------------------------------------
19// Vertex Definitions
20//-----------------------------------------------------------------------------
21
22struct VS_OUTPUT
23{
24   float4 Position : POSITION;
25   float4 Color : COLOR0;
26   float2 RedCoord : TEXCOORD0;
27   float2 GrnCoord : TEXCOORD1;
28   float2 BluCoord : TEXCOORD2;
29};
30
31struct VS_INPUT
32{
33   float4 Position : POSITION;
34   float4 Color : COLOR0;
35   float2 TexCoord : TEXCOORD0;
36   float2 ExtraInfo : TEXCOORD1;
37};
38
39struct PS_INPUT
40{
41   float4 Color : COLOR0;
42   float2 RedCoord : TEXCOORD0;
43   float2 GrnCoord : TEXCOORD1;
44   float2 BluCoord : TEXCOORD2;
45};
46
47//-----------------------------------------------------------------------------
48// Deconvergence Vertex Shader
49//-----------------------------------------------------------------------------
50
51uniform float RedConvergeX;
52uniform float RedConvergeY;
53uniform float GrnConvergeX;
54uniform float GrnConvergeY;
55uniform float BluConvergeX;
56uniform float BluConvergeY;
57
58uniform float TargetWidth;
59uniform float TargetHeight;
60
61uniform float RawWidth;
62uniform float RawHeight;
63
64uniform float WidthRatio;
65uniform float HeightRatio;
66
67uniform float RedRadialConvergeX;
68uniform float RedRadialConvergeY;
69uniform float GrnRadialConvergeX;
70uniform float GrnRadialConvergeY;
71uniform float BluRadialConvergeX;
72uniform float BluRadialConvergeY;
73
74VS_OUTPUT vs_main(VS_INPUT Input)
75{
76   VS_OUTPUT Output = (VS_OUTPUT)0;
77   
78   float2 TargetRawRatio = float2(TargetWidth / RawWidth, TargetWidth / RawWidth);
79   float2 invDims = float2(1.0f / RawWidth, 1.0f / RawHeight);
80   float2 Ratios = float2(1.0f / WidthRatio, 1.0f / HeightRatio);
81   Output.Position = float4(Input.Position.xyz, 1.0f);
82   Output.Position.x /= TargetWidth;
83   Output.Position.y /= TargetHeight;
84   Output.Position.y = 1.0f - Output.Position.y;
85   Output.Position.x -= 0.5f;
86   Output.Position.y -= 0.5f;
87   Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
88   Output.Color = Input.Color;
89   float2 InvTexSize = float2(1.0f / TargetWidth, 1.0f / TargetHeight);
90   float2 TexCoord = (Input.Position.xy * InvTexSize);
91   TexCoord = TexCoord;// + float2(0.5f / TargetWidth, 0.5f / TargetHeight);// * float2(WidthRatio, HeightRatio);//(Input.TexCoord - float2(0.5f, 0.5f)) / 8.0f + float2(0.25f, 0.25f);
92
93   Output.RedCoord.x = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + RedRadialConvergeX / RawWidth) + 0.5f) * Ratios.x + RedConvergeX * invDims.x;
94   Output.GrnCoord.x = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + GrnRadialConvergeX / RawWidth) + 0.5f) * Ratios.x + GrnConvergeX * invDims.x;
95   Output.BluCoord.x = ((((TexCoord.x / Ratios.x) - 0.5f)) * (1.0f + BluRadialConvergeX / RawWidth) + 0.5f) * Ratios.x + GrnConvergeX * invDims.x;
96   
97   Output.RedCoord.y = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + RedRadialConvergeY / RawHeight) + 0.5f) * Ratios.y + RedConvergeY * invDims.y;
98   Output.GrnCoord.y = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + GrnRadialConvergeY / RawHeight) + 0.5f) * Ratios.y + BluConvergeY * invDims.y;
99   Output.BluCoord.y = ((((TexCoord.y / Ratios.y) - 0.5f)) * (1.0f + BluRadialConvergeY / RawHeight) + 0.5f) * Ratios.y + BluConvergeY * invDims.y;
100   
101   return Output;
102}
103
104//-----------------------------------------------------------------------------
105// Deconvergence Pixel Shader
106//-----------------------------------------------------------------------------
107
108float4 ps_main(PS_INPUT Input) : COLOR
109{
110   float RedTexel = tex2D(DiffuseSampler, Input.RedCoord).r;
111   float GrnTexel = tex2D(DiffuseSampler, Input.GrnCoord).g;
112   float BluTexel = tex2D(DiffuseSampler, Input.BluCoord).b;
113   
114   return float4(RedTexel, GrnTexel, BluTexel, 1.0f);
115}
116
117//-----------------------------------------------------------------------------
118// Deconvergence Effect
119//-----------------------------------------------------------------------------
120
121technique DeconvergeTechnique
122{
123   pass Pass0
124   {
125      Lighting = FALSE;
126
127      VertexShader = compile vs_3_0 vs_main();
128      PixelShader  = compile ps_3_0 ps_main();
129   }
130}
src/osd/windows/winmain.c
r11575r11576
332332   { WINOPTION_HLSLPATH,                                       "hlsl",       OPTION_STRING,     "path to hlsl files" },
333333   { WINOPTION_SHADOW_MASK_ALPHA";fs_shadwa(0.0-1.0)",         "0.0",         OPTION_FLOAT,       "shadow mask alpha-blend value (1.0 is fully blended, 0.0 is no mask)" },
334334   { WINOPTION_SHADOW_MASK_TEXTURE";fs_shadwt(0.0-1.0)",       "aperture.png", OPTION_STRING,  "shadow mask texture name" },
335   { WINOPTION_SHADOW_MASK_WIDTH";fs_shadww",               "3.0",       OPTION_FLOAT,      "shadow mask width, in shadow mask pixels per emulated pixel" },
336   { WINOPTION_SHADOW_MASK_HEIGHT";fs_shadwh",               "3.0",       OPTION_FLOAT,      "shadow mask height, in shadow mask pixels per emulated pixel" },
335   { WINOPTION_SHADOW_MASK_RATIO_X";fs_shadwx",            "3.0",       OPTION_FLOAT,      "shadow mask texels per dot mask pixel in screen-relative X direction" },
336   { WINOPTION_SHADOW_MASK_RATIO_Y";fs_shadwy",            "3.0",       OPTION_FLOAT,      "shadow mask texels per dot mask pixel in screen-relative Y direction" },
337   { WINOPTION_SHADOW_MASK_COUNT_X";fs_shadww",            "640",        OPTION_INTEGER,   "shadow mask width, in phosphor dots" },
338   { WINOPTION_SHADOW_MASK_COUNT_Y";fs_shadwh",            "480",       OPTION_INTEGER,   "shadow mask height, in phosphor dots" },
337339   { WINOPTION_SHADOW_MASK_USIZE";fs_shadwu(0.0-1.0)",         "0.1875",    OPTION_FLOAT,      "shadow mask texture size in U direction" },
338340   { WINOPTION_SHADOW_MASK_VSIZE";fs_shadwv(0.0-1.0)",         "0.1875",    OPTION_FLOAT,      "shadow mask texture size in V direction" },
339   { WINOPTION_OVERSAMPLE_X";fs_overx(1.0-9.0)",               "1.0",         OPTION_FLOAT,       "oversample amount in screen-relative X direction, multiple" },
340   { WINOPTION_OVERSAMPLE_Y";fs_overy(1.0-9.0)",               "1.0",         OPTION_FLOAT,        "oversample amount in screen-relative Y direction, multiple" },
341   { WINOPTION_OVERSAMPLE_X";fs_overx(0.1-9.0)",               "1.0",         OPTION_FLOAT,       "oversample amount in screen-relative X direction, multiple" },
342   { WINOPTION_OVERSAMPLE_Y";fs_overy(0.1-9.0)",               "1.0",         OPTION_FLOAT,        "oversample amount in screen-relative Y direction, multiple" },
343   { WINOPTION_CURVATURE";fs_curv(0.0-4.0)",                  "0.0",       OPTION_FLOAT,       "screen curvature amount" },
341344   /* Beam-related values below this line*/
342   { WINOPTION_PINCUSHION_X";fs_pinx(0.0-4.0)",               "0.0",       OPTION_FLOAT,       "pincushion amount in screen-relative X direction" },
343   { WINOPTION_PINCUSHION_Y";fs_piny(0.0-4.0)",               "0.0",       OPTION_FLOAT,       "pincushion amount in screen-relative Y direction" },
345   { WINOPTION_PINCUSHION";fs_pin(0.0-4.0)",                  "0.0",       OPTION_FLOAT,       "pincushion amount" },
344346   { WINOPTION_SCANLINE_AMOUNT";fs_scanam(0.0-4.0)",          "0.0",       OPTION_FLOAT,       "overall alpha scaling value for scanlines" },
345347   { WINOPTION_SCANLINE_SCALE";fs_scansc(0.0-4.0)",           "1.0",       OPTION_FLOAT,       "overall height scaling value for scanlines" },
346348   { WINOPTION_SCANLINE_BRIGHT_SCALE";fs_scanbs(0.0-1.0)",    "1.0",       OPTION_FLOAT,       "overall brightness scaling value for scanlines (multiplicative)" },
r11575r11576
408410   { WINOPTION_Y_OFFSET";fs_yoffs(-1.0-1.0)",                 "0.0",       OPTION_FLOAT,      "Y signal offset value for NTSC colorspace convolution (additive)" },
409411   { WINOPTION_I_OFFSET";fs_ioffs(-1.0-1.0)",                 "0.0",       OPTION_FLOAT,      "I signal offset value for NTSC colorspace convolution (additive)" },
410412   { WINOPTION_Q_OFFSET";fs_qoffs(-1.0-1.0)",                 "0.0",       OPTION_FLOAT,      "Q signal offset value for NTSC colorspace convolution (additive)" },
411   { WINOPTION_SUBSAMPLE_LENGTH";fs_chrsub(1.0+)",            "1.0",       OPTION_FLOAT,      "chroma signal subsampling value, in pixels" },
412   { WINOPTION_CRAWL_WIDTH";fs_crawlw(0.0-8.0)",                 "0.0",       OPTION_FLOAT,      "dot crawl width (in pixels, 1.0 upward)" },
413   { WINOPTION_CRAWL_HEIGHT";fs_crawlh(0.0-8.0)",                "2.0",       OPTION_FLOAT,      "dot crawl height (in pixels, 1.0 upward)" },
414   { WINOPTION_CRAWL_RATE";fs_crawlr(1-8)",                    "2",         OPTION_INTEGER,    "dot crawl rate (in total frames, 1 upward)" },
415   { WINOPTION_CRAWL_SKIP";fs_crawls(0-7)",                      "2",         OPTION_INTEGER,    "dot crawl frame to skip (frame index, 0 upward)" },
416   /* "Just for fun" below this line */
417   { WINOPTION_EDGE_AMOUNT";fs_edgeen(0.0-2.0)",              "1.0",       OPTION_FLOAT,      "edge-detection alpha (just for fun)" },
418   { WINOPTION_EDGE_RATIO";fs_edgert(0.0-1.0)",               "0.0",       OPTION_FLOAT,      "edge-detection to baseline texel ratio (just for fun)" },
413   { WINOPTION_Y_SUBSAMPLE_LENGTH";fs_ysub(0.5-100.0)",        "0.5",       OPTION_FLOAT,      "Y signal subsampling value, in pixels" },
414   { WINOPTION_I_SUBSAMPLE_LENGTH";fs_isub(0.5-100.0)",        "0.5",       OPTION_FLOAT,      "I signal subsampling value, in pixels" },
415   { WINOPTION_Q_SUBSAMPLE_LENGTH";fs_qsub(0.5-100.0)",        "0.5",       OPTION_FLOAT,      "Q signal subsampling value, in pixels" },
419416
420417   // per-window options
421418   { NULL,                                           NULL,       OPTION_HEADER,     "PER-WINDOW VIDEO OPTIONS" },
r11575r11576
11781175   // flush stderr, so the data is actually written when output is being redirected
11791176   fflush(stderr);
11801177
1178   // flush stderr, so the data is actually written when output is being redirected
1179   fflush(stderr);
1180
11811181   // exit
11821182   return EXCEPTION_CONTINUE_SEARCH;
11831183}
src/osd/windows/winmain.h
r11575r11576
8383#define WINOPTION_HLSLPATH               "hlslpath"
8484#define WINOPTION_SHADOW_MASK_ALPHA         "shadow_mask_alpha"
8585#define WINOPTION_SHADOW_MASK_TEXTURE      "shadow_mask_texture"
86#define WINOPTION_SHADOW_MASK_WIDTH         "shadow_mask_pix_width"
87#define WINOPTION_SHADOW_MASK_HEIGHT      "shadow_mask_pix_height"
86#define WINOPTION_SHADOW_MASK_RATIO_X      "shadow_mask_pix_width"
87#define WINOPTION_SHADOW_MASK_RATIO_Y      "shadow_mask_pix_height"
88#define WINOPTION_SHADOW_MASK_COUNT_X      "shadow_mask_x_count"
89#define WINOPTION_SHADOW_MASK_COUNT_Y      "shadow_mask_y_count"
8890#define WINOPTION_SHADOW_MASK_USIZE         "shadow_mask_usize"
8991#define WINOPTION_SHADOW_MASK_VSIZE         "shadow_mask_vsize"
90#define WINOPTION_PINCUSHION_X            "pincushion_x"
91#define WINOPTION_PINCUSHION_Y            "pincushion_y"
92#define WINOPTION_PINCUSHION            "pincushion"
93#define WINOPTION_CURVATURE               "curvature"
9294#define WINOPTION_OVERSAMPLE_X            "oversample_x"
9395#define WINOPTION_OVERSAMPLE_Y            "oversample_y"
9496#define WINOPTION_SCANLINE_AMOUNT         "scanline_alpha"
r11575r11576
147149#define WINOPTION_Y_OFFSET               "y_offset"
148150#define WINOPTION_I_OFFSET               "i_offset"
149151#define WINOPTION_Q_OFFSET               "q_offset"
150#define WINOPTION_EDGE_AMOUNT            "edge_amount"
151#define WINOPTION_EDGE_RATIO            "edge_ratio"
152#define WINOPTION_SUBSAMPLE_LENGTH         "subsample_length"
152#define WINOPTION_Y_SUBSAMPLE_LENGTH      "y_subsample_length"
153#define WINOPTION_I_SUBSAMPLE_LENGTH      "i_subsample_length"
154#define WINOPTION_Q_SUBSAMPLE_LENGTH      "q_subsample_length"
153155#define WINOPTION_RED_PHOSPHOR            "red_phosphor_life"
154156#define WINOPTION_GREEN_PHOSPHOR         "green_phosphor_life"
155157#define WINOPTION_BLUE_PHOSPHOR            "blue_phosphor_life"
156#define WINOPTION_CRAWL_WIDTH            "dot_crawl_width"
157#define WINOPTION_CRAWL_HEIGHT            "dot_crawl_height"
158#define WINOPTION_CRAWL_RATE            "dot_crawl_rate"
159#define WINOPTION_CRAWL_SKIP            "dot_crawl_skip"
160158
161159// per-window options
162160#define WINOPTION_SCREEN            "screen"
r11575r11576
223221   // core post-processing options
224222   const char *screen_post_fx_dir() const { return value(WINOPTION_HLSLPATH); }
225223   bool d3d_hlsl_enable() const { return bool_value(WINOPTION_HLSL_ENABLE); }
226   float screen_pincushion_x() const { return float_value(WINOPTION_PINCUSHION_X); }
227   float screen_pincushion_y() const { return float_value(WINOPTION_PINCUSHION_Y); }
228224   float screen_shadow_mask_alpha() const { return float_value(WINOPTION_SHADOW_MASK_ALPHA); }
229225   const char *screen_shadow_mask_texture() const { return value(WINOPTION_SHADOW_MASK_TEXTURE); }
230   float screen_shadow_mask_width() const { return float_value(WINOPTION_SHADOW_MASK_WIDTH); }
231   float screen_shadow_mask_height() const { return float_value(WINOPTION_SHADOW_MASK_HEIGHT); }
226   float screen_shadow_mask_ratio_x() const { return float_value(WINOPTION_SHADOW_MASK_RATIO_X); }
227   float screen_shadow_mask_ratio_y() const { return float_value(WINOPTION_SHADOW_MASK_RATIO_Y); }
228   float screen_shadow_mask_count_x() const { return float_value(WINOPTION_SHADOW_MASK_COUNT_X); }
229   float screen_shadow_mask_count_y() const { return float_value(WINOPTION_SHADOW_MASK_COUNT_Y); }
232230   float screen_shadow_mask_u_size() const { return float_value(WINOPTION_SHADOW_MASK_USIZE); }
233231   float screen_shadow_mask_v_size() const { return float_value(WINOPTION_SHADOW_MASK_VSIZE); }
234   float screen_shadow_width_y() const { return float_value(WINOPTION_SHADOW_MASK_HEIGHT); }
235232   float screen_oversample_x() const { return float_value(WINOPTION_OVERSAMPLE_X); }
236233   float screen_oversample_y() const { return float_value(WINOPTION_OVERSAMPLE_Y); }
237234   float screen_scanline_amount() const { return float_value(WINOPTION_SCANLINE_AMOUNT); }
r11575r11576
239236   float screen_scanline_bright_scale() const { return float_value(WINOPTION_SCANLINE_BRIGHT_SCALE); }
240237   float screen_scanline_bright_offset() const { return float_value(WINOPTION_SCANLINE_BRIGHT_OFFSET); }
241238   float screen_scanline_offset() const { return float_value(WINOPTION_SCANLINE_OFFSET); }
239   float screen_pincushion() const { return float_value(WINOPTION_PINCUSHION); }
240   float screen_curvature() const { return float_value(WINOPTION_CURVATURE); }
242241   float screen_defocus_x() const { return float_value(WINOPTION_DEFOCUS_X); }
243242   float screen_defocus_y() const { return float_value(WINOPTION_DEFOCUS_Y); }
244243   float screen_red_converge_x() const { return float_value(WINOPTION_RED_CONVERGE_X); }
r11575r11576
290289   float screen_y_offset() const { return float_value(WINOPTION_Y_OFFSET); }
291290   float screen_i_offset() const { return float_value(WINOPTION_I_OFFSET); }
292291   float screen_q_offset() const { return float_value(WINOPTION_Q_OFFSET); }
293   float screen_edge_amount() const { return float_value(WINOPTION_EDGE_AMOUNT); }
294   float screen_edge_ratio() const { return float_value(WINOPTION_EDGE_RATIO); }
295   float screen_chroma_subsample_length() const { return float_value(WINOPTION_SUBSAMPLE_LENGTH); }
292   float screen_y_subsample_length() const { return float_value(WINOPTION_Y_SUBSAMPLE_LENGTH); }
293   float screen_i_subsample_length() const { return float_value(WINOPTION_I_SUBSAMPLE_LENGTH); }
294   float screen_q_subsample_length() const { return float_value(WINOPTION_Q_SUBSAMPLE_LENGTH); }
296295   float screen_red_phosphor() const { return float_value(WINOPTION_RED_PHOSPHOR); }
297296   float screen_green_phosphor() const { return float_value(WINOPTION_GREEN_PHOSPHOR); }
298297   float screen_blue_phosphor() const { return float_value(WINOPTION_BLUE_PHOSPHOR); }
299   float screen_dot_crawl_width() const { return float_value(WINOPTION_CRAWL_WIDTH); }
300   float screen_dot_crawl_height() const { return float_value(WINOPTION_CRAWL_HEIGHT); }
301   int screen_dot_crawl_rate() const { return int_value(WINOPTION_CRAWL_RATE); }
302   int screen_dot_crawl_skip() const { return int_value(WINOPTION_CRAWL_SKIP); }
303298
304299   // per-window options
305300   const char *screen() const { return value(WINOPTION_SCREEN); }
src/osd/windows/drawd3d.c
r11575r11576
130130   d3d_texture *         d3dtex;                  // Direct3D texture pointer
131131   d3d_surface *         d3dsurface;               // Direct3D offscreen plain surface pointer
132132   d3d_surface *         d3dtarget0;               // Direct3D render target surface pointer (pass 0, if necessary)
133   d3d_surface *         d3dtarget1;               // Direct3D render target surface pointer (pass 2, if necessary)
134   d3d_surface *         d3dtarget2;               // Direct3D render target surface pointer (pass 3, if necessary)
133   d3d_surface *         d3dtarget1;               // Direct3D render target surface pointer (pass 1, if necessary)
134   d3d_surface *         d3dtarget2;               // Direct3D render target surface pointer (pass 2, if necessary)
135   d3d_surface *         d3dsmalltarget0;         // Direct3D render target surface pointer (small pass 0, if necessary)
136   d3d_surface *         d3dsmalltarget1;         // Direct3D render target surface pointer (small pass 1, if necessary)
135137   d3d_texture *         d3dtexture0;            // Direct3D render target texture pointer (pass 0, if necessary)
136   d3d_texture *         d3dtexture1;            // Direct3D render target texture pointer (pass 2, if necessary)
137   d3d_texture *         d3dtexture2;            // Direct3D render target texture pointer (pass 3, if necessary)
138   d3d_texture *         d3dtexture1;            // Direct3D render target texture pointer (pass 1, if necessary)
139   d3d_texture *         d3dtexture2;            // Direct3D render target texture pointer (pass 2, if necessary)
140   d3d_texture *         d3dsmalltexture0;         // Direct3D render target texture pointer (small pass 0, if necessary)
141   d3d_texture *         d3dsmalltexture1;         // Direct3D render target texture pointer (small pass 1, if necessary)
138142   d3d_texture *         d3dfinaltex;            // Direct3D final (post-scaled) texture
139143};
140144
r11575r11576
190194   d3d_effect *         pincushion_effect;         // pointer to the current pincushion-effect object
191195   d3d_effect *         focus_effect;            // pointer to the current focus-effect object
192196   d3d_effect *         phosphor_effect;         // pointer to the current phosphor-effect object
197   d3d_effect *         deconverge_effect;         // pointer to the current deconvergence-effect object
198   d3d_effect *         color_effect;            // pointer to the current color-effect object
193199
194200   poly_info            poly[VERTEX_BUFFER_SIZE / 3];// array to hold polygons as they are created
195201   int                  numpolys;               // number of accumulated polygons
r11575r11576
357363      if(d3d->hlsl_enable && d3d->effect != NULL)
358364      {
359365         (*d3dintf->effect.set_texture)(d3d->effect, "Diffuse", (texture == NULL) ? NULL : texture->d3dfinaltex);
360         (*d3dintf->effect.set_texture)(d3d->post_effect, "Diffuse", (texture == NULL) ? NULL : texture->d3dfinaltex);
366         (*d3dintf->effect.set_texture)(d3d->color_effect, "Diffuse", (texture == NULL) ? NULL : texture->d3dfinaltex);
361367         (*d3dintf->effect.set_texture)(d3d->pincushion_effect, "Diffuse", (texture == NULL) ? NULL : texture->d3dfinaltex);
362368      }
363369      if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_texture call\n", (int)result);
r11575r11576
636642   d3d->vector_bitmap = NULL;
637643
638644   // experimental: free the shadow PNG
639   if(d3d->hlsl_enable)
645   if(d3d->hlsl_enable && d3d->shadow_bitmap != NULL)
640646   {
641647      global_free(d3d->shadow_bitmap);
642648      d3d->shadow_bitmap = NULL;
r11575r11576
850856
851857   // create the D3D device
852858   result = (*d3dintf->d3d.create_device)(d3dintf, d3d->adapter, D3DDEVTYPE_HAL, win_window_list->hwnd,
853               D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE, &d3d->presentation, &d3d->device);
859               D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE, &d3d->presentation, &d3d->device);
854860   if (result != D3D_OK)
855861   {
856862      // if we got a "DEVICELOST" error, it may be transitory; count it and only fail if
r11575r11576
900906   }
901907
902908   // experimental: initialize some more things if we're using HLSL
903   if(d3d->hlsl_enable)
909   if(d3d->hlsl_enable && d3dintf->post_fx_available)
904910   {
905911      const char *fx_dir = downcast<windows_options &>(window->machine().options()).screen_post_fx_dir();
906912      char primary_name_cstr[1024];
r11575r11576
908914      char pincushion_name_cstr[1024];
909915      char phosphor_name_cstr[1024];
910916      char focus_name_cstr[1024];
917      char deconverge_name_cstr[1024];
918      char color_name_cstr[1024];
911919
912920      sprintf(primary_name_cstr, "%s\\primary.fx", fx_dir);
913921      TCHAR *primary_name = tstring_from_utf8(primary_name_cstr);
r11575r11576
924932      sprintf(focus_name_cstr, "%s\\focus.fx", fx_dir);
925933      TCHAR *focus_name = tstring_from_utf8(focus_name_cstr);
926934
935      sprintf(deconverge_name_cstr, "%s\\deconverge.fx", fx_dir);
936      TCHAR *deconverge_name = tstring_from_utf8(deconverge_name_cstr);
937
938      sprintf(color_name_cstr, "%s\\color.fx", fx_dir);
939      TCHAR *color_name = tstring_from_utf8(color_name_cstr);
940
927941      // create the regular shader
928942      result = (*d3dintf->device.create_effect)(d3d->device, primary_name, &d3d->effect);
929943
r11575r11576
939953      // create the focus shader
940954      result = (*d3dintf->device.create_effect)(d3d->device, focus_name, &d3d->focus_effect);
941955
956      // create the deconvergence shader
957      result = (*d3dintf->device.create_effect)(d3d->device, deconverge_name, &d3d->deconverge_effect);
958
959      // create the color convolution shader
960      result = (*d3dintf->device.create_effect)(d3d->device, color_name, &d3d->color_effect);
961
942962      if (primary_name)
943963         osd_free(primary_name);
944964      if (post_name)
r11575r11576
949969         osd_free(phosphor_name);
950970      if (focus_name)
951971         osd_free(focus_name);
972      if (deconverge_name)
973         osd_free(deconverge_name);
974      if (color_name)
975         osd_free(color_name);
952976   }
953977
954978   return device_create_resources(d3d);
r11575r11576
967991   // allocate a vertex buffer to use
968992   result = (*d3dintf->device.create_vertex_buffer)(d3d->device,
969993            sizeof(d3d_vertex) * VERTEX_BUFFER_SIZE,
970            D3DUSAGE_DYNAMIC | D3DUSAGE_SOFTWAREPROCESSING | D3DUSAGE_WRITEONLY,
971            VERTEX_BASE_FORMAT | (d3d->hlsl_enable ? D3DFVF_XYZW : D3DFVF_XYZRHW), D3DPOOL_DEFAULT, &d3d->vertexbuf);
994            D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
995            VERTEX_BASE_FORMAT | ((d3d->hlsl_enable && d3dintf->post_fx_available) ? D3DFVF_XYZW : D3DFVF_XYZRHW), D3DPOOL_DEFAULT, &d3d->vertexbuf);
972996   if (result != D3D_OK)
973997   {
974998      mame_printf_error("Error creating vertex buffer (%08X)", (UINT32)result);
r11575r11576
9761000   }
9771001
9781002   // set the vertex format
979   result = (*d3dintf->device.set_vertex_format)(d3d->device, (D3DFORMAT)(VERTEX_BASE_FORMAT | (d3d->hlsl_enable ? D3DFVF_XYZW : D3DFVF_XYZRHW)));
1003   result = (*d3dintf->device.set_vertex_format)(d3d->device, (D3DFORMAT)(VERTEX_BASE_FORMAT | ((d3d->hlsl_enable && d3dintf->post_fx_available) ? D3DFVF_XYZW : D3DFVF_XYZRHW)));
9801004   if (result != D3D_OK)
9811005   {
9821006      mame_printf_error("Error setting vertex format (%08X)", (UINT32)result);
r11575r11576
10331057   }
10341058
10351059   // experimental: initialize some more things if we're using HLSL
1036   if(d3d->hlsl_enable)
1060   if(d3d->hlsl_enable && d3dintf->post_fx_available)
10371061   {
10381062      // experimental: create a default bitmap for our shader
10391063      if (d3d->default_bitmap != NULL)
r11575r11576
11201144         (*d3dintf->texture.release)(tex->d3dtexture1);
11211145      if (tex->d3dtexture2 != NULL)
11221146         (*d3dintf->texture.release)(tex->d3dtexture2);
1147      if (tex->d3dsmalltexture0 != NULL)
1148         (*d3dintf->texture.release)(tex->d3dsmalltexture0);
1149      if (tex->d3dsmalltexture1 != NULL)
1150         (*d3dintf->texture.release)(tex->d3dsmalltexture1);
11231151      if (tex->d3dtarget0 != NULL)
11241152         (*d3dintf->surface.release)(tex->d3dtarget0);
11251153      if (tex->d3dtarget1 != NULL)
11261154         (*d3dintf->surface.release)(tex->d3dtarget1);
11271155      if (tex->d3dtarget2 != NULL)
11281156         (*d3dintf->surface.release)(tex->d3dtarget2);
1157      if (tex->d3dsmalltarget0 != NULL)
1158         (*d3dintf->surface.release)(tex->d3dsmalltarget0);
1159      if (tex->d3dsmalltarget1 != NULL)
1160         (*d3dintf->surface.release)(tex->d3dsmalltarget1);
11291161      global_free(tex);
11301162   }
11311163
r11575r11576
11621194      (*d3dintf->effect.release)(d3d->focus_effect);
11631195      d3d->focus_effect = NULL;
11641196   }
1197   if(d3d->deconverge_effect != NULL)
1198   {
1199      (*d3dintf->effect.release)(d3d->deconverge_effect);
1200      d3d->deconverge_effect = NULL;
1201   }
1202   if(d3d->color_effect != NULL)
1203   {
1204      (*d3dintf->effect.release)(d3d->color_effect);
1205      d3d->color_effect = NULL;
1206   }
11651207
11661208   for(int index = 0; index < 9; index++)
11671209   {
r11575r11576
19431985
19441986   d3d_effect *curr_effect = d3d->effect;
19451987
1946   if(d3d->hlsl_enable)
1988   if(d3d->hlsl_enable && d3dintf->post_fx_available)
19471989   {
19481990      (*d3dintf->effect.set_technique)(d3d->effect, "TestTechnique");
1949      (*d3dintf->effect.set_technique)(d3d->post_effect, "TestTechnique");
1991      (*d3dintf->effect.set_technique)(d3d->post_effect, "ScanMaskTechnique");
19501992      (*d3dintf->effect.set_technique)(d3d->pincushion_effect, "TestTechnique");
19511993      (*d3dintf->effect.set_technique)(d3d->phosphor_effect, "TestTechnique");
19521994      (*d3dintf->effect.set_technique)(d3d->focus_effect, "TestTechnique");
1995      (*d3dintf->effect.set_technique)(d3d->deconverge_effect, "DeconvergeTechnique");
1996      (*d3dintf->effect.set_technique)(d3d->color_effect, "ColorTechnique");
19531997   }
19541998
19551999   d3d_surface *backbuffer;
19562000
19572001   // first remember the original render target in case we need to set a new one
1958   result = (*d3dintf->device.get_render_target)(d3d->device, 0, &backbuffer);
1959   if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device get_render_target call\n", (int)result);
2002   if(d3d->hlsl_enable && d3dintf->post_fx_available)
2003   {
2004      result = (*d3dintf->device.get_render_target)(d3d->device, 0, &backbuffer);
2005      if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device get_render_target call\n", (int)result);
2006   }
19602007
19612008   windows_options &options = downcast<windows_options &>(d3d->window->machine().options());
19622009
r11575r11576
19802027         set_wrap(d3d, PRIMFLAG_GET_TEXWRAP(poly->flags));
19812028         set_modmode(d3d, poly->modmode);
19822029
1983         if(d3d->hlsl_enable)
2030         if(d3d->hlsl_enable && d3dintf->post_fx_available)
19842031         {
19852032            if(PRIMFLAG_GET_TEXSHADE(d3d->last_texture_flags))
19862033            {
r11575r11576
19882035            }
19892036            else if(PRIMFLAG_GET_SCREENTEX(d3d->last_texture_flags))
19902037            {
2038               // Plug in all of the shader settings we're going to need
2039               // This is extremely slow, but we're not rendering models here,
2040               // just post-processing.
19912041               curr_effect = d3d->post_effect;
19922042
2043               (*d3dintf->effect.set_float)(curr_effect, "RawWidth", poly->texture != NULL ? (float)poly->texture->rawwidth : 8.0f);
2044               (*d3dintf->effect.set_float)(curr_effect, "RawHeight", poly->texture != NULL ? (float)poly->texture->rawheight : 8.0f);
2045               (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
2046               (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
2047               (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
2048               (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
2049               (*d3dintf->effect.set_float)(curr_effect, "PincushionAmount", (float)options.screen_pincushion());
2050               (*d3dintf->effect.set_float)(curr_effect, "CurvatureAmount", (float)options.screen_curvature());
2051               (*d3dintf->effect.set_float)(curr_effect, "UseShadow", d3d->shadow_texture == NULL ? 0.0f : 1.0f);
19932052               (*d3dintf->effect.set_texture)(curr_effect, "Shadow", d3d->shadow_texture == NULL ? NULL : d3d->shadow_texture->d3dfinaltex);
1994               (*d3dintf->effect.set_float)(curr_effect, "UseShadow", d3d->shadow_texture == NULL ? 0.0f : 1.0f);
19952053               (*d3dintf->effect.set_float)(curr_effect, "ShadowBrightness", (float)options.screen_shadow_mask_alpha());
1996               (*d3dintf->effect.set_float)(curr_effect, "ShadowPixelSizeX", (float)options.screen_shadow_mask_width());
1997               (*d3dintf->effect.set_float)(curr_effect, "ShadowPixelSizeY", (float)options.screen_shadow_mask_height());
2054               (*d3dintf->effect.set_float)(curr_effect, "ShadowPixelSizeX", (float)options.screen_shadow_mask_ratio_x());
2055               (*d3dintf->effect.set_float)(curr_effect, "ShadowPixelSizeY", (float)options.screen_shadow_mask_ratio_y());
2056               (*d3dintf->effect.set_float)(curr_effect, "ShadowMaskSizeX", (float)options.screen_shadow_mask_count_x());
2057               (*d3dintf->effect.set_float)(curr_effect, "ShadowMaskSizeY", (float)options.screen_shadow_mask_count_y());
19982058               (*d3dintf->effect.set_float)(curr_effect, "ShadowU", (float)options.screen_shadow_mask_u_size());
19992059               (*d3dintf->effect.set_float)(curr_effect, "ShadowV", (float)options.screen_shadow_mask_v_size());
20002060               (*d3dintf->effect.set_float)(curr_effect, "ShadowWidth", d3d->shadow_texture == NULL ? 1.0f : (float)d3d->shadow_texture->rawwidth);
20012061               (*d3dintf->effect.set_float)(curr_effect, "ShadowHeight", d3d->shadow_texture == NULL ? 1.0f : (float)d3d->shadow_texture->rawheight);
2002               (*d3dintf->effect.set_float)(curr_effect, "RawWidth", poly->texture != NULL ? (float)poly->texture->rawwidth : 8.0f);
2003               (*d3dintf->effect.set_float)(curr_effect, "RawHeight", poly->texture != NULL ? (float)poly->texture->rawheight : 8.0f);
2004               (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
2005               (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
2006               (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
2007               (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
2008               (*d3dintf->effect.set_float)(curr_effect, "PostPass", 0.0f);
2009               (*d3dintf->effect.set_float)(curr_effect, "PincushionAmountX", (float)options.screen_pincushion_x());
2010               (*d3dintf->effect.set_float)(curr_effect, "PincushionAmountY", (float)options.screen_pincushion_y());
20112062               (*d3dintf->effect.set_float)(curr_effect, "ScanlineAmount", (float)options.screen_scanline_amount());
20122063               (*d3dintf->effect.set_float)(curr_effect, "ScanlineScale", (float)options.screen_scanline_scale());
20132064               (*d3dintf->effect.set_float)(curr_effect, "ScanlineBrightScale", (float)options.screen_scanline_bright_scale());
20142065               (*d3dintf->effect.set_float)(curr_effect, "ScanlineBrightOffset", (float)options.screen_scanline_bright_offset());
20152066               (*d3dintf->effect.set_float)(curr_effect, "ScanlineOffset", (poly->texture != NULL && poly->texture->cur_frame == 0) ? 0.0f : (float)options.screen_scanline_offset());
2016               (*d3dintf->effect.set_float)(curr_effect, "RedConvergeX", (float)options.screen_red_converge_x());
2017               (*d3dintf->effect.set_float)(curr_effect, "RedConvergeY", (float)options.screen_red_converge_y());
2018               (*d3dintf->effect.set_float)(curr_effect, "GrnConvergeX", (float)options.screen_green_converge_x());
2019               (*d3dintf->effect.set_float)(curr_effect, "GrnConvergeY", (float)options.screen_green_converge_y());
2020               (*d3dintf->effect.set_float)(curr_effect, "BluConvergeX", (float)options.screen_blue_converge_x());
2021               (*d3dintf->effect.set_float)(curr_effect, "BluConvergeY", (float)options.screen_blue_converge_y());
2022               (*d3dintf->effect.set_float)(curr_effect, "RedRadialConvergeX", (float)options.screen_red_radial_converge_x());
2023               (*d3dintf->effect.set_float)(curr_effect, "RedRadialConvergeY", (float)options.screen_red_radial_converge_y());
2024               (*d3dintf->effect.set_float)(curr_effect, "GrnRadialConvergeX", (float)options.screen_green_radial_converge_x());
2025               (*d3dintf->effect.set_float)(curr_effect, "GrnRadialConvergeY", (float)options.screen_green_radial_converge_y());
2026               (*d3dintf->effect.set_float)(curr_effect, "BluRadialConvergeX", (float)options.screen_blue_radial_converge_x());
2027               (*d3dintf->effect.set_float)(curr_effect, "BluRadialConvergeY", (float)options.screen_blue_radial_converge_y());
2028               (*d3dintf->effect.set_float)(curr_effect, "RedFromRed", (float)options.screen_red_from_red());
2029               (*d3dintf->effect.set_float)(curr_effect, "RedFromGrn", (float)options.screen_red_from_green());
2030               (*d3dintf->effect.set_float)(curr_effect, "RedFromBlu", (float)options.screen_red_from_blue());
2031               (*d3dintf->effect.set_float)(curr_effect, "GrnFromRed", (float)options.screen_green_from_red());
2032               (*d3dintf->effect.set_float)(curr_effect, "GrnFromGrn", (float)options.screen_green_from_green());
2033               (*d3dintf->effect.set_float)(curr_effect, "GrnFromBlu", (float)options.screen_green_from_blue());
2034               (*d3dintf->effect.set_float)(curr_effect, "BluFromRed", (float)options.screen_blue_from_red());
2035               (*d3dintf->effect.set_float)(curr_effect, "BluFromGrn", (float)options.screen_blue_from_green());
2036               (*d3dintf->effect.set_float)(curr_effect, "BluFromBlu", (float)options.screen_blue_from_blue());
2037               (*d3dintf->effect.set_float)(curr_effect, "YfromY", (float)options.screen_y_from_y());
2038               (*d3dintf->effect.set_float)(curr_effect, "YfromI", (float)options.screen_y_from_i());
2039               (*d3dintf->effect.set_float)(curr_effect, "YfromQ", (float)options.screen_y_from_q());
2040               (*d3dintf->effect.set_float)(curr_effect, "IfromY", (float)options.screen_i_from_y());
2041               (*d3dintf->effect.set_float)(curr_effect, "IfromI", (float)options.screen_i_from_i());
2042               (*d3dintf->effect.set_float)(curr_effect, "IfromQ", (float)options.screen_i_from_q());
2043               (*d3dintf->effect.set_float)(curr_effect, "QfromY", (float)options.screen_q_from_y());
2044               (*d3dintf->effect.set_float)(curr_effect, "QfromI", (float)options.screen_q_from_i());
2045               (*d3dintf->effect.set_float)(curr_effect, "QfromQ", (float)options.screen_q_from_q());
2046               (*d3dintf->effect.set_float)(curr_effect, "RedOffset", (float)options.screen_red_offset());
2047               (*d3dintf->effect.set_float)(curr_effect, "GrnOffset", (float)options.screen_green_offset());
2048               (*d3dintf->effect.set_float)(curr_effect, "BluOffset", (float)options.screen_blue_offset());
2049               (*d3dintf->effect.set_float)(curr_effect, "RedScale", (float)options.screen_red_scale());
2050               (*d3dintf->effect.set_float)(curr_effect, "GrnScale", (float)options.screen_green_scale());
2051               (*d3dintf->effect.set_float)(curr_effect, "BluScale", (float)options.screen_blue_scale());
2052               (*d3dintf->effect.set_float)(curr_effect, "RedPower", (float)options.screen_red_power());
2053               (*d3dintf->effect.set_float)(curr_effect, "GrnPower", (float)options.screen_green_power());
2054               (*d3dintf->effect.set_float)(curr_effect, "BluPower", (float)options.screen_blue_power());
2055               (*d3dintf->effect.set_float)(curr_effect, "RedFloor", (float)options.screen_red_floor());
2056               (*d3dintf->effect.set_float)(curr_effect, "GrnFloor", (float)options.screen_green_floor());
2057               (*d3dintf->effect.set_float)(curr_effect, "BluFloor", (float)options.screen_blue_floor());
2058               (*d3dintf->effect.set_float)(curr_effect, "Saturation", (float)options.screen_saturation());
2059               (*d3dintf->effect.set_float)(curr_effect, "YScale", (float)options.screen_y_scale());
2060               (*d3dintf->effect.set_float)(curr_effect, "IScale", (float)options.screen_i_scale());
2061               (*d3dintf->effect.set_float)(curr_effect, "QScale", (float)options.screen_q_scale());
2062               (*d3dintf->effect.set_float)(curr_effect, "YOffset", (float)options.screen_y_offset());
2063               (*d3dintf->effect.set_float)(curr_effect, "IOffset", (float)options.screen_i_offset());
2064               (*d3dintf->effect.set_float)(curr_effect, "QOffset", (float)options.screen_q_offset());
2065               (*d3dintf->effect.set_float)(curr_effect, "EdgeDetectScale", (float)options.screen_edge_amount());
2066               (*d3dintf->effect.set_float)(curr_effect, "EdgeToBaseRatio", (float)options.screen_edge_ratio());
2067               (*d3dintf->effect.set_float)(curr_effect, "SubsampleLength", (float)options.screen_chroma_subsample_length());
2068               int frame = (poly->texture != NULL && poly->texture->cur_frame) ? (float)poly->texture->cur_frame : 0;
2069               frame = (frame == options.screen_dot_crawl_skip()) ? 0 : frame;
2070               (*d3dintf->effect.set_float)(curr_effect, "CurrFrame", (float)frame);
2071               (*d3dintf->effect.set_float)(curr_effect, "CrawlWidth", (float)options.screen_dot_crawl_width());
2072               (*d3dintf->effect.set_float)(curr_effect, "CrawlHeight", (float)options.screen_dot_crawl_height());
2073               (*d3dintf->effect.set_float)(curr_effect, "CrawlRate", (float)options.screen_dot_crawl_rate());
2074               (*d3dintf->effect.set_float)(curr_effect, "CrawlSkip", (float)options.screen_dot_crawl_skip());
20752067            }
20762068            else
20772069            {
r11575r11576
20852077      // set the blendmode if different
20862078      set_blendmode(d3d, PRIMFLAG_GET_BLENDMODE(poly->flags));
20872079
2088      if(d3d->hlsl_enable)
2080      if(d3d->hlsl_enable && d3dintf->post_fx_available)
20892081      {
20902082         assert(vertnum + poly->numverts <= d3d->numverts);
20912083
r11575r11576
20932085
20942086         if(PRIMFLAG_GET_SCREENTEX(d3d->last_texture_flags) && poly->texture != NULL)
20952087         {
2096            /* Render the initial screen pass */
2097            (*d3dintf->effect.set_float)(curr_effect, "FixedAlpha", 1.0f);
2088            curr_effect = d3d->color_effect;
20982089
2099            result = (*d3dintf->device.set_render_target)(d3d->device, 0, poly->texture->d3dtarget0);
2090            /* Render the initial color-convolution pass */
2091            (*d3dintf->effect.set_float)(curr_effect, "RawWidth", poly->texture != NULL ? (float)poly->texture->rawwidth : 8.0f);
2092            (*d3dintf->effect.set_float)(curr_effect, "RawHeight", poly->texture != NULL ? (float)poly->texture->rawheight : 8.0f);
2093            (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
2094            (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
2095            (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
2096            (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
2097            (*d3dintf->effect.set_float)(curr_effect, "RedFromRed", (float)options.screen_red_from_red());
2098            (*d3dintf->effect.set_float)(curr_effect, "RedFromGrn", (float)options.screen_red_from_green());
2099            (*d3dintf->effect.set_float)(curr_effect, "RedFromBlu", (float)options.screen_red_from_blue());
2100            (*d3dintf->effect.set_float)(curr_effect, "GrnFromRed", (float)options.screen_green_from_red());
2101            (*d3dintf->effect.set_float)(curr_effect, "GrnFromGrn", (float)options.screen_green_from_green());
2102            (*d3dintf->effect.set_float)(curr_effect, "GrnFromBlu", (float)options.screen_green_from_blue());
2103            (*d3dintf->effect.set_float)(curr_effect, "BluFromRed", (float)options.screen_blue_from_red());
2104            (*d3dintf->effect.set_float)(curr_effect, "BluFromGrn", (float)options.screen_blue_from_green());
2105            (*d3dintf->effect.set_float)(curr_effect, "BluFromBlu", (float)options.screen_blue_from_blue());
2106            (*d3dintf->effect.set_float)(curr_effect, "YfromY", (float)options.screen_y_from_y());
2107            (*d3dintf->effect.set_float)(curr_effect, "YfromI", (float)options.screen_y_from_i());
2108            (*d3dintf->effect.set_float)(curr_effect, "YfromQ", (float)options.screen_y_from_q());
2109            (*d3dintf->effect.set_float)(curr_effect, "IfromY", (float)options.screen_i_from_y());
2110            (*d3dintf->effect.set_float)(curr_effect, "IfromI", (float)options.screen_i_from_i());
2111            (*d3dintf->effect.set_float)(curr_effect, "IfromQ", (float)options.screen_i_from_q());
2112            (*d3dintf->effect.set_float)(curr_effect, "QfromY", (float)options.screen_q_from_y());
2113            (*d3dintf->effect.set_float)(curr_effect, "QfromI", (float)options.screen_q_from_i());
2114            (*d3dintf->effect.set_float)(curr_effect, "QfromQ", (float)options.screen_q_from_q());
2115            (*d3dintf->effect.set_float)(curr_effect, "RedOffset", (float)options.screen_red_offset());
2116            (*d3dintf->effect.set_float)(curr_effect, "GrnOffset", (float)options.screen_green_offset());
2117            (*d3dintf->effect.set_float)(curr_effect, "BluOffset", (float)options.screen_blue_offset());
2118            (*d3dintf->effect.set_float)(curr_effect, "RedScale", (float)options.screen_red_scale());
2119            (*d3dintf->effect.set_float)(curr_effect, "GrnScale", (float)options.screen_green_scale());
2120            (*d3dintf->effect.set_float)(curr_effect, "BluScale", (float)options.screen_blue_scale());
2121            (*d3dintf->effect.set_float)(curr_effect, "RedPower", (float)options.screen_red_power());
2122            (*d3dintf->effect.set_float)(curr_effect, "GrnPower", (float)options.screen_green_power());
2123            (*d3dintf->effect.set_float)(curr_effect, "BluPower", (float)options.screen_blue_power());
2124            (*d3dintf->effect.set_float)(curr_effect, "RedFloor", (float)options.screen_red_floor());
2125            (*d3dintf->effect.set_float)(curr_effect, "GrnFloor", (float)options.screen_green_floor());
2126            (*d3dintf->effect.set_float)(curr_effect, "BluFloor", (float)options.screen_blue_floor());
2127            (*d3dintf->effect.set_float)(curr_effect, "Saturation", (float)options.screen_saturation());
2128            (*d3dintf->effect.set_float)(curr_effect, "YScale", (float)options.screen_y_scale());
2129            (*d3dintf->effect.set_float)(curr_effect, "IScale", (float)options.screen_i_scale());
2130            (*d3dintf->effect.set_float)(curr_effect, "QScale", (float)options.screen_q_scale());
2131            (*d3dintf->effect.set_float)(curr_effect, "YOffset", (float)options.screen_y_offset());
2132            (*d3dintf->effect.set_float)(curr_effect, "IOffset", (float)options.screen_i_offset());
2133            (*d3dintf->effect.set_float)(curr_effect, "QOffset", (float)options.screen_q_offset());
2134            (*d3dintf->effect.set_float)(curr_effect, "YSubsampleLength", (float)options.screen_y_subsample_length());
2135            (*d3dintf->effect.set_float)(curr_effect, "ISubsampleLength", (float)options.screen_i_subsample_length());
2136            (*d3dintf->effect.set_float)(curr_effect, "QSubsampleLength", (float)options.screen_q_subsample_length());
21002137
2101            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 3\n", (int)result);
2102            result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
2138            result = (*d3dintf->device.set_render_target)(d3d->device, 0, poly->texture->d3dsmalltarget0);
2139
2140            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call\n", (int)result);
2141            result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(255,0,0,0), 0, 0);
21032142            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
21042143
21052144            (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
r11575r11576
21152154
21162155            (*d3dintf->effect.end)(curr_effect);
21172156
2118            // max() the two previous frames
2119            curr_effect = d3d->phosphor_effect;
2157            /* Deconverge pass */
2158            curr_effect = d3d->deconverge_effect;
2159            (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", poly->texture->d3dsmalltexture0);
21202160
21212161            (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
21222162            (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
21232163            (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
21242164            (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
2125            (*d3dintf->effect.set_float)(curr_effect, "RedPhosphor", (float)options.screen_red_phosphor());
2126            (*d3dintf->effect.set_float)(curr_effect, "GreenPhosphor", (float)options.screen_green_phosphor());
2127            (*d3dintf->effect.set_float)(curr_effect, "BluePhosphor", (float)options.screen_blue_phosphor());
2165            (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
2166            (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
2167            (*d3dintf->effect.set_float)(curr_effect, "RedConvergeX", (float)options.screen_red_converge_x());
2168            (*d3dintf->effect.set_float)(curr_effect, "RedConvergeY", (float)options.screen_red_converge_y());
2169            (*d3dintf->effect.set_float)(curr_effect, "GrnConvergeX", (float)options.screen_green_converge_x());
2170            (*d3dintf->effect.set_float)(curr_effect, "GrnConvergeY", (float)options.screen_green_converge_y());
2171            (*d3dintf->effect.set_float)(curr_effect, "BluConvergeX", (float)options.screen_blue_converge_x());
2172            (*d3dintf->effect.set_float)(curr_effect, "BluConvergeY", (float)options.screen_blue_converge_y());
2173            (*d3dintf->effect.set_float)(curr_effect, "RedRadialConvergeX", (float)options.screen_red_radial_converge_x());
2174            (*d3dintf->effect.set_float)(curr_effect, "RedRadialConvergeY", (float)options.screen_red_radial_converge_y());
2175            (*d3dintf->effect.set_float)(curr_effect, "GrnRadialConvergeX", (float)options.screen_green_radial_converge_x());
2176            (*d3dintf->effect.set_float)(curr_effect, "GrnRadialConvergeY", (float)options.screen_green_radial_converge_y());
2177            (*d3dintf->effect.set_float)(curr_effect, "BluRadialConvergeX", (float)options.screen_blue_radial_converge_x());
2178            (*d3dintf->effect.set_float)(curr_effect, "BluRadialConvergeY", (float)options.screen_blue_radial_converge_y());
21282179
2129            (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", poly->texture->d3dtexture0);
2130            (*d3dintf->effect.set_texture)(curr_effect, "LastPass", d3d->last_d3dtexture[cur_render_screen]);
2180            (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
21312181
2132            result = (*d3dintf->device.set_render_target)(d3d->device, 0, poly->texture->d3dtarget1);
2133            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 4\n", (int)result);
2182            result = (*d3dintf->device.set_render_target)(d3d->device, 0, poly->texture->d3dtarget2);
2183            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 6\n", (int)result);
21342184            result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
21352185            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
21362186
2137            (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
2138
21392187            for (UINT pass = 0; pass < num_passes; pass++)
21402188            {
21412189               (*d3dintf->effect.begin_pass)(curr_effect, pass);
r11575r11576
21472195
21482196            (*d3dintf->effect.end)(curr_effect);
21492197
2150            /* Pass along our phosphor'd screen */
2151            curr_effect = d3d->phosphor_effect;
2198            /* Defocus pass 1 */
2199            curr_effect = d3d->focus_effect;
21522200
2153            (*d3dintf->effect.set_float)(curr_effect, "FixedAlpha", 1.0f);
2201            (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", poly->texture->d3dtexture2);
21542202
2155            (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", poly->texture->d3dtexture1);
2156            (*d3dintf->effect.set_texture)(curr_effect, "LastPass", poly->texture->d3dtexture1);
2203            float defocus_x = (float)options.screen_defocus_x();
2204            float defocus_y = (float)options.screen_defocus_y();
2205            (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
2206            (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
2207            (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
2208            (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
2209            (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", poly->texture != NULL ? (1.0f / (poly->texture->ustop - poly->texture->ustart)) : 0.0f);
2210            (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", poly->texture != NULL ? (1.0f / (poly->texture->vstop - poly->texture->vstart)) : 0.0f);
2211            (*d3dintf->effect.set_float)(curr_effect, "DefocusX", defocus_x);
2212            (*d3dintf->effect.set_float)(curr_effect, "DefocusY", defocus_y);
2213            (*d3dintf->effect.set_float)(curr_effect, "FocusEnable", (defocus_x == 0.0f && defocus_y == 0.0f) ? 0.0f : 1.0f);
21572214
2158            result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->last_d3dtarget[cur_render_screen++]);
2159            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 5\n", (int)result);
2215            (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
2216
2217            result = (*d3dintf->device.set_render_target)(d3d->device, 0, poly->texture->d3dtarget0);
2218            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 6\n", (int)result);
21602219            result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
21612220            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
21622221
2163            (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
2164
21652222            for (UINT pass = 0; pass < num_passes; pass++)
21662223            {
21672224               (*d3dintf->effect.begin_pass)(curr_effect, pass);
r11575r11576
21732230
21742231            (*d3dintf->effect.end)(curr_effect);
21752232
2176            /* Next, defocus pass 1 */
2177            curr_effect = d3d->focus_effect;
2233            /* Defocus pass 2 */
21782234
2179            (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", poly->texture->d3dtexture1);
2235            (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", poly->texture->d3dtexture0);
21802236
2181            float defocus_x = (float)options.screen_defocus_x();
2182            float defocus_y = (float)options.screen_defocus_y();
21832237            (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
21842238            (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
21852239            (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
21862240            (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
2241            (*d3dintf->effect.set_float)(curr_effect, "WidthRatio", 1.0f);
2242            (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f);
21872243            (*d3dintf->effect.set_float)(curr_effect, "DefocusX", defocus_x);
21882244            (*d3dintf->effect.set_float)(curr_effect, "DefocusY", defocus_y);
21892245            (*d3dintf->effect.set_float)(curr_effect, "FocusEnable", (defocus_x == 0.0f && defocus_y == 0.0f) ? 0.0f : 1.0f);
21902246
21912247            (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
21922248
2193            result = (*d3dintf->device.set_render_target)(d3d->device, 0, poly->texture->d3dtarget2);
2194            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 6\n", (int)result);
2195            result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
2196            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
2249            result = (*d3dintf->device.set_render_target)(d3d->device, 0, poly->texture->d3dtarget1);
2250            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 7\n", (int)result);
21972251
21982252            for (UINT pass = 0; pass < num_passes; pass++)
21992253            {
r11575r11576
22062260
22072261            (*d3dintf->effect.end)(curr_effect);
22082262
2209            /* Lastly, defocus pass 1 */
2210            (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", poly->texture->d3dtexture2);
2263            // Simulate phosphorescence. This should happen after the shadow/scanline pass, but since
2264            // the phosphors are a direct result of the incoming texture, might as well just change the
2265            // input texture.
2266            curr_effect = d3d->phosphor_effect;
22112267
22122268            (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
22132269            (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
22142270            (*d3dintf->effect.set_float)(curr_effect, "RawWidth", (float)poly->texture->rawwidth);
22152271            (*d3dintf->effect.set_float)(curr_effect, "RawHeight", (float)poly->texture->rawheight);
2216            (*d3dintf->effect.set_float)(curr_effect, "DefocusX", defocus_x);
2217            (*d3dintf->effect.set_float)(curr_effect, "DefocusY", defocus_y);
2218            (*d3dintf->effect.set_float)(curr_effect, "FocusEnable", (defocus_x == 0.0f && defocus_y == 0.0f) ? 0.0f : 1.0f);
2272            (*d3dintf->effect.set_float)(curr_effect, "RedPhosphor", (float)options.screen_red_phosphor());
2273            (*d3dintf->effect.set_float)(curr_effect, "GreenPhosphor", (float)options.screen_green_phosphor());
2274            (*d3dintf->effect.set_float)(curr_effect, "BluePhosphor", (float)options.screen_blue_phosphor());
22192275
2276            (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", poly->texture->d3dtexture1);
2277            (*d3dintf->effect.set_texture)(curr_effect, "LastPass", d3d->last_d3dtexture[cur_render_screen]);
2278
2279            result = (*d3dintf->device.set_render_target)(d3d->device, 0, poly->texture->d3dtarget0);
2280            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 4\n", (int)result);
2281            result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
2282            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
2283
22202284            (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
22212285
2286            for (UINT pass = 0; pass < num_passes; pass++)
2287            {
2288               (*d3dintf->effect.begin_pass)(curr_effect, pass);
2289               // add the primitives
2290               result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
2291               if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
2292               (*d3dintf->effect.end_pass)(curr_effect);
2293            }
2294
2295            (*d3dintf->effect.end)(curr_effect);
2296
2297            /* Pass along our phosphor'd screen */
2298            curr_effect = d3d->phosphor_effect;
2299
2300            (*d3dintf->effect.set_float)(curr_effect, "FixedAlpha", 1.0f);
2301
2302            (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", poly->texture->d3dtexture1);
2303            (*d3dintf->effect.set_texture)(curr_effect, "LastPass", poly->texture->d3dtexture1);
2304
2305            result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->last_d3dtarget[cur_render_screen++]);
2306            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 5\n", (int)result);
2307            result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
2308            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
2309
2310            (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
2311
2312            for (UINT pass = 0; pass < num_passes; pass++)
2313            {
2314               (*d3dintf->effect.begin_pass)(curr_effect, pass);
2315               // add the primitives
2316               result = (*d3dintf->device.draw_primitive)(d3d->device, poly->type, vertnum, poly->count);
2317               if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device draw_primitive call\n", (int)result);
2318               (*d3dintf->effect.end_pass)(curr_effect);
2319            }
2320
2321            (*d3dintf->effect.end)(curr_effect);
2322
2323            /* Scanlines and shadow mask */
2324            curr_effect = d3d->post_effect;
2325
2326            (*d3dintf->effect.set_texture)(curr_effect, "Diffuse", poly->texture->d3dtexture0);
2327
22222328            result = (*d3dintf->device.set_render_target)(d3d->device, 0, backbuffer);
2223            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 7\n", (int)result);
2329            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_render_target call 5\n", (int)result);
2330            result = (*d3dintf->device.clear)(d3d->device, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0,0,0,0), 0, 0);
2331            if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device clear call\n", (int)result);
22242332
2333            (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
2334
22252335            for (UINT pass = 0; pass < num_passes; pass++)
22262336            {
22272337               (*d3dintf->effect.begin_pass)(curr_effect, pass);
r11575r11576
22342344            (*d3dintf->effect.end)(curr_effect);
22352345
22362346            poly->texture->cur_frame++;
2237            poly->texture->cur_frame %= options.screen_dot_crawl_rate();
2347            poly->texture->cur_frame %= 2;
22382348         }
22392349         else
22402350         {
r11575r11576
22452355            (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width);
22462356            (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height);
22472357            (*d3dintf->effect.set_float)(curr_effect, "PostPass", 0.0f);
2248            (*d3dintf->effect.set_float)(curr_effect, "PincushionAmountX", (float)options.screen_pincushion_x());
2249            (*d3dintf->effect.set_float)(curr_effect, "PincushionAmountY", (float)options.screen_pincushion_y());
2358            (*d3dintf->effect.set_float)(curr_effect, "PincushionAmountX", (float)options.screen_pincushion());
2359            (*d3dintf->effect.set_float)(curr_effect, "PincushionAmountY", (float)options.screen_pincushion());
22502360
22512361            (*d3dintf->effect.begin)(curr_effect, &num_passes, 0);
22522362
r11575r11576
22742384      vertnum += poly->numverts;
22752385   }
22762386
2277   (*d3dintf->surface.release)(backbuffer);
2387   if(d3d->hlsl_enable && d3dintf->post_fx_available)
2388   {
2389      (*d3dintf->surface.release)(backbuffer);
2390   }
22782391
22792392   // reset the vertex count
22802393   d3d->numverts = 0;
r11575r11576
23722485               if (result != D3D_OK)
23732486                  goto error;
23742487               (*d3dintf->texture.get_surface_level)(d3d->last_d3dtexture[d3d->registered_targets], 0, &d3d->last_d3dtarget[d3d->registered_targets]);
2375               d3d->registered_targets++;
23762488
23772489               result = (*d3dintf->device.create_texture)(d3d->device, (int)(d3d->width * d3d->oversample_x), (int)(d3d->height * d3d->oversample_y), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture->d3dtexture1);
23782490               if (result != D3D_OK)
r11575r11576
23832495               if (result != D3D_OK)
23842496                  goto error;
23852497               (*d3dintf->texture.get_surface_level)(texture->d3dtexture2, 0, &texture->d3dtarget2);
2498
2499               result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth, texture->rawheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture->d3dsmalltexture0);
2500               if (result != D3D_OK)
2501                  goto error;
2502               (*d3dintf->texture.get_surface_level)(texture->d3dsmalltexture0, 0, &texture->d3dsmalltarget0);
2503
2504               result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth, texture->rawheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture->d3dsmalltexture1);
2505               if (result != D3D_OK)
2506                  goto error;
2507               (*d3dintf->texture.get_surface_level)(texture->d3dsmalltexture1, 0, &texture->d3dsmalltarget1);
2508
2509               d3d->registered_targets++;
2510
23862511               break;
23872512            }
23882513         }
r11575r11576
24422567                  goto error;
24432568               (*d3dintf->texture.get_surface_level)(texture->d3dtexture2, 0, &texture->d3dtarget2);
24442569
2570               result = (*d3dintf->device.create_texture)(d3d->device, scwidth, scheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture->d3dsmalltexture0);
2571               if (result != D3D_OK)
2572                  goto error;
2573               (*d3dintf->texture.get_surface_level)(texture->d3dsmalltexture0, 0, &texture->d3dsmalltarget0);
2574
2575               result = (*d3dintf->device.create_texture)(d3d->device, scwidth, scheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &texture->d3dsmalltexture1);
2576               if (result != D3D_OK)
2577                  goto error;
2578               (*d3dintf->texture.get_surface_level)(texture->d3dsmalltexture0, 1, &texture->d3dsmalltarget1);
2579
24452580               break;
24462581            }
24472582            (*d3dintf->texture.release)(texture->d3dtex);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team