Advertisement
Guest User

Shader

a guest
Apr 11th, 2013
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. //ENBSeries: boris-vorontsov@yandex.ru, boris-vorontsov.narod.ru
  3. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  4. /*
  5. THIS IS HLSL (HIGH LEVEL SHADER LANGUAGE) FILE FOR EXECUTING ADDITIONAL
  6. HARDWARE EFFECTS. MAKE THE COPY BEFORE CHANGING IT!
  7. */
  8.  
  9. //keyboard controled variables
  10. float tempF1;
  11. float tempF2;
  12. float tempF3;
  13. float tempF4;
  14. float tempF5;
  15. float tempF6;
  16. float tempF7;
  17. float tempF8;
  18. float tempF9;
  19. float tempF0;
  20.  
  21.  
  22. //global variables, already set before executing this code
  23. float ScreenSize; //width of the display resolution (1024 f.e.)
  24. float ScreenScaleY; //screen proportions (1.333 for 1024/768)
  25. float ScreenBrightnessAdaptation;//(-10..10) for bloom it controls how much to dark in the night or when scene is dark (user defined constant factor)
  26. float bloomPower;//(0..10) actually used for bloom, but may be useful here (user defined constant factor)
  27. float useBloom;//(0 or 1) if bloom enabled by user
  28.  
  29.  
  30.  
  31. //textures
  32. texture2D texColor;
  33.  
  34. sampler2D SamplerColor = sampler_state
  35. {
  36. Texture = <texColor>;
  37. MinFilter = LINEAR;
  38. MagFilter = LINEAR;
  39. MipFilter = NONE;//NONE;
  40. AddressU = Clamp;
  41. AddressV = Clamp;
  42. SRGBTexture=FALSE;
  43. };
  44.  
  45. struct VS_OUTPUT_POST {
  46. float4 vpos : POSITION;
  47. float2 txcoord : TEXCOORD0;
  48. };
  49.  
  50. struct VS_INPUT_POST {
  51. float3 pos : POSITION;
  52. float2 txcoord : TEXCOORD0;
  53. };
  54.  
  55.  
  56.  
  57.  
  58. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  59. //
  60. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  61. VS_OUTPUT_POST VS_PostProcess(VS_INPUT_POST IN)
  62. {
  63. VS_OUTPUT_POST OUT;
  64.  
  65. float4 pos=float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
  66.  
  67. OUT.vpos=pos;
  68. OUT.txcoord.xy=IN.txcoord.xy;
  69.  
  70. return OUT;
  71. }
  72.  
  73.  
  74.  
  75.  
  76. float4 PS_PostProcess(VS_OUTPUT_POST In) : COLOR
  77. {
  78. /*
  79. float tempF1=0.2;
  80. float tempF2=0.2;
  81. float tempF3=0.2;
  82. float tempF4=0.2;
  83. float tempF5=0.4;
  84. float tempF6=2.25;
  85. float tempF7=0.12;
  86. float tempF8=0.12;
  87. float tempF9=1.25;
  88. float tempF0=0.7;
  89. */
  90. //START TO MAKE YOUR CHANGES FROM HERE
  91. float4 res;
  92. float4 uvsrc=0;
  93. uvsrc.xy=In.txcoord;
  94.  
  95.  
  96. float2 offset[8]=
  97. {
  98. float2(-1.0,-1.0),
  99. float2(-1.0, 1.0),
  100. float2( 1.0, 1.0),
  101. float2( 1.0,-1.0),
  102. float2( 0.0, 1.41),
  103. float2( 0.0,-1.41),
  104. float2(-1.41, 0.0),
  105. float2( 1.41, 0.0)
  106. };
  107. res=0.0;
  108. float4 coord=0.0;
  109. coord.xy=In.txcoord.xy;
  110. float4 origcolor=tex2D(SamplerColor, coord.xy);
  111. float origgray=max(origcolor.r, max(origcolor.g, origcolor.b));
  112. res+=origcolor;
  113. float range=0.7*tempF1/ScreenSize;
  114. for (int i=0; i<8; i++)
  115. {
  116.  
  117. coord.xy=In.txcoord+offset[i]*range;
  118. float4 color;
  119. float gray;
  120. color=tex2D(SamplerColor, coord.xy);
  121. float4 colordiff=abs(origcolor-color);
  122. gray=dot(colordiff.rgb,0.333);
  123. float lerpfact=saturate(4.0*abs(gray)*color.a);//saturate
  124. res+=lerp(origcolor, color, lerpfact);
  125. }
  126. res=res*0.11111;
  127.  
  128.  
  129.  
  130. float4 color=res; //tex2Dbias(SamplerColor, uvsrc);
  131.  
  132. float tf7=tempF7;
  133. float tf8=tempF8*0.55;
  134.  
  135. float3 correctedcolor=saturate((1.0-color*tempF9*0.24)*tempF0*0.16);
  136.  
  137. res.rgb=saturate(color.rgb-correctedcolor);
  138. res.rgb=pow(res.rgb,tf8)*tf7;
  139.  
  140. res.a=1.0;
  141. return res;
  142. }
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  151. //
  152. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  153. technique PostProcess
  154. {
  155. pass P0
  156. {
  157. VertexShader = compile vs_2_0 VS_PostProcess();
  158. PixelShader = compile ps_2_a PS_PostProcess();
  159.  
  160. FogEnable=FALSE;
  161. ALPHATESTENABLE=FALSE;
  162. SEPARATEALPHABLENDENABLE=FALSE;
  163. AlphaBlendEnable=FALSE;
  164. FogEnable=FALSE;
  165. SRGBWRITEENABLE=FALSE;
  166. }
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement