OpenBarnyard
 
Loading...
Searching...
No Matches
ASkinShaderHAL Class Reference

#include <ASkinShader_DX8.h>

Inheritance diagram for ASkinShaderHAL:
ASkinShader

Classes

struct  AUnknown
 

Public Member Functions

 TDECLARE_CLASS (ASkinShaderHAL, ASkinShader)
 
 ASkinShaderHAL ()
 
 ~ASkinShaderHAL ()
 
virtual void Flush () override
 
virtual void StartFlush () override
 
virtual void EndFlush () override
 
virtual TBOOL Create () override
 
virtual TBOOL Validate () override
 
virtual void Invalidate () override
 
virtual TBOOL TryInvalidate () override
 
virtual TBOOL TryValidate () override
 
virtual void Render (Toshi::TRenderPacket *a_pRenderPacket) override
 
virtual void EnableRenderEnvMap (TBOOL a_bEnable) override
 
virtual TBOOL IsHighEndSkinning () override
 
virtual void EnableHighEndSkinning (TBOOL a_bEnable) override
 
virtual TBOOL IsCapableHighEndSkinning () override
 
virtual TBOOL IsLightScattering () override
 
virtual void SetLightScattering (TBOOL a_bEnable) override
 
virtual TBOOL IsAlphaBlendMaterial () override
 
virtual void SetAlphaBlendMaterial (TBOOL a_bIsAlphaBlendMaterial) override
 
virtual ASkinMaterialCreateMaterial (const TCHAR *a_szName) override
 
virtual ASkinMeshCreateMesh (const TCHAR *a_szName) override
 
virtual TINT AddLight (const Toshi::TVector3 &a_rPosition, TFLOAT a_fIntensity) override
 
virtual void SetLight (TINT a_iIndex, const Toshi::TVector3 &a_rPosition, TFLOAT a_fIntensity) override
 
virtual void RemoveLight (TINT a_iIndex) override
 
virtual TBOOL IsEnableRenderEnvMap ()
 
virtual void SetSomeColour (TUINT a_uiR, TUINT a_uiG, TUINT a_uiB, TUINT a_uiA)
 
virtual TINT SetUnknown1 (TINT a_Unknown, TUINT8 a_fAlpha)
 
virtual void SetUnknown2 (TINT a_Unknown)
 
void SetAlphaRef (TINT a_iAlphaRef)
 
Toshi::TOrderTable * GetOrderTable (TUINT a_uiIndex)
 
- Public Member Functions inherited from ASkinShader
 TDECLARE_CLASS (ASkinShader, Toshi::TShader)
 
 ASkinShader ()
 
 ~ASkinShader ()
 
virtual void EnableClouds (TBOOL a_bEnabled)
 
virtual TBOOL IsEnabledClouds ()
 
virtual TBOOL IsCapablePointLights ()
 
virtual void SetPointLights (TBOOL a_bEnabled)
 
virtual TBOOL IsPointLightsEnabled ()
 

Static Public Attributes

static constexpr TUINT NUM_ORDER_TABLES = 3
 
static TUINT sm_eRenderStateFlags = 27
 
static Toshi::TMatrix44 sm_oWorldViewMatrix
 
static Toshi::TMatrix44 sm_oViewModelMatrix
 

Additional Inherited Members

- Protected Attributes inherited from ASkinShader
union { 
 
   TUINT8   m_SomeColourComponents [8] 
 
   TINT32   m_SomeColour 
 
};  
 
TINT m_Unk2
 
TFLOAT m_Unk3
 
TINT m_Unk4
 

Detailed Description

Definition at line 7 of file ASkinShader_DX8.h.

Constructor & Destructor Documentation

◆ ASkinShaderHAL()

ASkinShaderHAL::ASkinShaderHAL ( )

Definition at line 29 of file ASkinShader_DX8.cpp.

30 : m_hUnknownPixelShader( 0 ), m_hVertexShader( 0 ), m_hVertexShaderHD( 0 ), m_hPixelShader( 0 ), m_iAlphaRef( 128 ), m_bIsAlphaBlendMaterial( TFALSE ), m_fAMDPatch1( 0.0f ), m_bCPUSupportsFeature1( TFALSE ), m_bCPUSupportsFeature2( TFALSE ), m_bUnkFlag( TFALSE ), m_bHighEndSkinning( TTRUE ), m_bLightScattering( TTRUE ), m_fAMDPatch2( 1.0f )
31{
32}
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25

◆ ~ASkinShaderHAL()

ASkinShaderHAL::~ASkinShaderHAL ( )

Definition at line 34 of file ASkinShader_DX8.cpp.

35{
36}

Member Function Documentation

◆ AddLight()

TINT ASkinShaderHAL::AddLight ( const Toshi::TVector3 & a_rPosition,
TFLOAT a_fIntensity )
overridevirtual

Implements ASkinShader.

Definition at line 606 of file ASkinShader_DX8.cpp.

607{
608 TASSERT( !"Not implemeted in the original game" );
609 return 0;
610}
#define TASSERT(X,...)
Definition Defines.h:138

◆ Create()

TBOOL ASkinShaderHAL::Create ( )
overridevirtual

Definition at line 130 of file ASkinShader_DX8.cpp.

131{
132 m_aOrderTables[ 0 ].Create( this, -390 );
133 m_aOrderTables[ 1 ].Create( this, 1000 );
134 m_aOrderTables[ 2 ].Create( this, -400 );
135 return BaseClass::Create();
136}

◆ CreateMaterial()

ASkinMaterial * ASkinShaderHAL::CreateMaterial ( const TCHAR * a_szName)
overridevirtual

Implements ASkinShader.

Definition at line 574 of file ASkinShader_DX8.cpp.

575{
576 Validate();
577
578 auto pMaterial = new ASkinMaterialHAL();
579 pMaterial->SetShader( this );
580
581 if ( TNULL != a_szName )
582 pMaterial->SetName( a_szName );
583
585 {
586 auto pAlphaBlendMaterial = new ASkinMaterialHAL();
587 pAlphaBlendMaterial->SetShader( this );
588 pAlphaBlendMaterial->Create( 1 );
589
590 pMaterial->SetAlphaBlendMaterial( pAlphaBlendMaterial );
591 }
592
593 return pMaterial;
594}
#define TNULL
Definition Typedefs.h:23
virtual TBOOL IsAlphaBlendMaterial() override
virtual TBOOL Validate() override

◆ CreateMesh()

ASkinMesh * ASkinShaderHAL::CreateMesh ( const TCHAR * a_szName)
overridevirtual

Implements ASkinShader.

Definition at line 596 of file ASkinShader_DX8.cpp.

597{
598 Validate();
599
600 auto pMesh = new ASkinMeshHAL();
601 pMesh->SetOwnerShader( this );
602
603 return pMesh;
604}

◆ EnableHighEndSkinning()

void ASkinShaderHAL::EnableHighEndSkinning ( TBOOL a_bEnable)
overridevirtual

Reimplemented from ASkinShader.

Definition at line 526 of file ASkinShader_DX8.cpp.

527{
528 m_bHighEndSkinning = a_bEnable && IsCapableHighEndSkinning();
529}
virtual TBOOL IsCapableHighEndSkinning() override

◆ EnableRenderEnvMap()

void ASkinShaderHAL::EnableRenderEnvMap ( TBOOL a_bEnable)
overridevirtual

Reimplemented from ASkinShader.

Definition at line 516 of file ASkinShader_DX8.cpp.

517{
518 m_bRenderEnvMap = a_bEnable;
519}

◆ EndFlush()

void ASkinShaderHAL::EndFlush ( )
overridevirtual

Definition at line 120 of file ASkinShader_DX8.cpp.

121{
122 auto pRenderInterface = TRenderD3DInterface::Interface();
123 auto pDevice = pRenderInterface->GetDirect3DDevice();
124
125 pDevice->SetRenderState( D3DRS_SPECULARENABLE, 0 );
126 pDevice->SetRenderState( D3DRS_FOGENABLE, 0 );
127 pDevice->SetPixelShader( 0 );
128}
static TFORCEINLINE TRenderD3DInterface * Interface()
Gets the render interface singleton.

◆ Flush()

void ASkinShaderHAL::Flush ( )
overridevirtual

Definition at line 38 of file ASkinShader_DX8.cpp.

39{
40 if ( IsValidated() )
41 {
42 auto pRenderInterface = TRenderD3DInterface::Interface();
43 auto pCurrentContext = TRenderContextD3D::Upcast( pRenderInterface->GetCurrentContext() );
44 auto pDevice = pRenderInterface->GetDirect3DDevice();
45
46 if ( IsHighEndSkinning() )
47 {
48 pDevice->SetRenderState( D3DRS_ALPHATESTENABLE, 1 );
49 pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, 1 );
50 pDevice->SetRenderState( D3DRS_ALPHAFUNC, 5 );
51
52 DWORD bWasSpecularEnabled;
53 pDevice->GetRenderState( D3DRS_SPECULARENABLE, &bWasSpecularEnabled );
54 pDevice->SetRenderState( D3DRS_SPECULARENABLE, 0 );
55
56 pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, 4 );
57 pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, 2 );
58 pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, 0 );
59 pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, 4 );
60 pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, 2 );
61 pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, 0 );
62 pDevice->SetTextureStageState( 1, D3DTSS_COLOROP, 1 );
63 pDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, 1 );
64
65 pDevice->SetRenderState( D3DRS_CULLMODE, m_bRenderEnvMap ? 3 : 2 );
66 m_aOrderTables[ 0 ].Render();
67
68 pDevice->SetRenderState( D3DRS_SPECULARENABLE, bWasSpecularEnabled );
69 pDevice->SetRenderState( D3DRS_FOGENABLE, 0 );
70 pDevice->SetPixelShader( 0 );
71 }
72 else
73 {
74 SetupLowEndMode();
75 }
76 }
77
78 BaseClass::Flush();
79}
static TRenderContextD3D * Upcast(TRenderContext *a_pRenderContext)
virtual TBOOL IsHighEndSkinning() override

◆ GetOrderTable()

Toshi::TOrderTable * ASkinShaderHAL::GetOrderTable ( TUINT a_uiIndex)
inline

Definition at line 62 of file ASkinShader_DX8.h.

63 {
64 TASSERT( a_uiIndex < NUM_ORDER_TABLES );
65 return &m_aOrderTables[ a_uiIndex ];
66 }
static constexpr TUINT NUM_ORDER_TABLES

◆ Invalidate()

void ASkinShaderHAL::Invalidate ( )
overridevirtual

Definition at line 204 of file ASkinShader_DX8.cpp.

205{
206 if ( !IsValidated() ) return;
207
208 if ( !IsHighEndSkinning() )
209 {
210 m_SomeList.DeleteAll();
211 }
212 else
213 {
214 if ( m_hVertexShader != 0 )
215 {
217 m_hVertexShader = 0;
218 }
219
220 if ( m_hVertexShaderHD != 0 )
221 {
222 TRenderD3DInterface::DestroyVertexShader( m_hVertexShaderHD );
223 m_hVertexShaderHD = 0;
224 }
225
226 if ( m_hUnknownPixelShader != 0 )
227 {
228 TRenderD3DInterface::DestroyPixelShader( m_hUnknownPixelShader );
229 m_hUnknownPixelShader = 0;
230 }
231
232 if ( m_hPixelShader != 0 )
233 {
235 m_hPixelShader = 0;
236 }
237 }
238
239 BaseClass::Invalidate();
240}
static void DestroyPixelShader(DWORD a_hPixelShader)
Destroys a pixel shader.
static void DestroyVertexShader(DWORD a_hVertexShader)
Destroys a vertex shader.

◆ IsAlphaBlendMaterial()

TBOOL ASkinShaderHAL::IsAlphaBlendMaterial ( )
overridevirtual

Reimplemented from ASkinShader.

Definition at line 564 of file ASkinShader_DX8.cpp.

565{
566 return m_bIsAlphaBlendMaterial;
567}

◆ IsCapableHighEndSkinning()

TBOOL ASkinShaderHAL::IsCapableHighEndSkinning ( )
overridevirtual

Reimplemented from ASkinShader.

Definition at line 531 of file ASkinShader_DX8.cpp.

532{
533 D3DCAPS8 caps;
534
535 auto pRenderInterface = TRenderD3DInterface::Interface();
536 auto pDevice = pRenderInterface->GetDirect3DDevice();
537
538 if ( !pDevice )
539 {
540 auto pDirect3D = pRenderInterface->GetDirect3D();
541
542 TVALIDPTR( pDirect3D );
543 if ( !pDirect3D ) return TFALSE;
544
545 pDirect3D->GetDeviceCaps( 0, D3DDEVTYPE_HAL, &caps );
546 }
547 else
548 {
549 pDevice->GetDeviceCaps( &caps );
550 }
551
552 return ( ( caps.VertexShaderVersion & 0xFFFF ) > 256 ) && ( caps.DevCaps & 0x10000 );
553}
#define TVALIDPTR(PTR)
Definition Defines.h:139

◆ IsEnableRenderEnvMap()

TBOOL ASkinShaderHAL::IsEnableRenderEnvMap ( )
virtual

Definition at line 622 of file ASkinShader_DX8.cpp.

623{
624 return m_bRenderEnvMap;
625}

◆ IsHighEndSkinning()

TBOOL ASkinShaderHAL::IsHighEndSkinning ( )
overridevirtual

Reimplemented from ASkinShader.

Definition at line 521 of file ASkinShader_DX8.cpp.

522{
523 return m_bHighEndSkinning;
524}

◆ IsLightScattering()

TBOOL ASkinShaderHAL::IsLightScattering ( )
overridevirtual

Reimplemented from ASkinShader.

Definition at line 555 of file ASkinShader_DX8.cpp.

556{
557 return m_bLightScattering;
558}

◆ RemoveLight()

void ASkinShaderHAL::RemoveLight ( TINT a_iIndex)
overridevirtual

Implements ASkinShader.

Definition at line 617 of file ASkinShader_DX8.cpp.

618{
619 TASSERT( !"Not implemeted in the original game" );
620}

◆ Render()

void ASkinShaderHAL::Render ( Toshi::TRenderPacket * a_pRenderPacket)
overridevirtual

Definition at line 254 of file ASkinShader_DX8.cpp.

255{
256 if ( IsHighEndSkinning() )
257 {
258 if ( a_pRenderPacket && a_pRenderPacket->GetMesh() )
259 {
260 auto pMesh = TSTATICCAST( ASkinMeshHAL, a_pRenderPacket->GetMesh() );
261 auto pMaterial = TSTATICCAST( ASkinMaterialHAL, pMesh->GetMaterial() );
262
263 if ( pMesh->GetNumSubMeshes() == 0 ) return;
264
265 auto pSkeletonInstance = a_pRenderPacket->GetSkeletonInstance();
266 TVALIDPTR( pSkeletonInstance );
267
268 TVector4 vLightingLerp1 = TVector4( 1.0f, 1.0f, 1.0f, 1.0f );
269 TVector4 vLightingLerp2 = TVector4( 1.0f, 1.0f, 1.0f, 1.0f );
270
271 auto pRenderInterface = TRenderD3DInterface::Interface();
272 auto pCurrentContext = TRenderContextD3D::Upcast( pRenderInterface->GetCurrentContext() );
273 auto pD3DDevice = pRenderInterface->GetDirect3DDevice();
274
275 if ( pMaterial->IsHDLighting() && pMaterial->HasLighting1Tex() && pMaterial->HasLighting2Tex() )
276 {
277 // Apply lighting to the skin mesh that uses the HD shader
278 // HD shader uses 4 shading textures to character models look good
279
280 Validate();
281 pD3DDevice->SetVertexShader( m_hVertexShaderHD );
282 pD3DDevice->SetPixelShader( m_hPixelShader );
283
284 TMatrix44 oViewModel;
285 oViewModel.Invert( a_pRenderPacket->GetModelViewMatrix() );
286
287 TVector4 upVector;
288 upVector.Negate3( oViewModel.AsBasisVector4( 2 ) );
289
290 pD3DDevice->SetVertexShaderConstant( 94, &upVector, 1 );
291
292 TUINT ui8ShadeCoeff = a_pRenderPacket->GetShadeCoeff();
293 TFLOAT fShadeCoeff = a_pRenderPacket->GetShadeCoeff() * ( 1.0f / 255.0f );
294
295 auto pDevice = TSTATICCAST( TD3DAdapter::Mode::Device, pRenderInterface->GetCurrentDevice() );
296
297 if ( pDevice->GetD3DCaps().PixelShaderVersion < 0xffff0104 )
298 {
299 // Can't set all 4 textures at once
300
301 TTextureResourceHAL* pLightingTex1;
302 TTextureResourceHAL* pLightingTex2;
303
304 if ( ui8ShadeCoeff == 0 )
305 {
306 pLightingTex1 = pMaterial->GetLightingTexture( ASkinMaterial::LT_0 );
307 pLightingTex2 = pMaterial->GetLightingTexture( ASkinMaterial::LT_1 );
308 }
309 else if ( ui8ShadeCoeff == 255 )
310 {
311 pLightingTex1 = pMaterial->GetLightingTexture( ASkinMaterial::LT_2 );
312 pLightingTex2 = pMaterial->GetLightingTexture( ASkinMaterial::LT_3 );
313 }
314 else if ( ui8ShadeCoeff < 127 )
315 {
316 pLightingTex1 = pMaterial->GetLightingTexture( ASkinMaterial::LT_0 );
317 pLightingTex2 = pMaterial->GetLightingTexture( ASkinMaterial::LT_1 );
318
319 vLightingLerp2.x = ( 1.0f - ( fShadeCoeff + fShadeCoeff ) ) * 0.3f + 0.7f;
320 vLightingLerp2.y = vLightingLerp2.x;
321 vLightingLerp2.z = vLightingLerp2.x;
322 }
323 else
324 {
325 pLightingTex1 = pMaterial->GetLightingTexture( ASkinMaterial::LT_2 );
326 pLightingTex2 = pMaterial->GetLightingTexture( ASkinMaterial::LT_3 );
327
328 vLightingLerp1.x = ( ( fShadeCoeff - 0.5f ) + ( fShadeCoeff - 0.5f ) ) * 0.3f + 0.7f;
329 vLightingLerp1.y = vLightingLerp1.x;
330 vLightingLerp1.z = vLightingLerp1.x;
331 }
332
333 pD3DDevice->SetPixelShaderConstant( 0, &vLightingLerp1, 1 );
334 pD3DDevice->SetPixelShaderConstant( 1, &vLightingLerp2, 1 );
335 pD3DDevice->SetTexture( 1, pLightingTex1->GetD3DTexture() );
336 pD3DDevice->SetTextureStageState( 1, D3DTSS_MIPFILTER, 0 );
337 pD3DDevice->SetTexture( 2, pLightingTex2->GetD3DTexture() );
338 pD3DDevice->SetTextureStageState( 2, D3DTSS_MIPFILTER, 0 );
339 }
340 else
341 {
342 // Can set all 4 textures at once
343
344 if ( pMaterial->GetSomeTexture() && pRenderInterface->GetCurrentDevice() && !USE_ONE_TEXTURE_LIGHTING )
345 fShadeCoeff = fShadeCoeff - 0.3f;
346
347 vLightingLerp1.x = 1.0f - fShadeCoeff;
348 vLightingLerp1.y = vLightingLerp1.x;
349 vLightingLerp1.z = vLightingLerp1.x;
350 vLightingLerp1.w = 0.0f;
351
352 vLightingLerp2.x = fShadeCoeff;
353 vLightingLerp2.y = fShadeCoeff;
354 vLightingLerp2.z = fShadeCoeff;
355 vLightingLerp2.w = 0.0f;
356
357 pD3DDevice->SetTexture( 1, pMaterial->GetLightingTexture( ASkinMaterial::LT_0 )->GetD3DTexture() );
358 pD3DDevice->SetTextureStageState( 1, D3DTSS_MIPFILTER, 0 );
359
360 pD3DDevice->SetTexture( 2, pMaterial->GetLightingTexture( ASkinMaterial::LT_1 )->GetD3DTexture() );
361 pD3DDevice->SetTextureStageState( 2, D3DTSS_MIPFILTER, 0 );
362
363 pD3DDevice->SetTexture( 3, pMaterial->GetLightingTexture( ASkinMaterial::LT_2 )->GetD3DTexture() );
364 pD3DDevice->SetTextureStageState( 3, D3DTSS_MIPFILTER, 0 );
365
366 pD3DDevice->SetTexture( 4, pMaterial->GetLightingTexture( ASkinMaterial::LT_3 )->GetD3DTexture() );
367 pD3DDevice->SetTextureStageState( 4, D3DTSS_MIPFILTER, 0 );
368
369 pD3DDevice->SetPixelShaderConstant( 0, &vLightingLerp1, 1 );
370 pD3DDevice->SetPixelShaderConstant( 1, &vLightingLerp2, 1 );
371 }
372 }
373 else
374 {
375 // Apply lighting to the skin mesh that doesn't use the HD shader
376
377 TVector4 upVector = TVector4( 0.0f, 0.0f, 0.0f, 1.0f );
378 pD3DDevice->SetVertexShaderConstant( 94, &upVector, 1 );
379
380 Validate();
381 pD3DDevice->SetVertexShader( m_hVertexShader );
382 pD3DDevice->SetPixelShader( 0 );
383
384 auto pSomeTexture = pMaterial->GetSomeTexture();
385
386 if ( pSomeTexture && pRenderInterface->GetCurrentDevice() && USE_ONE_TEXTURE_LIGHTING )
387 {
388 constexpr TFLOAT kLightingLerp1 = 0.00f;
389 constexpr TFLOAT kLightingLerp2 = 0.25f;
390
391 pD3DDevice->SetTextureStageState( 3, D3DTSS_COLOROP, 1 );
392 pD3DDevice->SetTexture( 1, pSomeTexture->GetD3DTexture() );
393 pD3DDevice->SetTexture( 2, pSomeTexture->GetD3DTexture() );
394 pD3DDevice->SetTextureStageState( 1, D3DTSS_MIPFILTER, 2 );
395 pD3DDevice->SetTextureStageState( 2, D3DTSS_MIPFILTER, 2 );
396 vLightingLerp1.x = kLightingLerp1;
397 vLightingLerp1.y = kLightingLerp1;
398 vLightingLerp1.z = kLightingLerp1;
399 vLightingLerp1.w = 0.0f;
400
401 vLightingLerp2.x = kLightingLerp2;
402 vLightingLerp2.y = kLightingLerp2;
403 vLightingLerp2.z = kLightingLerp2;
404 vLightingLerp2.w = 0.0f;
405
406 pD3DDevice->SetPixelShaderConstant( 0, &vLightingLerp1, 1 );
407 pD3DDevice->SetPixelShaderConstant( 1, &vLightingLerp2, 1 );
408 pD3DDevice->SetPixelShader( m_hPixelShader );
409 }
410 }
411
412 TMatrix44 oModelViewProjection;
413 D3DXMatrixMultiply( oModelViewProjection, a_pRenderPacket->GetModelViewMatrix(), pCurrentContext->GetProjectionMatrix() );
414 D3DXMatrixTranspose( oModelViewProjection, oModelViewProjection );
415
416 static constexpr TVector4 s_vUnknown = TVector4( 256.0f, 256.0f, 256.0f, 256.0f );
417 pD3DDevice->SetVertexShaderConstant( VERTEX_SHADER_REGISTER_MVP, oModelViewProjection, 4 );
418 pD3DDevice->SetVertexShaderConstant( 4, &s_vUnknown, 1 );
419
420 TFLOAT fLightDirX = -a_pRenderPacket->GetLightDirection().x;
421 TFLOAT fLightDirY = -a_pRenderPacket->GetLightDirection().y;
422 TFLOAT fLightDirZ = -a_pRenderPacket->GetLightDirection().z;
423 TVector4 vLightColour = a_pRenderPacket->GetLightColour();
424
425 TVector4 vAmbientColour = a_pRenderPacket->GetAmbientColour();
426 vAmbientColour.w = a_pRenderPacket->GetAlpha();
427
428 TMatrix44 oModelView = a_pRenderPacket->GetModelViewMatrix();
429 TMatrix44 oWorldModelView;
430
431 for ( TINT i = 0; i < 4; i++ )
432 {
433 oWorldModelView.AsBasisVector4( i ).x = oModelView.m_f11 * sm_oWorldViewMatrix.AsBasisVector3( i ).x + oModelView.m_f12 * sm_oWorldViewMatrix.AsBasisVector3( i ).y + oModelView.m_f13 * sm_oWorldViewMatrix.AsBasisVector3( i ).z;
434 oWorldModelView.AsBasisVector4( i ).y = oModelView.m_f21 * sm_oWorldViewMatrix.AsBasisVector3( i ).x + oModelView.m_f22 * sm_oWorldViewMatrix.AsBasisVector3( i ).y + oModelView.m_f23 * sm_oWorldViewMatrix.AsBasisVector3( i ).z;
435 oWorldModelView.AsBasisVector4( i ).z = oModelView.m_f31 * sm_oWorldViewMatrix.AsBasisVector3( i ).x + oModelView.m_f32 * sm_oWorldViewMatrix.AsBasisVector3( i ).y + oModelView.m_f33 * sm_oWorldViewMatrix.AsBasisVector3( i ).z;
436 oWorldModelView.AsBasisVector4( i ).w = oModelView.m_f14 * sm_oWorldViewMatrix.AsBasisVector3( i ).x + oModelView.m_f24 * sm_oWorldViewMatrix.AsBasisVector3( i ).y + oModelView.m_f34 * sm_oWorldViewMatrix.AsBasisVector3( i ).z;
437 }
438
439 Toshi::TVector3 vLightDirWorld;
440 vLightDirWorld.x = oWorldModelView.m_f11 * fLightDirX + oWorldModelView.m_f21 * fLightDirY + oWorldModelView.m_f31 * fLightDirZ;
441 vLightDirWorld.y = oWorldModelView.m_f12 * fLightDirX + oWorldModelView.m_f22 * fLightDirY + oWorldModelView.m_f32 * fLightDirZ;
442 vLightDirWorld.z = oWorldModelView.m_f13 * fLightDirX + oWorldModelView.m_f23 * fLightDirY + oWorldModelView.m_f33 * fLightDirZ;
443 vLightDirWorld.Normalize();
444
445 TVector4 vUnkVector = TVector4( 1.0f, 0.0f, 0.0f, 1.0f );
446
447 pD3DDevice->SetVertexShaderConstant( 89, &vLightDirWorld, 1 );
448 pD3DDevice->SetVertexShaderConstant( 90, &vAmbientColour, 1 );
449 pD3DDevice->SetVertexShaderConstant( 91, &vLightColour, 1 );
450 pD3DDevice->SetVertexShaderConstant( 93, &vUnkVector, 1 );
451
452 TINT iAlpha = TINT( a_pRenderPacket->GetAlpha() * 128.0f );
453 if ( m_iAlphaRef < iAlpha ) iAlpha = m_iAlphaRef;
454 pD3DDevice->SetRenderState( D3DRS_ALPHAREF, iAlpha );
455
456 if ( pMaterial->GetBlendMode() != 0 || a_pRenderPacket->GetAlpha() < 1.0f )
457 {
458 if ( ISZERO( sm_eRenderStateFlags & 0x1b ) )
459 {
460 pD3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
461 sm_eRenderStateFlags |= 0x1b;
462 }
463 }
464 else if ( !ISZERO( sm_eRenderStateFlags & 0x1b ) )
465 {
466 pD3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
467 sm_eRenderStateFlags &= ~0x1b;
468 }
469
470 auto pVertexPool = TSTATICCAST( TVertexPoolResource, pMesh->GetVertexPool() );
471
472 TVertexBlockResource::HALBuffer vertexHALBuffer;
473 pVertexPool->GetHALBuffer( &vertexHALBuffer );
474 pD3DDevice->SetStreamSource( 0, vertexHALBuffer.apVertexBuffers[ 0 ], 0x28 );
475
476 for ( TINT i = 0; i < pMesh->GetNumSubMeshes(); i++ )
477 {
478 auto pSubMesh = pMesh->GetSubMesh( i );
479
480 TINT iCurrentRegister = VERTEX_SHADER_REGISTER_BONES;
481
482 for ( TUINT k = 0; k < pSubMesh->uiNumBones; k++ )
483 {
484 auto pBone = &pSkeletonInstance->GetBone( pSubMesh->aBones[ k ] );
485
486 TMatrix44 oBoneTransform;
487 D3DXMatrixTranspose( oBoneTransform, pBone->m_Transform );
488 pD3DDevice->SetVertexShaderConstant( iCurrentRegister, oBoneTransform, 3 );
489
490 iCurrentRegister += 3;
491 }
492
493 auto pIndexPool = TSTATICCAST( TIndexPoolResource, pSubMesh->pIndexPool );
494 TVALIDPTR( pIndexPool );
495
496 TIndexBlockResource::HALBuffer indexHALBuffer;
497 pIndexPool->GetHALBuffer( &indexHALBuffer );
498
499 pD3DDevice->SetIndices( indexHALBuffer.pIndexBuffer, vertexHALBuffer.uiVertexOffset );
500 pD3DDevice->DrawIndexedPrimitive(
501 D3DPT_TRIANGLESTRIP,
502 0,
503 pVertexPool->GetNumVertices(),
504 indexHALBuffer.uiIndexOffset,
505 pIndexPool->GetNumIndices()
506 );
507 }
508 }
509 }
510 else
511 {
512 RenderLowEnd( a_pRenderPacket );
513 }
514}
#define TSTATICCAST(POINTERTYPE, VALUE)
Definition Defines.h:69
#define ISZERO(X)
Definition Defines.h:3
unsigned int TUINT
Definition Typedefs.h:8
float TFLOAT
Definition Typedefs.h:4
int TINT
Definition Typedefs.h:7
#define USE_ONE_TEXTURE_LIGHTING
#define VERTEX_SHADER_REGISTER_MVP
#define VERTEX_SHADER_REGISTER_BONES
TFLOAT m_f21
Definition TMatrix44.h:361
TFLOAT m_f12
Definition TMatrix44.h:360
TBOOL Invert(const TMatrix44 &a_rRight)
Definition TMatrix44.cpp:88
TFLOAT m_f32
Definition TMatrix44.h:362
TFLOAT m_f13
Definition TMatrix44.h:360
TFLOAT m_f14
Definition TMatrix44.h:360
TFLOAT m_f11
Definition TMatrix44.h:360
TFLOAT m_f23
Definition TMatrix44.h:361
TFLOAT m_f22
Definition TMatrix44.h:361
TFLOAT m_f31
Definition TMatrix44.h:362
TFLOAT m_f24
Definition TMatrix44.h:361
const TVector4 & AsBasisVector4(BASISVECTOR a_iIndex) const
Definition TMatrix44.h:131
TFLOAT m_f34
Definition TMatrix44.h:362
TFLOAT m_f33
Definition TMatrix44.h:362
TFLOAT w
Definition TVector4.h:367
TFLOAT x
Definition TVector4.h:367
TFLOAT y
Definition TVector4.h:367
constexpr void Negate3(const TVector4 &vec)
Definition TVector4.h:265
TFLOAT z
Definition TVector4.h:367
IDirect3DTexture8 * GetD3DTexture()
IDirect3DVertexBuffer8 * apVertexBuffers[TVertexFactoryFormat::MAX_NUM_STREAMS]
static Toshi::TMatrix44 sm_oWorldViewMatrix
static TUINT sm_eRenderStateFlags

◆ SetAlphaBlendMaterial()

void ASkinShaderHAL::SetAlphaBlendMaterial ( TBOOL a_bIsAlphaBlendMaterial)
overridevirtual

Reimplemented from ASkinShader.

Definition at line 569 of file ASkinShader_DX8.cpp.

570{
571 m_bIsAlphaBlendMaterial = a_bIsAlphaBlendMaterial;
572}

◆ SetAlphaRef()

void ASkinShaderHAL::SetAlphaRef ( TINT a_iAlphaRef)

Definition at line 649 of file ASkinShader_DX8.cpp.

650{
651 auto pRender = TRenderD3DInterface::Interface();
652 auto pD3DDevice = pRender->GetDirect3DDevice();
653
654 pD3DDevice->SetRenderState( D3DRS_ALPHAREF, 1 );
655 m_iAlphaRef = a_iAlphaRef;
656}

◆ SetLight()

void ASkinShaderHAL::SetLight ( TINT a_iIndex,
const Toshi::TVector3 & a_rPosition,
TFLOAT a_fIntensity )
overridevirtual

Implements ASkinShader.

Definition at line 612 of file ASkinShader_DX8.cpp.

613{
614 TASSERT( !"Not implemeted in the original game" );
615}

◆ SetLightScattering()

void ASkinShaderHAL::SetLightScattering ( TBOOL a_bEnable)
overridevirtual

