Advertisement
Guest User

Untitled

a guest
Aug 21st, 2012
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.52 KB | None | 0 0
  1. float4x4 WorldViewProj;
  2.  
  3. texture Base  <
  4.     string UIName =  "Base Texture";
  5.     string ResourceType = "2D";
  6. >;
  7.  
  8. sampler2D BaseTexture = sampler_state {
  9.     Texture = <Base>;
  10.     AddressU = Wrap;
  11.     AddressV = Wrap;
  12. };
  13.  
  14. texture Overlay  <
  15.     string UIName =  "Overlay Texture";
  16.     string ResourceType = "2D";
  17. >;
  18.  
  19. sampler2D OverlayTexture = sampler_state {
  20.     Texture = <Overlay>;
  21.     AddressU = Wrap;
  22.     AddressV = Wrap;
  23. };
  24.  
  25.  
  26. texture PreRender : RENDERCOLORTARGET
  27.     <
  28.     string Format = "X8R8G8B8" ;
  29.     >;
  30.  
  31. sampler2D PreRenderSampler = sampler_state {
  32.     Texture = <PreRender>;
  33. };
  34.  
  35. struct VS_INPUT
  36. {
  37.     float4 Position : POSITION0;
  38.     float2 Tex      : TEXCOORD0;
  39.  
  40. };
  41.  
  42. struct VS_OUTPUT
  43. {
  44.     float4 Position : POSITION0;
  45.     float2 Tex      : TEXCOORD0;
  46. };
  47.  
  48. VS_OUTPUT cap_mainVS(VS_INPUT Input)
  49. {
  50.     VS_OUTPUT Output;
  51.     Output.Position = mul( Input.Position, WorldViewProj );
  52.     Output.Tex = Input.Tex;
  53.     return( Output );
  54. }
  55.  
  56. float4 cap_mainPS(float2 tex: TEXCOORD0, float2 pos: VPOS) : COLOR
  57. {
  58.     // пришлось захардкодить разрешение экрана, т.к. лезть в основной код лень
  59.     // особенно без наличия MSVS 2012
  60.     pos /= float2(1920.0f, 1080.0f);
  61.     pos = pos * 2.0f - 1.0f;
  62.     float d = distance(pos, float2(0.f, 0.f));
  63.     float2 rg;
  64.     sincos(d, rg.r, rg.g); // можно было бы сделать через look-up table, но сэкономим одно сэмплирование из текстур :)
  65.     return tex2D(BaseTexture, tex) * float4(abs(rg), 0.0f, 1.0f);
  66. }
  67.  
  68. ///////////////////////////////////////////////////////
  69.  
  70. struct Overlay_VS_INPUT
  71. {
  72.     float4 Position : POSITION0;
  73.     float2 Texture1 : TEXCOORD0;
  74. };
  75.  
  76. struct Overlay_VS_OUTPUT
  77. {
  78.     float4 Position : POSITION0;
  79.     float2 Texture1 : TEXCOORD0;
  80.     float2 Texture2 : TEXCOORD1;
  81.  
  82. };
  83.  
  84. Overlay_VS_OUTPUT over_mainVS(Overlay_VS_INPUT Input)
  85. {
  86.     Overlay_VS_OUTPUT Output;
  87.  
  88.     Output.Position = mul( Input.Position, WorldViewProj );
  89.     Output.Texture1 = Input.Texture1;
  90.     Output.Texture2 = Output.Position.xy*float2(0.5,0.5) + float2(0.5,0.5);
  91.  
  92.     return( Output );
  93. }
  94.  
  95. float4 over_mainPS(float2 tex :TEXCOORD0, float2 pos :TEXCOORD1) : COLOR
  96. {
  97.     vector tmp = tex2D(PreRenderSampler, tex);
  98.     return tmp;
  99. }
  100.  
  101.  
  102. technique technique0
  103. {      
  104.     pass p0
  105.     {
  106.         CullMode = None;
  107.         VertexShader = compile vs_3_0 cap_mainVS();
  108.         PixelShader = compile ps_3_0 cap_mainPS();
  109.     }
  110.  
  111.     pass p1
  112.     {
  113.         CullMode = None;
  114.         VertexShader = compile vs_3_0 over_mainVS();
  115.         PixelShader = compile ps_3_0 over_mainPS();
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement