From 55320a03f14c473b0fff89585713d2ebd8feb92a Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 12 Jan 2021 14:07:24 +0100 Subject: [PATCH] little cleanup of vehicle rendering --- src/core/re3.cpp | 2 +- src/extras/custompipes.cpp | 2 +- src/extras/custompipes.h | 2 +- src/extras/custompipes_d3d9.cpp | 11 ++++++----- src/extras/custompipes_gl.cpp | 11 ++++++----- src/extras/shaders/leedsVehicle_mobile.vert | 2 -- src/extras/shaders/leedsVehicle_mobile_PS.hlsl | 1 - src/extras/shaders/leedsVehicle_mobile_VS.hlsl | 3 --- src/extras/shaders/leedsVehicle_mobile_vs_gl.inc | 2 -- vendor/librw | 2 +- 10 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/core/re3.cpp b/src/core/re3.cpp index b7f8c8b2..efb6ec3b 100644 --- a/src/core/re3.cpp +++ b/src/core/re3.cpp @@ -669,7 +669,7 @@ extern bool gbRenderWorld2; e = DebugMenuAddVar("Render", "Vehicle Pipeline", &CustomPipes::VehiclePipeSwitch, nil, 1, CustomPipes::VEHICLEPIPE_PS2, CustomPipes::VEHICLEPIPE_MOBILE, vehpipenames); DebugMenuEntrySetWrap(e, true); - DebugMenuAddVarBool8("Render", "Chrome cheat", &CustomPipes::bChromeCheat, nil); + DebugMenuAddVarBool8("Render", "Glass Cars cheat", &CustomPipes::gGlassCarsCheat, nil); extern bool gbRenderDebugEnvMap; DebugMenuAddVarBool8("Render", "Show Env map", &gbRenderDebugEnvMap, nil); // DebugMenuAddVar("Render", "Neo Vehicle Shininess", &CustomPipes::VehicleShininess, nil, 0.1f, 0, 1.0f); diff --git a/src/extras/custompipes.cpp b/src/extras/custompipes.cpp index a636f8b0..247aa4b1 100644 --- a/src/extras/custompipes.cpp +++ b/src/extras/custompipes.cpp @@ -46,7 +46,7 @@ CustomMatCopy(void *dst, void *src, int32, int32) rw::TexDictionary *neoTxd; -bool bChromeCheat; +bool gGlassCarsCheat; bool bRenderingEnvMap; int32 EnvMapSize = 512; rw::Camera *EnvMapCam; diff --git a/src/extras/custompipes.h b/src/extras/custompipes.h index 9674a6d1..e83201ff 100644 --- a/src/extras/custompipes.h +++ b/src/extras/custompipes.h @@ -75,7 +75,7 @@ void CustomPipeInit(void); void CustomPipeShutdown(void); void SetTxdFindCallback(void); -extern bool bChromeCheat; +extern bool gGlassCarsCheat; extern bool bRenderingEnvMap; extern int32 EnvMapSize; extern rw::Camera *EnvMapCam; diff --git a/src/extras/custompipes_d3d9.cpp b/src/extras/custompipes_d3d9.cpp index 1dc4c0bb..9a02f874 100644 --- a/src/extras/custompipes_d3d9.cpp +++ b/src/extras/custompipes_d3d9.cpp @@ -114,7 +114,7 @@ leedsVehicleRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header) uploadMatrices(atomic->getFrame()->getLTM()); setVertexShader(leedsVehicle_VS); - if(bChromeCheat) + if(gGlassCarsCheat) setPixelShader(leedsVehicle_blend_PS); else setPixelShader(leedsVehicle_add_PS); @@ -131,10 +131,11 @@ leedsVehicleRenderCB(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *header) SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 255); float coef = 0.0f; - if(RpMatFXMaterialGetEffects(m) == rpMATFXEFFECTENVMAP) + if(RpMatFXMaterialGetEffects(m) == rpMATFXEFFECTENVMAP){ coef = CClock::ms_EnvMapTimeMultiplicator * RpMatFXMaterialGetEnvMapCoefficient(m)*0.5f; - if(bChromeCheat && coef > 0.0f) - coef = 1.0f; + if(gGlassCarsCheat) + coef = 1.0f; + } d3ddevice->SetPixelShaderConstantF(PSLOC_shininess, (float*)&coef, 1); setMaterial(m->color, m->surfaceProps); @@ -205,7 +206,7 @@ leedsVehicleRenderCB_mobile(rw::Atomic *atomic, rw::d3d9::InstanceDataHeader *he float coef = 0.0f; if(RpMatFXMaterialGetEffects(m) == rpMATFXEFFECTENVMAP){ coef = CClock::ms_EnvMapTimeMultiplicator * RpMatFXMaterialGetEnvMapCoefficient(m)*0.5f; - if(bChromeCheat) + if(gGlassCarsCheat) coef = 1.0f; } d3ddevice->SetPixelShaderConstantF(PSLOC_shininess, (float*)&coef, 1); diff --git a/src/extras/custompipes_gl.cpp b/src/extras/custompipes_gl.cpp index 35a30316..eeb62b8d 100644 --- a/src/extras/custompipes_gl.cpp +++ b/src/extras/custompipes_gl.cpp @@ -122,7 +122,7 @@ leedsVehicleRenderCB(rw::Atomic *atomic, rw::gl3::InstanceDataHeader *header) InstanceData *inst = header->inst; rw::int32 n = header->numMeshes; - if(bChromeCheat) + if(gGlassCarsCheat) leedsVehicleShader_blend->use(); else leedsVehicleShader_add->use(); @@ -138,10 +138,11 @@ leedsVehicleRenderCB(rw::Atomic *atomic, rw::gl3::InstanceDataHeader *header) rw::SetRenderState(VERTEXALPHA, inst->vertexAlpha || m->color.alpha != 0xFF); float coef = 0.0f; - if(RpMatFXMaterialGetEffects(m) == rpMATFXEFFECTENVMAP) + if(RpMatFXMaterialGetEffects(m) == rpMATFXEFFECTENVMAP){ coef = CClock::ms_EnvMapTimeMultiplicator * RpMatFXMaterialGetEnvMapCoefficient(m)*0.5f; - if(bChromeCheat && coef > 0.0f) - coef = 1.0f; + if(gGlassCarsCheat) + coef = 1.0f; + } glUniform1f(U(u_fxparams), coef); setMaterial(m->color, m->surfaceProps); @@ -216,7 +217,7 @@ leedsVehicleRenderCB_mobile(rw::Atomic *atomic, rw::gl3::InstanceDataHeader *hea float coef = 0.0f; if(RpMatFXMaterialGetEffects(m) == rpMATFXEFFECTENVMAP){ coef = CClock::ms_EnvMapTimeMultiplicator * RpMatFXMaterialGetEnvMapCoefficient(m)*0.5f; - if(bChromeCheat) + if(gGlassCarsCheat) coef = 1.0f; } glUniform1f(U(u_fxparams), coef); diff --git a/src/extras/shaders/leedsVehicle_mobile.vert b/src/extras/shaders/leedsVehicle_mobile.vert index e18c2f02..b2123fa4 100644 --- a/src/extras/shaders/leedsVehicle_mobile.vert +++ b/src/extras/shaders/leedsVehicle_mobile.vert @@ -26,11 +26,9 @@ main(void) v_color = in_color; vec4 combinedAmbient = mix(u_emiss, u_amb, Normal.z); -// v_color.rgb += u_ambLight.rgb*surfAmbient; v_color.rgb += combinedAmbient.rgb*surfAmbient; v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse; v_lightingCont = max(0.5, (v_color.r + v_color.g + v_color.b) / 3.0); -// v_color = clamp(v_color, 0.0, 1.0); v_color *= u_matColor; // for fresnel diff --git a/src/extras/shaders/leedsVehicle_mobile_PS.hlsl b/src/extras/shaders/leedsVehicle_mobile_PS.hlsl index e81c66c9..da09b872 100644 --- a/src/extras/shaders/leedsVehicle_mobile_PS.hlsl +++ b/src/extras/shaders/leedsVehicle_mobile_PS.hlsl @@ -45,7 +45,6 @@ float4 main(VS_out input) : COLOR float opacity = lerp(minOpacity, maxOpacity, fresnel)*pass1.a; float4 color = pass1 + float4(reflectivity * envOut, 0.0); -//float4 color = float4(reflectivity, reflectivity, reflectivity, reflectivity); color.a = opacity; color.rgb = lerp(fogColor.rgb, color.rgb, input.TexCoord0.z); diff --git a/src/extras/shaders/leedsVehicle_mobile_VS.hlsl b/src/extras/shaders/leedsVehicle_mobile_VS.hlsl index 667c0963..3085c5e4 100644 --- a/src/extras/shaders/leedsVehicle_mobile_VS.hlsl +++ b/src/extras/shaders/leedsVehicle_mobile_VS.hlsl @@ -38,15 +38,12 @@ VS_out main(in VS_in input) output.Color = input.Prelight; float4 combinedAmbient = lerp(emissive, ambient, N.z); -// output.Color.rgb += ambientLight.rgb * surfAmbient; output.Color.rgb += combinedAmbient.rgb * surfAmbient; int i; for(i = 0; i < numDirLights; i++) output.Color.xyz += DoDirLight(lights[i+firstDirLight], N)*surfDiffuse; lightingCont = max(0.5, (output.Color.r + output.Color.g + output.Color.b) / 3.0); - // PS2 clamps before material color -// output.Color = clamp(output.Color, 0.0, 1.0); output.Color *= matCol; // for fresnel diff --git a/src/extras/shaders/leedsVehicle_mobile_vs_gl.inc b/src/extras/shaders/leedsVehicle_mobile_vs_gl.inc index b1f07563..3609e369 100644 --- a/src/extras/shaders/leedsVehicle_mobile_vs_gl.inc +++ b/src/extras/shaders/leedsVehicle_mobile_vs_gl.inc @@ -27,11 +27,9 @@ const char *leedsVehicle_mobile_vert_src = " v_color = in_color;\n" " vec4 combinedAmbient = mix(u_emiss, u_amb, Normal.z);\n" -"// v_color.rgb += u_ambLight.rgb*surfAmbient;\n" " v_color.rgb += combinedAmbient.rgb*surfAmbient;\n" " v_color.rgb += DoDynamicLight(Vertex.xyz, Normal)*surfDiffuse;\n" " v_lightingCont = max(0.5, (v_color.r + v_color.g + v_color.b) / 3.0);\n" -"// v_color = clamp(v_color, 0.0, 1.0);\n" " v_color *= u_matColor;\n" " // for fresnel\n" diff --git a/vendor/librw b/vendor/librw index 61b288a9..78d540fc 160000 --- a/vendor/librw +++ b/vendor/librw @@ -1 +1 @@ -Subproject commit 61b288a9fe72ae4073c0ac5fd2a5815ed510c8c8 +Subproject commit 78d540fce0ca090b07377cee40d73eadfb7a699d