Программирование игр, создание игрового движка, OpenGL, DirectX, физика, форум
GameDev.ru / Программирование / Статьи / Детали использования сферических функций для интерактивного рендеринга. (3 стр)

Детали использования сферических функций для интерактивного рендеринга. (3 стр)

Автор:

8. Приложения

В данном разделе предоставлены исходные коды программ для предрасчёта, уплотнения геометрии и для финального рендеринга объектов.

Функция проецирования ДФРС с помощью интегрирования методом Монте-Карло:

/** Функция для предварительного расчёта ДФРС
    в базисе СФ для одной вершины модели **/
void CPRTMesh::ComputeVertex(VERTEX& rVertex)
{  
  /// проверка флага рассчитанности
  if(rVertex.bComputed)
    return;  

  /// Обнуляем вектор коэффициентов
  rVertex.vcCoeffs.Clear();

  /// Переводим вершину в мировое пространство
  VERTEX TransformedVertex(rVertex);
  TransformedVertex.Transform( m_mxWorld * 
    m_vecSubsets[TransformedVertex.idSubset].mxTransform);

  /// Небольшой отступ для устранения погрешности численных вычислений
  TransformedVertex.vcPos += TransformedVertex.vcNormal * m_cfgConfig.fNormEps;

  /// Для каждого предрасчитанного направления на сфере
  for(unsigned nSample=0;nSample<SH::Samples.GetNumSamples();++nSample) 
  {
    SH::Sample& sample = SH::Samples[nSample];

    /// вычисляем ламбертов коэффициент
    float H = TransformedVertex.vcNormal.Dot(sample.vec);

    /// проверяем, что мы находимся в видимой полусфере
    if(H > 0.0f)
    {
      /// проверяем самозатенение
      /// (самопересечение луча в данном направлении из текущей вершины)
      if(!Intersect(TransformedVertex.vcPos, sample.vec))
        /// в случае отсутствия затенения, добавляем предрассчитанные 
        /// значения базисных функций в данном направлении
        /// с учётом ламбертового веса
        rVertex.vcCoeffs += sample.vcCoeffs * H;
    }
  }

  /// нормируем реультат после проведения интегрирования
  float factor = 4.0f * PI / SH::Samples.GetNumSamples();
  rVertex.vcCoeffs *= factor;

  /// установка флага рассчитанности
  rVertex.bComputed = TRUE;
}

Функция расчёта ошибки в треугольнике:

float FACE::GetError(const float fAngleWeight)
{
  fVErr[0] = (V[0]->vcCoeffs - V[1]->vcCoeffs).Length();
  fVErr[1] = (V[1]->vcCoeffs - V[2]->vcCoeffs).Length();
  fVErr[2] = (V[2]->vcCoeffs - V[0]->vcCoeffs).Length();

  float3 n = !(V[0]->vcNormal + V[1]->vcNormal + V[2]->vcNormal);
  float fCos = max(-1.f, min(1.f, n.Dot(V[1]->vcNormal)));
  float fAngle = acosf(fCos);
  float fRes = (fVErr[0]+fVErr[1]+fVErr[2]) / 
    (1. + fAngleWeight * fAngle);
#define AREA_WEIGHT .5f
  fError = powf(fRes, 1-AREA_WEIGHT) * powf(fArea, AREA_WEIGHT);
  return fError;
}

Главная функция GlossyPRT() (функция расчёта ламбертовой составляющей и поворота ДФРС для матовых отражающих объектов и локальных источников света):

// Local light PRT
float3 vcLPRTLightPosObjSpace    : SS_LPRTLIGHTPOSOBJSPACE;
float3 vcLPRTLightColor          : SS_LPRTLIGHTCOLOR;

/// Spectral PRT
half4 aRLight[9]            : SS_PRTENVIRONMENTR;
half4 aGLight[9]            : SS_PRTENVIRONMENTG;
half4 aBLight[9]            : SS_PRTENVIRONMENTB;

// Specular spectral glossy PRT
half3 vGlossyEnvIllum[36]       : SS_GLOSSYPRT;
half vSpecFunction[12]          : SS_SPECPOWER;
half vGlossyShadowPower         : SS_SPECSHADOWPOWER;

void GetEnvIllum(inout half3 fShadow, const in half4 aTransfer[9])
{
  half4 vcR=0;
  half4 vcG=0;
  half4 vcB=0;
  for(int k = 0;k < 9;++k)
  {
    vcR += aRLight[k]*(2*aTransfer[k]-1);
    vcG += aGLight[k]*(2*aTransfer[k]-1);
    vcB += aBLight[k]*(2*aTransfer[k]-1);
  }
  fShadow.r = dot(vcR, 1);
  fShadow.g = dot(vcG, 1);
  fShadow.b = dot(vcB, 1);
}

void DotCoeffs1(inout half4 fRes, const in half4 a[9],
                const in half4 b[3])
{
  for(int k=0;k<3;++k)
    fRes+=(2*a[k]-1) * b[k];
}

void DotCoeffs2(inout half4 fRes, const in half4 a[9],
                const in half4 b[3])
{
  for(int k=0;k<3;++k)
    fRes+=(2*a[k+3]-1) * b[k];
}

void DotCoeffs3(inout half4 fRes, const in half4 a[9],
                const in half4 b[3])
{
  for(int k=0;k<3;++k)
    fRes+=(2*a[k+6]-1) * b[k];
}

void DotCoeffsSpectralA1(inout half3 vcRes, const in half3 a[36],
                          const in half b[12])
{
  for(int k=0;k<12;++k)
    vcRes+=a[k] * b[k];
}

void DotCoeffsSpectralA2(inout half3 vcRes, const in half3 a[36],
                          const in half b[12])
{
  for(int k=0;k<12;++k)
    vcRes+=a[k+12] * b[k];
}

void DotCoeffsSpectralA3(inout half3 vcRes, const in half3 a[36],
                        const in half b[12])
{
  for(int k=0;k<12;++k)
    vcRes+=a[k+24] * b[k];
}

void GlossyPRT(inout half3 vcShadow, const in half3 vcDir, 
              const in half3 vcNormal, const in half4 vTransfer[9])
{
  vcShadow = 0;
  half3 vcRefl=normalize(reflect(vcDir, vcNormal));

  half4 theta12_cs;
  theta12_cs.xy = normalize(vcRefl.xy);
  theta12_cs.zw = 2*theta12_cs.xx*theta12_cs.xy-half2(1,0);
  half4 theta34_cs;
  theta34_cs.xy = 2*theta12_cs.xy*(theta12_cs.zz+half2(-0.5,0.5));
  theta34_cs.zw = 2*theta12_cs.zz*theta12_cs.zw-half2(1,0);

  half4 phi12_cs;
  phi12_cs.y = vcRefl.z;
  phi12_cs.x = sqrt(1-vcRefl.z*vcRefl.z);
  phi12_cs.z = 2*phi12_cs.x*phi12_cs.x-1;
  phi12_cs.zw = 2*phi12_cs.xx*phi12_cs.xy-half2(1,0);
  static half4 phi34_cs;
  phi34_cs.xy = 2*phi12_cs.xy*(phi12_cs.zz+half2(-0.5,0.5));
  phi34_cs.zw = 2*phi12_cs.zz*phi12_cs.zw-half2(1,0);
  
  half4 vcGlossy[3];

  vcGlossy[0].x = (((vSpecFunction[0])*1));
  vcGlossy[0].y = (((vSpecFunction[1]*phi12_cs.x)*1)*theta12_cs.y);
  vcGlossy[0].z = (((vSpecFunction[1]*phi12_cs.y)*-1));
  vcGlossy[0].w = (((vSpecFunction[1]*phi12_cs.x)*1)*theta12_cs.x);
  vcGlossy[1].x = (((vSpecFunction[2])*-0.8660254037844386+(vSpecFunction[3]
    *phi12_cs.z)*0.5)*theta12_cs.w);
  vcGlossy[1].y = (((vSpecFunction[3]*phi12_cs.w)*-1)*theta12_cs.y);
  vcGlossy[1].z = (((vSpecFunction[2])*-0.5+(vSpecFunction[3]*phi12_cs.z)
    *-0.8660254037844380));
  vcGlossy[1].w = (((vSpecFunction[3]*phi12_cs.w)*-1)*theta12_cs.x);
  vcGlossy[2].x = (((vSpecFunction[2])*-0.8660254037844386+(vSpecFunction[3]
    *phi12_cs.z)*0.5)*theta12_cs.z);
  vcGlossy[2].y = (((vSpecFunction[4]*phi12_cs.x)*-0.9682458365518543
    +(vSpecFunction[5]*phi34_cs.x)*0.25)*theta34_cs.y);
  vcGlossy[2].z = (((vSpecFunction[5]*phi34_cs.y)*-0.6123724356957958
    +(vSpecFunction[4]*phi12_cs.y)*0.7905694150420920)*theta12_cs.w);
  vcGlossy[2].w = (((vSpecFunction[4]*phi12_cs.x)*-0.25+(vSpecFunction[5]
    *phi34_cs.x)*-0.9682458365518538)*theta12_cs.y);

  half4 vcK = 0;
  DotCoeffsSpectralA1(vcShadow, vGlossyEnvIllum, vcGlossy);
  DotCoeffs1(vcK, vTransfer, vcGlossy);

  vcGlossy[0].x = (((vSpecFunction[5]*phi34_cs.y)*0.7905694150420939
    +(vSpecFunction[4]*phi12_cs.y)*0.6123724356957899));
  vcGlossy[0].y = (((vSpecFunction[4]*phi12_cs.x)*-0.25
    +(vSpecFunction[5]*phi34_cs.x)*-0.9682458365518538)*theta12_cs.x);
  vcGlossy[0].z = (((vSpecFunction[5]*phi34_cs.y)*-0.6123724356957958
    +(vSpecFunction[4]*phi12_cs.y)*0.7905694150420920)*theta12_cs.z);
  vcGlossy[0].w = (((vSpecFunction[4]*phi12_cs.x)*-0.9682458365518543
    +(vSpecFunction[5]*phi34_cs.x)*0.25)*theta34_cs.x);
  vcGlossy[1].x = (((vSpecFunction[6])*0.7395099728874520
    +(vSpecFunction[7]*phi12_cs.z)*-0.6614378277661490
    +(vSpecFunction[8]*phi34_cs.z)*0.125)*theta34_cs.w);
  vcGlossy[1].y = (((vSpecFunction[8]*phi34_cs.w)*-0.3535533905932758
    +(vSpecFunction[7]*phi12_cs.w)*0.9354143466934818)*theta34_cs.y);
  vcGlossy[1].z = (((vSpecFunction[6])*0.5590169943749410
    +(vSpecFunction[7]*phi12_cs.z)*0.5
    +(vSpecFunction[8]*phi34_cs.z)*-0.6614378277661487)*theta12_cs.w);
  vcGlossy[1].w = (((vSpecFunction[8]*phi34_cs.w)*0.9354143466934846
    +(vSpecFunction[7]*phi12_cs.w)*0.3535533905932697)*theta12_cs.y);
  vcGlossy[2].x= (((vSpecFunction[6])*0.375
    +(vSpecFunction[7]*phi12_cs.z)*0.5590169943749408
    +(vSpecFunction[8]*phi34_cs.z)*0.7395099728874508));
  vcGlossy[2].y= (((vSpecFunction[8]*phi34_cs.w)*0.9354143466934846
    +(vSpecFunction[7]*phi12_cs.w)*0.3535533905932697)*theta12_cs.x);
  vcGlossy[2].z= (((vSpecFunction[6])*0.5590169943749410
    +(vSpecFunction[7]*phi12_cs.z)*0.5
    +(vSpecFunction[8]*phi34_cs.z)*-0.6614378277661487)*theta12_cs.z);
  vcGlossy[2].w= (((vSpecFunction[8]*phi34_cs.w)*-0.3535533905932758
    +(vSpecFunction[7]*phi12_cs.w)*0.9354143466934818)*theta34_cs.x);

  DotCoeffsSpectralA2(vcShadow, vGlossyEnvIllum, vcGlossy);
  DotCoeffs2(vcK, vTransfer, vcGlossy);

  half4 theta5phi5_cs;
  theta5phi5_cs.xy = 2*theta12_cs.xy*(theta34_cs.zz
    +theta12_cs.z*half2(-1,1)+0.5);
  theta5phi5_cs.zw = 2*phi12_cs.xy*(phi34_cs.zz+phi12_cs.z*half2(-1,1)+0.5);
  
  vcGlossy[0].x= (((vSpecFunction[6])*0.7395099728874520
    +(vSpecFunction[7]*phi12_cs.z)*-0.6614378277661490
    +(vSpecFunction[8]*phi34_cs.z)*0.125)*theta34_cs.z);
  vcGlossy[0].y= (((vSpecFunction[9]*phi12_cs.x)*0.9057110466368399
    +(vSpecFunction[10]*phi34_cs.x)*-0.4192627457812130
    +(vSpecFunction[11]*theta5phi5_cs.z)*0.0625)*theta5phi5_cs.y);
  vcGlossy[0].z= (((vSpecFunction[11]*theta5phi5_cs.w)*-0.1976423537605260
    +(vSpecFunction[10]*phi34_cs.y)*0.7954951288348645
    +(vSpecFunction[9]*phi12_cs.y)*-0.5728219618694758)*theta34_cs.w);
  vcGlossy[0].w= (((vSpecFunction[9]*phi12_cs.x)*0.4050462936504851
    +(vSpecFunction[10]*phi34_cs.x)*0.8125
    +(vSpecFunction[11]*theta5phi5_cs.z)*-0.4192627457812129)*theta34_cs.y);
  vcGlossy[1].x= (((vSpecFunction[11]*theta5phi5_cs.w)*0.6846531968814584
    +(vSpecFunction[10]*phi34_cs.y)*-0.3061862178478937
    +(vSpecFunction[9]*phi12_cs.y)*-0.6614378277661351)*theta12_cs.w);
  vcGlossy[1].y= (((vSpecFunction[9]*phi12_cs.x)*0.125
    +(vSpecFunction[10]*phi34_cs.x)*0.4050462936504848
    +(vSpecFunction[11]*theta5phi5_cs.z)*0.9057110466368387)*theta12_cs.y);
  vcGlossy[1].z = (((vSpecFunction[11]*theta5phi5_cs.w)*-0.7015607600201126
    +(vSpecFunction[10]*phi34_cs.y)*-0.5229125165837888
    +(vSpecFunction[9]*phi12_cs.y)*-0.4841229182759160));
  vcGlossy[1].w = (((vSpecFunction[9]*phi12_cs.x)*0.125
    +(vSpecFunction[10]*phi34_cs.x)*0.4050462936504848
    +(vSpecFunction[11]*theta5phi5_cs.z)*0.9057110466368387)*theta12_cs.x);
  vcGlossy[2].x = (((vSpecFunction[11]*theta5phi5_cs.w)*0.6846531968814584
    +(vSpecFunction[10]*phi34_cs.y)*-0.3061862178478937
    +(vSpecFunction[9]*phi12_cs.y)*-0.6614378277661351)*theta12_cs.z);
  vcGlossy[2].y = (((vSpecFunction[9]*phi12_cs.x)*0.4050462936504851
    +(vSpecFunction[10]*phi34_cs.x)*0.8125
    +(vSpecFunction[11]*theta5phi5_cs.z)*-0.4192627457812129)*theta34_cs.x);
  vcGlossy[2].z = (((vSpecFunction[11]*theta5phi5_cs.w)*-0.1976423537605260
    +(vSpecFunction[10]*phi34_cs.y)*0.7954951288348645
    +(vSpecFunction[9]*phi12_cs.y)*-0.5728219618694758)*theta34_cs.z);
  vcGlossy[2].w = (((vSpecFunction[9]*phi12_cs.x)*0.9057110466368399
    +(vSpecFunction[10]*phi34_cs.x)*-0.4192627457812130
    +(vSpecFunction[11]*theta5phi5_cs.z)*0.0625)*theta5phi5_cs.x);

  DotCoeffsSpectralA3(vcShadow, vGlossyEnvIllum, vcGlossy);
  DotCoeffs3(vcK, vTransfer, vcGlossy);

  vcShadow *= saturate(pow(saturate(dot(vcK, 1) 
    / max(dot(vcRefl, vcNormal), .0001f)), vGlossyShadowPower));
}

