Previous 199869 Revisions Next

r29466 Tuesday 8th April, 2014 at 18:34:47 UTC by Ryan Holtz
- Fixed bloom misalignment with HLSL. [MooglyGuy]
[hlsl]bloom.fx
[src/osd/windows]d3dhlsl.c d3dhlsl.h

trunk/hlsl/bloom.fx
r29465r29466
143143{
144144   float4 Position : POSITION;
145145   float4 Color : COLOR0;
146   float2 TexCoord : TEXCOORD0;
146   float4 TexCoord01 : TEXCOORD0;
147   float4 TexCoord23 : TEXCOORD1;
148   float4 TexCoord45 : TEXCOORD2;
149   float4 TexCoord67 : TEXCOORD3;
150   float4 TexCoord89 : TEXCOORD4;
151   float2 TexCoordA : TEXCOORD5;
147152};
148153
149154struct VS_INPUT
r29465r29466
157162struct PS_INPUT
158163{
159164   float4 Color : COLOR0;
160   float2 TexCoord : TEXCOORD0;
165   float4 TexCoord01 : TEXCOORD0;
166   float4 TexCoord23 : TEXCOORD1;
167   float4 TexCoord45 : TEXCOORD2;
168   float4 TexCoord67 : TEXCOORD3;
169   float4 TexCoord89 : TEXCOORD4;
170   float2 TexCoordA : TEXCOORD5;
161171};
162172
163173//-----------------------------------------------------------------------------
r29465r29466
165175//-----------------------------------------------------------------------------
166176
167177uniform float2 TargetSize;
178uniform float4 Level01Size;
179uniform float4 Level23Size;
180uniform float4 Level45Size;
181uniform float4 Level67Size;
182uniform float4 Level89Size;
183uniform float2 LevelASize;
168184
169185VS_OUTPUT vs_main(VS_INPUT Input)
170186{
r29465r29466
176192   Output.Position.xy -= float2(0.5f, 0.5f);
177193   Output.Position.xy *= float2(2.0f, 2.0f);
178194   Output.Color = Input.Color;
179   Output.TexCoord = (Input.Position.xy  + 0.5f) / TargetSize;
195   Output.TexCoord01 = Input.Position.xyxy / TargetSize.xyxy - 0.5f / Level01Size;
196   Output.TexCoord23 = Input.Position.xyxy / TargetSize.xyxy - 0.5f / Level23Size;
197   Output.TexCoord45 = Input.Position.xyxy / TargetSize.xyxy - 0.5f / Level45Size;
198   Output.TexCoord67 = Input.Position.xyxy / TargetSize.xyxy - 0.5f / Level67Size;
199   Output.TexCoord89 = Input.Position.xyxy / TargetSize.xyxy - 0.5f / Level89Size;
200   Output.TexCoordA = Input.Position.xy / TargetSize - 0.5f / LevelASize;
180201
181202   return Output;
182203}
r29465r29466
191212
192213float4 ps_main(PS_INPUT Input) : COLOR
193214{
194   float3 texel0 = tex2D(DiffuseSampler0, Input.TexCoord).rgb;
195   float3 texel1 = tex2D(DiffuseSampler1, Input.TexCoord).rgb;
196   float3 texel2 = tex2D(DiffuseSampler2, Input.TexCoord).rgb;
197   float3 texel3 = tex2D(DiffuseSampler3, Input.TexCoord).rgb;
198   float3 texel4 = tex2D(DiffuseSampler4, Input.TexCoord).rgb;
199   float3 texel5 = tex2D(DiffuseSampler5, Input.TexCoord).rgb;
200   float3 texel6 = tex2D(DiffuseSampler6, Input.TexCoord).rgb;
201   float3 texel7 = tex2D(DiffuseSampler7, Input.TexCoord).rgb;
202   float3 texel8 = tex2D(DiffuseSampler8, Input.TexCoord).rgb;
203   float3 texel9 = tex2D(DiffuseSampler9, Input.TexCoord).rgb;
204   float3 texelA = tex2D(DiffuseSamplerA, Input.TexCoord).rgb;
215   float3 texel0 = tex2D(DiffuseSampler0, Input.TexCoord01.xy).rgb;
216   float3 texel1 = tex2D(DiffuseSampler1, Input.TexCoord01.zw).rgb;
217   float3 texel2 = tex2D(DiffuseSampler2, Input.TexCoord23.xy).rgb;
218   float3 texel3 = tex2D(DiffuseSampler3, Input.TexCoord23.zw).rgb;
219   float3 texel4 = tex2D(DiffuseSampler4, Input.TexCoord45.xy).rgb;
220   float3 texel5 = tex2D(DiffuseSampler5, Input.TexCoord45.zw).rgb;
221   float3 texel6 = tex2D(DiffuseSampler6, Input.TexCoord67.xy).rgb;
222   float3 texel7 = tex2D(DiffuseSampler7, Input.TexCoord67.zw).rgb;
223   float3 texel8 = tex2D(DiffuseSampler8, Input.TexCoord89.xy).rgb;
224   float3 texel9 = tex2D(DiffuseSampler9, Input.TexCoord89.zw).rgb;
225   float3 texelA = tex2D(DiffuseSamplerA, Input.TexCoordA).rgb;
205226
206227   texel0 = texel0 * Level0123Weight.x;
207228   texel1 = texel1 * Level0123Weight.y;
trunk/src/osd/windows/d3dhlsl.c
r29465r29466
16641664   float bloom_height = rt->target_height;
16651665   vec2f screendims = d3d->get_dims();
16661666   curr_effect->set_vector("ScreenSize", 2, &screendims.c.x);
1667   float bloom_dims[11][2];
16671668   for(; bloom_size >= 2.0f && bloom_index < 11; bloom_size *= 0.5f)
16681669   {
1669      target_size[0] = bloom_width;
1670      target_size[1] = bloom_height;
1671      curr_effect->set_vector("TargetSize", 2, target_size);
1670      bloom_dims[bloom_index][0] = bloom_width;
1671      bloom_dims[bloom_index][1] = bloom_height;
1672      curr_effect->set_vector("TargetSize", 2, bloom_dims[bloom_index]);
16721673
16731674      curr_effect->begin(&num_passes, 0);
16741675
r29465r29466
16981699
16991700   curr_effect = bloom_effect;
17001701
1702   float target_size[2] = { d3d->get_width(), d3d->get_height() };
1703   curr_effect->set_vector("TargetSize", 2, target_size);
17011704   float weight0123[4] = { options->bloom_level0_weight, options->bloom_level1_weight, options->bloom_level2_weight, options->bloom_level3_weight };
17021705   float weight4567[4] = { options->bloom_level4_weight, options->bloom_level5_weight, options->bloom_level6_weight, options->bloom_level7_weight };
17031706   float weight89A[3]  = { options->bloom_level8_weight, options->bloom_level9_weight, options->bloom_level10_weight };
17041707   curr_effect->set_vector("Level0123Weight", 4, weight0123);
17051708   curr_effect->set_vector("Level4567Weight", 4, weight4567);
17061709   curr_effect->set_vector("Level89AWeight", 3, weight89A);
1707   curr_effect->set_vector("TargetSize", 2, &screendims.c.x);
1710   curr_effect->set_vector("Level01Size", 4, bloom_dims[0]);
1711   curr_effect->set_vector("Level23Size", 4, bloom_dims[2]);
1712   curr_effect->set_vector("Level45Size", 4, bloom_dims[4]);
1713   curr_effect->set_vector("Level67Size", 4, bloom_dims[6]);
1714   curr_effect->set_vector("Level89Size", 4, bloom_dims[8]);
1715   curr_effect->set_vector("LevelASize", 2, bloom_dims[10]);
17081716
17091717   curr_effect->set_texture("DiffuseA", rt->render_texture[2]);
17101718
r29465r29466
18461854      float bloom_height = rt->target_height;
18471855      float screen_size[2] = { d3d->get_width(), d3d->get_height() };
18481856      curr_effect->set_vector("ScreenSize", 2, screen_size);
1857      float bloom_dims[11][2];
18491858      for(; bloom_size >= 2.0f && bloom_index < 11; bloom_size *= 0.5f)
18501859      {
1851         target_size[0] = bloom_width;
1852         target_size[1] = bloom_height;
1853         curr_effect->set_vector("TargetSize", 2, target_size);
1860         bloom_dims[bloom_index][0] = bloom_width;
1861         bloom_dims[bloom_index][1] = bloom_height;
1862         curr_effect->set_vector("TargetSize", 2, bloom_dims[bloom_index]);
18541863
18551864         curr_effect->begin(&num_passes, 0);
18561865
r29465r29466
18911900      curr_effect->set_vector("Level0123Weight", 4, weight0123);
18921901      curr_effect->set_vector("Level4567Weight", 4, weight4567);
18931902      curr_effect->set_vector("Level89AWeight", 3, weight89A);
1903      curr_effect->set_vector("Level01Size", 4, bloom_dims[0]);
1904      curr_effect->set_vector("Level23Size", 4, bloom_dims[2]);
1905      curr_effect->set_vector("Level45Size", 4, bloom_dims[4]);
1906      curr_effect->set_vector("Level67Size", 4, bloom_dims[6]);
1907      curr_effect->set_vector("Level89Size", 4, bloom_dims[8]);
1908      curr_effect->set_vector("LevelASize", 2, bloom_dims[10]);
18941909
18951910      curr_effect->set_texture("DiffuseA", rt->render_texture[0]);
18961911
r29465r29466
31403155         m_shader->set_vector("Floor", 3, options->floor);
31413156         break;
31423157
3143      case CU_BLOOM_TARGET_SIZE:
3144         m_shader->set_vector("TargetSize", 2, shadersys->target_size);
3145         break;
31463158      case CU_BLOOM_RESCALE:
31473159         m_shader->set_float("BloomRescale", options->raster_bloom_scale);
31483160         break;
trunk/src/osd/windows/d3dhlsl.h
r29465r29466
8888      CU_POST_POWER,
8989      CU_POST_FLOOR,
9090
91      CU_BLOOM_TARGET_SIZE,
9291      CU_BLOOM_RESCALE,
9392      CU_BLOOM_LVL0123_WEIGHTS,
9493      CU_BLOOM_LVL4567_WEIGHTS,
r29465r29466
402401
403402   texture_info *          curr_texture;
404403   bool                    phosphor_passthrough;
405   float                   target_size[2];
406404
407405public:
408406   render_target *         targethead;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team