trunk/hlsl/artwork_support/post.fx
| r250292 | r250293 | |
| 152 | 152 | // Post-Processing Pixel Shader |
| 153 | 153 | //----------------------------------------------------------------------------- |
| 154 | 154 | |
| 155 | uniform float2 ScreenScale = float2(1.0f, 1.0f); |
| 156 | uniform float2 ScreenOffset = float2(0.0f, 0.0f); |
| 157 | |
| 155 | 158 | uniform float ScanlineAlpha = 1.0f; |
| 156 | 159 | uniform float ScanlineScale = 1.0f; |
| 157 | 160 | uniform float ScanlineBrightScale = 1.0f; |
| r250292 | r250293 | |
| 334 | 337 | return coord; |
| 335 | 338 | } |
| 336 | 339 | |
| 340 | float2 GetAdjustedCoords(float2 coord, float2 centerOffset, float distortionAmount) |
| 341 | { |
| 342 | float2 RatioCorrection = GetRatioCorrection(); |
| 343 | |
| 344 | // center coordinates |
| 345 | coord -= centerOffset; |
| 346 | |
| 347 | // apply ratio difference between screen and quad |
| 348 | coord /= RatioCorrection; |
| 349 | |
| 350 | // applay screen scale |
| 351 | coord /= ScreenScale; |
| 352 | |
| 353 | // distort coordinates |
| 354 | coord = GetDistortedCoords(coord, distortionAmount); |
| 355 | |
| 356 | // revert ratio difference between screen and quad |
| 357 | coord *= RatioCorrection; |
| 358 | |
| 359 | // un-center coordinates |
| 360 | coord += centerOffset; |
| 361 | |
| 362 | // apply screen offset |
| 363 | coord += (centerOffset * 2.0) * ScreenOffset; |
| 364 | |
| 365 | return coord; |
| 366 | } |
| 367 | |
| 337 | 368 | float4 ps_main(PS_INPUT Input) : COLOR |
| 338 | 369 | { |
| 339 | 370 | float2 ScreenTexelDims = 1.0f / ScreenDims; |
| r250292 | r250293 | |
| 345 | 376 | float2 ScreenCoord = Input.ScreenCoord / ScreenDims; |
| 346 | 377 | ScreenCoord = GetCoords(ScreenCoord, float2(0.5f, 0.5f), CurvatureAmount); |
| 347 | 378 | |
| 379 | float2 DistortionCoord = Input.TexCoord; |
| 380 | DistortionCoord = GetCoords(DistortionCoord, HalfSourceRect, CurvatureAmount); |
| 381 | |
| 348 | 382 | float2 BaseCoord = Input.TexCoord; |
| 349 | | BaseCoord = GetCoords(BaseCoord, HalfSourceRect, CurvatureAmount); |
| 383 | BaseCoord = GetAdjustedCoords(BaseCoord, HalfSourceRect, CurvatureAmount); |
| 350 | 384 | |
| 385 | float2 DistortionCoordCentered = DistortionCoord; |
| 386 | DistortionCoordCentered -= HalfSourceRect; |
| 387 | |
| 351 | 388 | float2 BaseCoordCentered = BaseCoord; |
| 352 | 389 | BaseCoordCentered -= HalfSourceRect; |
| 353 | 390 | |
| 354 | 391 | float4 BaseColor = tex2D(DiffuseSampler, BaseCoord); |
| 355 | 392 | BaseColor.a = 1.0f; |
| 356 | 393 | |
| 394 | if (BaseCoord.x < 0.0f || BaseCoord.y < 0.0f) |
| 395 | { |
| 396 | BaseColor.rgb = 0.0f; |
| 397 | } |
| 398 | |
| 357 | 399 | // Mask Simulation (may not affect bloom) |
| 358 | 400 | if (!PrepareBloom) |
| 359 | 401 | { |
| r250292 | r250293 | |
| 431 | 473 | // Vignetting Simulation (may not affect bloom) |
| 432 | 474 | if (!PrepareBloom) |
| 433 | 475 | { |
| 434 | | float2 VignetteCoord = BaseCoordCentered; |
| 476 | float2 VignetteCoord = DistortionCoordCentered; |
| 435 | 477 | |
| 436 | 478 | float VignetteFactor = GetVignetteFactor(VignetteCoord, VignettingAmount); |
| 437 | 479 | Output.rgb *= VignetteFactor; |
| r250292 | r250293 | |
| 442 | 484 | { |
| 443 | 485 | float3 LightColor = float3(1.0f, 0.90f, 0.80f); |
| 444 | 486 | |
| 445 | | float2 SpotCoord = BaseCoordCentered; |
| 446 | | float2 NoiseCoord = BaseCoordCentered; |
| 487 | float2 SpotCoord = DistortionCoordCentered; |
| 488 | float2 NoiseCoord = DistortionCoordCentered; |
| 447 | 489 | |
| 448 | 490 | float SpotAddend = GetSpotAddend(SpotCoord, ReflectionAmount); |
| 449 | 491 | float NoiseFactor = GetNoiseFactor(SpotAddend, random(NoiseCoord)); |
| r250292 | r250293 | |
| 451 | 493 | } |
| 452 | 494 | |
| 453 | 495 | // Round Corners Simulation (may affect bloom) |
| 454 | | float2 RoundCornerCoord = BaseCoordCentered; |
| 496 | float2 RoundCornerCoord = DistortionCoordCentered; |
| 455 | 497 | |
| 456 | 498 | float roundCornerFactor = GetRoundCornerFactor(RoundCornerCoord, RoundCornerAmount, SmoothBorderAmount); |
| 457 | 499 | Output.rgb *= roundCornerFactor; |
trunk/hlsl/post.fx
| r250292 | r250293 | |
| 77 | 77 | |
| 78 | 78 | uniform float2 ScreenDims; // size of the window or fullscreen |
| 79 | 79 | uniform float2 SourceDims; // size of the texture in power-of-two size |
| 80 | uniform float2 SourceRect; // size of the uv rectangle |
| 80 | 81 | uniform float2 TargetDims; // size of the target surface |
| 81 | 82 | |
| 82 | 83 | uniform float2 ShadowDims = float2(32.0f, 32.0f); // size of the shadow texture (extended to power-of-two size) |
| r250292 | r250293 | |
| 124 | 125 | // Post-Processing Pixel Shader |
| 125 | 126 | //----------------------------------------------------------------------------- |
| 126 | 127 | |
| 128 | uniform float2 ScreenScale = float2(1.0f, 1.0f); |
| 129 | uniform float2 ScreenOffset = float2(0.0f, 0.0f); |
| 130 | |
| 127 | 131 | uniform float ScanlineAlpha = 1.0f; |
| 128 | 132 | uniform float ScanlineScale = 1.0f; |
| 129 | 133 | uniform float ScanlineBrightScale = 1.0f; |
| r250292 | r250293 | |
| 138 | 142 | uniform float3 Power = float3(1.0f, 1.0f, 1.0f); |
| 139 | 143 | uniform float3 Floor = float3(0.0f, 0.0f, 0.0f); |
| 140 | 144 | |
| 145 | float2 GetAdjustedCoords(float2 coord, float2 centerOffset) |
| 146 | { |
| 147 | // center coordinates |
| 148 | coord -= centerOffset; |
| 149 | |
| 150 | // apply screen scale |
| 151 | coord /= ScreenScale; |
| 152 | |
| 153 | // un-center coordinates |
| 154 | coord += centerOffset; |
| 155 | |
| 156 | // apply screen offset |
| 157 | coord += (centerOffset * 2.0) * ScreenOffset; |
| 158 | |
| 159 | return coord; |
| 160 | } |
| 161 | |
| 141 | 162 | float4 ps_main(PS_INPUT Input) : COLOR |
| 142 | 163 | { |
| 143 | 164 | float2 ScreenTexelDims = 1.0f / ScreenDims; |
| 144 | 165 | |
| 166 | float2 HalfSourceRect = PrepareVector |
| 167 | ? float2(0.5f, 0.5f) |
| 168 | : SourceRect * 0.5f; |
| 169 | |
| 145 | 170 | float2 ScreenCoord = Input.ScreenCoord / ScreenDims; |
| 146 | | float2 BaseCoord = Input.TexCoord; |
| 171 | float2 BaseCoord = GetAdjustedCoords(Input.TexCoord, HalfSourceRect); |
| 147 | 172 | |
| 148 | 173 | // Color |
| 149 | 174 | float4 BaseColor = tex2D(DiffuseSampler, BaseCoord); |
| 150 | 175 | BaseColor.a = 1.0f; |
| 151 | 176 | |
| 177 | if (BaseCoord.x < 0.0f || BaseCoord.y < 0.0f) |
| 178 | { |
| 179 | BaseColor.rgb = 0.0f; |
| 180 | } |
| 181 | |
| 152 | 182 | // Mask Simulation (may not affect bloom) |
| 153 | 183 | if (!PrepareBloom) |
| 154 | 184 | { |
trunk/src/emu/render.cpp
| r250292 | r250293 | |
| 924 | 924 | m_base_view(NULL), |
| 925 | 925 | m_base_orientation(ROT0), |
| 926 | 926 | m_maxtexwidth(65536), |
| 927 | | m_maxtexheight(65536) |
| 927 | m_maxtexheight(65536), |
| 928 | m_scale_primitives(true), |
| 929 | m_offset_primitives(true) |
| 928 | 930 | { |
| 929 | 931 | // determine the base layer configuration based on options |
| 930 | 932 | m_base_layerconfig.set_backdrops_enabled(manager.machine().options().use_backdrops()); |
| r250292 | r250293 | |
| 1659 | 1661 | float yoffs = (container_xform.orientation & ORIENTATION_SWAP_XY) ? container.xoffset() : container.yoffset(); |
| 1660 | 1662 | if (container_xform.orientation & ORIENTATION_FLIP_X) xoffs = -xoffs; |
| 1661 | 1663 | if (container_xform.orientation & ORIENTATION_FLIP_Y) yoffs = -yoffs; |
| 1664 | if (!m_scale_primitives) |
| 1665 | { |
| 1666 | xscale = 1.0f; |
| 1667 | yscale = 1.0f; |
| 1668 | } |
| 1669 | if (!m_offset_primitives) |
| 1670 | { |
| 1671 | xoffs = 0.0f; |
| 1672 | yoffs = 0.0f; |
| 1673 | } |
| 1662 | 1674 | container_xform.xscale = xform.xscale * xscale; |
| 1663 | 1675 | container_xform.yscale = xform.yscale * yscale; |
| 1664 | 1676 | if (xform.no_center) |
trunk/src/emu/render.h
| r250292 | r250293 | |
| 898 | 898 | void set_orientation(int orientation) { m_orientation = orientation; } |
| 899 | 899 | void set_view(int viewindex); |
| 900 | 900 | void set_max_texture_size(int maxwidth, int maxheight); |
| 901 | void set_scale_primitives(bool enable) { m_scale_primitives = enable; } |
| 902 | void set_offset_primitives(bool enable) { m_offset_primitives = enable; } |
| 901 | 903 | |
| 902 | 904 | // layer config getters |
| 903 | 905 | bool backdrops_enabled() const { return m_layerconfig.backdrops_enabled(); } |
| r250292 | r250293 | |
| 996 | 998 | simple_list<render_container> m_debug_containers; // list of debug containers |
| 997 | 999 | INT32 m_clear_extent_count; // number of clear extents |
| 998 | 1000 | INT32 m_clear_extents[MAX_CLEAR_EXTENTS]; // array of clear extents |
| 1001 | bool m_scale_primitives; // determines if the primitive shall be scaled/offset by screen settings, |
| 1002 | bool m_offset_primitives; // otherwise the respective render API will handle it (default is true) |
| 999 | 1003 | |
| 1000 | 1004 | static render_screen_list s_empty_screen_list; |
| 1001 | 1005 | }; |
trunk/src/osd/modules/render/d3d/d3dhlsl.cpp
| r250292 | r250293 | |
| 964 | 964 | color_effect->add_uniform("Saturation", uniform::UT_FLOAT, uniform::CU_COLOR_SATURATION); |
| 965 | 965 | |
| 966 | 966 | prescale_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 967 | | prescale_effect->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS); |
| 968 | | |
| 967 | |
| 969 | 968 | deconverge_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 970 | 969 | deconverge_effect->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS); |
| 971 | 970 | deconverge_effect->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT); |
| r250292 | r250293 | |
| 988 | 987 | bloom_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS); |
| 989 | 988 | |
| 990 | 989 | post_effect->add_uniform("SourceDims", uniform::UT_VEC2, uniform::CU_SOURCE_DIMS); |
| 991 | | post_effect->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT); // backward compatibility |
| 990 | post_effect->add_uniform("SourceRect", uniform::UT_VEC2, uniform::CU_SOURCE_RECT); |
| 992 | 991 | post_effect->add_uniform("ScreenDims", uniform::UT_VEC2, uniform::CU_SCREEN_DIMS); |
| 993 | 992 | post_effect->add_uniform("TargetDims", uniform::UT_VEC2, uniform::CU_TARGET_DIMS); |
| 994 | 993 | post_effect->add_uniform("QuadDims", uniform::UT_VEC2, uniform::CU_QUAD_DIMS); // backward compatibility |
| r250292 | r250293 | |
| 1371 | 1370 | ? 3 |
| 1372 | 1371 | : 0; |
| 1373 | 1372 | |
| 1373 | render_container &screen_container = machine->first_screen()->container(); |
| 1374 | |
| 1375 | float xscale = screen_container.xscale(); |
| 1376 | float yscale = screen_container.yscale(); |
| 1377 | float xoffset = -screen_container.xoffset(); |
| 1378 | float yoffset = -screen_container.yoffset(); |
| 1379 | |
| 1380 | float screen_scale[2] = { xscale, yscale }; |
| 1381 | float screen_offset[2] = { xoffset, yoffset }; |
| 1382 | |
| 1374 | 1383 | curr_effect = post_effect; |
| 1375 | 1384 | curr_effect->update_uniforms(); |
| 1376 | 1385 | curr_effect->set_texture("ShadowTexture", shadow_texture == NULL ? NULL : shadow_texture->get_finaltex()); |
| 1377 | 1386 | curr_effect->set_texture("DiffuseTexture", rt->prescale_texture[next_index]); |
| 1387 | curr_effect->set_vector("ScreenScale", 2, screen_scale); |
| 1388 | curr_effect->set_vector("ScreenOffset", 2, screen_offset); |
| 1378 | 1389 | curr_effect->set_float("ScanlineOffset", texture->get_cur_frame() == 0 ? 0.0f : options->scanline_offset); |
| 1379 | 1390 | curr_effect->set_bool("OrientationSwapXY", orientation_swap_xy); |
| 1380 | 1391 | curr_effect->set_bool("RotationSwapXY", rotation_swap_xy); |