mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-11-18 05:07:45 +00:00
Merge branch 'lcs' of https://github.com/GTAmodding/re3 into lcs
This commit is contained in:
commit
9f288fc16f
|
@ -2179,7 +2179,7 @@ bool CUpsideDownCarCheck::IsCarUpsideDown(int32 id)
|
|||
// done(LCS)
|
||||
bool CUpsideDownCarCheck::IsCarUpsideDown(CVehicle* pVehicle)
|
||||
{
|
||||
assert(pVehicle);
|
||||
script_assert(pVehicle);
|
||||
return pVehicle->GetUp().z <= UPSIDEDOWN_UP_THRESHOLD &&
|
||||
pVehicle->GetMoveSpeed().Magnitude() < UPSIDEDOWN_MOVE_SPEED_THRESHOLD &&
|
||||
pVehicle->GetTurnSpeed().Magnitude() < UPSIDEDOWN_TURN_SPEED_THRESHOLD;
|
||||
|
@ -2411,7 +2411,7 @@ int32* GetPointerToScriptVariableForDebug(CRunningScript* pScript, uint32* pIp,
|
|||
return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL)];
|
||||
}
|
||||
else {
|
||||
assert(type >= ARGUMENT_TIMER);
|
||||
script_assert(type >= ARGUMENT_TIMER);
|
||||
sprintf(tmpstr, " TIMER%d@", (type - ARGUMENT_TIMER));
|
||||
strcat(buf, tmpstr);
|
||||
return &pScript->m_anLocalVariables[NUM_LOCAL_VARS + 8 + (type - ARGUMENT_TIMER)]; // why 8?
|
||||
|
@ -2534,7 +2534,7 @@ int32* GetPointerToScriptVariable(CRunningScript* pScript, uint32* pIp)
|
|||
return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL)];
|
||||
}
|
||||
else {
|
||||
assert(type >= ARGUMENT_TIMER);
|
||||
script_assert(type >= ARGUMENT_TIMER);
|
||||
return &pScript->m_anLocalVariables[NUM_LOCAL_VARS + 8 + (type - ARGUMENT_TIMER)];
|
||||
}
|
||||
}
|
||||
|
@ -4998,7 +4998,10 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
|
|||
return 0;
|
||||
}
|
||||
//case COMMAND_ADD_AMMO_TO_CAR:
|
||||
//case COMMAND_IS_PLAYER_STILL_ALIVE:
|
||||
case COMMAND_IS_PLAYER_STILL_ALIVE:
|
||||
CollectParameters(&m_nIp, 1);
|
||||
UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_WBState != WBSTATE_WASTED);
|
||||
return 0;
|
||||
case COMMAND_IS_PLAYER_DEAD:
|
||||
CollectParameters(&m_nIp, 1);
|
||||
UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_WBState == WBSTATE_WASTED);
|
||||
|
|
|
@ -836,7 +836,6 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
|
|||
case COMMAND_RESTORE_CLOCK:
|
||||
CClock::RestoreClock();
|
||||
return 0;
|
||||
/*
|
||||
case COMMAND_RESTART_CRITICAL_MISSION:
|
||||
{
|
||||
CollectParameters(&m_nIp, 4);
|
||||
|
@ -849,7 +848,6 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
|
|||
CWorld::Players[CWorld::PlayerInFocus].PlayerFailedCriticalMission();
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
case COMMAND_IS_PLAYER_PLAYING:
|
||||
{
|
||||
CollectParameters(&m_nIp, 1);
|
||||
|
@ -1357,12 +1355,14 @@ int8 CRunningScript::ProcessCommands600To699(int32 command)
|
|||
UpdateCompareFlag(CTheScripts::IsPedStopped(pPed));
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
case COMMAND_MESSAGE_WAIT:
|
||||
CollectParameters(&m_nIp, 2);
|
||||
m_nWakeTime = CTimer::GetTimeInMilliseconds() + ScriptParams[0];
|
||||
if (ScriptParams[1] != 0)
|
||||
m_bSkipWakeTime = true;
|
||||
return 1;
|
||||
/*
|
||||
case COMMAND_ADD_PARTICLE_EFFECT:
|
||||
{
|
||||
CollectParameters(&m_nIp, 5);
|
||||
|
|
|
@ -714,7 +714,7 @@ int8 CRunningScript::ProcessCommands1500To1599(int32 command)
|
|||
script_assert(false);
|
||||
return 0;
|
||||
case COMMAND_1539:
|
||||
script_assert(false);
|
||||
//TODO (REGISTER_OUTFIT_CHANGE)
|
||||
return 0;
|
||||
case COMMAND_1540:
|
||||
script_assert(false);
|
||||
|
@ -741,7 +741,9 @@ int8 CRunningScript::ProcessCommands1500To1599(int32 command)
|
|||
script_assert(false);
|
||||
return 0;
|
||||
case COMMAND_1548:
|
||||
script_assert(false);
|
||||
// TODO (GET_ONFOOT_CAMERA_MODE)
|
||||
ScriptParams[0] = 0;
|
||||
StoreParameters(&m_nIp, 1);
|
||||
return 0;
|
||||
case COMMAND_1549:
|
||||
CollectParameters(&m_nIp, 1);
|
||||
|
@ -847,8 +849,11 @@ int8 CRunningScript::ProcessCommands1500To1599(int32 command)
|
|||
script_assert(false);
|
||||
return 0;
|
||||
case COMMAND_1581:
|
||||
script_assert(false);
|
||||
{
|
||||
// TODO (SET_HELP_MESSAGE?)
|
||||
wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp);
|
||||
return 0;
|
||||
}
|
||||
case COMMAND_1582:
|
||||
script_assert(false);
|
||||
return 0;
|
||||
|
@ -1062,8 +1067,15 @@ int8 CRunningScript::ProcessCommands1600To1699(int32 command)
|
|||
script_assert(false);
|
||||
return 0;
|
||||
case COMMAND_1645:
|
||||
script_assert(false);
|
||||
{
|
||||
CollectParameters(&m_nIp, 1);
|
||||
// TODO (GET_STORED_WEAPON?)
|
||||
CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
|
||||
script_assert(pPed);
|
||||
ScriptParams[0] = pPed->m_storedWeapon;
|
||||
StoreParameters(&m_nIp, 1);
|
||||
return 0;
|
||||
}
|
||||
case COMMAND_1646:
|
||||
CollectParameters(&m_nIp, 1);
|
||||
// TODO (DISABLE_PAUSE_MENU?)
|
||||
|
@ -1100,7 +1112,8 @@ int8 CRunningScript::ProcessCommands1600To1699(int32 command)
|
|||
script_assert(false);
|
||||
return 0;
|
||||
case COMMAND_1656:
|
||||
script_assert(false);
|
||||
CollectParameters(&m_nIp, 2);
|
||||
// TODO (?)
|
||||
return 0;
|
||||
default:
|
||||
script_assert(0);
|
||||
|
|
|
@ -104,6 +104,11 @@ CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = {
|
|||
&RadioVCPRSprite,
|
||||
&RadioEspantosoSprite,
|
||||
&RadioEmotionSprite,
|
||||
&RadioWaveSprite, // tmp hack
|
||||
&RadioWaveSprite,
|
||||
&RadioWaveSprite,
|
||||
&RadioWaveSprite,
|
||||
&RadioWaveSprite,
|
||||
&RadioWaveSprite
|
||||
};
|
||||
|
||||
|
@ -1689,6 +1694,7 @@ CRadar::DrawLegend(int32 x, int32 y, int32 sprite)
|
|||
text = TheText.Get("LG_34");
|
||||
break;
|
||||
default:
|
||||
text = TheText.Get("LG_34"); // tmp hack
|
||||
break;
|
||||
}
|
||||
CFont::PrintString(SCREEN_SCALE_X(20.f) + x, SCREEN_SCALE_Y(3.0f) + y, text);
|
||||
|
|
|
@ -92,6 +92,11 @@ enum eRadarSprite
|
|||
RADAR_SPRITE_RADIO_ESPANTOSO,
|
||||
RADAR_SPRITE_RADIO_EMOTION,
|
||||
RADAR_SPRITE_RADIO_WAVE,
|
||||
RADAR_SPRITE_40, // tmp
|
||||
RADAR_SPRITE_41,
|
||||
RADAR_SPRITE_42,
|
||||
RADAR_SPRITE_43,
|
||||
RADAR_SPRITE_44,
|
||||
|
||||
RADAR_SPRITE_COUNT
|
||||
};
|
||||
|
|
|
@ -124,7 +124,7 @@ bool gbPrintMemoryUsage;
|
|||
#endif
|
||||
|
||||
#ifdef NEW_RENDERER
|
||||
bool gbNewRenderer;
|
||||
bool gbNewRenderer = true;
|
||||
#endif
|
||||
#ifdef FIX_BUGS
|
||||
// need to clear stencil for mblur fx. no idea why it works in the original game
|
||||
|
|
|
@ -133,5 +133,12 @@ void AttachRimPipe(rw::Clump *clump);
|
|||
|
||||
}
|
||||
|
||||
namespace WorldRender{
|
||||
extern int numBlendInsts[3];
|
||||
void AtomicFirstPass(RpAtomic *atomic, int pass);
|
||||
void AtomicFullyTransparent(RpAtomic *atomic, int pass, int fadeAlpha);
|
||||
void RenderBlendPass(int pass);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -201,7 +201,6 @@ worldRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header)
|
|||
using namespace rw::d3d;
|
||||
using namespace rw::d3d9;
|
||||
|
||||
int vsBits;
|
||||
setStreamSource(0, header->vertexStream[0].vertexBuffer, 0, header->vertexStream[0].stride);
|
||||
setIndices(header->indexBuffer);
|
||||
setVertexDeclaration(header->vertexDeclaration);
|
||||
|
@ -547,5 +546,187 @@ DestroyRimLightPipes(void)
|
|||
|
||||
}
|
||||
|
||||
#ifdef NEW_RENDERER
|
||||
|
||||
namespace WorldRender
|
||||
{
|
||||
|
||||
struct BuildingInst
|
||||
{
|
||||
rw::RawMatrix combinedMat;
|
||||
rw::d3d9::InstanceDataHeader *instHeader;
|
||||
uint8 fadeAlpha;
|
||||
bool lighting;
|
||||
};
|
||||
BuildingInst blendInsts[3][2000];
|
||||
int numBlendInsts[3];
|
||||
|
||||
static RwRGBAReal black;
|
||||
|
||||
static void
|
||||
SetMatrix(BuildingInst *building, rw::Matrix *worldMat)
|
||||
{
|
||||
using namespace rw;
|
||||
RawMatrix world, worldview;
|
||||
Camera *cam = engine->currentCamera;
|
||||
convMatrix(&world, worldMat);
|
||||
RawMatrix::mult(&worldview, &world, &cam->devView);
|
||||
RawMatrix::mult(&building->combinedMat, &worldview, &cam->devProj);
|
||||
}
|
||||
|
||||
static bool
|
||||
IsTextureTransparent(RwTexture *tex)
|
||||
{
|
||||
if(tex == nil || tex->raster == nil)
|
||||
return false;
|
||||
return PLUGINOFFSET(rw::d3d::D3dRaster, tex->raster, rw::d3d::nativeRasterOffset)->hasAlpha;
|
||||
}
|
||||
|
||||
// Render all opaque meshes and put atomics that needs blending
|
||||
// into the deferred list.
|
||||
void
|
||||
AtomicFirstPass(RpAtomic *atomic, int pass)
|
||||
{
|
||||
using namespace rw;
|
||||
using namespace rw::d3d;
|
||||
using namespace rw::d3d9;
|
||||
|
||||
BuildingInst *building = &blendInsts[pass][numBlendInsts[pass]];
|
||||
|
||||
atomic->getPipeline()->instance(atomic);
|
||||
building->instHeader = (d3d9::InstanceDataHeader*)atomic->geometry->instData;
|
||||
assert(building->instHeader != nil);
|
||||
assert(building->instHeader->platform == PLATFORM_D3D9);
|
||||
building->fadeAlpha = 255;
|
||||
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
|
||||
|
||||
bool setupDone = false;
|
||||
bool defer = false;
|
||||
SetMatrix(building, atomic->getFrame()->getLTM());
|
||||
|
||||
float colorscale[4];
|
||||
|
||||
InstanceData *inst = building->instHeader->inst;
|
||||
for(rw::uint32 i = 0; i < building->instHeader->numMeshes; i++, inst++){
|
||||
Material *m = inst->material;
|
||||
|
||||
if(inst->vertexAlpha || m->color.alpha != 255 ||
|
||||
IsTextureTransparent(m->texture)){
|
||||
defer = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// alright we're rendering this atomic
|
||||
if(!setupDone){
|
||||
setStreamSource(0, building->instHeader->vertexStream[0].vertexBuffer, 0, building->instHeader->vertexStream[0].stride);
|
||||
setIndices(building->instHeader->indexBuffer);
|
||||
setVertexDeclaration(building->instHeader->vertexDeclaration);
|
||||
setVertexShader(CustomPipes::leedsBuilding_VS);
|
||||
setPixelShader(CustomPipes::scale_PS);
|
||||
d3ddevice->SetVertexShaderConstantF(VSLOC_combined, (float*)&building->combinedMat, 4);
|
||||
|
||||
RGBAf amb, emiss;
|
||||
amb.red = CTimeCycle::GetAmbientRed();
|
||||
amb.green = CTimeCycle::GetAmbientGreen();
|
||||
amb.blue = CTimeCycle::GetAmbientBlue();
|
||||
amb.alpha = 1.0f;
|
||||
emiss = pAmbient->color;
|
||||
|
||||
d3ddevice->SetVertexShaderConstantF(CustomPipes::VSLOC_ambient, (float*)&amb, 1);
|
||||
d3ddevice->SetVertexShaderConstantF(CustomPipes::VSLOC_emissive, (float*)&emiss, 1);
|
||||
|
||||
colorscale[3] = 1.0f;
|
||||
|
||||
setupDone = true;
|
||||
}
|
||||
|
||||
float cs = 1.0f;
|
||||
if(m->texture)
|
||||
cs = 255/128.0f;
|
||||
colorscale[0] = colorscale[1] = colorscale[2] = cs;
|
||||
d3ddevice->SetPixelShaderConstantF(CustomPipes::PSLOC_colorscale, colorscale, 1);
|
||||
|
||||
if(m->texture)
|
||||
d3d::setTexture(0, m->texture);
|
||||
else
|
||||
d3d::setTexture(0, gpWhiteTexture); // actually we don't even render this
|
||||
|
||||
setMaterial(m->color, m->surfaceProps, 0.5f);
|
||||
|
||||
drawInst(building->instHeader, inst);
|
||||
}
|
||||
if(defer)
|
||||
numBlendInsts[pass]++;
|
||||
}
|
||||
|
||||
void
|
||||
AtomicFullyTransparent(RpAtomic *atomic, int pass, int fadeAlpha)
|
||||
{
|
||||
using namespace rw;
|
||||
using namespace rw::d3d;
|
||||
using namespace rw::d3d9;
|
||||
|
||||
BuildingInst *building = &blendInsts[pass][numBlendInsts[pass]];
|
||||
|
||||
atomic->getPipeline()->instance(atomic);
|
||||
building->instHeader = (d3d9::InstanceDataHeader*)atomic->geometry->instData;
|
||||
assert(building->instHeader != nil);
|
||||
assert(building->instHeader->platform == PLATFORM_D3D9);
|
||||
building->fadeAlpha = fadeAlpha;
|
||||
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
|
||||
SetMatrix(building, atomic->getFrame()->getLTM());
|
||||
numBlendInsts[pass]++;
|
||||
}
|
||||
|
||||
void
|
||||
RenderBlendPass(int pass)
|
||||
{
|
||||
using namespace rw;
|
||||
using namespace rw::d3d;
|
||||
using namespace rw::d3d9;
|
||||
|
||||
setVertexShader(CustomPipes::leedsBuilding_VS);
|
||||
setPixelShader(CustomPipes::scale_PS);
|
||||
|
||||
float colorscale[4];
|
||||
colorscale[3] = 1.0f;
|
||||
|
||||
int i;
|
||||
for(i = 0; i < numBlendInsts[pass]; i++){
|
||||
BuildingInst *building = &blendInsts[pass][i];
|
||||
|
||||
setStreamSource(0, building->instHeader->vertexStream[0].vertexBuffer, 0, building->instHeader->vertexStream[0].stride);
|
||||
setIndices(building->instHeader->indexBuffer);
|
||||
setVertexDeclaration(building->instHeader->vertexDeclaration);
|
||||
d3ddevice->SetVertexShaderConstantF(VSLOC_combined, (float*)&building->combinedMat, 4);
|
||||
|
||||
InstanceData *inst = building->instHeader->inst;
|
||||
for(rw::uint32 j = 0; j < building->instHeader->numMeshes; j++, inst++){
|
||||
Material *m = inst->material;
|
||||
if(!inst->vertexAlpha && m->color.alpha == 255 && !IsTextureTransparent(m->texture) && building->fadeAlpha == 255)
|
||||
continue; // already done this one
|
||||
|
||||
float cs = 1.0f;
|
||||
if(m->texture)
|
||||
cs = 255/128.0f;
|
||||
colorscale[0] = colorscale[1] = colorscale[2] = cs;
|
||||
d3ddevice->SetPixelShaderConstantF(CustomPipes::PSLOC_colorscale, colorscale, 1);
|
||||
|
||||
if(m->texture)
|
||||
d3d::setTexture(0, m->texture);
|
||||
else
|
||||
d3d::setTexture(0, gpWhiteTexture); // actually we don't even render this
|
||||
|
||||
rw::RGBA color = m->color;
|
||||
color.alpha = (color.alpha * building->fadeAlpha)/255;
|
||||
setMaterial(color, m->surfaceProps, 0.5f);
|
||||
|
||||
drawInst(building->instHeader, inst);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -245,7 +245,7 @@ worldRenderCB(rw::Atomic *atomic, rw::gl3::InstanceDataHeader *header)
|
|||
|
||||
setTexture(0, m->texture);
|
||||
|
||||
setMaterial(m->color, m->surfaceProps);
|
||||
setMaterial(m->color, m->surfaceProps, 0.5f);
|
||||
|
||||
rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF);
|
||||
|
||||
|
@ -616,5 +616,190 @@ CustomPipeRegisterGL(void)
|
|||
|
||||
}
|
||||
|
||||
#ifdef NEW_RENDERER
|
||||
|
||||
namespace WorldRender
|
||||
{
|
||||
|
||||
struct BuildingInst
|
||||
{
|
||||
rw::Matrix matrix;
|
||||
rw::gl3::InstanceDataHeader *instHeader;
|
||||
uint8 fadeAlpha;
|
||||
bool lighting;
|
||||
};
|
||||
BuildingInst blendInsts[3][2000];
|
||||
int numBlendInsts[3];
|
||||
|
||||
static RwRGBAReal black;
|
||||
|
||||
static bool
|
||||
IsTextureTransparent(RwTexture *tex)
|
||||
{
|
||||
if(tex == nil || tex->raster == nil)
|
||||
return false;
|
||||
return PLUGINOFFSET(rw::gl3::Gl3Raster, tex->raster, rw::gl3::nativeRasterOffset)->hasAlpha;
|
||||
}
|
||||
|
||||
// Render all opaque meshes and put atomics that needs blending
|
||||
// into the deferred list.
|
||||
void
|
||||
AtomicFirstPass(RpAtomic *atomic, int pass)
|
||||
{
|
||||
using namespace rw;
|
||||
using namespace rw::gl3;
|
||||
|
||||
BuildingInst *building = &blendInsts[pass][numBlendInsts[pass]];
|
||||
|
||||
atomic->getPipeline()->instance(atomic);
|
||||
building->instHeader = (gl3::InstanceDataHeader*)atomic->geometry->instData;
|
||||
assert(building->instHeader != nil);
|
||||
assert(building->instHeader->platform == PLATFORM_GL3);
|
||||
building->fadeAlpha = 255;
|
||||
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
|
||||
|
||||
bool setupDone = false;
|
||||
bool defer = false;
|
||||
building->matrix = *atomic->getFrame()->getLTM();
|
||||
|
||||
float colorscale[4];
|
||||
|
||||
InstanceData *inst = building->instHeader->inst;
|
||||
for(rw::uint32 i = 0; i < building->instHeader->numMeshes; i++, inst++){
|
||||
Material *m = inst->material;
|
||||
|
||||
if(inst->vertexAlpha || m->color.alpha != 255 ||
|
||||
IsTextureTransparent(m->texture)){
|
||||
defer = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// alright we're rendering this atomic
|
||||
if(!setupDone){
|
||||
CustomPipes::leedsWorldShader->use();
|
||||
// defaultShader->use();
|
||||
setWorldMatrix(&building->matrix);
|
||||
#ifdef RW_GL_USE_VAOS
|
||||
glBindVertexArray(building->instHeader->vao);
|
||||
#else
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, building->instHeader->ibo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, building->instHeader->vbo);
|
||||
setAttribPointers(building->instHeader->attribDesc, building->instHeader->numAttribs);
|
||||
#endif
|
||||
|
||||
RGBAf amb, emiss;
|
||||
amb.red = CTimeCycle::GetAmbientRed();
|
||||
amb.green = CTimeCycle::GetAmbientGreen();
|
||||
amb.blue = CTimeCycle::GetAmbientBlue();
|
||||
amb.alpha = 1.0f;
|
||||
emiss = pAmbient->color;
|
||||
|
||||
glUniform4fv(U(CustomPipes::u_amb), 1, (float*)&amb);
|
||||
glUniform4fv(U(CustomPipes::u_emiss), 1, (float*)&emiss);
|
||||
|
||||
colorscale[3] = 1.0f;
|
||||
|
||||
setupDone = true;
|
||||
}
|
||||
|
||||
setMaterial(m->color, m->surfaceProps, 0.5f);
|
||||
|
||||
float cs = 1.0f;
|
||||
if(m->texture)
|
||||
cs = 255/128.0f;
|
||||
colorscale[0] = colorscale[1] = colorscale[2] = cs;
|
||||
glUniform4fv(U(CustomPipes::u_colorscale), 1, colorscale);
|
||||
|
||||
setTexture(0, m->texture);
|
||||
|
||||
drawInst(building->instHeader, inst);
|
||||
}
|
||||
#ifndef RW_GL_USE_VAOS
|
||||
disableAttribPointers(building->instHeader->attribDesc, building->instHeader->numAttribs);
|
||||
#endif
|
||||
if(defer)
|
||||
numBlendInsts[pass]++;
|
||||
}
|
||||
|
||||
void
|
||||
AtomicFullyTransparent(RpAtomic *atomic, int pass, int fadeAlpha)
|
||||
{
|
||||
using namespace rw;
|
||||
using namespace rw::gl3;
|
||||
|
||||
BuildingInst *building = &blendInsts[pass][numBlendInsts[pass]];
|
||||
|
||||
atomic->getPipeline()->instance(atomic);
|
||||
building->instHeader = (gl3::InstanceDataHeader*)atomic->geometry->instData;
|
||||
assert(building->instHeader != nil);
|
||||
assert(building->instHeader->platform == PLATFORM_GL3);
|
||||
building->fadeAlpha = fadeAlpha;
|
||||
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
|
||||
building->matrix = *atomic->getFrame()->getLTM();
|
||||
numBlendInsts[pass]++;
|
||||
}
|
||||
|
||||
void
|
||||
RenderBlendPass(int pass)
|
||||
{
|
||||
using namespace rw;
|
||||
using namespace rw::gl3;
|
||||
|
||||
CustomPipes::leedsWorldShader->use();
|
||||
|
||||
RGBAf amb, emiss;
|
||||
amb.red = CTimeCycle::GetAmbientRed();
|
||||
amb.green = CTimeCycle::GetAmbientGreen();
|
||||
amb.blue = CTimeCycle::GetAmbientBlue();
|
||||
amb.alpha = 1.0f;
|
||||
emiss = pAmbient->color;
|
||||
|
||||
glUniform4fv(U(CustomPipes::u_amb), 1, (float*)&amb);
|
||||
glUniform4fv(U(CustomPipes::u_emiss), 1, (float*)&emiss);
|
||||
|
||||
float colorscale[4];
|
||||
colorscale[3] = 1.0f;
|
||||
|
||||
int i;
|
||||
for(i = 0; i < numBlendInsts[pass]; i++){
|
||||
BuildingInst *building = &blendInsts[pass][i];
|
||||
|
||||
#ifdef RW_GL_USE_VAOS
|
||||
glBindVertexArray(building->instHeader->vao);
|
||||
#else
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, building->instHeader->ibo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, building->instHeader->vbo);
|
||||
setAttribPointers(building->instHeader->attribDesc, building->instHeader->numAttribs);
|
||||
#endif
|
||||
setWorldMatrix(&building->matrix);
|
||||
|
||||
InstanceData *inst = building->instHeader->inst;
|
||||
for(rw::uint32 j = 0; j < building->instHeader->numMeshes; j++, inst++){
|
||||
Material *m = inst->material;
|
||||
if(!inst->vertexAlpha && m->color.alpha == 255 && !IsTextureTransparent(m->texture) && building->fadeAlpha == 255)
|
||||
continue; // already done this one
|
||||
|
||||
rw::RGBA color = m->color;
|
||||
color.alpha = (color.alpha * building->fadeAlpha)/255;
|
||||
setMaterial(color, m->surfaceProps, 0.5f);
|
||||
|
||||
float cs = 1.0f;
|
||||
if(m->texture)
|
||||
cs = 255/128.0f;
|
||||
colorscale[0] = colorscale[1] = colorscale[2] = cs;
|
||||
glUniform4fv(U(CustomPipes::u_colorscale), 1, colorscale);
|
||||
|
||||
setTexture(0, m->texture);
|
||||
|
||||
drawInst(building->instHeader, inst);
|
||||
}
|
||||
#ifndef RW_GL_USE_VAOS
|
||||
disableAttribPointers(building->instHeader->attribDesc, building->instHeader->numAttribs);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
uniform vec4 u_amb;
|
||||
uniform vec4 u_emiss;
|
||||
|
||||
#define surfEmissive (u_surfProps.w)
|
||||
|
||||
VSIN(ATTRIB_POS) vec3 in_pos;
|
||||
|
||||
VSOUT vec4 v_color;
|
||||
|
@ -18,7 +20,7 @@ main(void)
|
|||
|
||||
v_color = in_color;
|
||||
v_color.rgb *= u_amb.rgb;
|
||||
v_color.rgb += u_emiss.rgb;
|
||||
v_color.rgb += u_emiss.rgb*surfEmissive;
|
||||
v_color = clamp(v_color, 0.0, 1.0);
|
||||
v_color.a *= u_matColor.a;
|
||||
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,8 @@
|
|||
#include "standardConstants.h"
|
||||
|
||||
#define surfEmissive (surfProps.w)
|
||||
|
||||
|
||||
float4 emissive : register(c41);
|
||||
float4 ambient : register(c42);
|
||||
|
||||
|
@ -8,14 +11,12 @@ struct VS_in
|
|||
float4 Position : POSITION;
|
||||
float3 Normal : NORMAL;
|
||||
float2 TexCoord : TEXCOORD0;
|
||||
float2 TexCoord1 : TEXCOORD1;
|
||||
float4 Prelight : COLOR0;
|
||||
};
|
||||
|
||||
struct VS_out {
|
||||
float4 Position : POSITION;
|
||||
float3 TexCoord0 : TEXCOORD0; // also fog
|
||||
float2 TexCoord1 : TEXCOORD1;
|
||||
float4 Color : COLOR0;
|
||||
};
|
||||
|
||||
|
@ -29,11 +30,10 @@ VS_out main(in VS_in input)
|
|||
float3 Normal = mul(normalMat, input.Normal);
|
||||
|
||||
output.TexCoord0.xy = input.TexCoord;
|
||||
output.TexCoord1.xy = input.TexCoord1;
|
||||
|
||||
output.Color = input.Prelight;
|
||||
output.Color.rgb *= ambient.rgb;
|
||||
output.Color.rgb += emissive.rgb;
|
||||
output.Color.rgb += emissive.rgb*surfEmissive;
|
||||
|
||||
output.Color = clamp(output.Color, 0.0, 1.0);
|
||||
output.Color.a *= matCol.a;
|
||||
|
|
|
@ -1,37 +1,40 @@
|
|||
static unsigned char leedsBuilding_VS_cso[] = {
|
||||
0x00, 0x02, 0xfe, 0xff, 0xfe, 0xff, 0x42, 0x00, 0x43, 0x54, 0x41, 0x42,
|
||||
0x1c, 0x00, 0x00, 0x00, 0xd3, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfe, 0xff,
|
||||
0x05, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
|
||||
0xcc, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x02, 0x00, 0x2a, 0x00,
|
||||
0x01, 0x00, 0xaa, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x98, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00,
|
||||
0xa4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x29, 0x00, 0x01, 0x00, 0xa6, 0x00, 0x88, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00,
|
||||
0x01, 0x00, 0x3a, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xc5, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x32, 0x00,
|
||||
0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0x6d, 0x62, 0x69,
|
||||
0x65, 0x6e, 0x74, 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6d, 0x62,
|
||||
0x69, 0x6e, 0x65, 0x64, 0x4d, 0x61, 0x74, 0x00, 0x03, 0x00, 0x03, 0x00,
|
||||
0x04, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x65, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x76, 0x65, 0x00, 0x66, 0x6f, 0x67,
|
||||
0x44, 0x61, 0x74, 0x61, 0x00, 0x6d, 0x61, 0x74, 0x43, 0x6f, 0x6c, 0x00,
|
||||
0x76, 0x73, 0x5f, 0x32, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f,
|
||||
0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53,
|
||||
0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d,
|
||||
0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39,
|
||||
0x35, 0x32, 0x2e, 0x33, 0x31, 0x31, 0x31, 0x00, 0x51, 0x00, 0x00, 0x05,
|
||||
0x04, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02,
|
||||
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02,
|
||||
0x05, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02,
|
||||
0x05, 0x00, 0x01, 0x80, 0x02, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02,
|
||||
0x0a, 0x00, 0x00, 0x80, 0x03, 0x00, 0x0f, 0x90, 0x01, 0x00, 0x00, 0x02,
|
||||
0x00, 0x00, 0x07, 0x80, 0x2a, 0x00, 0xe4, 0xa0, 0x04, 0x00, 0x00, 0x04,
|
||||
0x00, 0x00, 0x07, 0x80, 0x03, 0x00, 0xe4, 0x90, 0x00, 0x00, 0xe4, 0x80,
|
||||
0x29, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x08, 0x80,
|
||||
0x03, 0x00, 0xff, 0x90, 0x0b, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80,
|
||||
0x00, 0x02, 0xfe, 0xff, 0xfe, 0xff, 0x4a, 0x00, 0x43, 0x54, 0x41, 0x42,
|
||||
0x1c, 0x00, 0x00, 0x00, 0xf1, 0x00, 0x00, 0x00, 0x00, 0x02, 0xfe, 0xff,
|
||||
0x06, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
|
||||
0xea, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x02, 0x00, 0x2a, 0x00,
|
||||
0x01, 0x00, 0xaa, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xac, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00,
|
||||
0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x29, 0x00, 0x01, 0x00, 0xa6, 0x00, 0x9c, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xd1, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00,
|
||||
0x01, 0x00, 0x3a, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xd9, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x32, 0x00,
|
||||
0x9c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00,
|
||||
0x02, 0x00, 0x0d, 0x00, 0x01, 0x00, 0x36, 0x00, 0x9c, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x61, 0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x00,
|
||||
0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6d, 0x62, 0x69, 0x6e, 0x65, 0x64,
|
||||
0x4d, 0x61, 0x74, 0x00, 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x6d, 0x69, 0x73,
|
||||
0x73, 0x69, 0x76, 0x65, 0x00, 0x66, 0x6f, 0x67, 0x44, 0x61, 0x74, 0x61,
|
||||
0x00, 0x6d, 0x61, 0x74, 0x43, 0x6f, 0x6c, 0x00, 0x73, 0x75, 0x72, 0x66,
|
||||
0x50, 0x72, 0x6f, 0x70, 0x73, 0x00, 0x76, 0x73, 0x5f, 0x32, 0x5f, 0x30,
|
||||
0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28,
|
||||
0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64,
|
||||
0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20,
|
||||
0x39, 0x2e, 0x32, 0x39, 0x2e, 0x39, 0x35, 0x32, 0x2e, 0x33, 0x31, 0x31,
|
||||
0x31, 0x00, 0xab, 0xab, 0x51, 0x00, 0x00, 0x05, 0x04, 0x00, 0x0f, 0xa0,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80,
|
||||
0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80,
|
||||
0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80,
|
||||
0x02, 0x00, 0x0f, 0x90, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x07, 0x80,
|
||||
0x29, 0x00, 0xe4, 0xa0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x07, 0x80,
|
||||
0x00, 0x00, 0xe4, 0x80, 0x0d, 0x00, 0xff, 0xa0, 0x04, 0x00, 0x00, 0x04,
|
||||
0x00, 0x00, 0x07, 0x80, 0x02, 0x00, 0xe4, 0x90, 0x2a, 0x00, 0xe4, 0xa0,
|
||||
0x00, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x08, 0x80,
|
||||
0x02, 0x00, 0xff, 0x90, 0x0b, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80,
|
||||
0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x03,
|
||||
0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x55, 0xa0,
|
||||
0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x08, 0xd0, 0x00, 0x00, 0xff, 0x80,
|
||||
|
@ -50,6 +53,5 @@ static unsigned char leedsBuilding_VS_cso[] = {
|
|||
0x00, 0x00, 0x00, 0x80, 0x0e, 0x00, 0xff, 0xa0, 0x0a, 0x00, 0x00, 0x03,
|
||||
0x00, 0x00, 0x04, 0xe0, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x55, 0xa0,
|
||||
0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x03, 0xe0, 0x01, 0x00, 0xe4, 0x90,
|
||||
0x01, 0x00, 0x00, 0x02, 0x01, 0x00, 0x03, 0xe0, 0x02, 0x00, 0xe4, 0x90,
|
||||
0xff, 0xff, 0x00, 0x00
|
||||
};
|
||||
|
|
|
@ -2,6 +2,8 @@ const char *leedsBuilding_vert_src =
|
|||
"uniform vec4 u_amb;\n"
|
||||
"uniform vec4 u_emiss;\n"
|
||||
|
||||
"#define surfEmissive (u_surfProps.w)\n"
|
||||
|
||||
"VSIN(ATTRIB_POS) vec3 in_pos;\n"
|
||||
|
||||
"VSOUT vec4 v_color;\n"
|
||||
|
@ -19,7 +21,7 @@ const char *leedsBuilding_vert_src =
|
|||
|
||||
" v_color = in_color;\n"
|
||||
" v_color.rgb *= u_amb.rgb;\n"
|
||||
" v_color.rgb += u_emiss.rgb;\n"
|
||||
" v_color.rgb += u_emiss.rgb*surfEmissive;\n"
|
||||
" v_color = clamp(v_color, 0.0, 1.0);\n"
|
||||
" v_color.a *= u_matColor.a;\n"
|
||||
|
||||
|
|
|
@ -347,8 +347,6 @@ enum {
|
|||
PASS_BLEND // normal blend
|
||||
};
|
||||
|
||||
static RwRGBAReal black;
|
||||
|
||||
static void
|
||||
SetStencilState(int state)
|
||||
{
|
||||
|
@ -377,314 +375,6 @@ SetStencilState(int state)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef RW_D3D9
|
||||
struct BuildingInst
|
||||
{
|
||||
rw::RawMatrix combinedMat;
|
||||
rw::d3d9::InstanceDataHeader *instHeader;
|
||||
uint8 fadeAlpha;
|
||||
bool lighting;
|
||||
};
|
||||
static BuildingInst blendInsts[3][2000];
|
||||
static int numBlendInsts[3];
|
||||
|
||||
static void
|
||||
SetMatrix(BuildingInst *building, rw::Matrix *worldMat)
|
||||
{
|
||||
using namespace rw;
|
||||
RawMatrix world, worldview;
|
||||
Camera *cam = engine->currentCamera;
|
||||
convMatrix(&world, worldMat);
|
||||
RawMatrix::mult(&worldview, &world, &cam->devView);
|
||||
RawMatrix::mult(&building->combinedMat, &worldview, &cam->devProj);
|
||||
}
|
||||
|
||||
static bool
|
||||
IsTextureTransparent(RwTexture *tex)
|
||||
{
|
||||
if(tex == nil || tex->raster == nil)
|
||||
return false;
|
||||
return PLUGINOFFSET(rw::d3d::D3dRaster, tex->raster, rw::d3d::nativeRasterOffset)->hasAlpha;
|
||||
}
|
||||
|
||||
// Render all opaque meshes and put atomics that needs blending
|
||||
// into the deferred list.
|
||||
static void
|
||||
AtomicFirstPass(RpAtomic *atomic, int pass)
|
||||
{
|
||||
using namespace rw;
|
||||
using namespace rw::d3d;
|
||||
using namespace rw::d3d9;
|
||||
|
||||
BuildingInst *building = &blendInsts[pass][numBlendInsts[pass]];
|
||||
|
||||
atomic->getPipeline()->instance(atomic);
|
||||
building->instHeader = (d3d9::InstanceDataHeader*)atomic->geometry->instData;
|
||||
assert(building->instHeader != nil);
|
||||
assert(building->instHeader->platform == PLATFORM_D3D9);
|
||||
building->fadeAlpha = 255;
|
||||
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
|
||||
|
||||
bool setupDone = false;
|
||||
bool defer = false;
|
||||
SetMatrix(building, atomic->getFrame()->getLTM());
|
||||
|
||||
InstanceData *inst = building->instHeader->inst;
|
||||
for(rw::uint32 i = 0; i < building->instHeader->numMeshes; i++, inst++){
|
||||
Material *m = inst->material;
|
||||
|
||||
if(inst->vertexAlpha || m->color.alpha != 255 ||
|
||||
IsTextureTransparent(m->texture)){
|
||||
defer = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// alright we're rendering this atomic
|
||||
if(!setupDone){
|
||||
setStreamSource(0, building->instHeader->vertexStream[0].vertexBuffer, 0, building->instHeader->vertexStream[0].stride);
|
||||
setIndices(building->instHeader->indexBuffer);
|
||||
setVertexDeclaration(building->instHeader->vertexDeclaration);
|
||||
setVertexShader(default_amb_VS);
|
||||
d3ddevice->SetVertexShaderConstantF(VSLOC_combined, (float*)&building->combinedMat, 4);
|
||||
if(building->lighting)
|
||||
setAmbient(pAmbient->color);
|
||||
else
|
||||
setAmbient(black);
|
||||
setupDone = true;
|
||||
}
|
||||
|
||||
setMaterial(m->color, m->surfaceProps);
|
||||
|
||||
if(m->texture){
|
||||
d3d::setTexture(0, m->texture);
|
||||
setPixelShader(default_tex_PS);
|
||||
}else
|
||||
setPixelShader(default_PS);
|
||||
|
||||
drawInst(building->instHeader, inst);
|
||||
}
|
||||
if(defer)
|
||||
numBlendInsts[pass]++;
|
||||
}
|
||||
|
||||
static void
|
||||
AtomicFullyTransparent(RpAtomic *atomic, int pass, int fadeAlpha)
|
||||
{
|
||||
using namespace rw;
|
||||
using namespace rw::d3d;
|
||||
using namespace rw::d3d9;
|
||||
|
||||
BuildingInst *building = &blendInsts[pass][numBlendInsts[pass]];
|
||||
|
||||
atomic->getPipeline()->instance(atomic);
|
||||
building->instHeader = (d3d9::InstanceDataHeader*)atomic->geometry->instData;
|
||||
assert(building->instHeader != nil);
|
||||
assert(building->instHeader->platform == PLATFORM_D3D9);
|
||||
building->fadeAlpha = fadeAlpha;
|
||||
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
|
||||
SetMatrix(building, atomic->getFrame()->getLTM());
|
||||
numBlendInsts[pass]++;
|
||||
}
|
||||
|
||||
static void
|
||||
RenderBlendPass(int pass)
|
||||
{
|
||||
using namespace rw;
|
||||
using namespace rw::d3d;
|
||||
using namespace rw::d3d9;
|
||||
|
||||
setVertexShader(default_amb_VS);
|
||||
|
||||
int i;
|
||||
for(i = 0; i < numBlendInsts[pass]; i++){
|
||||
BuildingInst *building = &blendInsts[pass][i];
|
||||
|
||||
setStreamSource(0, building->instHeader->vertexStream[0].vertexBuffer, 0, building->instHeader->vertexStream[0].stride);
|
||||
setIndices(building->instHeader->indexBuffer);
|
||||
setVertexDeclaration(building->instHeader->vertexDeclaration);
|
||||
d3ddevice->SetVertexShaderConstantF(VSLOC_combined, (float*)&building->combinedMat, 4);
|
||||
if(building->lighting)
|
||||
setAmbient(pAmbient->color);
|
||||
else
|
||||
setAmbient(black);
|
||||
|
||||
InstanceData *inst = building->instHeader->inst;
|
||||
for(rw::uint32 j = 0; j < building->instHeader->numMeshes; j++, inst++){
|
||||
Material *m = inst->material;
|
||||
if(!inst->vertexAlpha && m->color.alpha == 255 && !IsTextureTransparent(m->texture) && building->fadeAlpha == 255)
|
||||
continue; // already done this one
|
||||
|
||||
rw::RGBA color = m->color;
|
||||
color.alpha = (color.alpha * building->fadeAlpha)/255;
|
||||
setMaterial(color, m->surfaceProps);
|
||||
|
||||
if(m->texture){
|
||||
d3d::setTexture(0, m->texture);
|
||||
setPixelShader(default_tex_PS);
|
||||
}else
|
||||
setPixelShader(default_PS);
|
||||
|
||||
drawInst(building->instHeader, inst);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef RW_GL3
|
||||
struct BuildingInst
|
||||
{
|
||||
rw::Matrix matrix;
|
||||
rw::gl3::InstanceDataHeader *instHeader;
|
||||
uint8 fadeAlpha;
|
||||
bool lighting;
|
||||
};
|
||||
static BuildingInst blendInsts[3][2000];
|
||||
static int numBlendInsts[3];
|
||||
|
||||
static bool
|
||||
IsTextureTransparent(RwTexture *tex)
|
||||
{
|
||||
if(tex == nil || tex->raster == nil)
|
||||
return false;
|
||||
return PLUGINOFFSET(rw::gl3::Gl3Raster, tex->raster, rw::gl3::nativeRasterOffset)->hasAlpha;
|
||||
}
|
||||
|
||||
// Render all opaque meshes and put atomics that needs blending
|
||||
// into the deferred list.
|
||||
static void
|
||||
AtomicFirstPass(RpAtomic *atomic, int pass)
|
||||
{
|
||||
using namespace rw;
|
||||
using namespace rw::gl3;
|
||||
|
||||
BuildingInst *building = &blendInsts[pass][numBlendInsts[pass]];
|
||||
|
||||
atomic->getPipeline()->instance(atomic);
|
||||
building->instHeader = (gl3::InstanceDataHeader*)atomic->geometry->instData;
|
||||
assert(building->instHeader != nil);
|
||||
assert(building->instHeader->platform == PLATFORM_GL3);
|
||||
building->fadeAlpha = 255;
|
||||
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
|
||||
|
||||
WorldLights lights;
|
||||
lights.numAmbients = 1;
|
||||
lights.numDirectionals = 0;
|
||||
lights.numLocals = 0;
|
||||
if(building->lighting)
|
||||
lights.ambient = pAmbient->color;
|
||||
else
|
||||
lights.ambient = black;
|
||||
|
||||
bool setupDone = false;
|
||||
bool defer = false;
|
||||
building->matrix = *atomic->getFrame()->getLTM();
|
||||
|
||||
InstanceData *inst = building->instHeader->inst;
|
||||
for(rw::uint32 i = 0; i < building->instHeader->numMeshes; i++, inst++){
|
||||
Material *m = inst->material;
|
||||
|
||||
if(inst->vertexAlpha || m->color.alpha != 255 ||
|
||||
IsTextureTransparent(m->texture)){
|
||||
defer = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// alright we're rendering this atomic
|
||||
if(!setupDone){
|
||||
defaultShader->use();
|
||||
setWorldMatrix(&building->matrix);
|
||||
#ifdef RW_GL_USE_VAOS
|
||||
glBindVertexArray(building->instHeader->vao);
|
||||
#else
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, building->instHeader->ibo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, building->instHeader->vbo);
|
||||
setAttribPointers(building->instHeader->attribDesc, building->instHeader->numAttribs);
|
||||
#endif
|
||||
setLights(&lights);
|
||||
setupDone = true;
|
||||
}
|
||||
|
||||
setMaterial(m->color, m->surfaceProps);
|
||||
|
||||
setTexture(0, m->texture);
|
||||
|
||||
drawInst(building->instHeader, inst);
|
||||
}
|
||||
#ifndef RW_GL_USE_VAOS
|
||||
disableAttribPointers(building->instHeader->attribDesc, building->instHeader->numAttribs);
|
||||
#endif
|
||||
if(defer)
|
||||
numBlendInsts[pass]++;
|
||||
}
|
||||
|
||||
static void
|
||||
AtomicFullyTransparent(RpAtomic *atomic, int pass, int fadeAlpha)
|
||||
{
|
||||
using namespace rw;
|
||||
using namespace rw::gl3;
|
||||
|
||||
BuildingInst *building = &blendInsts[pass][numBlendInsts[pass]];
|
||||
|
||||
atomic->getPipeline()->instance(atomic);
|
||||
building->instHeader = (gl3::InstanceDataHeader*)atomic->geometry->instData;
|
||||
assert(building->instHeader != nil);
|
||||
assert(building->instHeader->platform == PLATFORM_GL3);
|
||||
building->fadeAlpha = fadeAlpha;
|
||||
building->lighting = !!(atomic->geometry->flags & rw::Geometry::LIGHT);
|
||||
building->matrix = *atomic->getFrame()->getLTM();
|
||||
numBlendInsts[pass]++;
|
||||
}
|
||||
|
||||
static void
|
||||
RenderBlendPass(int pass)
|
||||
{
|
||||
using namespace rw;
|
||||
using namespace rw::gl3;
|
||||
|
||||
defaultShader->use();
|
||||
WorldLights lights;
|
||||
lights.numAmbients = 1;
|
||||
lights.numDirectionals = 0;
|
||||
lights.numLocals = 0;
|
||||
|
||||
int i;
|
||||
for(i = 0; i < numBlendInsts[pass]; i++){
|
||||
BuildingInst *building = &blendInsts[pass][i];
|
||||
|
||||
#ifdef RW_GL_USE_VAOS
|
||||
glBindVertexArray(building->instHeader->vao);
|
||||
#else
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, building->instHeader->ibo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, building->instHeader->vbo);
|
||||
setAttribPointers(building->instHeader->attribDesc, building->instHeader->numAttribs);
|
||||
#endif
|
||||
setWorldMatrix(&building->matrix);
|
||||
if(building->lighting)
|
||||
lights.ambient = pAmbient->color;
|
||||
else
|
||||
lights.ambient = black;
|
||||
setLights(&lights);
|
||||
|
||||
InstanceData *inst = building->instHeader->inst;
|
||||
for(rw::uint32 j = 0; j < building->instHeader->numMeshes; j++, inst++){
|
||||
Material *m = inst->material;
|
||||
if(!inst->vertexAlpha && m->color.alpha == 255 && !IsTextureTransparent(m->texture) && building->fadeAlpha == 255)
|
||||
continue; // already done this one
|
||||
|
||||
rw::RGBA color = m->color;
|
||||
color.alpha = (color.alpha * building->fadeAlpha)/255;
|
||||
setMaterial(color, m->surfaceProps);
|
||||
|
||||
setTexture(0, m->texture);
|
||||
|
||||
drawInst(building->instHeader, inst);
|
||||
}
|
||||
#ifndef RW_GL_USE_VAOS
|
||||
disableAttribPointers(building->instHeader->attribDesc, building->instHeader->numAttribs);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
CRenderer::RenderOneBuilding(CEntity *ent, float camdist)
|
||||
{
|
||||
|
@ -715,16 +405,16 @@ CRenderer::RenderOneBuilding(CEntity *ent, float camdist)
|
|||
alpha = mi->m_alpha * fadefactor;
|
||||
|
||||
if(alpha == 255)
|
||||
AtomicFirstPass(atomic, pass);
|
||||
WorldRender::AtomicFirstPass(atomic, pass);
|
||||
else{
|
||||
// not quite sure what this is about, do we have to do that?
|
||||
RpGeometry *geo = RpAtomicGetGeometry(lodatm);
|
||||
if(geo != RpAtomicGetGeometry(atomic))
|
||||
RpAtomicSetGeometry(atomic, geo, rpATOMICSAMEBOUNDINGSPHERE);
|
||||
AtomicFullyTransparent(atomic, pass, alpha);
|
||||
WorldRender::AtomicFullyTransparent(atomic, pass, alpha);
|
||||
}
|
||||
}else
|
||||
AtomicFirstPass(atomic, pass);
|
||||
WorldRender::AtomicFirstPass(atomic, pass);
|
||||
|
||||
ent->bImBeingRendered = false; // TODO: this seems wrong, but do we even need it?
|
||||
}
|
||||
|
@ -779,16 +469,16 @@ CRenderer::RenderWorld(int pass)
|
|||
|
||||
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
|
||||
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, FALSE);
|
||||
RenderBlendPass(PASS_NOZ);
|
||||
WorldRender::RenderBlendPass(PASS_NOZ);
|
||||
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
|
||||
break;
|
||||
case 2:
|
||||
// Transparent
|
||||
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
|
||||
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
|
||||
RenderBlendPass(PASS_ADD);
|
||||
WorldRender::RenderBlendPass(PASS_ADD);
|
||||
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
|
||||
RenderBlendPass(PASS_BLEND);
|
||||
WorldRender::RenderBlendPass(PASS_BLEND);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -872,9 +562,9 @@ CRenderer::ClearForFrame(void)
|
|||
ms_nNoOfInVisibleEntities = 0;
|
||||
gSortedVehiclesAndPeds.Clear();
|
||||
|
||||
numBlendInsts[PASS_NOZ] = 0;
|
||||
numBlendInsts[PASS_ADD] = 0;
|
||||
numBlendInsts[PASS_BLEND] = 0;
|
||||
WorldRender::numBlendInsts[PASS_NOZ] = 0;
|
||||
WorldRender::numBlendInsts[PASS_ADD] = 0;
|
||||
WorldRender::numBlendInsts[PASS_BLEND] = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
2
vendor/librw
vendored
2
vendor/librw
vendored
|
@ -1 +1 @@
|
|||
Subproject commit ed9cb45ee9a2749a0a89231bf16f09a5c53bfc92
|
||||
Subproject commit 78d540fce0ca090b07377cee40d73eadfb7a699d
|
Loading…
Reference in a new issue