mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-08 11:38:08 +03:00
Added animated textures; Refactored screen width and height;
This commit is contained in:
parent
dd81bcb1b2
commit
dc196ca3d2
15 changed files with 263 additions and 61 deletions
|
@ -135,6 +135,8 @@ VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
|
||||||
|
|
||||||
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
||||||
{
|
{
|
||||||
|
int modelType = round(tex2D(NormalSampler, input.TextureCoordinate).w * 16.0f);
|
||||||
|
|
||||||
float3 diffuseColor = tex2D(ColorSampler, input.TextureCoordinate).rgb;
|
float3 diffuseColor = tex2D(ColorSampler, input.TextureCoordinate).rgb;
|
||||||
float3 ambientColor = tex2D(VertexColorSampler, input.TextureCoordinate).rgb;
|
float3 ambientColor = tex2D(VertexColorSampler, input.TextureCoordinate).rgb;
|
||||||
float4 light = tex2D(LightSampler, input.TextureCoordinate);
|
float4 light = tex2D(LightSampler, input.TextureCoordinate);
|
||||||
|
@ -145,7 +147,6 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
||||||
bool underwater = ((pixelFlags / 32) == 1);
|
bool underwater = ((pixelFlags / 32) == 1);
|
||||||
if (pixelFlags >= 32) pixelFlags -= 32;
|
if (pixelFlags >= 32) pixelFlags -= 32;
|
||||||
int modelType = pixelFlags;*/
|
int modelType = pixelFlags;*/
|
||||||
int modelType = round(tex2D(NormalSampler, input.TextureCoordinate).w * 16.0f);
|
|
||||||
//if (underwater)
|
//if (underwater)
|
||||||
// return float4(0, 0, 1, 1);
|
// return float4(0, 0, 1, 1);
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ PixelShaderOutput PixelShaderFunction(VertexShaderOutput input)
|
||||||
float3 yaxis = tex2D(CausticsSampler, p.xz).rgb;
|
float3 yaxis = tex2D(CausticsSampler, p.xz).rgb;
|
||||||
float3 zaxis = tex2D(CausticsSampler, p.xy).rgb;
|
float3 zaxis = tex2D(CausticsSampler, p.xy).rgb;
|
||||||
|
|
||||||
vertexColors += float4((xaxis * blending.x + yaxis * blending.y + zaxis * blending.z).xyz, 0.0f) * attenuation;
|
vertexColors += float4((xaxis * blending.x + yaxis * blending.y + zaxis * blending.z).xyz, 0.0f) * attenuation * 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ModelType == MODELTYPE_ROOM || ModelType == MODELTYPE_ROOM_UNDERWATER)
|
if (ModelType == MODELTYPE_ROOM || ModelType == MODELTYPE_ROOM_UNDERWATER)
|
||||||
|
|
|
@ -55,8 +55,8 @@ float4x4 LightProjection;
|
||||||
|
|
||||||
bool AmbientPass;
|
bool AmbientPass;
|
||||||
|
|
||||||
float HalfPixelX = 1.0f / 800.0f;
|
float HalfPixelX;
|
||||||
float HalfPixelY = 1.0f / 600.0f;
|
float HalfPixelY;
|
||||||
|
|
||||||
texture2D ColorMap;
|
texture2D ColorMap;
|
||||||
sampler ColorSampler = sampler_state
|
sampler ColorSampler = sampler_state
|
||||||
|
@ -152,7 +152,7 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
||||||
{
|
{
|
||||||
input.ScreenPosition.xy /= input.ScreenPosition.w;
|
input.ScreenPosition.xy /= input.ScreenPosition.w;
|
||||||
texCoord = 0.5f * (float2(input.ScreenPosition.x, -input.ScreenPosition.y) + 1);
|
texCoord = 0.5f * (float2(input.ScreenPosition.x, -input.ScreenPosition.y) + 1);
|
||||||
texCoord -= float2(0.5f / 800.0f, 0.5f / 600.0f);
|
texCoord -= float2(HalfPixelX, HalfPixelY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the normal and transform back to -1 ... 1
|
// Get the normal and transform back to -1 ... 1
|
||||||
|
|
|
@ -236,6 +236,8 @@
|
||||||
|
|
||||||
#define HealtBarTimer VAR_U_(0x0051CEA8, __int32)
|
#define HealtBarTimer VAR_U_(0x0051CEA8, __int32)
|
||||||
|
|
||||||
|
#define AnimatedTextureRanges VAR_U_(0x00D9ADA0, __int16*)
|
||||||
|
|
||||||
extern bool MonksAttackLara;
|
extern bool MonksAttackLara;
|
||||||
|
|
||||||
// Remapped variables
|
// Remapped variables
|
||||||
|
|
|
@ -63,6 +63,11 @@ typedef enum RENDERER_SPRITE_TYPE {
|
||||||
SPRITE_TYPE_3D
|
SPRITE_TYPE_3D
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum RENDERER_POLYGON_SHAPE {
|
||||||
|
RENDERER_POLYGON_QUAD,
|
||||||
|
RENDERER_POLYGON_TRIANGLE
|
||||||
|
};
|
||||||
|
|
||||||
#define SHADOW_MAP_SIZE 2048
|
#define SHADOW_MAP_SIZE 2048
|
||||||
|
|
||||||
#define TEXTURE_ATLAS_SIZE 4096
|
#define TEXTURE_ATLAS_SIZE 4096
|
||||||
|
@ -98,9 +103,9 @@ typedef enum RENDERER_SPRITE_TYPE {
|
||||||
#define SNOW_MAX_ANGLE_H 360
|
#define SNOW_MAX_ANGLE_H 360
|
||||||
#define SNOW_DELTA_Y 128.0f
|
#define SNOW_DELTA_Y 128.0f
|
||||||
|
|
||||||
#define NUM_UNDERWATER_DUST_PARTICLES 128
|
#define NUM_UNDERWATER_DUST_PARTICLES 512
|
||||||
#define UNDERWATER_DUST_PARTICLES_SIZE 48.0f
|
#define UNDERWATER_DUST_PARTICLES_SIZE 32.0f
|
||||||
#define UNDERWATER_DUST_PARTICLES_RADIUS (8 * 1024)
|
#define UNDERWATER_DUST_PARTICLES_RADIUS (10 * 1024)
|
||||||
|
|
||||||
#define NUM_SPRITES_PER_BUCKET 4096
|
#define NUM_SPRITES_PER_BUCKET 4096
|
||||||
#define NUM_LINES_PER_BUCKET 4096
|
#define NUM_LINES_PER_BUCKET 4096
|
||||||
|
|
|
@ -853,6 +853,42 @@ RendererMesh* Renderer::GetRendererMeshFromTrMesh(RendererObject* obj, __int16*
|
||||||
|
|
||||||
bool Renderer::PrepareDataForTheRenderer()
|
bool Renderer::PrepareDataForTheRenderer()
|
||||||
{
|
{
|
||||||
|
// Step -1 XD: prepare animated textures
|
||||||
|
__int16 numSets = *AnimatedTextureRanges;
|
||||||
|
__int16* animatedPtr = AnimatedTextureRanges;
|
||||||
|
animatedPtr++;
|
||||||
|
|
||||||
|
for (__int32 i = 0; i < numSets; i++)
|
||||||
|
{
|
||||||
|
RendererAnimatedTextureSet* set = new RendererAnimatedTextureSet();
|
||||||
|
__int16 numTextures = *animatedPtr + 1;
|
||||||
|
animatedPtr++;
|
||||||
|
|
||||||
|
for (__int32 j = 0; j < numTextures; j++)
|
||||||
|
{
|
||||||
|
__int16 textureId = *animatedPtr;
|
||||||
|
animatedPtr++;
|
||||||
|
|
||||||
|
OBJECT_TEXTURE* texture = &ObjectTextures[textureId];
|
||||||
|
__int32 tile = texture->tileAndFlag & 0x7FFF;
|
||||||
|
|
||||||
|
RendererAnimatedTexture* newTexture = new RendererAnimatedTexture();
|
||||||
|
newTexture->Id = textureId;
|
||||||
|
|
||||||
|
for (__int32 k = 0; k < 4; k++)
|
||||||
|
{
|
||||||
|
float x = (texture->vertices[k].x * 256.0f + 0.5f + GET_ATLAS_PAGE_X(tile)) / (float)TEXTURE_ATLAS_SIZE;
|
||||||
|
float y = (texture->vertices[k].y * 256.0f + 0.5f + GET_ATLAS_PAGE_Y(tile)) / (float)TEXTURE_ATLAS_SIZE;
|
||||||
|
|
||||||
|
newTexture->UV[k] = D3DXVECTOR2(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
set->Textures.push_back(newTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_animatedTextureSets.push_back(set);
|
||||||
|
}
|
||||||
|
|
||||||
// Step 0: free all previus resources
|
// Step 0: free all previus resources
|
||||||
for (map<__int32, RendererRoom*>::iterator it = m_rooms.begin(); it != m_rooms.end(); ++it)
|
for (map<__int32, RendererRoom*>::iterator it = m_rooms.begin(); it != m_rooms.end(); ++it)
|
||||||
delete (it->second);
|
delete (it->second);
|
||||||
|
@ -1005,7 +1041,10 @@ bool Renderer::PrepareDataForTheRenderer()
|
||||||
|
|
||||||
// Create vertices
|
// Create vertices
|
||||||
RendererBucket* bucket;
|
RendererBucket* bucket;
|
||||||
|
|
||||||
|
__int32 animatedSetIndex = getAnimatedTextureInfo(textureIndex);
|
||||||
__int32 bucketIndex = RENDERER_BUCKET_SOLID;
|
__int32 bucketIndex = RENDERER_BUCKET_SOLID;
|
||||||
|
|
||||||
if (!doubleSided)
|
if (!doubleSided)
|
||||||
{
|
{
|
||||||
if (texture->attribute == 2)
|
if (texture->attribute == 2)
|
||||||
|
@ -1024,8 +1063,17 @@ bool Renderer::PrepareDataForTheRenderer()
|
||||||
else
|
else
|
||||||
bucketIndex = RENDERER_BUCKET_ALPHA_TEST_DS;
|
bucketIndex = RENDERER_BUCKET_ALPHA_TEST_DS;
|
||||||
}
|
}
|
||||||
bucket = mesh->GetBucket(bucketIndex);
|
|
||||||
roomObject->HasDataInBucket[bucketIndex] = true;
|
if (animatedSetIndex == -1)
|
||||||
|
{
|
||||||
|
bucket = mesh->GetBucket(bucketIndex);
|
||||||
|
roomObject->HasDataInBucket[bucketIndex] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bucket = mesh->GetAnimatedBucket(bucketIndex);
|
||||||
|
roomObject->HasDataInAnimatedBucket[bucketIndex] = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate face normal
|
// Calculate face normal
|
||||||
D3DXVECTOR3 p0 = D3DXVECTOR3(vertices[poly->Vertices[0]].Vertex.x,
|
D3DXVECTOR3 p0 = D3DXVECTOR3(vertices[poly->Vertices[0]].Vertex.x,
|
||||||
|
@ -1079,6 +1127,8 @@ bool Renderer::PrepareDataForTheRenderer()
|
||||||
|
|
||||||
RendererPolygon newPolygon;
|
RendererPolygon newPolygon;
|
||||||
newPolygon.Shape = SHAPE_RECTANGLE;
|
newPolygon.Shape = SHAPE_RECTANGLE;
|
||||||
|
newPolygon.AnimatedSet = animatedSetIndex;
|
||||||
|
newPolygon.TextureId = textureIndex;
|
||||||
newPolygon.Indices[0] = baseVertices;
|
newPolygon.Indices[0] = baseVertices;
|
||||||
newPolygon.Indices[1] = baseVertices + 1;
|
newPolygon.Indices[1] = baseVertices + 1;
|
||||||
newPolygon.Indices[2] = baseVertices + 2;
|
newPolygon.Indices[2] = baseVertices + 2;
|
||||||
|
@ -1105,7 +1155,10 @@ bool Renderer::PrepareDataForTheRenderer()
|
||||||
|
|
||||||
// Create vertices
|
// Create vertices
|
||||||
RendererBucket* bucket;
|
RendererBucket* bucket;
|
||||||
|
|
||||||
|
__int32 animatedSetIndex = getAnimatedTextureInfo(textureIndex);
|
||||||
__int32 bucketIndex = RENDERER_BUCKET_SOLID;
|
__int32 bucketIndex = RENDERER_BUCKET_SOLID;
|
||||||
|
|
||||||
if (!doubleSided)
|
if (!doubleSided)
|
||||||
{
|
{
|
||||||
if (texture->attribute == 2)
|
if (texture->attribute == 2)
|
||||||
|
@ -1124,8 +1177,17 @@ bool Renderer::PrepareDataForTheRenderer()
|
||||||
else
|
else
|
||||||
bucketIndex = RENDERER_BUCKET_ALPHA_TEST_DS;
|
bucketIndex = RENDERER_BUCKET_ALPHA_TEST_DS;
|
||||||
}
|
}
|
||||||
bucket = mesh->GetBucket(bucketIndex);
|
|
||||||
roomObject->HasDataInBucket[bucketIndex] = true;
|
if (animatedSetIndex == -1)
|
||||||
|
{
|
||||||
|
bucket = mesh->GetBucket(bucketIndex);
|
||||||
|
roomObject->HasDataInBucket[bucketIndex] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bucket = mesh->GetAnimatedBucket(bucketIndex);
|
||||||
|
roomObject->HasDataInAnimatedBucket[bucketIndex] = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate face normal
|
// Calculate face normal
|
||||||
D3DXVECTOR3 p0 = D3DXVECTOR3(vertices[poly->Vertices[0]].Vertex.x,
|
D3DXVECTOR3 p0 = D3DXVECTOR3(vertices[poly->Vertices[0]].Vertex.x,
|
||||||
|
@ -1176,6 +1238,8 @@ bool Renderer::PrepareDataForTheRenderer()
|
||||||
|
|
||||||
RendererPolygon newPolygon;
|
RendererPolygon newPolygon;
|
||||||
newPolygon.Shape = SHAPE_TRIANGLE;
|
newPolygon.Shape = SHAPE_TRIANGLE;
|
||||||
|
newPolygon.AnimatedSet = animatedSetIndex;
|
||||||
|
newPolygon.TextureId = textureIndex;
|
||||||
newPolygon.Indices[0] = baseVertices;
|
newPolygon.Indices[0] = baseVertices;
|
||||||
newPolygon.Indices[1] = baseVertices + 1;
|
newPolygon.Indices[1] = baseVertices + 1;
|
||||||
newPolygon.Indices[2] = baseVertices + 2;
|
newPolygon.Indices[2] = baseVertices + 2;
|
||||||
|
@ -2776,11 +2840,11 @@ void Renderer::DrawDebugInfo()
|
||||||
m_sprite->SetTransform(&scale);
|
m_sprite->SetTransform(&scale);
|
||||||
m_sprite->Draw(m_colorBuffer->GetTexture(), NULL, &D3DXVECTOR3(0, 0, 0), &D3DXVECTOR3(0, 0, 0), 0xFFFFFFFF);
|
m_sprite->Draw(m_colorBuffer->GetTexture(), NULL, &D3DXVECTOR3(0, 0, 0), &D3DXVECTOR3(0, 0, 0), 0xFFFFFFFF);
|
||||||
m_sprite->SetTransform(&scale);
|
m_sprite->SetTransform(&scale);
|
||||||
m_sprite->Draw(m_normalBuffer->GetTexture(), NULL, &D3DXVECTOR3(0, 0, 0), &D3DXVECTOR3(800, 0, 0), 0xFFFFFFFF);
|
m_sprite->Draw(m_normalBuffer->GetTexture(), NULL, &D3DXVECTOR3(0, 0, 0), &D3DXVECTOR3(1200, 0, 0), 0xFFFFFFFF);
|
||||||
m_sprite->SetTransform(&scale);
|
m_sprite->SetTransform(&scale);
|
||||||
m_sprite->Draw(m_vertexLightBuffer->GetTexture(), NULL, &D3DXVECTOR3(0, 0, 0), &D3DXVECTOR3(1600, 0, 0), 0xFFFFFFFF);
|
m_sprite->Draw(m_vertexLightBuffer->GetTexture(), NULL, &D3DXVECTOR3(0, 0, 0), &D3DXVECTOR3(2400, 0, 0), 0xFFFFFFFF);
|
||||||
m_sprite->SetTransform(&scale);
|
m_sprite->SetTransform(&scale);
|
||||||
m_sprite->Draw(m_lightBuffer->GetTexture(), NULL, &D3DXVECTOR3(0, 0, 0), &D3DXVECTOR3(2400, 0, 0), 0xFFFFFFFF);
|
m_sprite->Draw(m_lightBuffer->GetTexture(), NULL, &D3DXVECTOR3(0, 0, 0), &D3DXVECTOR3(3600, 0, 0), 0xFFFFFFFF);
|
||||||
|
|
||||||
m_sprite->End();
|
m_sprite->End();
|
||||||
|
|
||||||
|
@ -3513,7 +3577,7 @@ void Renderer::CollectSceneItems()
|
||||||
|
|
||||||
bool Renderer::DrawScene(RENDERER_PASSES pass)
|
bool Renderer::DrawScene(RENDERER_PASSES pass)
|
||||||
{
|
{
|
||||||
if (pass == RENDERER_PASSES::RENDERER_PASS_GBUFFER)
|
/*if (pass == RENDERER_PASSES::RENDERER_PASS_GBUFFER)
|
||||||
{
|
{
|
||||||
for (__int32 i = 0; i < m_roomsToDraw.size(); i++)
|
for (__int32 i = 0; i < m_roomsToDraw.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -3521,8 +3585,8 @@ bool Renderer::DrawScene(RENDERER_PASSES pass)
|
||||||
if (room == NULL)
|
if (room == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID, RENDERER_PASSES::RENDERER_PASS_GBUFFER);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID, RENDERER_PASSES::RENDERER_PASS_GBUFFER, false);
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID_DS, RENDERER_PASSES::RENDERER_PASS_GBUFFER);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID_DS, RENDERER_PASSES::RENDERER_PASS_GBUFFER, false);
|
||||||
|
|
||||||
// Draw static objects
|
// Draw static objects
|
||||||
ROOM_INFO* r = room->Room;
|
ROOM_INFO* r = room->Room;
|
||||||
|
@ -3560,8 +3624,8 @@ bool Renderer::DrawScene(RENDERER_PASSES pass)
|
||||||
if (room == NULL)
|
if (room == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_ALPHA_TEST, RENDERER_PASSES::RENDERER_PASS_GBUFFER);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_ALPHA_TEST, RENDERER_PASSES::RENDERER_PASS_GBUFFER, false);
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_ALPHA_TEST_DS, RENDERER_PASSES::RENDERER_PASS_GBUFFER);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_ALPHA_TEST_DS, RENDERER_PASSES::RENDERER_PASS_GBUFFER, false);
|
||||||
|
|
||||||
// Draw static objects
|
// Draw static objects
|
||||||
ROOM_INFO* r = room->Room;
|
ROOM_INFO* r = room->Room;
|
||||||
|
@ -3599,8 +3663,8 @@ bool Renderer::DrawScene(RENDERER_PASSES pass)
|
||||||
if (room == NULL)
|
if (room == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_TRANSPARENT, RENDERER_PASSES::RENDERER_PASS_TRANSPARENT);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_TRANSPARENT, RENDERER_PASSES::RENDERER_PASS_TRANSPARENT, false);
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_TRANSPARENT_DS, RENDERER_PASSES::RENDERER_PASS_TRANSPARENT);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_TRANSPARENT_DS, RENDERER_PASSES::RENDERER_PASS_TRANSPARENT, false);
|
||||||
|
|
||||||
// Draw static objects
|
// Draw static objects
|
||||||
ROOM_INFO* r = room->Room;
|
ROOM_INFO* r = room->Room;
|
||||||
|
@ -3630,7 +3694,7 @@ bool Renderer::DrawScene(RENDERER_PASSES pass)
|
||||||
|
|
||||||
DrawGunshells(RENDERER_BUCKETS::RENDERER_BUCKET_TRANSPARENT, RENDERER_PASSES::RENDERER_PASS_TRANSPARENT);
|
DrawGunshells(RENDERER_BUCKETS::RENDERER_BUCKET_TRANSPARENT, RENDERER_PASSES::RENDERER_PASS_TRANSPARENT);
|
||||||
DrawGunshells(RENDERER_BUCKETS::RENDERER_BUCKET_TRANSPARENT_DS, RENDERER_PASSES::RENDERER_PASS_TRANSPARENT);
|
DrawGunshells(RENDERER_BUCKETS::RENDERER_BUCKET_TRANSPARENT_DS, RENDERER_PASSES::RENDERER_PASS_TRANSPARENT);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3665,6 +3729,8 @@ bool Renderer::DrawSceneLightPrePass(bool dump)
|
||||||
CollectSceneItems();
|
CollectSceneItems();
|
||||||
UpdateLaraAnimations();
|
UpdateLaraAnimations();
|
||||||
UpdateItemsAnimations();
|
UpdateItemsAnimations();
|
||||||
|
if (GnFrameCounter % 2 == 0)
|
||||||
|
UpdateAnimatedTextures();
|
||||||
|
|
||||||
auto time2 = chrono::high_resolution_clock::now();
|
auto time2 = chrono::high_resolution_clock::now();
|
||||||
m_timeUpdate = (chrono::duration_cast<ns>(time2 - time1)).count();
|
m_timeUpdate = (chrono::duration_cast<ns>(time2 - time1)).count();
|
||||||
|
@ -3728,9 +3794,12 @@ bool Renderer::DrawSceneLightPrePass(bool dump)
|
||||||
if (room == NULL)
|
if (room == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID, RENDERER_PASSES::RENDERER_PASS_GBUFFER);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID, RENDERER_PASSES::RENDERER_PASS_GBUFFER, false);
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID_DS, RENDERER_PASSES::RENDERER_PASS_GBUFFER);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID, RENDERER_PASSES::RENDERER_PASS_GBUFFER, true);
|
||||||
|
|
||||||
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID_DS, RENDERER_PASSES::RENDERER_PASS_GBUFFER, false);
|
||||||
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID_DS, RENDERER_PASSES::RENDERER_PASS_GBUFFER, true);
|
||||||
|
|
||||||
// Draw static objects
|
// Draw static objects
|
||||||
ROOM_INFO* r = room->Room;
|
ROOM_INFO* r = room->Room;
|
||||||
if (r->numMeshes != 0)
|
if (r->numMeshes != 0)
|
||||||
|
@ -3767,9 +3836,12 @@ bool Renderer::DrawSceneLightPrePass(bool dump)
|
||||||
if (room == NULL)
|
if (room == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_ALPHA_TEST, RENDERER_PASSES::RENDERER_PASS_GBUFFER);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_ALPHA_TEST, RENDERER_PASSES::RENDERER_PASS_GBUFFER, false);
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_ALPHA_TEST_DS, RENDERER_PASSES::RENDERER_PASS_GBUFFER);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_ALPHA_TEST, RENDERER_PASSES::RENDERER_PASS_GBUFFER, true);
|
||||||
|
|
||||||
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_ALPHA_TEST_DS, RENDERER_PASSES::RENDERER_PASS_GBUFFER, false);
|
||||||
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_ALPHA_TEST_DS, RENDERER_PASSES::RENDERER_PASS_GBUFFER, true);
|
||||||
|
|
||||||
// Draw static objects
|
// Draw static objects
|
||||||
ROOM_INFO* r = room->Room;
|
ROOM_INFO* r = room->Room;
|
||||||
if (r->numMeshes != 0)
|
if (r->numMeshes != 0)
|
||||||
|
@ -3969,8 +4041,11 @@ bool Renderer::DrawSceneLightPrePass(bool dump)
|
||||||
if (room == NULL)
|
if (room == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID, RENDERER_PASSES::RENDERER_PASS_RECONSTRUCT_DEPTH);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID, RENDERER_PASSES::RENDERER_PASS_RECONSTRUCT_DEPTH, false);
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID_DS, RENDERER_PASSES::RENDERER_PASS_RECONSTRUCT_DEPTH);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID, RENDERER_PASSES::RENDERER_PASS_RECONSTRUCT_DEPTH, true);
|
||||||
|
|
||||||
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID_DS, RENDERER_PASSES::RENDERER_PASS_RECONSTRUCT_DEPTH, false);
|
||||||
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_SOLID_DS, RENDERER_PASSES::RENDERER_PASS_RECONSTRUCT_DEPTH, true);
|
||||||
|
|
||||||
// Draw static objects
|
// Draw static objects
|
||||||
ROOM_INFO* r = room->Room;
|
ROOM_INFO* r = room->Room;
|
||||||
|
@ -4004,8 +4079,8 @@ bool Renderer::DrawSceneLightPrePass(bool dump)
|
||||||
if (room == NULL)
|
if (room == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_ALPHA_TEST, RENDERER_PASSES::RENDERER_PASS_RECONSTRUCT_DEPTH);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_ALPHA_TEST, RENDERER_PASSES::RENDERER_PASS_RECONSTRUCT_DEPTH, false);
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_ALPHA_TEST_DS, RENDERER_PASSES::RENDERER_PASS_RECONSTRUCT_DEPTH);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_ALPHA_TEST_DS, RENDERER_PASSES::RENDERER_PASS_RECONSTRUCT_DEPTH, false);
|
||||||
|
|
||||||
// Draw static objects
|
// Draw static objects
|
||||||
ROOM_INFO* r = room->Room;
|
ROOM_INFO* r = room->Room;
|
||||||
|
@ -4053,8 +4128,11 @@ bool Renderer::DrawSceneLightPrePass(bool dump)
|
||||||
if (room == NULL)
|
if (room == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_TRANSPARENT, RENDERER_PASSES::RENDERER_PASS_TRANSPARENT);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_TRANSPARENT, RENDERER_PASSES::RENDERER_PASS_TRANSPARENT, false);
|
||||||
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_TRANSPARENT_DS, RENDERER_PASSES::RENDERER_PASS_TRANSPARENT);
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_TRANSPARENT, RENDERER_PASSES::RENDERER_PASS_TRANSPARENT, true);
|
||||||
|
|
||||||
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_TRANSPARENT_DS, RENDERER_PASSES::RENDERER_PASS_TRANSPARENT, false);
|
||||||
|
DrawRoomLPP(m_roomsToDraw[i], RENDERER_BUCKETS::RENDERER_BUCKET_TRANSPARENT_DS, RENDERER_PASSES::RENDERER_PASS_TRANSPARENT, true);
|
||||||
|
|
||||||
// Draw static objects
|
// Draw static objects
|
||||||
ROOM_INFO* r = room->Room;
|
ROOM_INFO* r = room->Room;
|
||||||
|
@ -4484,7 +4562,7 @@ bool Renderer::DrawItemLPP(RendererItemToDraw* itemToDraw, RENDERER_BUCKETS buck
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Renderer::DrawRoomLPP(__int32 roomIndex, RENDERER_BUCKETS bucketIndex, RENDERER_PASSES pass)
|
bool Renderer::DrawRoomLPP(__int32 roomIndex, RENDERER_BUCKETS bucketIndex, RENDERER_PASSES pass, bool animated)
|
||||||
{
|
{
|
||||||
D3DXMATRIX world;
|
D3DXMATRIX world;
|
||||||
UINT cPasses = 1;
|
UINT cPasses = 1;
|
||||||
|
@ -4493,16 +4571,14 @@ bool Renderer::DrawRoomLPP(__int32 roomIndex, RENDERER_BUCKETS bucketIndex, REND
|
||||||
ROOM_INFO* r = room->Room;
|
ROOM_INFO* r = room->Room;
|
||||||
RendererObject* roomObj = room->RoomObject;
|
RendererObject* roomObj = room->RoomObject;
|
||||||
|
|
||||||
if (!roomObj->HasDataInBucket[bucketIndex])
|
if ((!animated && !roomObj->HasDataInBucket[bucketIndex]) ||
|
||||||
|
(animated && !roomObj->HasDataInAnimatedBucket[bucketIndex]))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (roomObj->ObjectMeshes.size() == 0)
|
if (roomObj->ObjectMeshes.size() == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
RendererMesh* mesh = roomObj->ObjectMeshes[0];
|
RendererMesh* mesh = roomObj->ObjectMeshes[0];
|
||||||
RendererBucket* bucket = mesh->GetBucket(bucketIndex);
|
|
||||||
|
|
||||||
SetGpuStateForBucket(bucketIndex);
|
|
||||||
|
|
||||||
LPD3DXEFFECT effect;
|
LPD3DXEFFECT effect;
|
||||||
if (pass == RENDERER_PASSES::RENDERER_PASS_SHADOW_MAP)
|
if (pass == RENDERER_PASSES::RENDERER_PASS_SHADOW_MAP)
|
||||||
|
@ -4532,17 +4608,40 @@ bool Renderer::DrawRoomLPP(__int32 roomIndex, RENDERER_BUCKETS bucketIndex, REND
|
||||||
effect->SetInt(effect->GetParameterByName(NULL, "ModelType"), MODEL_TYPES::MODEL_TYPE_ROOM);
|
effect->SetInt(effect->GetParameterByName(NULL, "ModelType"), MODEL_TYPES::MODEL_TYPE_ROOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_device->SetStreamSource(0, bucket->GetVertexBuffer(), 0, sizeof(RendererVertex));
|
if (!animated)
|
||||||
m_device->SetIndices(bucket->GetIndexBuffer());
|
|
||||||
|
|
||||||
for (int iPass = 0; iPass < cPasses; iPass++)
|
|
||||||
{
|
{
|
||||||
effect->BeginPass(iPass);
|
// Non animated buckets are rendered with vertex buffers
|
||||||
effect->CommitChanges();
|
RendererBucket* bucket = mesh->GetBucket(bucketIndex);
|
||||||
|
SetGpuStateForBucket(bucketIndex);
|
||||||
DrawPrimitives(D3DPRIMITIVETYPE::D3DPT_TRIANGLELIST, 0, 0, bucket->NumVertices, 0, bucket->NumIndices / 3);
|
|
||||||
|
|
||||||
effect->EndPass();
|
m_device->SetStreamSource(0, bucket->GetVertexBuffer(), 0, sizeof(RendererVertex));
|
||||||
|
m_device->SetIndices(bucket->GetIndexBuffer());
|
||||||
|
|
||||||
|
for (int iPass = 0; iPass < cPasses; iPass++)
|
||||||
|
{
|
||||||
|
effect->BeginPass(iPass);
|
||||||
|
effect->CommitChanges();
|
||||||
|
|
||||||
|
DrawPrimitives(D3DPRIMITIVETYPE::D3DPT_TRIANGLELIST, 0, 0, bucket->NumVertices, 0, bucket->NumIndices / 3);
|
||||||
|
|
||||||
|
effect->EndPass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RendererBucket* bucket = mesh->GetAnimatedBucket(bucketIndex);
|
||||||
|
SetGpuStateForBucket(bucketIndex);
|
||||||
|
|
||||||
|
for (int iPass = 0; iPass < cPasses; iPass++)
|
||||||
|
{
|
||||||
|
effect->BeginPass(iPass);
|
||||||
|
effect->CommitChanges();
|
||||||
|
|
||||||
|
m_device->DrawIndexedPrimitiveUP(D3DPRIMITIVETYPE::D3DPT_TRIANGLELIST, 0, bucket->NumVertices, bucket->NumIndices / 3,
|
||||||
|
bucket->Indices.data(), D3DFORMAT::D3DFMT_INDEX32, bucket->Vertices.data(), sizeof(RendererVertex));
|
||||||
|
|
||||||
|
effect->EndPass();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -5828,19 +5927,16 @@ void Renderer::DrawRipples()
|
||||||
|
|
||||||
void Renderer::DrawUnderwaterDust()
|
void Renderer::DrawUnderwaterDust()
|
||||||
{
|
{
|
||||||
if (!IsRoomUnderwater(Camera.pos.roomNumber))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (m_firstUnderwaterDustParticles)
|
if (m_firstUnderwaterDustParticles)
|
||||||
{
|
{
|
||||||
for (__int32 i = 0; i < NUM_UNDERWATER_DUST_PARTICLES; i++)
|
for (__int32 i = 0; i < NUM_UNDERWATER_DUST_PARTICLES; i++)
|
||||||
m_underwaterDustParticles[i].Reset = true;
|
m_underwaterDustParticles[i].Reset = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (__int32 i = 0; i < NUM_UNDERWATER_DUST_PARTICLES; i++)
|
for (__int32 i = 0; i < NUM_UNDERWATER_DUST_PARTICLES; i++)
|
||||||
{
|
{
|
||||||
RendererUnderwaterDustParticle* dust = &m_underwaterDustParticles[i];
|
RendererUnderwaterDustParticle* dust = &m_underwaterDustParticles[i];
|
||||||
|
|
||||||
if (dust->Reset)
|
if (dust->Reset)
|
||||||
{
|
{
|
||||||
dust->X = LaraItem->pos.xPos + rand() % UNDERWATER_DUST_PARTICLES_RADIUS - UNDERWATER_DUST_PARTICLES_RADIUS / 2.0f;
|
dust->X = LaraItem->pos.xPos + rand() % UNDERWATER_DUST_PARTICLES_RADIUS - UNDERWATER_DUST_PARTICLES_RADIUS / 2.0f;
|
||||||
|
@ -5876,4 +5972,69 @@ void Renderer::DrawUnderwaterDust()
|
||||||
m_firstUnderwaterDustParticles = false;
|
m_firstUnderwaterDustParticles = false;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
__int32 Renderer::getAnimatedTextureInfo(__int16 textureId)
|
||||||
|
{
|
||||||
|
for (__int32 i = 0; i < m_animatedTextureSets.size(); i++)
|
||||||
|
{
|
||||||
|
RendererAnimatedTextureSet* set = m_animatedTextureSets[i];
|
||||||
|
for (__int32 j = 0; j < set->Textures.size(); j++)
|
||||||
|
{
|
||||||
|
if (set->Textures[j]->Id == textureId)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::UpdateAnimatedTextures()
|
||||||
|
{
|
||||||
|
for (__int32 i = 0; i < m_rooms.size(); i++)
|
||||||
|
{
|
||||||
|
RendererRoom* room = m_rooms[i];
|
||||||
|
RendererObject* roomObj = room->RoomObject;
|
||||||
|
if (roomObj->ObjectMeshes.size() == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
RendererMesh* mesh = roomObj->ObjectMeshes[0];
|
||||||
|
|
||||||
|
for (__int32 bucketIndex = 0; bucketIndex < NUM_BUCKETS; bucketIndex++)
|
||||||
|
{
|
||||||
|
RendererBucket* bucket = mesh->GetAnimatedBucket(bucketIndex);
|
||||||
|
if (bucket->Vertices.size() == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (__int32 p = 0; p < bucket->Polygons.size(); p++)
|
||||||
|
{
|
||||||
|
RendererPolygon* polygon = &bucket->Polygons[p];
|
||||||
|
RendererAnimatedTextureSet* set = m_animatedTextureSets[polygon->AnimatedSet];
|
||||||
|
__int32 textureIndex = -1;
|
||||||
|
for (__int32 j = 0; j < set->Textures.size(); j++)
|
||||||
|
{
|
||||||
|
if (set->Textures[j]->Id == polygon->TextureId)
|
||||||
|
{
|
||||||
|
textureIndex = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (textureIndex == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (textureIndex == set->Textures.size() - 1)
|
||||||
|
textureIndex = 0;
|
||||||
|
else
|
||||||
|
textureIndex++;
|
||||||
|
|
||||||
|
polygon->TextureId = set->Textures[textureIndex]->Id;
|
||||||
|
|
||||||
|
for (__int32 v = 0; v < (polygon->Shape == SHAPE_RECTANGLE ? 4 : 3); v++)
|
||||||
|
{
|
||||||
|
bucket->Vertices[polygon->Indices[v]].u = set->Textures[textureIndex]->UV[v].x;
|
||||||
|
bucket->Vertices[polygon->Indices[v]].v = set->Textures[textureIndex]->UV[v].y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -64,6 +64,8 @@ typedef struct RendererVertex {
|
||||||
|
|
||||||
typedef struct RendererPolygon {
|
typedef struct RendererPolygon {
|
||||||
byte Shape;
|
byte Shape;
|
||||||
|
__int32 AnimatedSet;
|
||||||
|
__int32 TextureId;
|
||||||
__int32 Distance;
|
__int32 Distance;
|
||||||
__int32 Indices[4];
|
__int32 Indices[4];
|
||||||
};
|
};
|
||||||
|
@ -102,6 +104,15 @@ typedef struct RendererDynamicLight {
|
||||||
float Out;
|
float Out;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct RendererAnimatedTexture {
|
||||||
|
__int32 Id;
|
||||||
|
D3DXVECTOR2 UV[4];
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct RendererAnimatedTextureSet {
|
||||||
|
vector<RendererAnimatedTexture*> Textures;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct RendererRoom {
|
typedef struct RendererRoom {
|
||||||
ROOM_INFO* Room;
|
ROOM_INFO* Room;
|
||||||
RendererObject* RoomObject;
|
RendererObject* RoomObject;
|
||||||
|
@ -539,7 +550,10 @@ class Renderer
|
||||||
bool m_enableZwrite;
|
bool m_enableZwrite;
|
||||||
bool m_enableZtest;
|
bool m_enableZtest;
|
||||||
__int32 m_currentCausticsFrame = 0;
|
__int32 m_currentCausticsFrame = 0;
|
||||||
|
vector<RendererAnimatedTextureSet*> m_animatedTextureSets;
|
||||||
|
|
||||||
|
__int32 getAnimatedTextureInfo(__int16 textureId);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
D3DXMATRIX ViewMatrix;
|
D3DXMATRIX ViewMatrix;
|
||||||
D3DXMATRIX ProjectionMatrix;
|
D3DXMATRIX ProjectionMatrix;
|
||||||
|
@ -628,7 +642,7 @@ public:
|
||||||
bool DrawSceneLightPrePass(bool dump);
|
bool DrawSceneLightPrePass(bool dump);
|
||||||
bool BindRenderTargets(RenderTarget2D* rt1, RenderTarget2D* rt2, RenderTarget2D* rt3, RenderTarget2D* rt4);
|
bool BindRenderTargets(RenderTarget2D* rt1, RenderTarget2D* rt2, RenderTarget2D* rt3, RenderTarget2D* rt4);
|
||||||
bool RestoreBackBuffer();
|
bool RestoreBackBuffer();
|
||||||
bool DrawRoomLPP(__int32 roomIndex, RENDERER_BUCKETS bucketIndex, RENDERER_PASSES pass);
|
bool DrawRoomLPP(__int32 roomIndex, RENDERER_BUCKETS bucketIndex, RENDERER_PASSES pass, bool animated);
|
||||||
bool DrawStaticLPP(__int32 roomIndex, __int32 staticIndex, RENDERER_BUCKETS bucketIndex, RENDERER_PASSES pass);
|
bool DrawStaticLPP(__int32 roomIndex, __int32 staticIndex, RENDERER_BUCKETS bucketIndex, RENDERER_PASSES pass);
|
||||||
bool DrawLaraLPP(RENDERER_BUCKETS bucketIndex, RENDERER_PASSES pass);
|
bool DrawLaraLPP(RENDERER_BUCKETS bucketIndex, RENDERER_PASSES pass);
|
||||||
bool DrawItemLPP(RendererItemToDraw* itemToDraw, RENDERER_BUCKETS bucketIndex, RENDERER_PASSES pass);
|
bool DrawItemLPP(RendererItemToDraw* itemToDraw, RENDERER_BUCKETS bucketIndex, RENDERER_PASSES pass);
|
||||||
|
@ -645,4 +659,5 @@ public:
|
||||||
bool DrawScene(RENDERER_PASSES pass);
|
bool DrawScene(RENDERER_PASSES pass);
|
||||||
bool IsRoomUnderwater(__int16 roomNumber);
|
bool IsRoomUnderwater(__int16 roomNumber);
|
||||||
bool IsInRoom(__int32 x, __int32 y, __int32 z, __int16 roomNumber);
|
bool IsInRoom(__int32 x, __int32 y, __int32 z, __int16 roomNumber);
|
||||||
|
void UpdateAnimatedTextures();
|
||||||
};
|
};
|
|
@ -26,6 +26,7 @@ public:
|
||||||
vector<RendererVertex> Vertices;
|
vector<RendererVertex> Vertices;
|
||||||
vector<__int32> Indices;
|
vector<__int32> Indices;
|
||||||
vector<RendererPolygon> Polygons;
|
vector<RendererPolygon> Polygons;
|
||||||
|
vector<RendererPolygon> AnimatedPolygons;
|
||||||
__int32 StartVertex;
|
__int32 StartVertex;
|
||||||
__int32 NumTriangles;
|
__int32 NumTriangles;
|
||||||
__int32 NumVertices;
|
__int32 NumVertices;
|
||||||
|
|
|
@ -17,6 +17,10 @@ RendererMesh::RendererMesh(LPDIRECT3DDEVICE9 device)
|
||||||
m_buckets = (RendererBucket**)malloc(NUM_BUCKETS * sizeof(RendererBucket*));
|
m_buckets = (RendererBucket**)malloc(NUM_BUCKETS * sizeof(RendererBucket*));
|
||||||
for (__int32 i = 0; i < NUM_BUCKETS; i++)
|
for (__int32 i = 0; i < NUM_BUCKETS; i++)
|
||||||
m_buckets[i] = new RendererBucket(device);
|
m_buckets[i] = new RendererBucket(device);
|
||||||
|
|
||||||
|
m_animatedBuckets = (RendererBucket**)malloc(NUM_BUCKETS * sizeof(RendererBucket*));
|
||||||
|
for (__int32 i = 0; i < NUM_BUCKETS; i++)
|
||||||
|
m_animatedBuckets[i] = new RendererBucket(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
RendererMesh::~RendererMesh()
|
RendererMesh::~RendererMesh()
|
||||||
|
@ -24,9 +28,18 @@ RendererMesh::~RendererMesh()
|
||||||
for (__int32 i = 0; i < NUM_BUCKETS; i++)
|
for (__int32 i = 0; i < NUM_BUCKETS; i++)
|
||||||
delete m_buckets[i];
|
delete m_buckets[i];
|
||||||
delete m_buckets;
|
delete m_buckets;
|
||||||
|
|
||||||
|
for (__int32 i = 0; i < NUM_BUCKETS; i++)
|
||||||
|
delete m_animatedBuckets[i];
|
||||||
|
delete m_animatedBuckets;
|
||||||
}
|
}
|
||||||
|
|
||||||
RendererBucket* RendererMesh::GetBucket(__int32 bucketIndex)
|
RendererBucket* RendererMesh::GetBucket(__int32 bucketIndex)
|
||||||
{
|
{
|
||||||
return m_buckets[bucketIndex];
|
return m_buckets[bucketIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
RendererBucket* RendererMesh::GetAnimatedBucket(__int32 bucketIndex)
|
||||||
|
{
|
||||||
|
return m_animatedBuckets[bucketIndex];
|
||||||
}
|
}
|
|
@ -12,6 +12,7 @@ class RendererMesh
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
RendererBucket** m_buckets;
|
RendererBucket** m_buckets;
|
||||||
|
RendererBucket** m_animatedBuckets;
|
||||||
LPDIRECT3DDEVICE9 m_device;
|
LPDIRECT3DDEVICE9 m_device;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -20,4 +21,5 @@ public:
|
||||||
|
|
||||||
vector<D3DXVECTOR3> Positions;
|
vector<D3DXVECTOR3> Positions;
|
||||||
RendererBucket* GetBucket(__int32 bucketIndex);
|
RendererBucket* GetBucket(__int32 bucketIndex);
|
||||||
|
RendererBucket* GetAnimatedBucket(__int32 bucketIndex);
|
||||||
};
|
};
|
|
@ -32,6 +32,7 @@ public:
|
||||||
vector<RendererBone*> LinearizedBones;
|
vector<RendererBone*> LinearizedBones;
|
||||||
__int32 GetId();
|
__int32 GetId();
|
||||||
bool HasDataInBucket[NUM_BUCKETS];
|
bool HasDataInBucket[NUM_BUCKETS];
|
||||||
|
bool HasDataInAnimatedBucket[NUM_BUCKETS];
|
||||||
bool DoNotDraw;
|
bool DoNotDraw;
|
||||||
__int32 NumVertices;
|
__int32 NumVertices;
|
||||||
//bool(Renderer::*DrawRoutine)(RendererItemToDraw* itemToDraw, RENDERER_BUCKETS bucketIndex, RENDERER_PASSES pass);
|
//bool(Renderer::*DrawRoutine)(RendererItemToDraw* itemToDraw, RENDERER_BUCKETS bucketIndex, RENDERER_PASSES pass);
|
||||||
|
|
|
@ -135,6 +135,8 @@ VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
|
||||||
|
|
||||||
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
||||||
{
|
{
|
||||||
|
int modelType = round(tex2D(NormalSampler, input.TextureCoordinate).w * 16.0f);
|
||||||
|
|
||||||
float3 diffuseColor = tex2D(ColorSampler, input.TextureCoordinate).rgb;
|
float3 diffuseColor = tex2D(ColorSampler, input.TextureCoordinate).rgb;
|
||||||
float3 ambientColor = tex2D(VertexColorSampler, input.TextureCoordinate).rgb;
|
float3 ambientColor = tex2D(VertexColorSampler, input.TextureCoordinate).rgb;
|
||||||
float4 light = tex2D(LightSampler, input.TextureCoordinate);
|
float4 light = tex2D(LightSampler, input.TextureCoordinate);
|
||||||
|
@ -145,7 +147,6 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
||||||
bool underwater = ((pixelFlags / 32) == 1);
|
bool underwater = ((pixelFlags / 32) == 1);
|
||||||
if (pixelFlags >= 32) pixelFlags -= 32;
|
if (pixelFlags >= 32) pixelFlags -= 32;
|
||||||
int modelType = pixelFlags;*/
|
int modelType = pixelFlags;*/
|
||||||
int modelType = round(tex2D(NormalSampler, input.TextureCoordinate).w * 16.0f);
|
|
||||||
//if (underwater)
|
//if (underwater)
|
||||||
// return float4(0, 0, 1, 1);
|
// return float4(0, 0, 1, 1);
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ PixelShaderOutput PixelShaderFunction(VertexShaderOutput input)
|
||||||
float3 yaxis = tex2D(CausticsSampler, p.xz).rgb;
|
float3 yaxis = tex2D(CausticsSampler, p.xz).rgb;
|
||||||
float3 zaxis = tex2D(CausticsSampler, p.xy).rgb;
|
float3 zaxis = tex2D(CausticsSampler, p.xy).rgb;
|
||||||
|
|
||||||
vertexColors += float4((xaxis * blending.x + yaxis * blending.y + zaxis * blending.z).xyz, 0.0f) * attenuation;
|
vertexColors += float4((xaxis * blending.x + yaxis * blending.y + zaxis * blending.z).xyz, 0.0f) * attenuation * 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ModelType == MODELTYPE_ROOM || ModelType == MODELTYPE_ROOM_UNDERWATER)
|
if (ModelType == MODELTYPE_ROOM || ModelType == MODELTYPE_ROOM_UNDERWATER)
|
||||||
|
|
|
@ -55,8 +55,8 @@ float4x4 LightProjection;
|
||||||
|
|
||||||
bool AmbientPass;
|
bool AmbientPass;
|
||||||
|
|
||||||
float HalfPixelX = 1.0f / 800.0f;
|
float HalfPixelX;
|
||||||
float HalfPixelY = 1.0f / 600.0f;
|
float HalfPixelY;
|
||||||
|
|
||||||
texture2D ColorMap;
|
texture2D ColorMap;
|
||||||
sampler ColorSampler = sampler_state
|
sampler ColorSampler = sampler_state
|
||||||
|
@ -152,7 +152,7 @@ float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
|
||||||
{
|
{
|
||||||
input.ScreenPosition.xy /= input.ScreenPosition.w;
|
input.ScreenPosition.xy /= input.ScreenPosition.w;
|
||||||
texCoord = 0.5f * (float2(input.ScreenPosition.x, -input.ScreenPosition.y) + 1);
|
texCoord = 0.5f * (float2(input.ScreenPosition.x, -input.ScreenPosition.y) + 1);
|
||||||
texCoord -= float2(0.5f / 800.0f, 0.5f / 600.0f);
|
texCoord -= float2(HalfPixelX, HalfPixelY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the normal and transform back to -1 ... 1
|
// Get the normal and transform back to -1 ... 1
|
||||||
|
|
|
@ -100,7 +100,7 @@ __int32 __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lp
|
||||||
|
|
||||||
//DXInitialise(App.WindowHandle);
|
//DXInitialise(App.WindowHandle);
|
||||||
g_Renderer = new Renderer();
|
g_Renderer = new Renderer();
|
||||||
g_Renderer->Initialise(800, 600, true, App.WindowHandle);
|
g_Renderer->Initialise(Rect.right, Rect.bottom, true, App.WindowHandle);
|
||||||
|
|
||||||
// Initialize audio
|
// Initialize audio
|
||||||
Sound_Init();
|
Sound_Init();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue