Minor lighting fixes and initial Mode 8 implementation
This commit is contained in:
parent
cd7937f73c
commit
79ec379c66
|
@ -1,5 +1,8 @@
|
||||||
<component name="ProjectCodeStyleConfiguration">
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
<code_scheme name="Project" version="173">
|
<code_scheme name="Project" version="173">
|
||||||
|
<MarkdownNavigatorCodeStyleSettings>
|
||||||
|
<option name="RIGHT_MARGIN" value="72" />
|
||||||
|
</MarkdownNavigatorCodeStyleSettings>
|
||||||
<Objective-C>
|
<Objective-C>
|
||||||
<option name="NAMESPACE_BRACE_PLACEMENT" value="2" />
|
<option name="NAMESPACE_BRACE_PLACEMENT" value="2" />
|
||||||
<option name="FUNCTION_BRACE_PLACEMENT" value="2" />
|
<option name="FUNCTION_BRACE_PLACEMENT" value="2" />
|
||||||
|
|
|
@ -23,6 +23,21 @@ CLight::CLight()
|
||||||
// This function is reverse engineered from the kiosk demo's code
|
// This function is reverse engineered from the kiosk demo's code
|
||||||
float CLight::CalculateRadius() const
|
float CLight::CalculateRadius() const
|
||||||
{
|
{
|
||||||
|
if (mDistAttenCoefficients.Y < FLT_EPSILON && mDistAttenCoefficients.Z < FLT_EPSILON)
|
||||||
|
return FLT_MAX;
|
||||||
|
|
||||||
|
float Intensity = GetIntensity();
|
||||||
|
if (mDistAttenCoefficients.Z > FLT_EPSILON) {
|
||||||
|
if (Intensity <= FLT_EPSILON)
|
||||||
|
return 0.f;
|
||||||
|
return std::sqrt(Intensity / (0.0588235f * mDistAttenCoefficients.Z));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mDistAttenCoefficients.Y > FLT_EPSILON)
|
||||||
|
return Intensity / (0.0588235f * mDistAttenCoefficients.Y);
|
||||||
|
return 0.f;
|
||||||
|
|
||||||
|
#if 0
|
||||||
if ((mDistAttenCoefficients.Y >= FLT_EPSILON) ||
|
if ((mDistAttenCoefficients.Y >= FLT_EPSILON) ||
|
||||||
(mDistAttenCoefficients.Z >= FLT_EPSILON))
|
(mDistAttenCoefficients.Z >= FLT_EPSILON))
|
||||||
{
|
{
|
||||||
|
@ -51,17 +66,25 @@ float CLight::CalculateRadius() const
|
||||||
}
|
}
|
||||||
|
|
||||||
else return 3000000000000000000000000000000000000.f;
|
else return 3000000000000000000000000000000000000.f;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is also reverse engineered from the kiosk demo's code
|
// This function is also reverse engineered from the kiosk demo's code
|
||||||
float CLight::CalculateIntensity() const
|
float CLight::CalculateIntensity() const
|
||||||
{
|
{
|
||||||
|
float coef = 1.f;
|
||||||
|
if (mType == ELightType::Custom)
|
||||||
|
coef = mAngleAttenCoefficients.X;
|
||||||
|
|
||||||
|
return coef * std::max(mColor.R, std::max(mColor.G, mColor.B));
|
||||||
|
#if 0
|
||||||
// Get the color component with the greatest numeric value
|
// Get the color component with the greatest numeric value
|
||||||
float Greatest = (mColor.G >= mColor.B) ? mColor.G : mColor.B;
|
float Greatest = (mColor.G >= mColor.B) ? mColor.G : mColor.B;
|
||||||
Greatest = (mColor.R >= Greatest) ? mColor.R : Greatest;
|
Greatest = (mColor.R >= Greatest) ? mColor.R : Greatest;
|
||||||
|
|
||||||
float Multiplier = (mType == ELightType::Custom) ? mAngleAttenCoefficients.X : 1.0f;
|
float Multiplier = (mType == ELightType::Custom) ? mAngleAttenCoefficients.X : 1.0f;
|
||||||
return Greatest * Multiplier;
|
return Greatest * Multiplier;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// As is this one... partly
|
// As is this one... partly
|
||||||
|
@ -69,10 +92,7 @@ CVector3f CLight::CalculateSpotAngleAtten()
|
||||||
{
|
{
|
||||||
if (mType != ELightType::Spot) return CVector3f(1.f, 0.f, 0.f);
|
if (mType != ELightType::Spot) return CVector3f(1.f, 0.f, 0.f);
|
||||||
|
|
||||||
if ((mSpotCutoff < 0.f) || (mSpotCutoff > 90.f))
|
float RadianCutoff = mSpotCutoff * (3.1415927f / 180.f);
|
||||||
return CVector3f(1.f, 0.f, 0.f);
|
|
||||||
|
|
||||||
float RadianCutoff = (mSpotCutoff * 3.1415927f) / 180.f;
|
|
||||||
float RadianCosine = cosf(RadianCutoff);
|
float RadianCosine = cosf(RadianCutoff);
|
||||||
float InvCosine = 1.f - RadianCosine;
|
float InvCosine = 1.f - RadianCosine;
|
||||||
|
|
||||||
|
@ -88,7 +108,7 @@ float CLight::GetRadius() const
|
||||||
mDirtyFlags &= ~CLIGHT_NO_RADIUS;
|
mDirtyFlags &= ~CLIGHT_NO_RADIUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mCachedRadius * 2;
|
return mCachedRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
float CLight::GetIntensity() const
|
float CLight::GetIntensity() const
|
||||||
|
@ -223,7 +243,7 @@ CLight CLight::BuildLocalAmbient(const CVector3f& rkPosition, const CColor& rkCo
|
||||||
pLight.mPosition = rkPosition;
|
pLight.mPosition = rkPosition;
|
||||||
pLight.mDirection = skDefaultLightDir;
|
pLight.mDirection = skDefaultLightDir;
|
||||||
pLight.mColor = rkColor;
|
pLight.mColor = rkColor;
|
||||||
pLight.mSpotCutoff = 0.f;
|
pLight.mSpotCutoff = 180.f;
|
||||||
return pLight;
|
return pLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +254,7 @@ CLight CLight::BuildDirectional(const CVector3f& rkPosition, const CVector3f& rk
|
||||||
pLight.mPosition = rkPosition;
|
pLight.mPosition = rkPosition;
|
||||||
pLight.mDirection = rkDirection;
|
pLight.mDirection = rkDirection;
|
||||||
pLight.mColor = rkColor;
|
pLight.mColor = rkColor;
|
||||||
pLight.mSpotCutoff = 0.f;
|
pLight.mSpotCutoff = 180.f;
|
||||||
return pLight;
|
return pLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +265,7 @@ CLight CLight::BuildSpot(const CVector3f& rkPosition, const CVector3f& rkDirecti
|
||||||
pLight.mPosition = rkPosition;
|
pLight.mPosition = rkPosition;
|
||||||
pLight.mDirection = -rkDirection.Normalized();
|
pLight.mDirection = -rkDirection.Normalized();
|
||||||
pLight.mColor = rkColor;
|
pLight.mColor = rkColor;
|
||||||
pLight.mSpotCutoff = Cutoff * 0.5f;
|
pLight.mSpotCutoff = Cutoff;
|
||||||
pLight.mAngleAttenCoefficients = pLight.CalculateSpotAngleAtten();
|
pLight.mAngleAttenCoefficients = pLight.CalculateSpotAngleAtten();
|
||||||
return pLight;
|
return pLight;
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,33 @@ void CMaterialPass::SetAnimCurrent(FRenderOptions Options, uint32 PassIndex)
|
||||||
|
|
||||||
case EUVAnimMode::ConvolutedModeB: // Mode 8 (MP3/DKCR only)
|
case EUVAnimMode::ConvolutedModeB: // Mode 8 (MP3/DKCR only)
|
||||||
{
|
{
|
||||||
// todo
|
float t = mAnimParams[2] + (Seconds * mAnimParams[3]);
|
||||||
|
float sin = std::sin(t);
|
||||||
|
float cos = std::cos(t);
|
||||||
|
/* TODO Properly implement the mode type */
|
||||||
|
if (mAnimConvolutedModeBType == EUVConvolutedModeBType::Zero)
|
||||||
|
{
|
||||||
|
} else if (mAnimConvolutedModeBType == EUVConvolutedModeBType::One)
|
||||||
|
{
|
||||||
|
} else if (mAnimConvolutedModeBType == EUVConvolutedModeBType::Two)
|
||||||
|
{
|
||||||
|
|
||||||
|
} else if (mAnimConvolutedModeBType == EUVConvolutedModeBType::Three)
|
||||||
|
{
|
||||||
|
|
||||||
|
} else if (mAnimConvolutedModeBType == EUVConvolutedModeBType::Four)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
float X = (mAnimParams[0] * (mAnimParams[5] + (mAnimParams[6] * Seconds))) + (0.5f - (0.5f * (cos - sin)));
|
||||||
|
float Y = (mAnimParams[1] * (mAnimParams[5] + (mAnimParams[7] * Seconds))) + (0.5f - (0.5f * (sin + cos)));
|
||||||
|
TexMtx = CMatrix4f(mAnimParams[0] * cos, mAnimParams[1] * -sin, 0.f,
|
||||||
|
X,
|
||||||
|
mAnimParams[0] * sin, mAnimParams[1] * cos, 0.f,
|
||||||
|
Y,
|
||||||
|
0.f, 0.f, 0.f, 1.f,
|
||||||
|
0.f, 0.f, 0.f, 1.f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,8 @@ class CMaterialPass
|
||||||
uint32 mTexCoordSource; // Should maybe be an enum but worried about conflicts with EVertexDescriptionn
|
uint32 mTexCoordSource; // Should maybe be an enum but worried about conflicts with EVertexDescriptionn
|
||||||
TResPtr<CTexture> mpTexture;
|
TResPtr<CTexture> mpTexture;
|
||||||
EUVAnimMode mAnimMode;
|
EUVAnimMode mAnimMode;
|
||||||
float mAnimParams[4];
|
EUVConvolutedModeBType mAnimConvolutedModeBType;
|
||||||
|
float mAnimParams[8];
|
||||||
bool mEnabled;
|
bool mEnabled;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -103,5 +103,13 @@ enum class EUVAnimMode
|
||||||
NoUVAnim = -1
|
NoUVAnim = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class EUVConvolutedModeBType {
|
||||||
|
Zero,
|
||||||
|
One,
|
||||||
|
Two,
|
||||||
|
Three,
|
||||||
|
Four
|
||||||
|
};
|
||||||
|
|
||||||
#endif // ETEVENUMS
|
#endif // ETEVENUMS
|
||||||
|
|
||||||
|
|
|
@ -400,6 +400,17 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
|
||||||
|
|
||||||
// Unknown/unsupported animation type
|
// Unknown/unsupported animation type
|
||||||
case EUVAnimMode::ConvolutedModeB:
|
case EUVAnimMode::ConvolutedModeB:
|
||||||
|
pPass->mAnimConvolutedModeBType = EUVConvolutedModeBType(mpFile->ReadLong());
|
||||||
|
pPass->mAnimParams[0] = mpFile->ReadFloat();
|
||||||
|
pPass->mAnimParams[1] = mpFile->ReadFloat();
|
||||||
|
pPass->mAnimParams[2] = mpFile->ReadFloat();
|
||||||
|
pPass->mAnimParams[3] = mpFile->ReadFloat();
|
||||||
|
pPass->mAnimParams[4] = mpFile->ReadFloat();
|
||||||
|
pPass->mAnimParams[5] = mpFile->ReadFloat();
|
||||||
|
pPass->mAnimParams[6] = mpFile->ReadFloat();
|
||||||
|
pPass->mAnimParams[7] = mpFile->ReadFloat();
|
||||||
|
debugf("%s: UVMode8 Used with type %i", *mpFile->GetSourceString(), int(pPass->mAnimConvolutedModeBType));
|
||||||
|
break;
|
||||||
case EUVAnimMode::Eleven:
|
case EUVAnimMode::Eleven:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue