Advertisement
PsichiX

Untitled

Feb 12th, 2014
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Custom/Contrast And Brightness" {
  2. Properties {
  3. _MainTex ("Base (RGB)", 2D) = "white" {}
  4. }
  5. SubShader {
  6. Pass {
  7. CGPROGRAM
  8.  
  9. #pragma vertex vMain
  10. #pragma fragment fMain
  11.  
  12. uniform sampler2D _MainTex;
  13. uniform float _Contrast;
  14. uniform float _Brightness;
  15.  
  16. struct INPUT
  17. {
  18. float4 position : POSITION;
  19. float2 coord : TEXCOORD0;
  20. };
  21.  
  22. struct OUTPUT
  23. {
  24. float4 position : SV_POSITION;
  25. float2 coord : TEXCOORD0;
  26. };
  27.  
  28. OUTPUT vMain( INPUT input )
  29. {
  30. OUTPUT output;
  31. output.position = mul( UNITY_MATRIX_MVP, input.position );
  32. output.coord = input.coord;
  33. return output;
  34. }
  35.  
  36. float4 fMain( OUTPUT input ) : COLOR
  37. {
  38. // tu hardkodujemy jako consty zeby dzialalo z SetReplacementShader()
  39. const float contrast = 1.3;
  40. const float brightness = 0.1;
  41.  
  42. float4 col = tex2D( _MainTex, input.coord );
  43. col.xyz = ( ( col.xyz - 0.5.xxx ) * contrast.xxx ) + 0.5.xxx;
  44. col.xyz += brightness.xxx;
  45. return col;
  46. }
  47.  
  48. ENDCG
  49. }
  50. }
  51. FallBack "Diffuse"
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement