mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-19 01:46:27 +00:00
Making CColor use floats instead of u8s
This commit is contained in:
@@ -233,8 +233,7 @@ void CDrawUtil::DrawBillboard(CTexture* pTexture, const CVector3f& Position, con
|
||||
glUniform2f(ScaleLoc, Scale.x, Scale.y);
|
||||
|
||||
GLuint TintLoc = mpBillboardShader->GetUniformLocation("TintColor");
|
||||
CVector4f Tint4f = Tint.ToVector4f();
|
||||
glUniform4f(TintLoc, Tint4f.x, Tint4f.y, Tint4f.z, Tint4f.w);
|
||||
glUniform4f(TintLoc, Tint.r, Tint.g, Tint.b, Tint.a);
|
||||
|
||||
pTexture->Bind(0);
|
||||
|
||||
@@ -263,12 +262,10 @@ void CDrawUtil::DrawLightBillboard(ELightType Type, const CColor& LightColor, co
|
||||
glUniform2f(ScaleLoc, Scale.x, Scale.y);
|
||||
|
||||
GLuint ColorLoc = mpLightBillboardShader->GetUniformLocation("LightColor");
|
||||
CVector4f Color4f = LightColor.ToVector4f();
|
||||
glUniform4f(ColorLoc, Color4f.x, Color4f.y, Color4f.z, Color4f.w);
|
||||
glUniform4f(ColorLoc, LightColor.r, LightColor.g, LightColor.b, LightColor.a);
|
||||
|
||||
GLuint TintLoc = mpLightBillboardShader->GetUniformLocation("TintColor");
|
||||
CVector4f Tint4f = Tint.ToVector4f();
|
||||
glUniform4f(TintLoc, Tint4f.x, Tint4f.y, Tint4f.z, Tint4f.w);
|
||||
glUniform4f(TintLoc, Tint.r, Tint.g, Tint.b, Tint.a);
|
||||
|
||||
CTexture *pTexA = GetLightTexture(Type);
|
||||
CTexture *pTexB = GetLightMask(Type);
|
||||
@@ -297,8 +294,7 @@ void CDrawUtil::UseColorShader(const CColor& kColor)
|
||||
mpColorShader->SetCurrent();
|
||||
|
||||
GLuint ColorLoc = mpColorShader->GetUniformLocation("ColorIn");
|
||||
CVector4f ColorVec4 = kColor.ToVector4f();
|
||||
glUniform4f(ColorLoc, ColorVec4.x, ColorVec4.y, ColorVec4.z, ColorVec4.w);
|
||||
glUniform4f(ColorLoc, kColor.r, kColor.g, kColor.b, kColor.a);
|
||||
|
||||
CMaterial::KillCachedMaterial();
|
||||
}
|
||||
@@ -312,8 +308,7 @@ void CDrawUtil::UseColorShaderLighting(const CColor& kColor)
|
||||
glUniform1i(NumLightsLoc, CGraphics::sNumLights);
|
||||
|
||||
GLuint ColorLoc = mpColorShaderLighting->GetUniformLocation("ColorIn");
|
||||
CVector4f ColorVec4 = kColor.ToVector4f();
|
||||
glUniform4f(ColorLoc, ColorVec4.x, ColorVec4.y, ColorVec4.z, ColorVec4.w);
|
||||
glUniform4f(ColorLoc, kColor.r, kColor.g, kColor.b, kColor.a);
|
||||
|
||||
CMaterial::KillCachedMaterial();
|
||||
}
|
||||
@@ -329,8 +324,7 @@ void CDrawUtil::UseTextureShader(const CColor& TintColor)
|
||||
mpTextureShader->SetCurrent();
|
||||
|
||||
GLuint TintColorLoc = mpTextureShader->GetUniformLocation("TintColor");
|
||||
CVector4f TintVec4 = TintColor.ToVector4f();
|
||||
glUniform4f(TintColorLoc, TintVec4.x, TintVec4.y, TintVec4.z, TintVec4.w);
|
||||
glUniform4f(TintColorLoc, TintColor.r, TintColor.g, TintColor.b, TintColor.a);
|
||||
|
||||
CMaterial::KillCachedMaterial();
|
||||
}
|
||||
@@ -342,8 +336,7 @@ void CDrawUtil::UseCollisionShader(const CColor& TintColor /*= CColor::skWhite*/
|
||||
LoadCheckerboardTexture(0);
|
||||
|
||||
GLuint TintColorLoc = mpCollisionShader->GetUniformLocation("TintColor");
|
||||
CVector4f Tint4f = TintColor.ToVector4f();
|
||||
glUniform4f(TintColorLoc, Tint4f.x, Tint4f.y, Tint4f.z, Tint4f.w);
|
||||
glUniform4f(TintColorLoc, TintColor.r, TintColor.g, TintColor.b, TintColor.a);
|
||||
|
||||
CMaterial::KillCachedMaterial();
|
||||
}
|
||||
|
||||
@@ -158,16 +158,16 @@ void CGraphics::SetDefaultLighting()
|
||||
sDefaultDirectionalLights[2].Load();
|
||||
UpdateLightBlock();
|
||||
|
||||
sVertexBlock.COLOR0_Amb = CColor::skGray.ToVector4f();
|
||||
sVertexBlock.COLOR0_Amb = CColor::skGray;
|
||||
UpdateVertexBlock();
|
||||
}
|
||||
|
||||
void CGraphics::SetupAmbientColor()
|
||||
{
|
||||
if (sLightMode == eWorldLighting)
|
||||
sVertexBlock.COLOR0_Amb = sAreaAmbientColor.ToVector4f() * sWorldLightMultiplier;
|
||||
sVertexBlock.COLOR0_Amb = sAreaAmbientColor * sWorldLightMultiplier;
|
||||
else
|
||||
sVertexBlock.COLOR0_Amb = skDefaultAmbientColor.ToVector4f();
|
||||
sVertexBlock.COLOR0_Amb = skDefaultAmbientColor;
|
||||
}
|
||||
|
||||
void CGraphics::SetIdentityMVP()
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
/**
|
||||
* todo: should probably be replaced with a CGraphicsState class which
|
||||
* can be instantiated and is probably more safe/functional than global access.
|
||||
* also,
|
||||
* also, should probably have inline set/get functions rather than having all
|
||||
* members public so that we can track when a value is modified and maybe
|
||||
* execute extra functionality when certain values are changed
|
||||
*/
|
||||
class CGraphics
|
||||
{
|
||||
@@ -41,9 +43,9 @@ public:
|
||||
{
|
||||
CMatrix4f TexMatrices[10];
|
||||
CMatrix4f PostMatrices[20];
|
||||
CVector4f COLOR0_Amb;
|
||||
CVector4f COLOR0_Mat;
|
||||
CVector4f COLOR1_Amb;
|
||||
CColor COLOR0_Amb;
|
||||
CColor COLOR0_Mat;
|
||||
CColor COLOR1_Amb;
|
||||
CVector4f COLOR1_Mat;
|
||||
};
|
||||
static SVertexBlock sVertexBlock;
|
||||
@@ -51,9 +53,9 @@ public:
|
||||
// SPixelBlock
|
||||
struct SPixelBlock
|
||||
{
|
||||
CVector4f Konst[4];
|
||||
CVector4f TevColor;
|
||||
CVector4f TintColor;
|
||||
CColor Konst[4];
|
||||
CColor TevColor;
|
||||
CColor TintColor;
|
||||
};
|
||||
static SPixelBlock sPixelBlock;
|
||||
|
||||
@@ -64,7 +66,7 @@ public:
|
||||
{
|
||||
CVector4f Position;
|
||||
CVector4f Direction;
|
||||
CVector4f Color;
|
||||
CColor Color;
|
||||
CVector4f DistAtten;
|
||||
CVector4f AngleAtten;
|
||||
};
|
||||
|
||||
@@ -46,8 +46,7 @@ void CRenderer::Init()
|
||||
{
|
||||
if (!mInitialized)
|
||||
{
|
||||
CVector4f ClearVec = mClearColor.ToVector4f();
|
||||
glClearColor(ClearVec.x, ClearVec.y, ClearVec.z, ClearVec.w);
|
||||
glClearColor(mClearColor.r, mClearColor.g, mClearColor.b, mClearColor.a);
|
||||
mContextIndex = CGraphics::GetContextIndex();
|
||||
mInitialized = true;
|
||||
}
|
||||
@@ -134,16 +133,11 @@ void CRenderer::SetBloom(EBloomMode BloomMode)
|
||||
mOptions &= ~eEnableBloom;
|
||||
}
|
||||
|
||||
void CRenderer::SetFont(CFont* /*pFont*/)
|
||||
{
|
||||
}
|
||||
|
||||
void CRenderer::SetClearColor(CColor Clear)
|
||||
void CRenderer::SetClearColor(const CColor& Clear)
|
||||
{
|
||||
mClearColor = Clear;
|
||||
CVector4f ClearVec = Clear.ToVector4f();
|
||||
ClearVec.w = 0.f;
|
||||
glClearColor(ClearVec.x, ClearVec.y, ClearVec.z, ClearVec.w);
|
||||
mClearColor.a = 0.f;
|
||||
glClearColor(mClearColor.r, mClearColor.g, mClearColor.b, mClearColor.a);
|
||||
}
|
||||
|
||||
void CRenderer::SetViewportSize(u32 Width, u32 Height)
|
||||
@@ -191,12 +185,12 @@ void CRenderer::RenderBloom()
|
||||
static const float skVOffset[6] = { -0.012275f, -0.007815f, -0.003350f,
|
||||
0.003350f, 0.007815f, 0.012275f };
|
||||
|
||||
static const CColor skTintColors[6] = { CColor((u8) 17, 17, 17, 255),
|
||||
CColor((u8) 53, 53, 53, 255),
|
||||
CColor((u8) 89, 89, 89, 255),
|
||||
CColor((u8) 89, 89, 89, 255),
|
||||
CColor((u8) 53, 53, 53, 255),
|
||||
CColor((u8) 17, 17, 17, 255) };
|
||||
static const CColor skTintColors[6] = { CColor::Integral(17, 17, 17),
|
||||
CColor::Integral(53, 53, 53),
|
||||
CColor::Integral(89, 89, 89),
|
||||
CColor::Integral(89, 89, 89),
|
||||
CColor::Integral(53, 53, 53),
|
||||
CColor::Integral(17, 17, 17) };
|
||||
|
||||
u32 BloomWidth = (mBloomMode == eBloom ? mBloomWidth : mViewportWidth);
|
||||
u32 BloomHeight = (mBloomMode == eBloom ? mBloomHeight : mViewportHeight);
|
||||
@@ -295,9 +289,9 @@ void CRenderer::RenderSky(CModel *pSkyboxModel, const SViewInfo& ViewInfo)
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CVector4f(1.f, 1.f, 1.f, 1.f);
|
||||
CGraphics::sPixelBlock.TevColor = CVector4f(1.f, 1.f, 1.f, 1.f);
|
||||
CGraphics::sPixelBlock.TintColor = CColor::skWhite.ToVector4f();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skWhite;
|
||||
CGraphics::sPixelBlock.TevColor = CColor::skWhite;
|
||||
CGraphics::sPixelBlock.TintColor = CColor::skWhite;
|
||||
CGraphics::sNumLights = 0;
|
||||
CGraphics::UpdateVertexBlock();
|
||||
CGraphics::UpdatePixelBlock();
|
||||
@@ -377,9 +371,7 @@ void CRenderer::ClearDepthBuffer()
|
||||
// ************ PRIVATE ************
|
||||
void CRenderer::InitFramebuffer()
|
||||
{
|
||||
CVector4f Clear = mClearColor.ToVector4f();
|
||||
Clear.w = 0.f;
|
||||
glClearColor(Clear.x, Clear.y, Clear.z, Clear.w);
|
||||
glClearColor(mClearColor.r, mClearColor.g, mClearColor.b, mClearColor.a);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glDepthMask(GL_TRUE);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
@@ -67,8 +67,7 @@ public:
|
||||
void ToggleOccluders(bool b);
|
||||
void ToggleAlphaDisabled(bool b);
|
||||
void SetBloom(EBloomMode BloomMode);
|
||||
void SetFont(CFont *pFont);
|
||||
void SetClearColor(CColor Clear);
|
||||
void SetClearColor(const CColor& Clear);
|
||||
void SetViewportSize(u32 Width, u32 Height);
|
||||
|
||||
// Render
|
||||
|
||||
@@ -36,8 +36,6 @@ CVector2f CFont::RenderString(const TString& String, CRenderer* /*pRenderer*/, f
|
||||
GLuint ModelMtxLoc = pTextShader->GetUniformLocation("ModelMtx");
|
||||
GLuint ColorLoc = pTextShader->GetUniformLocation("FontColor");
|
||||
GLuint LayerLoc = pTextShader->GetUniformLocation("RGBALayer");
|
||||
CVector4f FillColor4f = FillColor.ToVector4f();
|
||||
CVector4f StrokeColor4f = StrokeColor.ToVector4f();
|
||||
mpFontTexture->Bind(0);
|
||||
smGlyphVertices.Bind();
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
@@ -117,7 +115,7 @@ CVector2f CFont::RenderString(const TString& String, CRenderer* /*pRenderer*/, f
|
||||
|
||||
// Draw fill
|
||||
glUniform1i(LayerLoc, GlyphLayer);
|
||||
glUniform4fv(ColorLoc, 1, &FillColor4f.x);
|
||||
glUniform4fv(ColorLoc, 1, &FillColor.r);
|
||||
smGlyphIndices.DrawElements();
|
||||
|
||||
// Draw stroke
|
||||
@@ -129,7 +127,7 @@ CVector2f CFont::RenderString(const TString& String, CRenderer* /*pRenderer*/, f
|
||||
else if (mTextureFormat == 8) StrokeLayer = GlyphLayer - 2;
|
||||
|
||||
glUniform1i(LayerLoc, StrokeLayer);
|
||||
glUniform4fv(ColorLoc, 1, &StrokeColor4f.x);
|
||||
glUniform4fv(ColorLoc, 1, &StrokeColor.r);
|
||||
smGlyphIndices.DrawElements();
|
||||
}
|
||||
|
||||
|
||||
@@ -200,21 +200,21 @@ void CLight::Load() const
|
||||
case eDirectional:
|
||||
Light->Position = CVector4f(-mDirection * 1048576.f, 1.f);
|
||||
Light->Direction = CVector4f(mDirection, 0.f);
|
||||
Light->Color = mColor.ToVector4f() * CGraphics::sWorldLightMultiplier;
|
||||
Light->Color = mColor * CGraphics::sWorldLightMultiplier;
|
||||
Light->DistAtten = CVector4f(1.f, 0.f, 0.f, 0.f);
|
||||
Light->AngleAtten = CVector4f(1.f, 0.f, 0.f, 0.f);
|
||||
break;
|
||||
case eSpot:
|
||||
Light->Position = CVector4f(mPosition, 1.f);
|
||||
Light->Direction = CVector4f(mDirection, 0.f);
|
||||
Light->Color = mColor.ToVector4f() * CGraphics::sWorldLightMultiplier;
|
||||
Light->Color = mColor * CGraphics::sWorldLightMultiplier;
|
||||
Light->DistAtten = mDistAttenCoefficients;
|
||||
Light->AngleAtten = mAngleAttenCoefficients;
|
||||
break;
|
||||
case eCustom:
|
||||
Light->Position = CVector4f(mPosition, 1.f);
|
||||
Light->Direction = CVector4f(mDirection, 0.f);
|
||||
Light->Color = mColor.ToVector4f() * CGraphics::sWorldLightMultiplier;
|
||||
Light->Color = mColor * CGraphics::sWorldLightMultiplier;
|
||||
Light->DistAtten = mDistAttenCoefficients;
|
||||
Light->AngleAtten = mAngleAttenCoefficients;
|
||||
break;
|
||||
|
||||
@@ -131,11 +131,11 @@ bool CMaterial::SetCurrent(ERenderOptions Options)
|
||||
|
||||
// Set konst inputs
|
||||
for (u32 iKonst = 0; iKonst < 4; iKonst++)
|
||||
CGraphics::sPixelBlock.Konst[iKonst] = mKonstColors[iKonst].ToVector4f();
|
||||
CGraphics::sPixelBlock.Konst[iKonst] = mKonstColors[iKonst];
|
||||
|
||||
// Set color channels
|
||||
// COLOR0_Amb is initialized by the node instead of by the material
|
||||
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skWhite.ToVector4f();
|
||||
CGraphics::sVertexBlock.COLOR0_Mat = CColor::skWhite;
|
||||
|
||||
// Set depth write - force on if alpha is disabled (lots of weird depth issues otherwise)
|
||||
if ((mOptions & eDepthWrite) || (Options & eNoAlpha)) glDepthMask(GL_TRUE);
|
||||
|
||||
@@ -173,7 +173,7 @@ void CMaterialCooker::WriteMaterialPrime(COutputStream& Out)
|
||||
{
|
||||
Out.WriteLong(NumKonst);
|
||||
for (u32 iKonst = 0; iKonst < NumKonst; iKonst++)
|
||||
Out.WriteLong( mpMat->Konst(iKonst).AsLongRGBA() );
|
||||
Out.WriteLong( mpMat->Konst(iKonst).ToLongRGBA() );
|
||||
}
|
||||
|
||||
// Blend Mode
|
||||
|
||||
@@ -81,7 +81,7 @@ CMaterial* CMaterialLoader::ReadPrimeMaterial()
|
||||
for (u32 iKonst = 0; iKonst < KonstCount; iKonst++)
|
||||
{
|
||||
if (iKonst >= 4) break;
|
||||
pMat->mKonstColors[iKonst] = CColor(*mpFile);
|
||||
pMat->mKonstColors[iKonst] = CColor(*mpFile, true);
|
||||
}
|
||||
if (KonstCount > 4) mpFile->Seek(0x4 * (KonstCount - 4), SEEK_CUR);
|
||||
}
|
||||
@@ -303,7 +303,7 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
|
||||
if (Type == "CLR ")
|
||||
{
|
||||
CFourCC ClrType = mpFile->ReadLong();
|
||||
CColor ClrVal(*mpFile);
|
||||
CColor ClrVal(*mpFile, true);
|
||||
|
||||
if (ClrType == "DIFB")
|
||||
{
|
||||
|
||||
@@ -97,8 +97,7 @@ CPropertyStruct* CScriptLoader::LoadStructMP1(CInputStream& SCLY, CStructTemplat
|
||||
break;
|
||||
}
|
||||
case eColorProperty: {
|
||||
CVector4f color(SCLY);
|
||||
CColor v(color.x, color.y, color.z, color.w);
|
||||
CColor v(SCLY);
|
||||
pProp = new CColorProperty(v);
|
||||
break;
|
||||
}
|
||||
@@ -334,8 +333,7 @@ void CScriptLoader::LoadStructMP2(CInputStream& SCLY, CPropertyStruct *pStruct,
|
||||
|
||||
case eColorProperty: {
|
||||
CColorProperty *pColorCast = static_cast<CColorProperty*>(pProp);
|
||||
CVector4f Color(SCLY);
|
||||
pColorCast->Set(CColor(Color.x, Color.y, Color.z, Color.w));
|
||||
pColorCast->Set(CColor(SCLY));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ void CTextureDecoder::FullDecodeGXTexture(CInputStream& TXTR)
|
||||
else if (mTexelFormat == eGX_C8) Pixel = DecodePixelC8(TXTR.ReadByte(), mPaletteInput);
|
||||
else if (mTexelFormat == eGX_RGB565) Pixel = DecodePixelRGB565(TXTR.ReadShort());
|
||||
else if (mTexelFormat == eGX_RGB5A3) Pixel = DecodePixelRGB5A3(TXTR.ReadShort());
|
||||
else if (mTexelFormat == eGX_RGBA8) Pixel = CColor(TXTR);
|
||||
else if (mTexelFormat == eGX_RGBA8) Pixel = CColor(TXTR, true);
|
||||
|
||||
Out.WriteLong(Pixel.ToLongARGB());
|
||||
}
|
||||
@@ -558,25 +558,26 @@ void CTextureDecoder::ReadPixelRGB565(CInputStream& src, COutputStream& dst)
|
||||
void CTextureDecoder::ReadPixelRGB5A3(CInputStream& src, COutputStream& dst)
|
||||
{
|
||||
u16 px = src.ReadShort();
|
||||
CColor c;
|
||||
u8 r, g, b, a;
|
||||
|
||||
if (px & 0x8000) // RGB5
|
||||
{
|
||||
c.b = Extend5to8(px >> 10);
|
||||
c.g = Extend5to8(px >> 5);
|
||||
c.r = Extend5to8(px >> 0);
|
||||
c.a = 0xFF;
|
||||
b = Extend5to8(px >> 10);
|
||||
g = Extend5to8(px >> 5);
|
||||
r = Extend5to8(px >> 0);
|
||||
a = 255;
|
||||
}
|
||||
|
||||
else // RGB4A3
|
||||
{
|
||||
c.a = Extend3to8(px >> 12);
|
||||
c.b = Extend4to8(px >> 8);
|
||||
c.g = Extend4to8(px >> 4);
|
||||
c.r = Extend4to8(px >> 0);
|
||||
a = Extend3to8(px >> 12);
|
||||
b = Extend4to8(px >> 8);
|
||||
g = Extend4to8(px >> 4);
|
||||
r = Extend4to8(px >> 0);
|
||||
}
|
||||
|
||||
dst.WriteLong(c.ToLongARGB());
|
||||
u32 c = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
dst.WriteLong(c);
|
||||
}
|
||||
|
||||
void CTextureDecoder::ReadPixelRGBA8(CInputStream& src, COutputStream& dst)
|
||||
@@ -606,26 +607,26 @@ CColor CTextureDecoder::DecodePixelI4(u8 Byte, u8 WhichPixel)
|
||||
{
|
||||
if (WhichPixel == 1) Byte >>= 4;
|
||||
u8 px = Extend4to8(Byte);
|
||||
return CColor(px, px, px, 0xFF);
|
||||
return CColor::Integral(px, px, px);
|
||||
}
|
||||
|
||||
CColor CTextureDecoder::DecodePixelI8(u8 Byte)
|
||||
{
|
||||
return CColor(Byte, Byte, Byte, 0xFF);
|
||||
return CColor::Integral(Byte, Byte, Byte);
|
||||
}
|
||||
|
||||
CColor CTextureDecoder::DecodePixelIA4(u8 Byte)
|
||||
{
|
||||
u8 Alpha = Extend4to8(Byte >> 4);
|
||||
u8 Lum = Extend4to8(Byte);
|
||||
return CColor(Lum, Lum, Lum, Alpha);
|
||||
return CColor::Integral(Lum, Lum, Lum, Alpha);
|
||||
}
|
||||
|
||||
CColor CTextureDecoder::DecodePixelIA8(u16 Short)
|
||||
{
|
||||
u8 Alpha = (Short >> 8) & 0xFF;
|
||||
u8 Lum = Short & 0xFF;
|
||||
return CColor(Lum, Lum, Lum, Alpha);
|
||||
return CColor::Integral(Lum, Lum, Lum, Alpha);
|
||||
}
|
||||
|
||||
CColor CTextureDecoder::DecodePixelC4(u8 Byte, u8 WhichPixel, CInputStream& PaletteStream)
|
||||
@@ -654,7 +655,7 @@ CColor CTextureDecoder::DecodePixelRGB565(u16 Short)
|
||||
u8 b = Extend5to8( (u8) (Short >> 11) );
|
||||
u8 g = Extend6to8( (u8) (Short >> 5) );
|
||||
u8 r = Extend5to8( (u8) (Short) );
|
||||
return CColor(r, g, b, 0xFF);
|
||||
return CColor::Integral(r, g, b, 0xFF);
|
||||
}
|
||||
|
||||
CColor CTextureDecoder::DecodePixelRGB5A3(u16 Short)
|
||||
@@ -664,7 +665,7 @@ CColor CTextureDecoder::DecodePixelRGB5A3(u16 Short)
|
||||
u8 b = Extend5to8( (u8) (Short >> 10));
|
||||
u8 g = Extend5to8( (u8) (Short >> 5));
|
||||
u8 r = Extend5to8( (u8) (Short) );
|
||||
return CColor(r, g, b, 0xFF);
|
||||
return CColor::Integral(r, g, b, 0xFF);
|
||||
}
|
||||
|
||||
else // RGB4A3
|
||||
@@ -673,7 +674,7 @@ CColor CTextureDecoder::DecodePixelRGB5A3(u16 Short)
|
||||
u8 b = Extend4to8( (u8) (Short >> 8) );
|
||||
u8 g = Extend4to8( (u8) (Short >> 4) );
|
||||
u8 r = Extend4to8( (u8) (Short) );
|
||||
return CColor(r, g, b, a);
|
||||
return CColor::Integral(r, g, b, a);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -819,9 +820,8 @@ void CTextureDecoder::DecodeBlockBC3(CInputStream& src, COutputStream& dst, u32
|
||||
}
|
||||
}
|
||||
|
||||
CColor CTextureDecoder::DecodeDDSPixel(CInputStream&)
|
||||
CColor CTextureDecoder::DecodeDDSPixel(CInputStream& /*DDS*/)
|
||||
{
|
||||
// Not using parameter 1 (CInputStream& - DDS)
|
||||
return CColor::skWhite;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,16 +41,16 @@ void CModelNode::Draw(ERenderOptions Options, int ComponentIndex, const SViewInf
|
||||
{
|
||||
CGraphics::SetDefaultLighting();
|
||||
CGraphics::UpdateLightBlock();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
CGraphics::sNumLights = 0;
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack.ToVector4f();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack;
|
||||
}
|
||||
|
||||
CGraphics::sPixelBlock.TevColor = CVector4f(1,1,1,1);
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
|
||||
CGraphics::sPixelBlock.TevColor = CColor::skWhite;
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo);
|
||||
LoadModelMatrix();
|
||||
|
||||
if (ComponentIndex < 0)
|
||||
|
||||
@@ -182,27 +182,28 @@ void CSceneNode::BuildLightList(CGameArea *pArea)
|
||||
void CSceneNode::LoadLights(const SViewInfo& ViewInfo)
|
||||
{
|
||||
CGraphics::sNumLights = 0;
|
||||
CGraphics::ELightingMode Mode = (ViewInfo.GameMode ? CGraphics::eWorldLighting : CGraphics::sLightMode);
|
||||
|
||||
if (CGraphics::sLightMode == CGraphics::eWorldLighting || ViewInfo.GameMode)
|
||||
switch (Mode)
|
||||
{
|
||||
case CGraphics::eNoLighting:
|
||||
// No lighting: default ambient color, no dynamic lights
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor;
|
||||
break;
|
||||
|
||||
case CGraphics::eBasicLighting:
|
||||
// Basic lighting: default ambient color, default dynamic lights
|
||||
CGraphics::SetDefaultLighting();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor;
|
||||
break;
|
||||
|
||||
case CGraphics::eWorldLighting:
|
||||
// World lighting: world ambient color, node dynamic lights
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = mAmbientColor.ToVector4f();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = mAmbientColor;
|
||||
|
||||
for (u32 iLight = 0; iLight < mLightCount; iLight++)
|
||||
mLights[iLight]->Load();
|
||||
}
|
||||
|
||||
else if (CGraphics::sLightMode == CGraphics::eBasicLighting)
|
||||
{
|
||||
// Basic lighting: default ambient color, default dynamic lights
|
||||
CGraphics::SetDefaultLighting();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f();
|
||||
}
|
||||
|
||||
else if (CGraphics::sLightMode == CGraphics::eNoLighting)
|
||||
{
|
||||
// No lighting: default ambient color, no dynamic lights
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor.ToVector4f();
|
||||
break;
|
||||
}
|
||||
|
||||
CGraphics::UpdateLightBlock();
|
||||
|
||||
@@ -163,9 +163,9 @@ void CScriptNode::Draw(ERenderOptions Options, int ComponentIndex, const SViewIn
|
||||
// Draw model if possible!
|
||||
if (mpActiveModel)
|
||||
{
|
||||
if (mpExtra) CGraphics::sPixelBlock.TevColor = mpExtra->TevColor().ToVector4f();
|
||||
else CGraphics::sPixelBlock.TevColor = CColor::skWhite.ToVector4f();
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
|
||||
if (mpExtra) CGraphics::sPixelBlock.TevColor = mpExtra->TevColor();
|
||||
else CGraphics::sPixelBlock.TevColor = CColor::skWhite;
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo);
|
||||
CGraphics::UpdatePixelBlock();
|
||||
|
||||
if (ComponentIndex < 0)
|
||||
@@ -447,7 +447,7 @@ void CScriptNode::GeneratePosition()
|
||||
|
||||
CColor CScriptNode::WireframeColor() const
|
||||
{
|
||||
return CColor((u8) 12, 135, 194, 255);
|
||||
return CColor::Integral(12, 135, 194);
|
||||
}
|
||||
|
||||
CScriptObject* CScriptNode::Object() const
|
||||
|
||||
@@ -48,10 +48,10 @@ void CStaticNode::Draw(ERenderOptions Options, int ComponentIndex, const SViewIn
|
||||
{
|
||||
if (!mpModel) return;
|
||||
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CVector4f(0, 0, 0, 1);
|
||||
float Multiplier = CGraphics::sWorldLightMultiplier;
|
||||
CGraphics::sPixelBlock.TevColor = CVector4f(Multiplier,Multiplier,Multiplier,1);
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo).ToVector4f();
|
||||
CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack;
|
||||
float Mul = CGraphics::sWorldLightMultiplier;
|
||||
CGraphics::sPixelBlock.TevColor = CColor(Mul,Mul,Mul);
|
||||
CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo);
|
||||
CGraphics::sNumLights = 0;
|
||||
CGraphics::UpdateLightBlock();
|
||||
LoadModelMatrix();
|
||||
|
||||
@@ -201,7 +201,7 @@ void CDamageableTriggerExtra::AddToRenderer(CRenderer *pRenderer, const SViewInf
|
||||
void CDamageableTriggerExtra::Draw(ERenderOptions Options, int /*ComponentIndex*/, const SViewInfo& ViewInfo)
|
||||
{
|
||||
LoadModelMatrix();
|
||||
CGraphics::sPixelBlock.TintColor = mpParent->TintColor(ViewInfo).ToVector4f();
|
||||
CGraphics::sPixelBlock.TintColor = mpParent->TintColor(ViewInfo);
|
||||
mpMat->SetCurrent(Options);
|
||||
|
||||
// Note: The plane the game renders this onto is 5x4.5, which is why we divide the tex coords by this value
|
||||
|
||||
@@ -67,8 +67,8 @@ void CDoorExtra::Draw(ERenderOptions Options, int ComponentIndex, const SViewInf
|
||||
if (mpShieldColorProp)
|
||||
Tint *= mpShieldColorProp->Get();
|
||||
|
||||
CGraphics::sPixelBlock.TintColor = Tint.ToVector4f();
|
||||
CGraphics::sPixelBlock.TevColor = CColor::skWhite.ToVector4f();
|
||||
CGraphics::sPixelBlock.TintColor = Tint;
|
||||
CGraphics::sPixelBlock.TevColor = CColor::skWhite;
|
||||
CGraphics::UpdatePixelBlock();
|
||||
|
||||
if (ComponentIndex < 0)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "CPointOfInterestExtra.h"
|
||||
|
||||
const CColor CPointOfInterestExtra::skRegularColor ((u32) 0xFF7000FF);
|
||||
const CColor CPointOfInterestExtra::skImportantColor((u32) 0xFF0000FF);
|
||||
const CColor CPointOfInterestExtra::skRegularColor = CColor::Integral(0xFF,0x70,0x00);
|
||||
const CColor CPointOfInterestExtra::skImportantColor = CColor::Integral(0xFF,0x00,0x00);
|
||||
|
||||
CPointOfInterestExtra::CPointOfInterestExtra(CScriptObject *pInstance, CSceneManager *pScene, CSceneNode *pParent)
|
||||
: CScriptExtra(pInstance, pScene, pParent)
|
||||
|
||||
Reference in New Issue
Block a user