summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/main.cpp5
-rw-r--r--src/core/re3.cpp16
-rw-r--r--src/extras/custompipes.cpp5
-rw-r--r--src/extras/custompipes.h3
-rw-r--r--src/extras/custompipes_d3d9.cpp139
-rw-r--r--src/extras/custompipes_gl.cpp141
-rw-r--r--src/extras/shaders/Makefile18
-rw-r--r--src/extras/shaders/leedsVehicle.vert27
-rw-r--r--src/extras/shaders/leedsVehicle_VS.csobin0 -> 1204 bytes
-rw-r--r--src/extras/shaders/leedsVehicle_VS.hlsl45
-rw-r--r--src/extras/shaders/leedsVehicle_VS.inc103
-rw-r--r--src/extras/shaders/leedsVehicle_add.frag32
-rw-r--r--src/extras/shaders/leedsVehicle_add_PS.csobin0 -> 496 bytes
-rw-r--r--src/extras/shaders/leedsVehicle_add_PS.hlsl34
-rw-r--r--src/extras/shaders/leedsVehicle_add_PS.inc44
-rw-r--r--src/extras/shaders/leedsVehicle_add_gl.inc34
-rw-r--r--src/extras/shaders/leedsVehicle_blend.frag32
-rw-r--r--src/extras/shaders/leedsVehicle_blend_PS.csobin0 -> 572 bytes
-rw-r--r--src/extras/shaders/leedsVehicle_blend_PS.hlsl33
-rw-r--r--src/extras/shaders/leedsVehicle_blend_PS.inc50
-rw-r--r--src/extras/shaders/leedsVehicle_blend_gl.inc34
-rw-r--r--src/extras/shaders/leedsVehicle_vs_gl.inc29
-rw-r--r--src/render/Renderer.cpp185
-rw-r--r--src/render/Renderer.h2
24 files changed, 991 insertions, 20 deletions
diff --git a/src/core/main.cpp b/src/core/main.cpp
index ea6f25ec..03a7fcc2 100644
--- a/src/core/main.cpp
+++ b/src/core/main.cpp
@@ -1159,6 +1159,8 @@ if(gbRenderWorld1)
if(gbRenderRoads)
CRenderer::RenderRoads();
+ CRenderer::GenerateEnvironmentMap(); // should be after static shadows, but that's weird
+
CRenderer::RenderPeds();
// not sure where to put these since LCS has no underwater entities
@@ -1172,7 +1174,7 @@ if(gbRenderWater)
if(gbRenderEverythingBarRoads)
CRenderer::RenderEverythingBarRoads();
- // get env map here?
+ // seam fixer
// moved this:
// CRenderer::RenderFadingInEntities();
}
@@ -1195,7 +1197,6 @@ void
RenderEffects_new(void)
{
CShadows::RenderStaticShadows();
- // CRenderer::GenerateEnvironmentMap
CShadows::RenderStoredShadows();
CSkidmarks::Render();
CRubbish::Render();
diff --git a/src/core/re3.cpp b/src/core/re3.cpp
index 3a5488d1..65bb61b4 100644
--- a/src/core/re3.cpp
+++ b/src/core/re3.cpp
@@ -578,22 +578,19 @@ DebugMenuPopulate(void)
DebugMenuAddCmd("Spawn", "Spawn Stinger", [](){ SpawnCar(MI_STINGER); });
DebugMenuAddCmd("Spawn", "Spawn Infernus", [](){ SpawnCar(MI_INFERNUS); });
DebugMenuAddCmd("Spawn", "Spawn Cheetah", [](){ SpawnCar(MI_CHEETAH); });
- DebugMenuAddCmd("Spawn", "Spawn Phoenix", [](){ SpawnCar(MI_PHEONIX); });
+ DebugMenuAddCmd("Spawn", "Spawn Esprit", [](){ SpawnCar(MI_ESPRIT); });
DebugMenuAddCmd("Spawn", "Spawn Banshee", [](){ SpawnCar(MI_BANSHEE); });
DebugMenuAddCmd("Spawn", "Spawn Esperanto", [](){ SpawnCar(MI_ESPERANT); });
DebugMenuAddCmd("Spawn", "Spawn Stallion", [](){ SpawnCar(MI_STALLION); });
- DebugMenuAddCmd("Spawn", "Spawn Admiral", [](){ SpawnCar(MI_ADMIRAL); });
- DebugMenuAddCmd("Spawn", "Spawn Washington", [](){ SpawnCar(MI_WASHING); });
+ DebugMenuAddCmd("Spawn", "Spawn Mafia", [](){ SpawnCar(MI_MAFIA); });
+ DebugMenuAddCmd("Spawn", "Spawn Kuruma", [](){ SpawnCar(MI_KURUMA); });
DebugMenuAddCmd("Spawn", "Spawn Taxi", [](){ SpawnCar(MI_TAXI); });
DebugMenuAddCmd("Spawn", "Spawn Police", [](){ SpawnCar(MI_POLICE); });
DebugMenuAddCmd("Spawn", "Spawn Enforcer", [](){ SpawnCar(MI_ENFORCER); });
- DebugMenuAddCmd("Spawn", "Spawn Cuban", [](){ SpawnCar(MI_CUBAN); });
- DebugMenuAddCmd("Spawn", "Spawn Voodoo", [](){ SpawnCar(MI_VOODOO); });
+ DebugMenuAddCmd("Spawn", "Spawn Diablo", [](){ SpawnCar(MI_DIABLOS); });
+ DebugMenuAddCmd("Spawn", "Spawn Yardie", [](){ SpawnCar(MI_YARDIE); });
DebugMenuAddCmd("Spawn", "Spawn BF injection", [](){ SpawnCar(MI_BFINJECT); });
DebugMenuAddCmd("Spawn", "Spawn Maverick", [](){ SpawnCar(MI_MAVERICK); });
- DebugMenuAddCmd("Spawn", "Spawn VCN Maverick", [](){ SpawnCar(MI_VCNMAV); });
- DebugMenuAddCmd("Spawn", "Spawn Sparrow", [](){ SpawnCar(MI_SPARROW); });
- DebugMenuAddCmd("Spawn", "Spawn Sea Sparrow", [](){ SpawnCar(MI_SEASPAR); });
DebugMenuAddCmd("Spawn", "Spawn Hunter", [](){ SpawnCar(MI_HUNTER); });
DebugMenuAddCmd("Spawn", "Spawn Rhino", [](){ SpawnCar(MI_RHINO); });
DebugMenuAddCmd("Spawn", "Spawn Firetruck", [](){ SpawnCar(MI_FIRETRUCK); });
@@ -601,8 +598,6 @@ DebugMenuPopulate(void)
DebugMenuAddCmd("Spawn", "Spawn PCJ 600", [](){ SpawnCar(MI_PCJ600); });
DebugMenuAddCmd("Spawn", "Spawn Faggio", [](){ SpawnCar(MI_FAGGIO); });
DebugMenuAddCmd("Spawn", "Spawn Freeway", [](){ SpawnCar(MI_FREEWAY); });
- DebugMenuAddCmd("Spawn", "Spawn Squalo", [](){ SpawnCar(MI_SQUALO); });
- DebugMenuAddCmd("Spawn", "Spawn Skimmer", [](){ SpawnCar(MI_SKIMMER); });
DebugMenuAddVarBool8("Render", "Draw hud", &CHud::m_Wants_To_Draw_Hud, nil);
DebugMenuAddVarBool8("Render", "Backface Culling", &gBackfaceCulling, nil);
@@ -651,6 +646,7 @@ extern bool gbRenderWorld2;
e = DebugMenuAddVar("Render", "Vehicle Pipeline", &CustomPipes::VehiclePipeSwitch, nil,
1, CustomPipes::VEHICLEPIPE_MATFX, CustomPipes::VEHICLEPIPE_NEO, vehpipenames);
DebugMenuEntrySetWrap(e, true);
+ DebugMenuAddVarBool8("Render", "Chrome cheat", &CustomPipes::bChromeCheat, nil);
DebugMenuAddVar("Render", "Neo Vehicle Shininess", &CustomPipes::VehicleShininess, nil, 0.1f, 0, 1.0f);
DebugMenuAddVar("Render", "Neo Vehicle Specularity", &CustomPipes::VehicleSpecularity, nil, 0.1f, 0, 1.0f);
DebugMenuAddVarBool8("Render", "Neo Ped Rim light enable", &CustomPipes::RimlightEnable, nil);
diff --git a/src/extras/custompipes.cpp b/src/extras/custompipes.cpp
index 2cecf1c0..f7f8bbe5 100644
--- a/src/extras/custompipes.cpp
+++ b/src/extras/custompipes.cpp
@@ -46,13 +46,14 @@ CustomMatCopy(void *dst, void *src, int32, int32)
rw::TexDictionary *neoTxd;
+bool bChromeCheat;
bool bRenderingEnvMap;
int32 EnvMapSize = 128;
rw::Camera *EnvMapCam;
rw::Texture *EnvMapTex;
rw::Texture *EnvMaskTex;
-static rw::RWDEVICE::Im2DVertex EnvScreenQuad[4];
-static int16 QuadIndices[6] = { 0, 1, 2, 0, 2, 3 };
+rw::RWDEVICE::Im2DVertex EnvScreenQuad[4];
+int16 QuadIndices[6] = { 0, 1, 2, 0, 2, 3 };
static rw::Camera*
CreateEnvMapCam(rw::World *world)
diff --git a/src/extras/custompipes.h b/src/extras/custompipes.h
index f9181fe9..aed34520 100644
--- a/src/extras/custompipes.h
+++ b/src/extras/custompipes.h
@@ -75,11 +75,14 @@ void CustomPipeInit(void);
void CustomPipeShutdown(void);
void SetTxdFindCallback(void);
+extern bool bChromeCheat;
extern bool bRenderingEnvMap;
extern int32 EnvMapSize;
extern rw::Camera *EnvMapCam;
extern rw::Texture *EnvMapTex;
extern rw::Texture *EnvMaskTex;
+extern rw::RWDEVICE::Im2DVertex EnvScreenQuad[4];
+extern int16 QuadIndices[6];
void EnvMapRender(void);
enum {
diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp
index 993a64ce..2483bb30 100644
--- a/src/extras/custompipes_d3d9.cpp
+++ b/src/extras/custompipes_d3d9.cpp
@@ -4,6 +4,8 @@
#ifdef RW_D3D9
#ifdef EXTENDED_PIPELINES
+#include "rpmatfx.h"
+
#include "main.h"
#include "RwHelper.h"
#include "Lights.h"
@@ -42,13 +44,112 @@ enum {
VSLOC_emissive = rw::d3d::VSLOC_afterLights,
VSLOC_ambient,
- PSLOC_colorscale = 1
+ PSLOC_colorscale = 1,
+
+ // Leed vehicle
+ VSLOC_texMat = rw::d3d::VSLOC_afterLights,
+
+ PSLOC_shininess = 1,
+
};
/*
- * Neo Vehicle pipe
+ * Leeds & Neo Vehicle pipe
*/
+static void *leedsVehicle_VS;
+static void *leedsVehicle_blend_PS;
+static void *leedsVehicle_add_PS;
+
+static rw::RawMatrix normal2texcoord_flipU = {
+ { -0.5f, 0.0f, 0.0f }, 0.0f,
+ { 0.0f, -0.5f, 0.0f }, 0.0f,
+ { 0.0f, 0.0f, 1.0f }, 0.0f,
+ { 0.5f, 0.5f, 0.0f }, 1.0f
+};
+
+void
+uploadEnvMatrix(rw::Frame *frame)
+{
+ using namespace rw;
+ Matrix invMat;
+ if(frame == nil)
+ frame = engine->currentCamera->getFrame();
+
+ RawMatrix envMtx, invMtx;
+ Matrix tmp = *frame->getLTM();
+ // Now the weird part: we remove the camera pitch
+ tmp.at.z = 0.0f;
+ tmp.at = normalize(tmp.at);
+ tmp.right.x = -tmp.at.y;
+ tmp.right.y = tmp.at.x;
+ tmp.right.z = 0.0f;;
+ tmp.up.set(0.0f, 0.0f, 1.0f);
+ tmp.pos.set(0.0f, 0.0f, 0.0f);
+ tmp.flags = Matrix::TYPEORTHONORMAL;
+
+ Matrix::invert(&invMat, &tmp);
+ convMatrix(&invMtx, &invMat);
+ RawMatrix::mult(&envMtx, &invMtx, &normal2texcoord_flipU);
+ d3d::d3ddevice->SetVertexShaderConstantF(VSLOC_texMat, (float*)&envMtx, 4);
+}
+
+void
+leedsVehicleRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header)
+{
+ using namespace rw;
+ 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);
+
+ vsBits = lightingCB_Shader(atomic);
+ uploadMatrices(atomic->getFrame()->getLTM());
+
+ setVertexShader(leedsVehicle_VS);
+ if(bChromeCheat)
+ setPixelShader(leedsVehicle_blend_PS);
+ else
+ setPixelShader(leedsVehicle_add_PS);
+
+ d3d::setTexture(1, EnvMapTex);
+ uploadEnvMatrix(nil);
+
+ SetRenderState(SRCBLEND, BLENDONE);
+
+ InstanceData *inst = header->inst;
+ for(rw::uint32 i = 0; i < header->numMeshes; i++){
+ Material *m = inst->material;
+
+ SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 255);
+
+ float coef = 0.0f;
+ if(RpMatFXMaterialGetEffects(m) == rpMATFXEFFECTENVMAP)
+ coef = RpMatFXMaterialGetEnvMapCoefficient(m);
+ coef *= 0.5f;
+ if(bChromeCheat && coef > 0.0f)
+ coef = 1.0f;
+ d3ddevice->SetPixelShaderConstantF(PSLOC_shininess, (float*)&coef, 1);
+
+ setMaterial(m->color, m->surfaceProps);
+
+ if(m->texture)
+ d3d::setTexture(0, m->texture);
+ else
+ d3d::setTexture(0, gpWhiteTexture);
+
+ drawInst(header, inst);
+ inst++;
+ }
+
+ d3d::setTexture(1, nil);
+
+ SetRenderState(SRCBLEND, BLENDSRCALPHA);
+}
+
static void *neoVehicle_VS;
static void *neoVehicle_PS;
@@ -90,7 +191,8 @@ vehicleRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header)
// TODO: make this less of a kludge
if(VehiclePipeSwitch == VEHICLEPIPE_MATFX){
- matFXGlobals.pipelines[rw::platform]->render(atomic);
+ leedsVehicleRenderCB(atomic, header);
+ // matFXGlobals.pipelines[rw::platform]->render(atomic);
return;
}
@@ -164,6 +266,18 @@ CreateVehiclePipe(void)
neoVehicle_PS = rw::d3d::createPixelShader(neoVehicle_PS_cso);
assert(neoVehicle_PS);
+#include "shaders/leedsVehicle_VS.inc"
+ leedsVehicle_VS = rw::d3d::createVertexShader(leedsVehicle_VS_cso);
+ assert(leedsVehicle_VS);
+
+#include "shaders/leedsVehicle_blend_PS.inc"
+ leedsVehicle_blend_PS = rw::d3d::createPixelShader(leedsVehicle_blend_PS_cso);
+ assert(leedsVehicle_blend_PS);
+
+#include "shaders/leedsVehicle_add_PS.inc"
+ leedsVehicle_add_PS = rw::d3d::createPixelShader(leedsVehicle_add_PS_cso);
+ assert(leedsVehicle_add_PS);
+
rw::d3d9::ObjPipeline *pipe = rw::d3d9::ObjPipeline::create();
pipe->instanceCB = rw::d3d9::defaultInstanceCB;
@@ -181,6 +295,15 @@ DestroyVehiclePipe(void)
rw::d3d::destroyPixelShader(neoVehicle_PS);
neoVehicle_PS = nil;
+ rw::d3d::destroyVertexShader(leedsVehicle_VS);
+ leedsVehicle_VS = nil;
+
+ rw::d3d::destroyPixelShader(leedsVehicle_blend_PS);
+ leedsVehicle_blend_PS = nil;
+
+ rw::d3d::destroyPixelShader(leedsVehicle_add_PS);
+ leedsVehicle_add_PS = nil;
+
((rw::d3d9::ObjPipeline*)vehiclePipe)->destroy();
vehiclePipe = nil;
}
@@ -688,6 +811,16 @@ RenderBlendPass(int pass)
setVertexShader(CustomPipes::leedsBuilding_VS);
setPixelShader(CustomPipes::scale_PS);
+ 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);
+
float colorscale[4];
colorscale[3] = 1.0f;
diff --git a/src/extras/custompipes_gl.cpp b/src/extras/custompipes_gl.cpp
index 193a4ac6..e9350802 100644
--- a/src/extras/custompipes_gl.cpp
+++ b/src/extras/custompipes_gl.cpp
@@ -3,6 +3,8 @@
#ifdef RW_OPENGL
#ifdef EXTENDED_PIPELINES
+#include "rpmatfx.h"
+
#include "main.h"
#include "RwHelper.h"
#include "Lights.h"
@@ -37,14 +39,126 @@ static int32 u_amb;
static int32 u_emiss;
static int32 u_colorscale;
+static int32 u_texMatrix;
+static int32 u_fxparams;
+
#define U(i) currentShader->uniformLocations[i]
/*
- * Neo Vehicle pipe
+ * Leeds & Neo Vehicle pipe
*/
+rw::gl3::Shader *leedsVehicleShader_add;
+rw::gl3::Shader *leedsVehicleShader_blend;
+
rw::gl3::Shader *neoVehicleShader;
+static rw::RawMatrix normal2texcoord_flipU = {
+ { -0.5f, 0.0f, 0.0f }, 0.0f,
+ { 0.0f, -0.5f, 0.0f }, 0.0f,
+ { 0.0f, 0.0f, 1.0f }, 0.0f,
+ { 0.5f, 0.5f, 0.0f }, 1.0f
+};
+
+static void
+uploadEnvMatrix(rw::Frame *frame)
+{
+ using namespace rw;
+ using namespace rw::gl3;
+
+ Matrix invMat;
+ if(frame == nil)
+ frame = engine->currentCamera->getFrame();
+
+ // cache the matrix across multiple meshes
+ static RawMatrix envMtx;
+// can't do it, frame matrix may change
+// if(frame != lastEnvFrame){
+// lastEnvFrame = frame;
+ {
+
+ Matrix tmp = *frame->getLTM();
+ // Now the weird part: we remove the camera pitch
+ tmp.at.z = 0.0f;
+ tmp.at = normalize(tmp.at);
+ tmp.right.x = -tmp.at.y;
+ tmp.right.y = tmp.at.x;
+ tmp.right.z = 0.0f;;
+ tmp.up.set(0.0f, 0.0f, 1.0f);
+ tmp.pos.set(0.0f, 0.0f, 0.0f);
+ tmp.flags = Matrix::TYPEORTHONORMAL;
+
+ RawMatrix invMtx;
+ Matrix::invert(&invMat, &tmp);
+ convMatrix(&invMtx, &invMat);
+ RawMatrix::mult(&envMtx, &invMtx, &normal2texcoord_flipU);
+ }
+ glUniformMatrix4fv(U(u_texMatrix), 1, GL_FALSE, (float*)&envMtx);
+}
+
+static void
+leedsVehicleRenderCB(rw::Atomic *atomic, rw::gl3::InstanceDataHeader *header)
+{
+ using namespace rw;
+ using namespace rw::gl3;
+
+ Material *m;
+
+ setWorldMatrix(atomic->getFrame()->getLTM());
+ lightingCB(atomic);
+
+#ifdef RW_GL_USE_VAOS
+ glBindVertexArray(header->vao);
+#else
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, header->ibo);
+ glBindBuffer(GL_ARRAY_BUFFER, header->vbo);
+ setAttribPointers(header->attribDesc, header->numAttribs);
+#endif
+
+ InstanceData *inst = header->inst;
+ rw::int32 n = header->numMeshes;
+
+ if(bChromeCheat)
+ leedsVehicleShader_blend->use();
+ else
+ leedsVehicleShader_add->use();
+
+ setTexture(1, EnvMapTex);
+ uploadEnvMatrix(nil);
+
+ SetRenderState(SRCBLEND, BLENDONE);
+
+ while(n--){
+ m = inst->material;
+
+ rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF);
+
+ float coef = 0.0f;
+ if(RpMatFXMaterialGetEffects(m) == rpMATFXEFFECTENVMAP)
+ coef = RpMatFXMaterialGetEnvMapCoefficient(m);
+ coef *= 0.5f;
+ if(bChromeCheat && coef > 0.0f)
+ coef = 1.0f;
+ glUniform1f(U(u_fxparams), coef);
+
+ setMaterial(m->color, m->surfaceProps);
+
+ setTexture(0, m->texture);
+
+ drawInst(header, inst);
+ inst++;
+ }
+
+ setTexture(1, nil);
+
+ SetRenderState(SRCBLEND, BLENDSRCALPHA);
+
+#ifndef RW_GL_USE_VAOS
+ disableAttribPointers(header->attribDesc, header->numAttribs);
+#endif
+}
+
+
static void
uploadSpecLights(void)
{
@@ -85,7 +199,8 @@ vehicleRenderCB(rw::Atomic *atomic, rw::gl3::InstanceDataHeader *header)
// TODO: make this less of a kludge
if(VehiclePipeSwitch == VEHICLEPIPE_MATFX){
- matFXGlobals.pipelines[rw::platform]->render(atomic);
+ leedsVehicleRenderCB(atomic, header);
+// matFXGlobals.pipelines[rw::platform]->render(atomic);
return;
}
@@ -172,6 +287,19 @@ CreateVehiclePipe(void)
assert(neoVehicleShader);
}
+ {
+#include "shaders/leedsVehicle_add_gl.inc"
+#include "shaders/leedsVehicle_blend_gl.inc"
+#include "shaders/leedsVehicle_vs_gl.inc"
+ const char *vs[] = { shaderDecl, header_vert_src, leedsVehicle_vert_src, nil };
+ const char *fs_add[] = { shaderDecl, header_frag_src, leedsVehicle_add_frag_src, nil };
+ const char *fs_blend[] = { shaderDecl, header_frag_src, leedsVehicle_blend_frag_src, nil };
+ leedsVehicleShader_add = Shader::create(vs, fs_add);
+ assert(leedsVehicleShader_add);
+ leedsVehicleShader_blend = Shader::create(vs, fs_blend);
+ assert(leedsVehicleShader_blend);
+ }
+
rw::gl3::ObjPipeline *pipe = rw::gl3::ObjPipeline::create();
pipe->instanceCB = rw::gl3::defaultInstanceCB;
@@ -186,6 +314,12 @@ DestroyVehiclePipe(void)
neoVehicleShader->destroy();
neoVehicleShader = nil;
+ leedsVehicleShader_add->destroy();
+ leedsVehicleShader_add = nil;
+
+ leedsVehicleShader_blend->destroy();
+ leedsVehicleShader_blend = nil;
+
((rw::gl3::ObjPipeline*)vehiclePipe)->destroy();
vehiclePipe = nil;
}
@@ -611,6 +745,9 @@ CustomPipeRegisterGL(void)
u_amb = rw::gl3::registerUniform("u_amb");
u_emiss = rw::gl3::registerUniform("u_emiss");
u_colorscale = rw::gl3::registerUniform("u_colorscale");
+
+ u_texMatrix = rw::gl3::registerUniform("u_texMatrix");
+ u_fxparams = rw::gl3::registerUniform("u_fxparams");
}
diff --git a/src/extras/shaders/Makefile b/src/extras/shaders/Makefile
index 355d71af..7fa0f125 100644
--- a/src/extras/shaders/Makefile
+++ b/src/extras/shaders/Makefile
@@ -4,7 +4,8 @@ all: im2d_gl.inc simple_fs_gl.inc default_UV2_gl.inc \
neoWorldVC_fs_gl.inc neoGloss_vs_gl.inc neoGloss_fs_gl.inc \
neoVehicle_vs_gl.inc neoVehicle_fs_gl.inc \
im2d_UV2_gl.inc screenDroplet_fs_gl.inc \
- leedsBuilding_vs_gl.inc scale_fs_gl.inc
+ leedsBuilding_vs_gl.inc scale_fs_gl.inc \
+ leedsVehicle_vs_gl.inc leedsVehicle_add_gl.inc leedsVehicle_blend_gl.inc
im2d_gl.inc: im2d.vert
(echo 'const char *im2d_vert_src =';\
@@ -87,3 +88,18 @@ scale_fs_gl.inc: scale.frag
(echo 'const char *scale_frag_src =';\
sed 's/..*/"&\\n"/' scale.frag;\
echo ';') >scale_fs_gl.inc
+
+leedsVehicle_vs_gl.inc: leedsVehicle.vert
+ (echo 'const char *leedsVehicle_vert_src =';\
+ sed 's/..*/"&\\n"/' leedsVehicle.vert;\
+ echo ';') >leedsVehicle_vs_gl.inc
+
+leedsVehicle_add_gl.inc: leedsVehicle_add.frag
+ (echo 'const char *leedsVehicle_add_frag_src =';\
+ sed 's/..*/"&\\n"/' leedsVehicle_add.frag;\
+ echo ';') >leedsVehicle_add_gl.inc
+
+leedsVehicle_blend_gl.inc: leedsVehicle_blend.frag
+ (echo 'const char *leedsVehicle_blend_frag_src =';\
+ sed 's/..*/"&\\n"/' leedsVehicle_blend.frag;\
+ echo ';') >leedsVehicle_blend_gl.inc
diff --git a/src/extras/shaders/leedsVehicle.vert b/src/extras/shaders/leedsVehicle.vert
new file mode 100644
index 00000000..b93c7ea0
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle.vert
@@ -0,0 +1,27 @@
+uniform mat4 u_texMatrix;
+
+VSIN(ATTRIB_POS) vec3 in_pos;
+
+VSOUT vec4 v_color;
+VSOUT vec2 v_tex0;
+VSOUT vec2 v_tex1;
+VSOUT float v_fog;
+
+void
+main(void)
+{
+ vec4 Vertex = u_world * vec4(in_pos, 1.0);
+ gl_Position = u_proj * u_view * Vertex;
+ vec3 Normal = mat3(u_world) * in_normal;
+
+ v_tex0 = in_tex0;
+ v_tex1 = (u_texMatrix * vec4(Normal, 1.0)).xy;
+
+ v_color = in_color;
+ v_color.rgb += u_ambLight.rgb*surfAmbient;
+ v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse;
+ v_color = clamp(v_color, 0.0, 1.0);
+ v_color *= u_matColor;
+
+ v_fog = DoFog(gl_Position.w);
+}
diff --git a/src/extras/shaders/leedsVehicle_VS.cso b/src/extras/shaders/leedsVehicle_VS.cso
new file mode 100644
index 00000000..57db3798
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle_VS.cso
Binary files differ
diff --git a/src/extras/shaders/leedsVehicle_VS.hlsl b/src/extras/shaders/leedsVehicle_VS.hlsl
new file mode 100644
index 00000000..eb53313a
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle_VS.hlsl
@@ -0,0 +1,45 @@
+#include "standardConstants.h"
+
+float4x4 texMat : register(c41);
+
+struct VS_in
+{
+ float4 Position : POSITION;
+ float3 Normal : NORMAL;
+ float2 TexCoord : TEXCOORD0;
+ float4 Prelight : COLOR0;
+};
+
+struct VS_out {
+ float4 Position : POSITION;
+ float3 TexCoord0 : TEXCOORD0; // also fog
+ float2 TexCoord1 : TEXCOORD1;
+ float4 Color : COLOR0;
+};
+
+
+VS_out main(in VS_in input)
+{
+ VS_out output;
+
+ output.Position = mul(combinedMat, input.Position);
+ float3 V = mul(worldMat, input.Position).xyz;
+ float3 N = mul(normalMat, input.Normal);
+
+ output.TexCoord0.xy = input.TexCoord;
+ output.TexCoord1 = mul(texMat, float4(N, 1.0)).xy;
+
+ output.Color = input.Prelight;
+ output.Color.rgb += ambientLight.rgb * surfAmbient;
+
+ int i;
+ for(i = 0; i < numDirLights; i++)
+ output.Color.xyz += DoDirLight(lights[i+firstDirLight], N)*surfDiffuse;
+ // PS2 clamps before material color
+ output.Color = clamp(output.Color, 0.0, 1.0);
+ output.Color *= matCol;
+
+ output.TexCoord0.z = clamp((output.Position.w - fogEnd)*fogRange, fogDisable, 1.0);
+
+ return output;
+}
diff --git a/src/extras/shaders/leedsVehicle_VS.inc b/src/extras/shaders/leedsVehicle_VS.inc
new file mode 100644
index 00000000..89527d72
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle_VS.inc
@@ -0,0 +1,103 @@
+static unsigned char leedsVehicle_VS_cso[] = {
+ 0x00, 0x02, 0xfe, 0xff, 0xfe, 0xff, 0x8d, 0x00, 0x43, 0x54, 0x41, 0x42,
+ 0x1c, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x00, 0x02, 0xfe, 0xff,
+ 0x0a, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0xf5, 0x01, 0x00, 0x00, 0xe4, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0f, 0x00,
+ 0x01, 0x00, 0x3e, 0x00, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x04, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00,
+ 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00,
+ 0x02, 0x00, 0x10, 0x00, 0x01, 0x00, 0x42, 0x00, 0x2c, 0x01, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x3c, 0x01, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00,
+ 0x01, 0x00, 0x3a, 0x00, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x44, 0x01, 0x00, 0x00, 0x02, 0x00, 0x11, 0x00, 0x18, 0x00, 0x46, 0x00,
+ 0x90, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x01, 0x00, 0x00,
+ 0x02, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x32, 0x00, 0xf4, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xa7, 0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00,
+ 0x03, 0x00, 0x22, 0x00, 0xb4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc4, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00,
+ 0xd4, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x01, 0x00, 0x00,
+ 0x02, 0x00, 0x0d, 0x00, 0x01, 0x00, 0x36, 0x00, 0xf4, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xee, 0x01, 0x00, 0x00, 0x02, 0x00, 0x29, 0x00,
+ 0x04, 0x00, 0xa6, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x61, 0x6d, 0x62, 0x69, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x67, 0x68, 0x74,
+ 0x00, 0xab, 0xab, 0xab, 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,
+ 0x66, 0x69, 0x72, 0x73, 0x74, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x00, 0xab,
+ 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x66, 0x6f, 0x67, 0x44, 0x61, 0x74, 0x61, 0x00,
+ 0x6c, 0x69, 0x67, 0x68, 0x74, 0x73, 0x00, 0x63, 0x6f, 0x6c, 0x6f, 0x72,
+ 0x00, 0xab, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x6f, 0x73, 0x69,
+ 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x00, 0xab, 0x4b, 0x01, 0x00, 0x00, 0x54, 0x01, 0x00, 0x00,
+ 0x64, 0x01, 0x00, 0x00, 0x54, 0x01, 0x00, 0x00, 0x6d, 0x01, 0x00, 0x00,
+ 0x54, 0x01, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0c, 0x00,
+ 0x08, 0x00, 0x03, 0x00, 0x78, 0x01, 0x00, 0x00, 0x6d, 0x61, 0x74, 0x43,
+ 0x6f, 0x6c, 0x00, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x4d, 0x61, 0x74,
+ 0x00, 0xab, 0xab, 0xab, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00, 0x03, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0x75, 0x6d, 0x44,
+ 0x69, 0x72, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x73, 0x00, 0xab, 0xab, 0xab,
+ 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x73, 0x75, 0x72, 0x66, 0x50, 0x72, 0x6f, 0x70,
+ 0x73, 0x00, 0x74, 0x65, 0x78, 0x4d, 0x61, 0x74, 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, 0xab, 0x51, 0x00, 0x00, 0x05,
+ 0x04, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40,
+ 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02,
+ 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02,
+ 0x03, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02,
+ 0x05, 0x00, 0x00, 0x80, 0x02, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02,
+ 0x0a, 0x00, 0x00, 0x80, 0x03, 0x00, 0x0f, 0x90, 0x05, 0x00, 0x00, 0x03,
+ 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x55, 0x90, 0x01, 0x00, 0xe4, 0xa0,
+ 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0,
+ 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04,
+ 0x00, 0x00, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0xaa, 0x90,
+ 0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80,
+ 0x03, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0xff, 0x90, 0x00, 0x00, 0xe4, 0x80,
+ 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0xe4, 0x80,
+ 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x07, 0x80, 0x01, 0x00, 0x55, 0x90,
+ 0x09, 0x00, 0xe4, 0xa0, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07, 0x80,
+ 0x08, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x90, 0x00, 0x00, 0xe4, 0x80,
+ 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07, 0x80, 0x0a, 0x00, 0xe4, 0xa0,
+ 0x01, 0x00, 0xaa, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x02,
+ 0x01, 0x00, 0x01, 0x80, 0x0d, 0x00, 0x00, 0xa0, 0x04, 0x00, 0x00, 0x04,
+ 0x01, 0x00, 0x07, 0x80, 0x0f, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x80,
+ 0x03, 0x00, 0xe4, 0x90, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x07, 0x80,
+ 0x01, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, 0x08, 0x80,
+ 0x04, 0x00, 0x00, 0xa0, 0x26, 0x00, 0x00, 0x01, 0x00, 0x00, 0xe4, 0xf0,
+ 0x02, 0x00, 0x00, 0x03, 0x03, 0x00, 0x01, 0x80, 0x01, 0x00, 0xff, 0x80,
+ 0x10, 0x00, 0x00, 0xa0, 0x05, 0x00, 0x00, 0x03, 0x03, 0x00, 0x01, 0x80,
+ 0x03, 0x00, 0x00, 0x80, 0x04, 0x00, 0x55, 0xa0, 0x2e, 0x00, 0x00, 0x02,
+ 0x00, 0x00, 0x01, 0xb0, 0x03, 0x00, 0x00, 0x80, 0x08, 0x00, 0x00, 0x04,
+ 0x03, 0x00, 0x01, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x13, 0x20, 0xe4, 0xa1,
+ 0x00, 0x00, 0x00, 0xb0, 0x0b, 0x00, 0x00, 0x03, 0x03, 0x00, 0x01, 0x80,
+ 0x03, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0xa0, 0x05, 0x00, 0x00, 0x04,
+ 0x03, 0x00, 0x07, 0x80, 0x03, 0x00, 0x00, 0x80, 0x11, 0x20, 0xe4, 0xa0,
+ 0x00, 0x00, 0x00, 0xb0, 0x04, 0x00, 0x00, 0x04, 0x02, 0x00, 0x07, 0x80,
+ 0x03, 0x00, 0xe4, 0x80, 0x0d, 0x00, 0xaa, 0xa0, 0x02, 0x00, 0xe4, 0x80,
+ 0x02, 0x00, 0x00, 0x03, 0x01, 0x00, 0x08, 0x80, 0x01, 0x00, 0xff, 0x80,
+ 0x04, 0x00, 0xaa, 0xa0, 0x27, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02,
+ 0x02, 0x00, 0x08, 0x80, 0x03, 0x00, 0xff, 0x90, 0x0b, 0x00, 0x00, 0x03,
+ 0x01, 0x00, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0xa0,
+ 0x0a, 0x00, 0x00, 0x03, 0x01, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0x80,
+ 0x04, 0x00, 0xaa, 0xa0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0xd0,
+ 0x01, 0x00, 0xe4, 0x80, 0x0c, 0x00, 0xe4, 0xa0, 0x05, 0x00, 0x00, 0x03,
+ 0x01, 0x00, 0x03, 0x80, 0x00, 0x00, 0x55, 0x80, 0x2a, 0x00, 0xe4, 0xa0,
+ 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x80, 0x29, 0x00, 0xe4, 0xa0,
+ 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04,
+ 0x00, 0x00, 0x03, 0x80, 0x2b, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0xaa, 0x80,
+ 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, 0x00, 0x03, 0x01, 0x00, 0x03, 0xe0,
+ 0x00, 0x00, 0xe4, 0x80, 0x2c, 0x00, 0xe4, 0xa0, 0x02, 0x00, 0x00, 0x03,
+ 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0xff, 0x80, 0x0e, 0x00, 0x55, 0xa1,
+ 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x80,
+ 0x0e, 0x00, 0xaa, 0xa0, 0x0b, 0x00, 0x00, 0x03, 0x00, 0x00, 0x01, 0x80,
+ 0x00, 0x00, 0x00, 0x80, 0x0e, 0x00, 0xff, 0xa0, 0x0a, 0x00, 0x00, 0x03,
+ 0x00, 0x00, 0x04, 0xe0, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0xaa, 0xa0,
+ 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x03, 0xe0, 0x02, 0x00, 0xe4, 0x90,
+ 0xff, 0xff, 0x00, 0x00
+};
diff --git a/src/extras/shaders/leedsVehicle_add.frag b/src/extras/shaders/leedsVehicle_add.frag
new file mode 100644
index 00000000..e9bcef74
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle_add.frag
@@ -0,0 +1,32 @@
+uniform sampler2D tex0;
+uniform sampler2D tex1;
+
+uniform float u_fxparams;
+
+#define shininess (u_fxparams)
+
+FSIN vec4 v_color;
+FSIN vec2 v_tex0;
+FSIN vec2 v_tex1;
+FSIN float v_fog;
+
+void
+main(void)
+{
+ vec4 pass1 = v_color*texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));
+ vec4 pass2 = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y));
+ pass2.a *= shininess;
+
+ pass1.rgb = mix(u_fogColor.rgb, pass1.rgb, v_fog);
+ pass2.rgb = mix(vec3(0.0, 0.0, 0.0), pass2.rgb, v_fog);
+
+ // We simulate drawing this in two passes.
+ // We premultiply alpha so render state should be one.
+ vec4 color;
+ color.rgb = pass1.rgb*pass1.a + pass2.rgb*pass2.a;
+ color.a = pass1.a;
+
+ DoAlphaTest(color.a);
+
+ FRAGCOLOR(color);
+}
diff --git a/src/extras/shaders/leedsVehicle_add_PS.cso b/src/extras/shaders/leedsVehicle_add_PS.cso
new file mode 100644
index 00000000..11db8b0e
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle_add_PS.cso
Binary files differ
diff --git a/src/extras/shaders/leedsVehicle_add_PS.hlsl b/src/extras/shaders/leedsVehicle_add_PS.hlsl
new file mode 100644
index 00000000..943926cf
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle_add_PS.hlsl
@@ -0,0 +1,34 @@
+struct VS_out {
+ float4 Position : POSITION;
+ float3 TexCoord0 : TEXCOORD0;
+ float2 TexCoord1 : TEXCOORD1;
+ float4 Color : COLOR0;
+};
+
+sampler2D diffTex : register(s0);
+sampler2D envTex : register(s1);
+
+float4 fogColor : register(c0);
+
+float4 fxparams : register(c1);
+
+#define shininess (fxparams.x)
+
+float4 main(VS_out input) : COLOR
+{
+ float4 pass1 = input.Color*tex2D(diffTex, input.TexCoord0.xy);
+ float4 pass2 = tex2D(envTex, input.TexCoord1.xy);
+ pass2.a *= shininess;
+
+ pass1.rgb = lerp(fogColor.rgb, pass1.rgb, input.TexCoord0.z);
+ pass2.rgb = lerp(float3(0.0, 0.0, 0.0), pass2.rgb, input.TexCoord0.z);
+
+ // We simulate drawing this in two passes.
+ // First pass with standard blending, second with addition
+ // We premultiply alpha so render state should be one.
+ float4 color;
+ color.rgb = pass1.rgb*pass1.a + pass2.rgb*pass2.a;
+ color.a = pass1.a;
+
+ return color;
+}
diff --git a/src/extras/shaders/leedsVehicle_add_PS.inc b/src/extras/shaders/leedsVehicle_add_PS.inc
new file mode 100644
index 00000000..dc8378f4
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle_add_PS.inc
@@ -0,0 +1,44 @@
+static unsigned char leedsVehicle_add_PS_cso[] = {
+ 0x00, 0x02, 0xff, 0xff, 0xfe, 0xff, 0x40, 0x00, 0x43, 0x54, 0x41, 0x42,
+ 0x1c, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xff,
+ 0x04, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0xc1, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x02, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x84, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x01, 0x00, 0x06, 0x00,
+ 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0xa8, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,
+ 0x01, 0x00, 0x06, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x64, 0x69, 0x66, 0x66, 0x54, 0x65, 0x78, 0x00, 0x04, 0x00, 0x0c, 0x00,
+ 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x65, 0x6e, 0x76, 0x54, 0x65, 0x78, 0x00, 0xab, 0x04, 0x00, 0x0c, 0x00,
+ 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x66, 0x6f, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0xab, 0xab, 0xab,
+ 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x66, 0x78, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73,
+ 0x00, 0x70, 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, 0xab,
+ 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x07, 0xb0,
+ 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x03, 0xb0,
+ 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90,
+ 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x00, 0x08, 0x0f, 0xa0,
+ 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x01, 0x08, 0x0f, 0xa0,
+ 0x42, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0xb0,
+ 0x01, 0x08, 0xe4, 0xa0, 0x42, 0x00, 0x00, 0x03, 0x01, 0x00, 0x0f, 0x80,
+ 0x00, 0x00, 0xe4, 0xb0, 0x00, 0x08, 0xe4, 0xa0, 0x05, 0x00, 0x00, 0x03,
+ 0x00, 0x00, 0x08, 0x80, 0x00, 0x00, 0xff, 0x80, 0x01, 0x00, 0x00, 0xa0,
+ 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0xe4, 0x80,
+ 0x00, 0x00, 0xaa, 0xb0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x07, 0x80,
+ 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04,
+ 0x01, 0x00, 0x07, 0x80, 0x00, 0x00, 0xe4, 0x90, 0x01, 0x00, 0xe4, 0x80,
+ 0x00, 0x00, 0xe4, 0xa1, 0x05, 0x00, 0x00, 0x03, 0x02, 0x00, 0x08, 0x80,
+ 0x01, 0x00, 0xff, 0x80, 0x00, 0x00, 0xff, 0x90, 0x04, 0x00, 0x00, 0x04,
+ 0x01, 0x00, 0x07, 0x80, 0x00, 0x00, 0xaa, 0xb0, 0x01, 0x00, 0xe4, 0x80,
+ 0x00, 0x00, 0xe4, 0xa0, 0x04, 0x00, 0x00, 0x04, 0x02, 0x00, 0x07, 0x80,
+ 0x01, 0x00, 0xe4, 0x80, 0x02, 0x00, 0xff, 0x80, 0x00, 0x00, 0xe4, 0x80,
+ 0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80, 0x02, 0x00, 0xe4, 0x80,
+ 0xff, 0xff, 0x00, 0x00
+};
diff --git a/src/extras/shaders/leedsVehicle_add_gl.inc b/src/extras/shaders/leedsVehicle_add_gl.inc
new file mode 100644
index 00000000..a9835b13
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle_add_gl.inc
@@ -0,0 +1,34 @@
+const char *leedsVehicle_add_frag_src =
+"uniform sampler2D tex0;\n"
+"uniform sampler2D tex1;\n"
+
+"uniform float u_fxparams;\n"
+
+"#define shininess (u_fxparams)\n"
+
+"FSIN vec4 v_color;\n"
+"FSIN vec2 v_tex0;\n"
+"FSIN vec2 v_tex1;\n"
+"FSIN float v_fog;\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" vec4 pass1 = v_color*texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n"
+" vec4 pass2 = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y));\n"
+" pass2.a *= shininess;\n"
+
+" pass1.rgb = mix(u_fogColor.rgb, pass1.rgb, v_fog);\n"
+" pass2.rgb = mix(vec3(0.0, 0.0, 0.0), pass2.rgb, v_fog);\n"
+
+" // We simulate drawing this in two passes.\n"
+" // We premultiply alpha so render state should be one.\n"
+" vec4 color;\n"
+" color.rgb = pass1.rgb*pass1.a + pass2.rgb*pass2.a;\n"
+" color.a = pass1.a;\n"
+
+" DoAlphaTest(color.a);\n"
+
+" FRAGCOLOR(color);\n"
+"}\n"
+;
diff --git a/src/extras/shaders/leedsVehicle_blend.frag b/src/extras/shaders/leedsVehicle_blend.frag
new file mode 100644
index 00000000..a3fab072
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle_blend.frag
@@ -0,0 +1,32 @@
+uniform sampler2D tex0;
+uniform sampler2D tex1;
+
+uniform float u_fxparams;
+
+#define shininess (u_fxparams)
+
+FSIN vec4 v_color;
+FSIN vec2 v_tex0;
+FSIN vec2 v_tex1;
+FSIN float v_fog;
+
+void
+main(void)
+{
+ vec4 pass1 = v_color*texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));
+ vec4 pass2 = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y));
+ pass2.a *= shininess;
+
+ pass1.rgb = mix(u_fogColor.rgb, pass1.rgb, v_fog);
+ pass2.rgb = mix(vec3(0.0, 0.0, 0.0), pass2.rgb, v_fog);
+
+ // We simulate drawing this in two passes.
+ // We premultiply alpha so render state should be one.
+ vec4 color;
+ color.rgb = pass1.rgb*pass1.a*(1.0-pass2.a) + pass2.rgb*pass2.a;
+ color.a = pass1.a*(1.0-pass2.a) + pass2.a;
+
+ DoAlphaTest(color.a);
+
+ FRAGCOLOR(color);
+}
diff --git a/src/extras/shaders/leedsVehicle_blend_PS.cso b/src/extras/shaders/leedsVehicle_blend_PS.cso
new file mode 100644
index 00000000..8d104803
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle_blend_PS.cso
Binary files differ
diff --git a/src/extras/shaders/leedsVehicle_blend_PS.hlsl b/src/extras/shaders/leedsVehicle_blend_PS.hlsl
new file mode 100644
index 00000000..e32970b2
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle_blend_PS.hlsl
@@ -0,0 +1,33 @@
+struct VS_out {
+ float4 Position : POSITION;
+ float3 TexCoord0 : TEXCOORD0;
+ float2 TexCoord1 : TEXCOORD1;
+ float4 Color : COLOR0;
+};
+
+sampler2D diffTex : register(s0);
+sampler2D envTex : register(s1);
+
+float4 fogColor : register(c0);
+
+float4 fxparams : register(c1);
+
+#define shininess (fxparams.x)
+
+float4 main(VS_out input) : COLOR
+{
+ float4 pass1 = input.Color*tex2D(diffTex, input.TexCoord0.xy);
+ float4 pass2 = tex2D(envTex, input.TexCoord1.xy);
+ pass2.a *= shininess;
+
+ pass1.rgb = lerp(fogColor.rgb, pass1.rgb, input.TexCoord0.z);
+ pass2.rgb = lerp(float3(0.0, 0.0, 0.0), pass2.rgb, input.TexCoord0.z);
+
+ // We simulate drawing this in two passes.
+ // We premultiply alpha so render state should be one.
+ float4 color;
+ color.rgb = pass1.rgb*pass1.a*(1.0-pass2.a) + pass2.rgb*pass2.a;
+ color.a = pass1.a*(1.0-pass2.a) + pass2.a;
+
+ return color;
+}
diff --git a/src/extras/shaders/leedsVehicle_blend_PS.inc b/src/extras/shaders/leedsVehicle_blend_PS.inc
new file mode 100644
index 00000000..94fb000c
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle_blend_PS.inc
@@ -0,0 +1,50 @@
+static unsigned char leedsVehicle_blend_PS_cso[] = {
+ 0x00, 0x02, 0xff, 0xff, 0xfe, 0xff, 0x40, 0x00, 0x43, 0x54, 0x41, 0x42,
+ 0x1c, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xff,
+ 0x04, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+ 0xc1, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x02, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x84, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x01, 0x00, 0x06, 0x00,
+ 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0xa8, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,
+ 0x01, 0x00, 0x06, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x64, 0x69, 0x66, 0x66, 0x54, 0x65, 0x78, 0x00, 0x04, 0x00, 0x0c, 0x00,
+ 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x65, 0x6e, 0x76, 0x54, 0x65, 0x78, 0x00, 0xab, 0x04, 0x00, 0x0c, 0x00,
+ 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x66, 0x6f, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0xab, 0xab, 0xab,
+ 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x66, 0x78, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73,
+ 0x00, 0x70, 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, 0xab,
+ 0x51, 0x00, 0x00, 0x05, 0x02, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x80, 0x3f,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x07, 0xb0,
+ 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x03, 0xb0,
+ 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90,
+ 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x00, 0x08, 0x0f, 0xa0,
+ 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x01, 0x08, 0x0f, 0xa0,
+ 0x42, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xb0,
+ 0x00, 0x08, 0xe4, 0xa0, 0x42, 0x00, 0x00, 0x03, 0x01, 0x00, 0x0f, 0x80,
+ 0x01, 0x00, 0xe4, 0xb0, 0x01, 0x08, 0xe4, 0xa0, 0x04, 0x00, 0x00, 0x04,
+ 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0xe4, 0x90, 0x00, 0x00, 0xe4, 0x80,
+ 0x00, 0x00, 0xe4, 0xa1, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x08, 0x80,
+ 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0xff, 0x90, 0x04, 0x00, 0x00, 0x04,
+ 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0xaa, 0xb0, 0x00, 0x00, 0xe4, 0x80,
+ 0x00, 0x00, 0xe4, 0xa0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x07, 0x80,
+ 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x05, 0x00, 0x00, 0x03,
+ 0x01, 0x00, 0x07, 0x80, 0x01, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xaa, 0xb0,
+ 0x05, 0x00, 0x00, 0x03, 0x02, 0x00, 0x08, 0x80, 0x01, 0x00, 0xff, 0x80,
+ 0x01, 0x00, 0x00, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x80,
+ 0x01, 0x00, 0x00, 0xa0, 0x04, 0x00, 0x00, 0x04, 0x01, 0x00, 0x08, 0x80,
+ 0x01, 0x00, 0xff, 0x80, 0x02, 0x00, 0x00, 0x81, 0x02, 0x00, 0x00, 0xa0,
+ 0x04, 0x00, 0x00, 0x04, 0x03, 0x00, 0x08, 0x80, 0x00, 0x00, 0xff, 0x80,
+ 0x01, 0x00, 0xff, 0x80, 0x02, 0x00, 0xff, 0x80, 0x12, 0x00, 0x00, 0x04,
+ 0x03, 0x00, 0x07, 0x80, 0x02, 0x00, 0xff, 0x80, 0x01, 0x00, 0xe4, 0x80,
+ 0x00, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x02, 0x00, 0x08, 0x0f, 0x80,
+ 0x03, 0x00, 0xe4, 0x80, 0xff, 0xff, 0x00, 0x00
+};
diff --git a/src/extras/shaders/leedsVehicle_blend_gl.inc b/src/extras/shaders/leedsVehicle_blend_gl.inc
new file mode 100644
index 00000000..707afb10
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle_blend_gl.inc
@@ -0,0 +1,34 @@
+const char *leedsVehicle_blend_frag_src =
+"uniform sampler2D tex0;\n"
+"uniform sampler2D tex1;\n"
+
+"uniform float u_fxparams;\n"
+
+"#define shininess (u_fxparams)\n"
+
+"FSIN vec4 v_color;\n"
+"FSIN vec2 v_tex0;\n"
+"FSIN vec2 v_tex1;\n"
+"FSIN float v_fog;\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" vec4 pass1 = v_color*texture(tex0, vec2(v_tex0.x, 1.0-v_tex0.y));\n"
+" vec4 pass2 = texture(tex1, vec2(v_tex1.x, 1.0-v_tex1.y));\n"
+" pass2.a *= shininess;\n"
+
+" pass1.rgb = mix(u_fogColor.rgb, pass1.rgb, v_fog);\n"
+" pass2.rgb = mix(vec3(0.0, 0.0, 0.0), pass2.rgb, v_fog);\n"
+
+" // We simulate drawing this in two passes.\n"
+" // We premultiply alpha so render state should be one.\n"
+" vec4 color;\n"
+" color.rgb = pass1.rgb*pass1.a*(1.0-pass2.a) + pass2.rgb*pass2.a;\n"
+" color.a = pass1.a*(1.0-pass2.a) + pass2.a;\n"
+
+" DoAlphaTest(color.a);\n"
+
+" FRAGCOLOR(color);\n"
+"}\n"
+;
diff --git a/src/extras/shaders/leedsVehicle_vs_gl.inc b/src/extras/shaders/leedsVehicle_vs_gl.inc
new file mode 100644
index 00000000..eb36b6e9
--- /dev/null
+++ b/src/extras/shaders/leedsVehicle_vs_gl.inc
@@ -0,0 +1,29 @@
+const char *leedsVehicle_vert_src =
+"uniform mat4 u_texMatrix;\n"
+
+"VSIN(ATTRIB_POS) vec3 in_pos;\n"
+
+"VSOUT vec4 v_color;\n"
+"VSOUT vec2 v_tex0;\n"
+"VSOUT vec2 v_tex1;\n"
+"VSOUT float v_fog;\n"
+
+"void\n"
+"main(void)\n"
+"{\n"
+" vec4 Vertex = u_world * vec4(in_pos, 1.0);\n"
+" gl_Position = u_proj * u_view * Vertex;\n"
+" vec3 Normal = mat3(u_world) * in_normal;\n"
+
+" v_tex0 = in_tex0;\n"
+" v_tex1 = (u_texMatrix * vec4(Normal, 1.0)).xy;\n"
+
+" v_color = in_color;\n"
+" v_color.rgb += u_ambLight.rgb*surfAmbient;\n"
+" v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse;\n"
+" v_color = clamp(v_color, 0.0, 1.0);\n"
+" v_color *= u_matColor;\n"
+
+" v_fog = DoFog(gl_Position.w);\n"
+"}\n"
+;
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 91a34592..3065027b 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -2,6 +2,7 @@
#include "common.h"
#include "main.h"
+#include "General.h"
#include "Lights.h"
#include "ModelInfo.h"
#include "Treadable.h"
@@ -20,6 +21,7 @@
#include "ModelIndices.h"
#include "Streaming.h"
#include "Shadows.h"
+#include "Coronas.h"
#include "PointLights.h"
#include "Occlusion.h"
#include "Renderer.h"
@@ -40,6 +42,8 @@ bool gbDontRenderPeds;
bool gbDontRenderObjects;
bool gbDontRenderVehicles;
+bool gbRenderDebugEnvMap;
+
// unused
int16 TestCloseThings;
int16 TestBigThings;
@@ -1642,3 +1646,184 @@ CRenderer::RemoveVehiclePedLights(CEntity *ent, bool reset)
SetAmbientColours();
DeActivateDirectional();
}
+
+
+#include "postfx.h"
+
+static RwIm2DVertex Screen2EnvQuad[4];
+static RwImVertexIndex EnvQuadIndices[6] = { 0, 1, 2, 0, 2, 3 };
+
+static void
+SetQuadVertices(RwRaster *env, RwRaster *screen, float z)
+{
+ uint32 width = RwRasterGetWidth(env);
+ uint32 height = RwRasterGetHeight(env);
+
+ float zero, xmax, ymax;
+
+ zero = -HALFPX;
+ xmax = width - HALFPX;
+ ymax = height - HALFPX;
+
+ float recipz = 1.0f/z;
+ float umax = (float)SCREEN_WIDTH/RwRasterGetWidth(screen);
+ float vmax = (float)SCREEN_HEIGHT/RwRasterGetHeight(screen);
+
+ RwIm2DVertexSetScreenX(&Screen2EnvQuad[0], zero);
+ RwIm2DVertexSetScreenY(&Screen2EnvQuad[0], zero);
+ RwIm2DVertexSetScreenZ(&Screen2EnvQuad[0], RwIm2DGetNearScreenZ());
+ RwIm2DVertexSetCameraZ(&Screen2EnvQuad[0], z);
+ RwIm2DVertexSetRecipCameraZ(&Screen2EnvQuad[0], recipz);
+ RwIm2DVertexSetU(&Screen2EnvQuad[0], 0.0f, recipz);
+ RwIm2DVertexSetV(&Screen2EnvQuad[0], 0.0f, recipz);
+ RwIm2DVertexSetIntRGBA(&Screen2EnvQuad[0], 255, 255, 255, 255);
+
+ RwIm2DVertexSetScreenX(&Screen2EnvQuad[1], zero);
+ RwIm2DVertexSetScreenY(&Screen2EnvQuad[1], ymax);
+ RwIm2DVertexSetScreenZ(&Screen2EnvQuad[1], RwIm2DGetNearScreenZ());
+ RwIm2DVertexSetCameraZ(&Screen2EnvQuad[1], z);
+ RwIm2DVertexSetRecipCameraZ(&Screen2EnvQuad[1], recipz);
+ RwIm2DVertexSetU(&Screen2EnvQuad[1], 0.0f, recipz);
+ RwIm2DVertexSetV(&Screen2EnvQuad[1], vmax, recipz);
+ RwIm2DVertexSetIntRGBA(&Screen2EnvQuad[1], 255, 255, 255, 255);
+
+ RwIm2DVertexSetScreenX(&Screen2EnvQuad[2], xmax);
+ RwIm2DVertexSetScreenY(&Screen2EnvQuad[2], ymax);
+ RwIm2DVertexSetScreenZ(&Screen2EnvQuad[2], RwIm2DGetNearScreenZ());
+ RwIm2DVertexSetCameraZ(&Screen2EnvQuad[2], z);
+ RwIm2DVertexSetRecipCameraZ(&Screen2EnvQuad[2], recipz);
+ RwIm2DVertexSetU(&Screen2EnvQuad[2], umax, recipz);
+ RwIm2DVertexSetV(&Screen2EnvQuad[2], vmax, recipz);
+ RwIm2DVertexSetIntRGBA(&Screen2EnvQuad[2], 255, 255, 255, 255);
+
+ RwIm2DVertexSetScreenX(&Screen2EnvQuad[3], xmax);
+ RwIm2DVertexSetScreenY(&Screen2EnvQuad[3], zero);
+ RwIm2DVertexSetScreenZ(&Screen2EnvQuad[3], RwIm2DGetNearScreenZ());
+ RwIm2DVertexSetCameraZ(&Screen2EnvQuad[3], z);
+ RwIm2DVertexSetRecipCameraZ(&Screen2EnvQuad[3], recipz);
+ RwIm2DVertexSetU(&Screen2EnvQuad[3], umax, recipz);
+ RwIm2DVertexSetV(&Screen2EnvQuad[3], 0.0f, recipz);
+ RwIm2DVertexSetIntRGBA(&Screen2EnvQuad[3], 255, 255, 255, 255);
+}
+
+static RwIm2DVertex coronaVerts[4*4];
+static RwImVertexIndex coronaIndices[6*4];
+static int numCoronaVerts, numCoronaIndices;
+
+static void
+AddCorona(float x, float y, float sz)
+{
+ float nearz, recipz;
+ RwIm2DVertex *v;
+ nearz = RwIm2DGetNearScreenZ();
+ float z = RwCameraGetNearClipPlane(RwCameraGetCurrentCamera());
+ recipz = 1.0f/z;
+
+ v = &coronaVerts[numCoronaVerts];
+ RwIm2DVertexSetScreenX(&v[0], x);
+ RwIm2DVertexSetScreenY(&v[0], y);
+ RwIm2DVertexSetScreenZ(&v[0], z);
+ RwIm2DVertexSetScreenZ(&v[0], nearz);
+ RwIm2DVertexSetRecipCameraZ(&v[0], recipz);
+ RwIm2DVertexSetU(&v[0], 0.0f, recipz);
+ RwIm2DVertexSetV(&v[0], 0.0f, recipz);
+ RwIm2DVertexSetIntRGBA(&v[0], 255, 255, 255, 255);
+
+ RwIm2DVertexSetScreenX(&v[1], x);
+ RwIm2DVertexSetScreenY(&v[1], y + sz);
+ RwIm2DVertexSetScreenZ(&v[1], z);
+ RwIm2DVertexSetScreenZ(&v[1], nearz);
+ RwIm2DVertexSetRecipCameraZ(&v[1], recipz);
+ RwIm2DVertexSetU(&v[1], 0.0f, recipz);
+ RwIm2DVertexSetV(&v[1], 1.0f, recipz);
+ RwIm2DVertexSetIntRGBA(&v[1], 255, 255, 255, 255);
+
+ RwIm2DVertexSetScreenX(&v[2], x + sz);
+ RwIm2DVertexSetScreenY(&v[2], y + sz);
+ RwIm2DVertexSetScreenZ(&v[2], z);
+ RwIm2DVertexSetScreenZ(&v[2], nearz);
+ RwIm2DVertexSetRecipCameraZ(&v[2], recipz);
+ RwIm2DVertexSetU(&v[2], 1.0f, recipz);
+ RwIm2DVertexSetV(&v[2], 1.0f, recipz);
+ RwIm2DVertexSetIntRGBA(&v[2], 255, 255, 255, 255);
+
+ RwIm2DVertexSetScreenX(&v[3], x + sz);
+ RwIm2DVertexSetScreenY(&v[3], y);
+ RwIm2DVertexSetScreenZ(&v[3], z);
+ RwIm2DVertexSetScreenZ(&v[3], nearz);
+ RwIm2DVertexSetRecipCameraZ(&v[3], recipz);
+ RwIm2DVertexSetU(&v[3], 1.0f, recipz);
+ RwIm2DVertexSetV(&v[3], 0.0f, recipz);
+ RwIm2DVertexSetIntRGBA(&v[3], 255, 255, 255, 255);
+
+
+ coronaIndices[numCoronaIndices++] = numCoronaVerts;
+ coronaIndices[numCoronaIndices++] = numCoronaVerts + 1;
+ coronaIndices[numCoronaIndices++] = numCoronaVerts + 2;
+ coronaIndices[numCoronaIndices++] = numCoronaVerts;
+ coronaIndices[numCoronaIndices++] = numCoronaVerts + 2;
+ coronaIndices[numCoronaIndices++] = numCoronaVerts + 3;
+ numCoronaVerts += 4;
+}
+#include "Debug.h"
+
+static void
+DrawEnvMapCoronas(float heading)
+{
+ RwRaster *rt = RwTextureGetRaster(CustomPipes::EnvMapTex);
+ const float BIG = 89.0f * RwRasterGetWidth(rt)/128.0f;
+ const float SMALL = 38.0f * RwRasterGetHeight(rt)/128.0f;
+
+ float x;
+ numCoronaVerts = 0;
+ numCoronaIndices = 0;
+ x = (heading - PI)/TWOPI;// - 1.0f;
+ x *= BIG+SMALL;
+ AddCorona(x, 0.0f, BIG); x += BIG;
+ AddCorona(x, 12.0f, SMALL); x += SMALL;
+ AddCorona(x, 0.0f, BIG); x += BIG;
+ AddCorona(x, 12.0f, SMALL); x += SMALL;
+
+ RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDONE);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDONE);
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
+ RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpCoronaTexture[CCoronas::TYPE_STAR]));
+ RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, coronaVerts, numCoronaVerts, coronaIndices, numCoronaIndices);
+ RwRenderStateSet(rwRENDERSTATESRCBLEND, (void*)rwBLENDSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void*)rwBLENDINVSRCALPHA);
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
+}
+
+void
+CRenderer::GenerateEnvironmentMap(void)
+{
+ // We'll probably do this differently eventually
+ // re-using all sorts of stuff here...
+
+ CPostFX::GetBackBuffer(Scene.camera);
+
+ RwCameraBeginUpdate(CustomPipes::EnvMapCam);
+
+ // get current scene
+ SetQuadVertices(RwTextureGetRaster(CustomPipes::EnvMapTex), CPostFX::pBackBuffer, RwCameraGetNearClipPlane(RwCameraGetCurrentCamera()));
+ RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
+ RwRenderStateSet(rwRENDERSTATETEXTURERASTER, CPostFX::pBackBuffer);
+ RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
+ RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, Screen2EnvQuad, 4, EnvQuadIndices, 6);
+ RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
+ RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
+
+ // Draw coronas
+ DrawEnvMapCoronas(TheCamera.GetForward().Heading());
+
+ RwCameraEndUpdate(CustomPipes::EnvMapCam);
+
+
+ RwCameraBeginUpdate(Scene.camera);
+
+ if(gbRenderDebugEnvMap){
+ RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(CustomPipes::EnvMapTex));
+ RwIm2DRenderIndexedPrimitive(rwPRIMTYPETRILIST, CustomPipes::EnvScreenQuad, 4, (RwImVertexIndex*)CustomPipes::QuadIndices, 6);
+ }
+}
diff --git a/src/render/Renderer.h b/src/render/Renderer.h
index 9b202098..a4b6b0b8 100644
--- a/src/render/Renderer.h
+++ b/src/render/Renderer.h
@@ -102,4 +102,6 @@ public:
static void RenderTransparentWater(void); // keep-out polys and transparent water
#endif
static void InsertEntityIntoList(CEntity *ent);
+
+ static void GenerateEnvironmentMap(void);
};