Guest User

Блик HLSL fx

a guest
Jun 8th, 2014
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.56 KB | None | 0 0
  1. float4x4 ViewProj : ViewProjection;
  2. float4x4 World : World;
  3.  
  4. float Time;
  5. float4 BlickColor;
  6.  
  7. struct VertexOutput
  8. {
  9.    float4 Pos: POSITION;
  10.    float2 TexCoord: TEXCOORD0;
  11. };
  12.  
  13. texture MainTexture : MainTexture;
  14. sampler MainTextureSampler = sampler_state {
  15.     Texture = <MainTexture>;
  16.     MinFilter=linear;
  17.     MagFilter=linear;
  18.     MipFilter=linear;
  19. };
  20. texture StencilTexture : StencilTexture;
  21. sampler StencilTextureSampler = sampler_state {
  22.     Texture = <StencilTexture>;
  23.     MinFilter=linear;
  24.     MagFilter=linear;
  25.     MipFilter=linear;
  26. };
  27. texture TimeTexture : TimeTexture;
  28. sampler TimeTextureSampler = sampler_state {
  29.     Texture = <TimeTexture>;
  30.     MinFilter=linear;
  31.     MagFilter=linear;
  32.     MipFilter=linear;
  33. };
  34.  
  35. float4 PixelShaderFunction(VertexOutput input) : COLOR0
  36. {
  37.     float4 ResultColor = tex2D(MainTextureSampler, input.TexCoord);
  38.  
  39.     float4 StencilColor = tex2D(StencilTextureSampler, input.TexCoord);
  40.     if (all(StencilColor))
  41.     {
  42.         float4 MidT = tex2D(TimeTextureSampler, input.TexCoord);
  43.         float Dt = (Time - MidT.x);
  44.         float LerpValue;
  45.         if (Dt < 0)
  46.         {
  47.             LerpValue = abs(Dt / MidT.x);
  48.         }
  49.         else
  50.         {
  51.             LerpValue = abs(Dt / (1 - MidT.x));
  52.         }
  53.        
  54.         ResultColor = lerp(BlickColor, ResultColor, LerpValue);
  55.     }
  56.  
  57.     return ResultColor;
  58. }
  59.  
  60. technique Blick
  61. {
  62.     pass Pass1
  63.     {
  64.         // TODO: set renderstates here.
  65.         CullMode = None;
  66.  
  67.         PixelShader = compile ps_2_0 PixelShaderFunction();
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment