From 968a611aa92148e4c440c08aed0afb10ff956392 Mon Sep 17 00:00:00 2001 From: dexy Date: Wed, 11 Dec 2019 21:38:40 +1100 Subject: [PATCH] Support for normal_only and spec_only decals in deferred mode --- CodeWalker.Shaders/BasicPS_Deferred.hlsl | 16 +++++++++++----- Rendering/Shaders/BasicShader.cs | 13 +++++++++---- Shaders/BasicPS_Deferred.cso | Bin 6468 -> 6752 bytes 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/CodeWalker.Shaders/BasicPS_Deferred.hlsl b/CodeWalker.Shaders/BasicPS_Deferred.hlsl index 6dcda36..bf6c7c3 100644 --- a/CodeWalker.Shaders/BasicPS_Deferred.hlsl +++ b/CodeWalker.Shaders/BasicPS_Deferred.hlsl @@ -34,8 +34,10 @@ PS_OUTPUT main(VS_OUTPUT input) } if (IsDistMap) c = float4(c.rgb * 2, (c.r + c.g + c.b) - 1); + if (IsDecal == 4) c.a = c.r; if ((IsDecal == 0) && (c.a <= 0.33)) discard; if ((IsDecal == 1) && (c.a <= 0.0)) discard; + if ((IsDecal >= 3) && (c.a <= 0.0)) discard; if (IsDecal == 0) c.a = 1; if (IsDecal == 2) { @@ -49,7 +51,7 @@ PS_OUTPUT main(VS_OUTPUT input) { c.rgb *= input.Tint.rgb; } - if (IsDecal == 1) + if ((IsDecal == 1) || (IsDecal >= 3)) { c.a *= input.Colour0.a; } @@ -157,12 +159,16 @@ PS_OUTPUT main(VS_OUTPUT input) c.a = saturate(c.a); + float4 a = c.aaaa; + if(IsDecal==3) a.xzw = 0; //normal_only + if(IsDecal==4) a.xyw = 0; //spec_only + PS_OUTPUT output; - output.Diffuse = c; - output.Normal = float4(saturate(norm * 0.5 + 0.5), c.a); - output.Specular = float4(spec, c.a); - output.Irradiance = float4(input.Colour0.rg, emiss, c.a); + output.Diffuse = float4(c.rgb, a.x); + output.Normal = float4(saturate(norm * 0.5 + 0.5), a.y); + output.Specular = float4(spec, a.z); + output.Irradiance = float4(input.Colour0.rg, emiss, a.w); return output; } diff --git a/Rendering/Shaders/BasicShader.cs b/Rendering/Shaders/BasicShader.cs index b229667..ff45b59 100644 --- a/Rendering/Shaders/BasicShader.cs +++ b/Rendering/Shaders/BasicShader.cs @@ -730,11 +730,16 @@ namespace CodeWalker.Rendering case 731050667: //weapon_normal_spec_palette.sps if (usetint) { tintflag = 0; pstintflag = 2; } //use diffuse sampler alpha for tint lookup! break; - case 3880384844://{decal_spec_only.sps}w - case 600733812://{decal_amb_only.sps} - case 2842248626://{spec_decal.sps} - case 2457676400://{reflect_decal.sps} + case 341123999://{decal_normal_only.sps} case 2706821972://{mirror_decal.sps} + case 2457676400://{reflect_decal.sps} + decalflag = 3; + break; + case 3880384844://{decal_spec_only.sps} + case 2842248626://{spec_decal.sps} + decalflag = 4; + break; + case 600733812://{decal_amb_only.sps} //if (RenderMode == WorldRenderMode.Default) usediff = false; break; case 2655725442://{decal_dirt.sps} diff --git a/Shaders/BasicPS_Deferred.cso b/Shaders/BasicPS_Deferred.cso index 8dd453cf06e5993d7cf44bc1cd51a7477e363686..f98285ba2a242f1466f4908ce821fe87a2049156 100644 GIT binary patch delta 1488 zcmZ`(Pe>GD6n`^2GtR8-znNY4AF-<*C<9aEuB^NHU7d_AsgHQtLCQ!z3k zh0vl*WcTo9EX$|jcD~&YSpWB%Q+{Sd>>9Xc1D99gC9~nT^)$Y#X+L-+S-J`%Bm*}j zfFujGRJX^Q2bQzq*CA^sL0r3QK3wKa>o-J&J6rNaU*y9K`C z+WbWnIv=>D87Kg4g)sOA972=@>|K~b^|5@(l13rjmshwzG{QUXa9$zd8WaMg&6A$z zs8gG7dRd#nDZ;=hsZchs37XI%pwDm4XX8G)O4Mvv(@mMN_v0cEL102P!v zIF*oCBcPl$YZabnr29}Wg^EZ>MEB*@TE1+39q;Cdov&(vwo;aHEeD<; zjBy?0rChQP_7c&&A8IlB%`@49U6kv&tgwBa>rX*9E-bGtOfKA${UhEHox|UA!;(Hx Jn!EG8e*kw1pbY>3 delta 1403 zcma)6O=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