Rendering/Lighting: Difference between revisions

From wowdev
Jump to navigation Jump to search
Line 11: Line 11:


   CImVector color = 0;
   CImVector color = 0;
  bool blendExtLight;
   bool lightRes;
   bool lightRes;


Line 18: Line 19:
     operator*(&lPos, pos, &mapObjDef->invMat);
     operator*(&lPos, pos, &mapObjDef->invMat);


     lightRes = CMapObj::QueryLighting(mapObjDef->mapObj, groupIdx, &lPos, *polyIdx, &color, (bool *)&mapObjDef + 3);
     lightRes = CMapObj::QueryLighting(mapObjDef->mapObj, groupIdx, &lPos, *polyIdx, &color, &blendExtLight);


   } else {
   } else {
Line 44: Line 45:
     seg.end = lEnd;
     seg.end = lEnd;


     lightRes = CMapObj::QueryLighting(mapObjDef->mapObj, groupIdx, &seg, &color, (bool *)&mapObjDef + 3);
     lightRes = CMapObj::QueryLighting(mapObjDef->mapObj, groupIdx, &seg, &color, &blendExtLight);


   }
   }
Line 52: Line 53:
     CMapStaticEntity::AdjustLighting(&color, &this->dirColor, 0xA8u, &this->ambColor, 0x60u);
     CMapStaticEntity::AdjustLighting(&color, &this->dirColor, 0xA8u, &this->ambColor, 0x60u);


     if (BYTE3(mapObjDef)) {
    // Set to true if MOPY.flags & 0x01
 
     if (blendExtLight) {


       dnInfo = DayNightGetInfo();
       dnInfo = DayNightGetInfo();


       if (color.a) {
       if (color.a) {
         CImVector::BlendRGB255(&this->dirColor, color.a, (const CImVector *)dnInfo + 106);
         CImVector::BlendRGB255(&this->dirColor, color.a, (const CImVector *)dnInfo + 106);
         CImVector::BlendRGB255(&this->ambColor, color.a, (const CImVector *)dnInfo + 107);
         CImVector::BlendRGB255(&this->ambColor, color.a, (const CImVector *)dnInfo + 107);
       }
       }



Revision as of 20:46, 7 October 2017

Overview

Note: this page largely deals with how lighting worked in the WotLK era. Large chunks of this are relevant from the vanilla era through WoD.

Doodad Lighting

CMapDoodadDef::QueryInteriorLighting

void CMapDoodadDef::QueryInteriorLighting(CMapDoodadDef *this, CMapObjDef *mapObjDef, uint32_t groupIdx, uint16_t *polyIdx, const C3Vector *pos) {

  CImVector color = 0;
  bool blendExtLight;
  bool lightRes;

  if (polyIdx) {

    C3Vector lPos;
    operator*(&lPos, pos, &mapObjDef->invMat);

    lightRes = CMapObj::QueryLighting(mapObjDef->mapObj, groupIdx, &lPos, *polyIdx, &color, &blendExtLight);

  } else {

    C3Vector wStart;
    C3Vector lStart;

    wStart.x = this->m_mat.columns[3].x;
    wStart.y = this->m_mat.columns[3].y;
    wStart.z = this->m_mat.columns[3].z + 1.5;

    operator*(&lStart, &wStart, &mapObjDef->invMat);

    C3Vector wEnd;
    C3Vector lEnd;

    wEnd.x = this->m_mat.columns[3].x;
    wEnd.y = this->m_mat.columns[3].y;
    wEnd.z = this->m_mat.columns[3].z - 1760.0;

    operator*(&lEnd, &wEnd, &mapObjDef->invMat);

    C3Segment seg;
    seg.start = lStart;
    seg.end = lEnd;

    lightRes = CMapObj::QueryLighting(mapObjDef->mapObj, groupIdx, &seg, &color, &blendExtLight);

  }

  if (lightRes) {

    CMapStaticEntity::AdjustLighting(&color, &this->dirColor, 0xA8u, &this->ambColor, 0x60u);

    // Set to true if MOPY.flags & 0x01

    if (blendExtLight) {

      dnInfo = DayNightGetInfo();

      if (color.a) {

        CImVector::BlendRGB255(&this->dirColor, color.a, (const CImVector *)dnInfo + 106);
        CImVector::BlendRGB255(&this->ambColor, color.a, (const CImVector *)dnInfo + 107);

      }

      this->dirColor.a = color.a;
      this->unk3 |= 0x1000u;

    } else {

      this->unk3 &= 0xFFFFEFFF;

    }

  }

}