void LPRTLight(inout half fShadow, const in half3 vcDir, 
                const in half vSHCoeffs[36])
{
  half4 theta12_cs;
  theta12_cs.xy = normalize(vcDir.xy);
  theta12_cs.zw = 2*theta12_cs.xx*theta12_cs.xy-half2(1,0);
  half4 theta34_cs;
  theta34_cs.xy = 2*theta12_cs.xy*(theta12_cs.zz+half2(-0.5,0.5));
  theta34_cs.zw = 2*theta12_cs.zz*theta12_cs.zw-half2(1,0);
  half2 theta5_cs = 2*theta12_cs.xy*(theta34_cs.zz
    +theta12_cs.z*half2(-1,1)+0.5);

  half4 phi12_cs;
  phi12_cs.y = vcDir.z;
  phi12_cs.x = sqrt(1-vcDir.z*vcDir.z);
  phi12_cs.z = 2*phi12_cs.x*phi12_cs.x-1;
  phi12_cs.zw = 2*phi12_cs.xx*phi12_cs.xy-half2(1,0);
  half4 phi34_cs;
  phi34_cs.xy = 2*phi12_cs.xy*(phi12_cs.zz+half2(-0.5,0.5));
  phi34_cs.zw = 2*phi12_cs.zz*phi12_cs.zw-half2(1,0);
  half2 phi5_cs = 2*phi12_cs.xy*(phi34_cs.zz+phi12_cs.z*half2(-1,1)+0.5);
  
  fShadow+=vSHCoeffs[0]*((((0.886477530002594))));
  fShadow+=vSHCoeffs[1]*((((-1.5349903106689453)*phi12_cs.x))*theta12_cs.y);
  fShadow+=vSHCoeffs[2]*((((-1.5349903106689453)*phi12_cs.y)*-1.));
  fShadow+=vSHCoeffs[3]*((((-1.5349903106689453)*phi12_cs.x))*theta12_cs.x);
  fShadow+=vSHCoeffs[4]*((((-0.9906591773033142))*-0.8660254037844386
    +((1.7158721685409546)*phi12_cs.z)*0.5)*theta12_cs.w);
  fShadow+=vSHCoeffs[5]*((((1.7158721685409546)*phi12_cs.w)*-1.)*theta12_cs.y);
  fShadow+=vSHCoeffs[6]*((((-0.9906591773033142))*-0.5+((1.7158721685409546)
    *phi12_cs.z)*-0.866025403784438));
  fShadow+=vSHCoeffs[7]*((((1.7158721685409546)*phi12_cs.w)*-1.)*theta12_cs.x);
  fShadow+=vSHCoeffs[8]*((((-0.9906591773033142))*-0.8660254037844386
    +((1.7158721685409546)*phi12_cs.z)*0.5)*theta12_cs.z);
  fShadow+=vSHCoeffs[9]*((((1.4352685213088989)*phi12_cs.x)*-0.9682458365518543
    +((-1.8529237508773804)*phi34_cs.x)*0.25)*theta34_cs.y);
  fShadow+=vSHCoeffs[10]*((((-1.8529237508773804)*phi34_cs.y)*-0.6123724356957958
    +((1.4352685213088989)*phi12_cs.y)*0.790569415042092)*theta12_cs.w);
  fShadow+=vSHCoeffs[11]*((((1.4352685213088989)*phi12_cs.x)*-0.25
    +((-1.8529237508773804)*phi34_cs.x)*-0.9682458365518538)*theta12_cs.y);
  fShadow+=vSHCoeffs[12]*((((-1.8529237508773804)*phi34_cs.y)*0.7905694150420939
    +((1.4352685213088989)*phi12_cs.y)*0.6123724356957899));
  fShadow+=vSHCoeffs[13]*((((1.4352685213088989)*phi12_cs.x)*-0.25
    +((-1.8529237508773804)*phi34_cs.x)*-0.9682458365518538)*theta12_cs.x);
  fShadow+=vSHCoeffs[14]*((((-1.8529237508773804)*phi34_cs.y)*-0.612372435695795
    8+((1.4352685213088989)*phi12_cs.y)*0.790569415042092)*theta12_cs.z);
  fShadow+=vSHCoeffs[15]*((((1.4352685213088989)*phi12_cs.x)*-0.9682458365518543
    +((-1.8529237508773804)*phi34_cs.x)*0.25)*theta34_cs.x);
  fShadow+=vSHCoeffs[16]*((((0.9960511922836304))*0.7395099728874520
    +((-1.4848254919052124)*phi12_cs.z)*-0.6614378277661490
    +((1.9642394781112671)*phi34_cs.z)*0.125)*theta34_cs.w);
  fShadow+=vSHCoeffs[17]*((((1.9642394781112671)*phi34_cs.w)*-0.3535533905932758
    +((-1.4848254919052124)*phi12_cs.w)*0.9354143466934818)*theta34_cs.y);
  fShadow+=vSHCoeffs[18]*((((0.9960511922836304))*0.5590169943749410
    +((-1.4848254919052124)*phi12_cs.z)*0.5+((1.9642394781112671)*phi34_cs.z)
    *-0.6614378277661487)*theta12_cs.w);
  fShadow+=vSHCoeffs[19]*((((1.9642394781112671)*phi34_cs.w)*0.9354143466934846
    +((-1.4848254919052124)*phi12_cs.w)*0.3535533905932697)*theta12_cs.y);
  fShadow+=vSHCoeffs[20]*((((0.9960511922836304))*0.375+((-1.4848254919052124)
    *phi12_cs.z)*0.5590169943749408+((1.9642394781112671)*phi34_cs.z)
    *0.7395099728874508));
  fShadow+=vSHCoeffs[21]*((((1.9642394781112671)*phi34_cs.w)*0.9354143466934846
    +((-1.4848254919052124)*phi12_cs.w)*0.3535533905932697)*theta12_cs.x);
  fShadow+=vSHCoeffs[22]*((((0.9960511922836304))*0.5590169943749410
    +((-1.4848254919052124)*phi12_cs.z)*0.5+((1.9642394781112671)*phi34_cs.z)
    *-0.6614378277661487)*theta12_cs.z);
  fShadow+=vSHCoeffs[23]*((((1.9642394781112671)*phi34_cs.w)*-0.3535533905932758
    +((-1.4848254919052124)*phi12_cs.w)*0.9354143466934818)*theta34_cs.x);
  fShadow+=vSHCoeffs[24]*((((0.9960511922836304))*0.7395099728874520
    +((-1.4848254919052124)*phi12_cs.z)*-0.6614378277661490
    +((1.9642394781112671)*phi34_cs.z)*0.125)*theta34_cs.z);
  fShadow+=vSHCoeffs[25]*((((-1.4212626218795776)*phi12_cs.x)
    *0.9057110466368399+((1.5351389646530151)*phi34_cs.x)*-0.4192627457812130
    +((-2.0596053600311279)*phi5_cs.x)*0.0625)*theta5_cs.y);
  fShadow+=vSHCoeffs[26]*((((-2.0596053600311279)*phi5_cs.y)
    *-0.1976423537605260+((1.5351389646530151)*phi34_cs.y)*0.7954951288348645
    +((-1.4212626218795776)*phi12_cs.y)*-0.5728219618694758)*theta34_cs.w);
  fShadow+=vSHCoeffs[27]*((((-1.4212626218795776)*phi12_cs.x)*0.4050462936504851
    +((1.5351389646530151)*phi34_cs.x)*0.8125+((-2.0596053600311279)*phi5_cs.x)
    *-0.4192627457812129)*theta34_cs.y);
  fShadow+=vSHCoeffs[28]*((((-2.0596053600311279)*phi5_cs.y)*0.6846531968814584
    +((1.5351389646530151)*phi34_cs.y)*-0.3061862178478937
    +((-1.4212626218795776)*phi12_cs.y)*-0.6614378277661351)*theta12_cs.w);
  fShadow+=vSHCoeffs[29]*((((-1.4212626218795776)*phi12_cs.x)*0.125
    +((1.5351389646530151)*phi34_cs.x)*0.4050462936504848
    +((-2.0596053600311279)*phi5_cs.x)*0.9057110466368387)*theta12_cs.y);
  fShadow+=vSHCoeffs[30]*((((-2.0596053600311279)*phi5_cs.y)*-0.7015607600201126
    +((1.5351389646530151)*phi34_cs.y)*-0.5229125165837888
    +((-1.4212626218795776)*phi12_cs.y)*-0.484122918275916));
  fShadow+=vSHCoeffs[31]*((((-1.4212626218795776)*phi12_cs.x)*0.125
    +((1.5351389646530151)*phi34_cs.x)*0.4050462936504848
    +((-2.0596053600311279)*phi5_cs.x)*0.9057110466368387)*theta12_cs.x);
  fShadow+=vSHCoeffs[32]*((((-2.0596053600311279)*phi5_cs.y)*0.6846531968814584
    +((1.5351389646530151)*phi34_cs.y)*-0.3061862178478937
    +((-1.4212626218795776)*phi12_cs.y)*-0.6614378277661351)*theta12_cs.z);
  fShadow+=vSHCoeffs[33]*((((-1.4212626218795776)*phi12_cs.x)*0.4050462936504851
    +((1.5351389646530151)*phi34_cs.x)*0.8125
    +((-2.0596053600311279)*phi5_cs.x)*-0.4192627457812129)*theta34_cs.x);
  fShadow+=vSHCoeffs[34]*((((-2.0596053600311279)*phi5_cs.y)
    *-0.1976423537605260
    +((1.5351389646530151)*phi34_cs.y)*0.7954951288348645+((-1.4212626218795776)
    *phi12_cs.y)*-0.5728219618694758)*theta34_cs.z);
  fShadow+=vSHCoeffs[35]*((((-1.4212626218795776)*phi12_cs.x)*0.9057110466368399
    +((1.5351389646530151)*phi34_cs.x)*-0.4192627457812130+((-2.0596053600311279)
    *phi5_cs.x)*0.0625)*theta5_cs.x);
}


void GetLocalShadow( inout half3 fShadow, const in half aTransfer[36],
                     const in half3 vcPos)
{
  half3 vcDir=vcLPRTLightPosObjSpace-vcPos;
  half fDist=length(vcDir);
  vcDir/=fDist;
  
  half fShad=0;
  LPRTLight(fShad, vcDir, aTransfer);
  fShadow += fShad*vcLPRTLightColor/(fDist);
}

9. Список литературы



•  [1] AGRAWALA, M, RAMAMOORTHI, R, HEIRICH, A, AND MOLL, L, Efficient Image-Based Methods for Rendering Soft Shadows, SIGGRAPH '00, 375-384.
•  [2] AIREY, J, ROHLF, J, AND BROOKS, F, Towards Image Realism with Interactive Update Rates in
•  Complex Virtual Building Environments,1990 Symposium on Interactive 3D Graphics, 24(2), 41-50.
•  [3] ASHIKHMIN, M, AND SHIRLEY, P, Steerable Illumination Textures, ACM Transactions on Graphics, 2(3), to appear.
•  [4] CABRAL, B, MAX, N, AND SPRINGMEYER, R, Bidirectional Reflection Functions from Surface Bump Maps, SIIGRAPH '87, 273-281.
•  [5] CABRAL, B, OLANO, M, AND NEMEC, P, Reflection Space Image Based Rendering, SIGGRAPH '99, 165-170..
•  [6] COHEN, M, AND WALLACE, J, Radiosity and Realistic Image Synthesis, Academic Press Professional, Cambridge, 1993.
•  [7] COOK, R, PORTER, T, AND CARPENTER, L, Distributed Ray Tracing, SIGGRAPH '84, 137-146.
•  [8] DEBEVEC, P, Rendering Synthetic Objects into Real Scenes: Bridging Traditional and Image-Based Graphics with Global Illumination and High Dynamic Range Photogaphy, SIGGRAPH '98, 189-198.
•  [9] DEBEVEC, P, HAWKINS, T, TCHOU, C, DUIKER, H, SAROKIN, W, AND SAGAR, M, Acquiring the Reflectance Field of a Human Face, SIGGRAPH 2000, 145-156.
•  [10] DOBASHI, Y, KANEDA, K, NAKATANI, H, AND YAMASHITA, H, A Quick Rendering Method Using Basis Functions for Interactive Lighting Design, Eurographics '95, 229-240.
•  [II]  DORSEY, J, SILLION, F, AND GREENBERG, D, Design and Simulation of Opera Lighting and Projection Effects, SIGGRAPH '91, 41-50.
•  [12] D'ZMURA, M, Shading Ambiguity: Reflection and Illumination. In Computational Models of Visual Processing (1991), Landy and Movshon, eds., MIT Press, Cambridge, 187-207.
•  [13] EDMONDS, A, Angular Momentum in Quantum Mechanics, Princeton University, Princeton, 1960.
•  [14] GREENE, N, Environment Mapping and Other applications of World Projections, IEEE CG&A, 6(11):21-29, 1986.
•  [15] GREGER, G., SHIRLEY, P, HUBBARD, P, AND GREENBERG, D, The Irradiance Volume, IEEE Computer Graphics And Applications, 6(11):21-29, 1986.
•  [16] HAKURA, Z, AND SNYDER, J, Realistic Reflections and Refractions on Graphics Hardware with Hybrid Rendering and Layered Environment Maps, Eurographics Workshop on Rendering, 2001, 289-300.
•  [17] HAEBERLI, P, AND AKELEY, K, The Accumulation Buffer: Hardware Support for High-Quality Rendering, SIGGRAPH '90, 309-318.
•  [18] HEIDRICH, W, LENSCH, H, COHEN, M, AND SEIDEL, H, Light Field Techniques for Reflections and Refractions, Eurographics Rendering Workshop 99,195-375.
•  [19] HEIDRICH, W, SEIDEL H, Realistic, Hardware-Accelerated Shading and Lighting, SIGGRAPH '99, 171-178.
•  [20] HEIDRICH, W, DAUBERT, K, KAUTZ, J, AND SEIDEL, H, Illuminating Micro Geometry based on Precomputed Visibility, SIGGRAPH '00, 455-464.
•  [21] JENSEN, H, Global Illumination using Photon Maps, Eurographics Workshop on Rendering 1996, 21-30.
•  [22] JENSEN, H, MARSCHNER, S, LEVOY, M, AND HANRAHAN, P, A Practical Model for Subsurface Light Transport, SIGGRAPH '01, '511-518.
•  [23] KAUTZ, J, AND MCCOOL, M, Interactive Rendering with Arbitrary ДФРСs using Separable Approximations, Eurographics Workshop on Rendering 99,.247-260.
•  [24] KAUTZ, J, VAZQUEZ, P, HEIDRICH, W, AND SEIDEL, H, A Unified Approach to Pre-filtered Environment Maps, Eurographics Workshop on Rendering 2000, 185-196.
•  [25] KAJIYA, J, The Rendering Equation, SIGGRAPH '86, 143-150.
•  [26] KEATING, B, AND MAX, N, Shadow Penumbras for Complex Objects by Depth-Dependent Filtering of Multi-Layer Depth Images, Eurographics Rendering Workshop, 1996, pp.205-220.
•  [27] KELLER, A, Instant Radiosity, SIGGRAPH '97, 49-56.
•  [28] LINDE, Y, BUZO, A, AND GRAY, R, An algorithm for Vector Quantizer Design, IEEE Transactions on Communication COM-28, 1980,84-95.
•  [29] LOKOVIC, T, AND VEACH, E, Deep Shadow Maps, SIGGRAPH '00,
•  pp.385-392.
•  [30] MALZBENDER, T, GELB, D, AND WOLTERS, H, Polynomial Texture Maps, SIGGRAPH '01, 519-528.
•  [31] MAX, N, Horizon Mapping: Shadows for Bump-Mapped Surfaces, The Visual Computer, July 1998, 109-117.
•  [32] MILLER, G, Efficient Algorithms for Local and Global Accessibility Shading, SIGGRAPH '94, 319-326.
•  [33] NIMEROFF, J, SIMONCELLI, E, AND DORSEY, J, Efficient Re-rendering of Natural Environments,  Eurographics Workshop  on Rendering 1994, 359-373.
•  [34] RAMAMOORTHI, R, AND HANRAHAN, P, An Efficient Representation for Irradiance Environment Maps, SIGGRAPH '01, 497-500.
•  [35] REEVES,  W,  SALESIN, D,  AND  COOK,  R,  Rendering Antialiased Shadows with Depth Maps, SIGGRAPH '87, '283-291.
•  [36] SEGAL, M, KOROBKIN, C, VAN WIDENFELT, R, FORAN, J, AND HAE-BERLI, P, Fast Shadows and Lighting Effects Using Texture Mapping, SIGGRAPH '92, '249-252.
•  [37]  SCHRODER, P, AND SWELDENS, W, Spherical Wavelets: Efficiently Representing the Sphere, SIGGRAPH '95, '161-172.
•  [38] SILLION, F, ARVO, J, WESTIN, S, AND GREENBERG, D, A Global Illumination Solution for General Reflectance Distributions,  SIGGRAPH '91, 187-196.
•  [39]  SOLER, C, AND SILLION, F, Fast Calculation of Soft Shadow Textures Using Convolution, SIGGRAPH '98, '321-332.
•  [40] TEO, P, SIMONCELLI, E, AND HEEGER, D, Efficient Linear Re-rendering for Interactive Lighting Design, October 1997 Report No. STAN-CS-TN-97-60, Stanford University, 1997.
•  [41] WARD, G, RUBINSTEIN, F, AND CLEAR, R, A Ray Tracing Solution for Diffuse Interreflection, SIGGRAPH '88, '85-92.
•  [42] WESTIN, S, ARVO, J, TORRANCE, K, Predicting Reflectance Functions from Complex Surfaces, SIGGRAPH '92, 255-264.
•  [43] WILLIAMS, L, Casting Curved Shadows on Curved Surfaces, SIGGRAPH '78, 270-274.
•  [44] ZARE, R, Angular Momentum:  Understanding Spatial Aspects in Chemistry and Physics, Wiley, New York, 1987.
•  [45] Green, R., R&D Programmer, 2003. Spherical Harmonic Lighting: The Gritty Details
•  [46] Sloan, P., Kautz, J., Snyder, J. 2002. Precomputed radiance transfer for real-time rendering in dynamic, low-frequency lighting environments.
•  [47] А. Игнатенко, Использование двулучевой функции отражательной способности (ДФОС)
•  [48] Sloan, P., Kautz, J., Snyder, J. 2002. Precomputed radiance transfer for real-time rendering in dynamic, low-frequency lighting environments.
•  [48] Капланян, А. 2005. Технология предрасчёта освещения модели для получения мягких теней от динамических неточечных источников света, КРИ’05 (http://kriconf.ru/2005/rec/KRI_2005_Programming_03apr_gal12_01_An… an_Akella.ppt)
Страницы: 1 2 3

12 октября 2009

#BRDF, #global illumination

2001—2018 © GameDev.ru — Разработка игр