Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualCryZe

Posted 30 January 2013 - 08:26 AM

I'd reduce unnecessary calculations even more. Also your nominators were subtracting the values instead of adding them: 

 

float cosThetaIncidence = dot(N, L);
float sinThetaIncidence = sqrt(1 - cosThetaIncidence * cosThetaIncidence);

float sinThetaTransmittance = n1 * (sinThetaIncidence / n2);
float cosThetaTransmittance = sqrt(1 - sinThetaTransmittance * sinThetaTransmittance);

float n1CosThetaTransmittance = n1 * cosThetaTransmittance;
float n2CosThetaTransmittance = n2 * cosThetaTransmittance;
float n1CosThetaIncidence = n1 * cosThetaIncidence;
float n2CosThetaIncidence = n2 * cosThetaIncidence;

float sPolarizedSqrt = (n1CosThetaIncidence - n2CosThetaTransmittance) / (n1CosThetaIncidence + n2CosThetaTransmittance);
float sPolarized = sPolarizedSqrt * sPolarizedSqrt;

float pPolarizedSqrt = (n2CosThetaIncidence - n1CosThetaTransmittance) / (n2CosThetaIncidence + n1CosThetaTransmittance);
float pPolarized = pPolarizedSqrt * pPolarizedSqrt;

float fresnel = (sPolarized + pPolarized) / 2;

 

 


#8CryZe

Posted 30 January 2013 - 08:22 AM

I'd reduce unnecessary calculations even more. Also your nominators were subtracting the values instead of adding them:

 

float cosThetaIncidence = dot(N, L);
float sinThetaIncidence = sqrt(1 - cosThetaIncidence * cosThetaIncidence);

float cosThetaTransmittance = n1 * (sinThetaIncidence / n2);
cosThetaTransmittance = sqrt(1 - cosThetaTransmittance * cosThetaTransmittance);

float n1CosThetaTransmittance = n1 * cosThetaTransmittance;
float n2CosThetaTransmittance = n2 * cosThetaTransmittance;
float n1CosThetaIncidence = n1 * cosThetaIncidence;
float n2CosThetaIncidence = n2 * cosThetaIncidence;

float rsSqrt = (n1CosThetaIncidence - n2CosThetaTransmittance) / (n1CosThetaIncidence + n2CosThetaTransmittance);
float rs = rsSqrt * rsSqrt;

float rpSqrt = (n2CosThetaIncidence - n1CosThetaTransmittance) / (n2CosThetaIncidence + n1CosThetaTransmittance);
float rp = rpSqrt * rpSqrt;

float r = (rs + rp) / 2;

 

 


#7CryZe

Posted 30 January 2013 - 08:22 AM

I'd reduce unnecessary calculations even more. Also your nominators were subtracting the values instead of adding them:
float cosThetaIncidence = dot(N, L);
float sinThetaIncidence = sqrt(1 - cosThetaIncidence * cosThetaIncidence);
float cosThetaTransmittance = n1 * (sinThetaIncidence / n2);
cosThetaTransmittance = sqrt(1 - cosThetaTransmittance * cosThetaTransmittance);
float n1CosThetaTransmittance = n1 * cosThetaTransmittance;
float n2CosThetaTransmittance = n2 * cosThetaTransmittance;
float n1CosThetaIncidence = n1 * cosThetaIncidence;
float n2CosThetaIncidence = n2 * cosThetaIncidence;
float rsSqrt = (n1CosThetaIncidence - n2CosThetaTransmittance) / (n1CosThetaIncidence + n2CosThetaTransmittance);
float rs = rsSqrt * rsSqrt;
float rpSqrt = (n2CosThetaIncidence - n1CosThetaTransmittance) / (n2CosThetaIncidence + n1CosThetaTransmittance);
float rp = rpSqrt * rpSqrt;
float r = (rs + rp) / 2;

#6CryZe

Posted 30 January 2013 - 08:21 AM

I'd reduce unnecessary calculations even more. Also your nominators were subtracting the values instead of adding them:
float cosThetaIncidence = dot(N, L);
float sinThetaIncidence = sqrt(1 - cosThetaIncidence * cosThetaIncidence);
float cosThetaTransmittance = n1 * (sinThetaIncidence / n2);
cosThetaTransmittance = sqrt(1 - cosThetaTransmittance * cosThetaTransmittance);
float n1CosThetaTransmittance = n1 * cosThetaTransmittance;
float n2CosThetaTransmittance = n2 * cosThetaTransmittance;
float n1CosThetaIncidence = n1 * cosThetaIncidence;
float n2CosThetaIncidence = n2 * cosThetaIncidence;
float rsSqrt = (n1CosThetaIncidence - n2CosThetaTransmittance) / (n1CosThetaIncidence + n2CosThetaTransmittance);
float rs = rsSqrt * rsSqrt;
float rpSqrt = (n2CosThetaIncidence - n1CosThetaTransmittance) / (n2CosThetaIncidence + n1CosThetaTransmittance);
float rp = rpSqrt * rpSqrt;
float r = (rs + rp) / 2;

#5CryZe

Posted 30 January 2013 - 08:21 AM

I'd reduce unnecessary calculations even more. Also your nominators were subtracting the values instead of adding them:
float cosThetaIncidence = dot(N, L);
float sinThetaIncidence = sqrt(1 - cosThetaIncidence * cosThetaIncidence);
float cosThetaTransmittance = n1 * (sinThetaIncidence / n2);
cosThetaTransmittance = sqrt(1 - cosThetaTransmittance * cosThetaTransmittance);
float n1CosThetaTransmittance = n1 * cosThetaTransmittance;
float n2CosThetaTransmittance = n2 * cosThetaTransmittance;
float n1CosThetaIncidence = n1 * cosThetaIncidence;
float n2CosThetaIncidence = n2 * cosThetaIncidence;
float rsSqrt = (n1CosThetaIncidence - n2CosThetaTransmittance) / (n1CosThetaIncidence + n2CosThetaTransmittance);
float rs = rsSqrt * rsSqrt;
float rpSqrt = (n2CosThetaIncidence - n1CosThetaTransmittance) / (n2CosThetaIncidence + n1CosThetaTransmittance);
float rp = rpSqrt * rpSqrt;
float r = (rs + rp) / 2;

#4CryZe

Posted 30 January 2013 - 08:20 AM

I'd reduce unnecessary calculations even more. Also your nominators were subtracting the values instead of adding them: 

float cosThetaIncidence = dot(N, L);
float sinThetaIncidence = sqrt(1 - cosThetaIncidence * cosThetaIncidence);

float cosThetaTransmittance = n1 * (sinThetaIncidence / n2);
cosThetaTransmittance = sqrt(1 - t1 * t1);

float n1CosThetaTransmittance = n1 * cosThetaTransmittance;
float n2CosThetaTransmittance = n2 * cosThetaTransmittance;
float n1CosThetaIncidence = n1 * cosThetaIncidence;
float n2CosThetaIncidence = n2 * cosThetaIncidence;

float rsSqrt = (n1CosThetaIncidence - n2CosThetaTransmittance) / (n1CosThetaIncidence + n2CosThetaTransmittance);
float rs = rsSqrt * rsSqrt;

float rpSqrt = (n2CosThetaIncidence - n1CosThetaTransmittance) / (n2CosThetaIncidence + n1CosThetaTransmittance);
float rp = rpSqrt * rpSqrt;

float r = (rs + rp) / 2;

 

 


PARTNERS