Paste Code
Paste Blends
Paste Images
sampler s0 : register(s0);

float4 main(float2 tex : TEXCOORD0) : COLOR
{

float exposure = float(15);
float luminance = float(-0.5);

float4 input = tex2D(s0,tex);
float4 output = float4(1,1,1,1);

//calculate exposure
input *= exposure;

//convert to YCbCr
float Y = float(0.299*input.r + 0.587 * input.g + 0.114 * input.b);
float Cb = float(-0.1687 * input.r + -0.3313 * input.g + 0.5 * input.b + 0.5);
float Cr = float(0.5 * input.r - 0.4187 * input.g - 0.0813 * input.b + 0.5);

//calculate luminance
Y = Y+ luminance;


//convert back to RGB
float R = float(Y + 1.402 * (Cr - 0.5));
float G = float(Y - 0.34414 * (Cb - 0.5) - 0.71414 * (Cr - 0.5));
float B = float(Y + 1.772 * (Cb - 0.5));



//DRAW Original
if (tex.y<0.5){
output = tex2D(s0,tex);


//DRAW Exposure + Luminance
}else {
output = float4(R,G,B,1);
}



return output;
}
  1. sampler s0 : register(s0);
  2.  
  3. float4 main(float2 tex : TEXCOORD0) : COLOR
  4. {
  5.  
  6.        float exposure = float(15);
  7.        float luminance = float(-0.5);
  8.  
  9.        float4 input = tex2D(s0,tex);
  10.        float4 output = float4(1,1,1,1);
  11.  
  12.        //calculate exposure
  13.        input *= exposure;
  14.  
  15.        //convert to YCbCr
  16.        float Y = float(0.299*input.r + 0.587 * input.g + 0.114 * input.b);
  17.        float Cb = float(-0.1687 * input.r + -0.3313 * input.g + 0.5 * input.b + 0.5);
  18.        float Cr = float(0.5 * input.r - 0.4187 * input.g - 0.0813 * input.b + 0.5);
  19.  
  20.        //calculate luminance
  21.        Y = Y+ luminance;
  22.  
  23.  
  24.        //convert back to RGB
  25.        float R = float(Y + 1.402 * (Cr - 0.5));
  26.        float G = float(Y - 0.34414 * (Cb - 0.5) - 0.71414 * (Cr - 0.5));
  27.        float B = float(Y + 1.772 * (Cb - 0.5));
  28.  
  29.  
  30.  
  31.        //DRAW Original
  32.        if (tex.y<0.5){
  33.                output = tex2D(s0,tex);
  34.  
  35.  
  36.        //DRAW Exposure + Luminance
  37.        }else {
  38.                output = float4(R,G,B,1);
  39.        }
  40.  
  41.  
  42.  
  43.        return output;
  44. }
go to heaven