Reimplemented from ASkinShader.

Definition at line 560 of file ASkinShader_DX8.cpp.

561{
562}

◆ SetSomeColour()

void ASkinShaderHAL::SetSomeColour ( TUINT a_uiR,
TUINT a_uiG,
TUINT a_uiB,
TUINT a_uiA )
virtual

Definition at line 627 of file ASkinShader_DX8.cpp.

628{
629 m_SomeColour = ( ( a_uiA << 8 | a_uiB ) << 8 | a_uiG ) << 8 | a_uiR;
630}
TINT32 m_SomeColour
Definition ASkinShader.h:44

◆ SetUnknown1()

TINT ASkinShaderHAL::SetUnknown1 ( TINT a_Unknown,
TUINT8 a_fAlpha )
virtual

Definition at line 632 of file ASkinShader_DX8.cpp.

633{
634 if ( m_SomeColourComponents[ 1 ] < 2 )
635 m_Unk3 = a_fAlpha * ( 1.0f / 128.0f );
636 else if ( m_SomeColourComponents[ 0 ] == 0 )
637 m_Unk3 = 1.0f;
638 else
639 m_Unk3 = 0.0f;
640
641 return m_Unk2;
642}
TUINT8 m_SomeColourComponents[8]
Definition ASkinShader.h:43
TFLOAT m_Unk3
Definition ASkinShader.h:47

◆ SetUnknown2()

void ASkinShaderHAL::SetUnknown2 ( TINT a_Unknown)
virtual

Definition at line 644 of file ASkinShader_DX8.cpp.

645{
646 m_Unk2 = a_Unknown;
647}

◆ StartFlush()

void ASkinShaderHAL::StartFlush ( )
overridevirtual

Definition at line 81 of file ASkinShader_DX8.cpp.

82{
83 auto pRenderInterface = TRenderD3DInterface::Interface();
84 auto pCurrentContext = TRenderContextD3D::Upcast( pRenderInterface->GetCurrentContext() );
85 auto pDevice = pRenderInterface->GetDirect3DDevice();
86
87 if ( IsValidated() )
88 {
89 pDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU, 1 );
90 pDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV, 1 );
91
92 if ( IsHighEndSkinning() )
93 {
94 pDevice->SetRenderState( D3DRS_ALPHATESTENABLE, 1 );
95 pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, 1 );
96 pDevice->SetRenderState( D3DRS_ALPHAFUNC, 5 );
97
98 DWORD bWasSpecularEnabled;
99 pDevice->GetRenderState( D3DRS_SPECULARENABLE, &bWasSpecularEnabled );
100 pDevice->SetRenderState( D3DRS_SPECULARENABLE, 0 );
101
102 pDevice->SetTextureStageState( 0, D3DTSS_COLOROP, 4 );
103 pDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, 2 );
104 pDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, 0 );
105 pDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, 4 );
106 pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, 2 );
107 pDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, 0 );
108 pDevice->SetTextureStageState( 1, D3DTSS_COLOROP, 1 );
109 pDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, 1 );
110 pDevice->SetRenderState( D3DRS_CULLMODE, m_bRenderEnvMap ? 3 : 2 );
111 }
112 else
113 {
114 SetupLowEndMode();
115 return;
116 }
117 }
118}

◆ TDECLARE_CLASS()

ASkinShaderHAL::TDECLARE_CLASS ( ASkinShaderHAL ,
ASkinShader  )

◆ TryInvalidate()

TBOOL ASkinShaderHAL::TryInvalidate ( )
overridevirtual

Definition at line 242 of file ASkinShader_DX8.cpp.

243{
244 Invalidate();
245 return TTRUE;
246}
virtual void Invalidate() override

◆ TryValidate()

TBOOL ASkinShaderHAL::TryValidate ( )
overridevirtual

Definition at line 248 of file ASkinShader_DX8.cpp.

249{
250 Validate();
251 return TTRUE;
252}

◆ Validate()

TBOOL ASkinShaderHAL::Validate ( )
overridevirtual

Definition at line 148 of file ASkinShader_DX8.cpp.

149{
150 if ( IsValidated() )
151 return TTRUE;
152
154
155 if ( IsHighEndSkinning() )
156 {
157 // High end mode
158
159 constexpr static TUINT8 s_VertexShaderFunction[] = { 0x01, 0x01, 0xfe, 0xff, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x04, 0x00, 0xe4, 0xa0, 0x03, 0x00, 0xe4, 0x90, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00, 0x00, 0x80, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0f, 0x80, 0x05, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0x00, 0x90, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0f, 0x80, 0x06, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0x00, 0x90, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0f, 0x80, 0x07, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00, 0x55, 0x80, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0f, 0x80, 0x05, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0x55, 0x90, 0x03, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0f, 0x80, 0x06, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0x55, 0x90, 0x04, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0f, 0x80, 0x07, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0x55, 0x90, 0x05, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00, 0xaa, 0x80, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0f, 0x80, 0x05, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0xaa, 0x90, 0x03, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0f, 0x80, 0x06, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0xaa, 0x90, 0x04, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0f, 0x80, 0x07, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0xaa, 0x90, 0x05, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00, 0xff, 0x80, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0f, 0x80, 0x05, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0xff, 0x90, 0x03, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0f, 0x80, 0x06, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0xff, 0x90, 0x04, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0f, 0x80, 0x07, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0xff, 0x90, 0x05, 0x00, 0xe4, 0x80, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x80, 0x03, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x90, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01, 0x80, 0x03, 0x00, 0xe4, 0x80, 0x01, 0x00, 0xe4, 0x90, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x80, 0x04, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x90, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x02, 0x80, 0x04, 0x00, 0xe4, 0x80, 0x01, 0x00, 0xe4, 0x90, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x04, 0x80, 0x05, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x90, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x04, 0x80, 0x05, 0x00, 0xe4, 0x80, 0x01, 0x00, 0xe4, 0x90, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x80, 0x02, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x80, 0x14, 0x00, 0x00, 0x00, 0x07, 0x00, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x07, 0x00, 0xe4, 0x80, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x80, 0x02, 0x00, 0x54, 0x80, 0x5f, 0x00, 0x54, 0xa0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0xaa, 0x80, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x80, 0x02, 0x00, 0x54, 0x80, 0x5f, 0x00, 0xfe, 0xa0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x00, 0x00, 0x55, 0x80, 0x00, 0x00, 0xaa, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x06, 0x00, 0xe4, 0x80, 0x59, 0x00, 0xe4, 0xa1, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x80, 0x5d, 0x00, 0xaa, 0xa0, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x80, 0x02, 0x00, 0x00, 0x80, 0x5d, 0x00, 0xff, 0xa0, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x02, 0x00, 0x00, 0x80, 0x5b, 0x00, 0xa4, 0xa0, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x80, 0x02, 0x00, 0xff, 0x80, 0x02, 0x00, 0x00, 0x81, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x02, 0x00, 0x00, 0x80, 0x5a, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xd0, 0x00, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xd0, 0x5a, 0x00, 0xff, 0xa0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x04, 0x00, 0xe4, 0x90, 0xff, 0xff, 0x00, 0x00 };
160 constexpr static TUINT8 s_VertexHDShaderFunction[] = { 0x01, 0x01, 0xfe, 0xff, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x04, 0x00, 0xe4, 0xa0, 0x03, 0x00, 0xe4, 0x90, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00, 0x00, 0x80, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0f, 0x80, 0x05, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0x00, 0x90, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0f, 0x80, 0x06, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0x00, 0x90, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0f, 0x80, 0x07, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00, 0x55, 0x80, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0f, 0x80, 0x05, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0x55, 0x90, 0x03, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0f, 0x80, 0x06, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0x55, 0x90, 0x04, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0f, 0x80, 0x07, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0x55, 0x90, 0x05, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00, 0xaa, 0x80, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0f, 0x80, 0x05, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0xaa, 0x90, 0x03, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0f, 0x80, 0x06, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0xaa, 0x90, 0x04, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0f, 0x80, 0x07, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0xaa, 0x90, 0x05, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xb0, 0x00, 0x00, 0xff, 0x80, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0f, 0x80, 0x05, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0xff, 0x90, 0x03, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0f, 0x80, 0x06, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0xff, 0x90, 0x04, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x0f, 0x80, 0x07, 0x20, 0xe4, 0xa0, 0x02, 0x00, 0xff, 0x90, 0x05, 0x00, 0xe4, 0x80, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x80, 0x03, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x90, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x01, 0x80, 0x03, 0x00, 0xe4, 0x80, 0x01, 0x00, 0xe4, 0x90, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x80, 0x04, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x90, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x02, 0x80, 0x04, 0x00, 0xe4, 0x80, 0x01, 0x00, 0xe4, 0x90, 0x09, 0x00, 0x00, 0x00, 0x02, 0x00, 0x04, 0x80, 0x05, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x90, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x04, 0x80, 0x05, 0x00, 0xe4, 0x80, 0x01, 0x00, 0xe4, 0x90, 0x0d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x80, 0x02, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0x80, 0x14, 0x00, 0x00, 0x00, 0x07, 0x00, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x07, 0x00, 0xe4, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x06, 0x00, 0xe4, 0x80, 0x59, 0x00, 0xe4, 0xa1, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x06, 0x00, 0xe4, 0x80, 0x5e, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xd0, 0x5a, 0x00, 0xff, 0xa0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x04, 0x00, 0xe4, 0x90, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x54, 0x80, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x54, 0x80, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x54, 0x80, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x54, 0x80, 0xff, 0xff, 0x00, 0x00 };
161
162 if ( CreateSkinVertexShader( "ASkinShader_D3D8_Win.vsh", (DWORD*)s_VertexShaderFunction, &m_hVertexShader ) &&
163 CreateSkinVertexShader( "ASkinShader_D3D8_Win.vsh", (DWORD*)s_VertexHDShaderFunction, &m_hVertexShaderHD ) )
164 {
165 constexpr static TUINT8 s_PixelShaderFunction[] = { 0x04, 0x01, 0xff, 0xff, 0xfd, 0xff, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xb0, 0x42, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0xb0, 0x42, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0xb0, 0x42, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0f, 0x80, 0x03, 0x00, 0xe4, 0xb0, 0x42, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0f, 0x80, 0x04, 0x00, 0xe4, 0xb0, 0x12, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0xe4, 0x80, 0x03, 0x00, 0xe4, 0x80, 0x12, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x02, 0x00, 0xe4, 0x80, 0x04, 0x00, 0xe4, 0x80, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x01, 0x00, 0xe4, 0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, 0xe4, 0x80, 0x05, 0x00, 0x00, 0x40, 0x00, 0x00, 0x08, 0x80, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0xff, 0x90, 0xff, 0xff, 0x00, 0x00 };
166 constexpr static TUINT8 s_PixelShaderFunctionLowEnd[] = { 0x01, 0x01, 0xff, 0xff, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xb0, 0x42, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0xb0, 0x42, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0f, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x80, 0x01, 0x00, 0xe4, 0xb1, 0x00, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0xe4, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x80, 0x01, 0x00, 0xe4, 0xa0, 0x02, 0x00, 0xe4, 0xb0, 0x00, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x08, 0x80, 0x00, 0x00, 0xff, 0xb0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
167
168 auto pRenderInterface = TRenderD3DInterface::Interface();
169 auto pD3DDevice = pRenderInterface->GetDirect3DDevice();
170 auto pDevice = TSTATICCAST( TD3DAdapter::Mode::Device, pRenderInterface->GetCurrentDevice() );
171
172 if ( pDevice->GetD3DCaps().PixelShaderVersion < 0xffff0104 )
173 {
174 TRenderD3DInterface::CreatePixelShader( (DWORD*)s_PixelShaderFunctionLowEnd, &m_hPixelShader );
175 }
176 else
177 {
178 TRenderD3DInterface::CreatePixelShader( (DWORD*)s_PixelShaderFunction, &m_hPixelShader );
179 }
180
181 ApplyGPUSpecificPatches();
182 CheckCPUFeature1();
183 CheckCPUFeature2();
184
185 return BaseClass::Validate();
186 }
187 else
188 {
189 return TFALSE;
190 }
191 }
192 else
193 {
194 // Low end mode
195
196 ApplyGPUSpecificPatches();
197 CheckCPUFeature1();
198 CheckCPUFeature2();
199
200 return BaseClass::Validate();
201 }
202}
uint8_t TUINT8
Definition Typedefs.h:17
static TBOOL CreatePixelShader(const DWORD *a_pFunction, DWORD *a_pOutPixelShader)
Creates a pixel shader.
virtual void EnableHighEndSkinning(TBOOL a_bEnable) override

Member Data Documentation

◆ NUM_ORDER_TABLES

TUINT ASkinShaderHAL::NUM_ORDER_TABLES = 3
staticconstexpr

Definition at line 16 of file ASkinShader_DX8.h.

◆ sm_eRenderStateFlags

TUINT ASkinShaderHAL::sm_eRenderStateFlags = 27
inlinestatic

Definition at line 76 of file ASkinShader_DX8.h.

◆ sm_oViewModelMatrix

Toshi::TMatrix44 ASkinShaderHAL::sm_oViewModelMatrix
inlinestatic

Definition at line 78 of file ASkinShader_DX8.h.

◆ sm_oWorldViewMatrix

Toshi::TMatrix44 ASkinShaderHAL::sm_oWorldViewMatrix
inlinestatic

Definition at line 77 of file ASkinShader_DX8.h.


The documentation for this class was generated from the following files: