mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-25 16:32:55 +08:00
Weapon rendering improvements
This commit is contained in:
parent
57d5a2758e
commit
dead879d99
@ -5,6 +5,7 @@ Texture2D<float4> Bumpmap : register(t2);
|
|||||||
Texture2D<float4> Specmap : register(t3);
|
Texture2D<float4> Specmap : register(t3);
|
||||||
Texture2D<float4> Detailmap : register(t4);
|
Texture2D<float4> Detailmap : register(t4);
|
||||||
Texture2D<float4> Colourmap2 : register(t5);
|
Texture2D<float4> Colourmap2 : register(t5);
|
||||||
|
Texture2D<float4> TintPalette : register(t6);
|
||||||
SamplerState TextureSS : register(s0);
|
SamplerState TextureSS : register(s0);
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +20,7 @@ cbuffer PSSceneVars : register(b0)
|
|||||||
cbuffer PSGeomVars : register(b2)
|
cbuffer PSGeomVars : register(b2)
|
||||||
{
|
{
|
||||||
uint EnableTexture;//1+=diffuse1, 2+=diffuse2
|
uint EnableTexture;//1+=diffuse1, 2+=diffuse2
|
||||||
uint EnableTint;
|
uint EnableTint;//1=default, 2=weapons (use diffuse.a for tint lookup)
|
||||||
uint EnableNormalMap;
|
uint EnableNormalMap;
|
||||||
uint EnableSpecMap;
|
uint EnableSpecMap;
|
||||||
uint EnableDetailMap;
|
uint EnableDetailMap;
|
||||||
@ -80,6 +81,15 @@ float4 main(VS_OUTPUT input) : SV_TARGET
|
|||||||
float4 c2 = Colourmap2.Sample(TextureSS, input.Texcoord1);
|
float4 c2 = Colourmap2.Sample(TextureSS, input.Texcoord1);
|
||||||
c = c2.a * c2 + (1 - c2.a) * c;
|
c = c2.a * c2 + (1 - c2.a) * c;
|
||||||
}
|
}
|
||||||
|
if (EnableTint == 2)
|
||||||
|
{
|
||||||
|
//weapon tint
|
||||||
|
float tx = (round(c.a * 255.009995) - 32.0) * 0.007813; //okay R* this is just silly
|
||||||
|
float ty = 0.03125 * 0.5;// //1;//what to use for Y value? cb12[2].w in R* shader
|
||||||
|
float4 c3 = TintPalette.Sample(TextureSS, float2(tx, ty));
|
||||||
|
c.rgb *= c3.rgb;
|
||||||
|
c.a = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsDistMap) c = float4(c.rgb*2, (c.r+c.g+c.b) - 1);
|
if (IsDistMap) c = float4(c.rgb*2, (c.r+c.g+c.b) - 1);
|
||||||
if ((IsDecal == 0) && (c.a <= 0.33)) discard;
|
if ((IsDecal == 0) && (c.a <= 0.33)) discard;
|
||||||
@ -93,7 +103,7 @@ float4 main(VS_OUTPUT input) : SV_TARGET
|
|||||||
}
|
}
|
||||||
c.a = saturate(c.a*AlphaScale);
|
c.a = saturate(c.a*AlphaScale);
|
||||||
}
|
}
|
||||||
if (EnableTint > 0)
|
if (EnableTint == 1)
|
||||||
{
|
{
|
||||||
c.rgb *= input.Tint.rgb;
|
c.rgb *= input.Tint.rgb;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ float4 main(VS_OUTPUT input) : SV_TARGET
|
|||||||
if (EnableTexture == 1)
|
if (EnableTexture == 1)
|
||||||
{
|
{
|
||||||
float4 c = Colourmap.Sample(TextureSS, input.Texcoord);
|
float4 c = Colourmap.Sample(TextureSS, input.Texcoord);
|
||||||
|
if (EnableTint == 2) { c.a = 1; }
|
||||||
if ((IsDecal == 0) && (c.a <= 0.33)) discard;
|
if ((IsDecal == 0) && (c.a <= 0.33)) discard;
|
||||||
if ((IsDecal == 1) && (c.a <= 0.0)) discard;
|
if ((IsDecal == 1) && (c.a <= 0.0)) discard;
|
||||||
}
|
}
|
||||||
|
@ -637,6 +637,7 @@ namespace CodeWalker.Rendering
|
|||||||
detltex = itex;
|
detltex = itex;
|
||||||
break;
|
break;
|
||||||
case ShaderParamNames.TintPaletteSampler:
|
case ShaderParamNames.TintPaletteSampler:
|
||||||
|
case ShaderParamNames.TextureSamplerDiffPal:
|
||||||
tintpal = itex;
|
tintpal = itex;
|
||||||
if (tintpal.Key != null)
|
if (tintpal.Key != null)
|
||||||
{
|
{
|
||||||
@ -649,6 +650,7 @@ namespace CodeWalker.Rendering
|
|||||||
isdistmap = true;
|
isdistmap = true;
|
||||||
break;
|
break;
|
||||||
case ShaderParamNames.DiffuseSampler2:
|
case ShaderParamNames.DiffuseSampler2:
|
||||||
|
case ShaderParamNames.DiffuseExtraSampler:
|
||||||
texture2 = itex;
|
texture2 = itex;
|
||||||
break;
|
break;
|
||||||
case ShaderParamNames.heightSampler:
|
case ShaderParamNames.heightSampler:
|
||||||
@ -710,6 +712,14 @@ namespace CodeWalker.Rendering
|
|||||||
case 1229591973://{trees_normal_spec_tnt.sps}
|
case 1229591973://{trees_normal_spec_tnt.sps}
|
||||||
if (usetint) tintflag = 2; //use 2nd vertex colour channel for tint...
|
if (usetint) tintflag = 2; //use 2nd vertex colour channel for tint...
|
||||||
break;
|
break;
|
||||||
|
case 3267631682: //weapon_normal_spec_detail_tnt.sps
|
||||||
|
case 14185869: //weapon_normal_spec_tnt.sps
|
||||||
|
break; //regular tinting?
|
||||||
|
case 231364109: //weapon_normal_spec_cutout_palette.sps
|
||||||
|
case 3294641629://weapon_normal_spec_detail_palette.sps
|
||||||
|
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 3880384844://{decal_spec_only.sps}w
|
||||||
case 600733812://{decal_amb_only.sps}
|
case 600733812://{decal_amb_only.sps}
|
||||||
case 2842248626://{spec_decal.sps}
|
case 2842248626://{spec_decal.sps}
|
||||||
@ -799,6 +809,10 @@ namespace CodeWalker.Rendering
|
|||||||
{
|
{
|
||||||
tintpal.SetVSResource(context, 0);
|
tintpal.SetVSResource(context, 0);
|
||||||
}
|
}
|
||||||
|
if (pstintflag == 2)
|
||||||
|
{
|
||||||
|
tintpal.SetPSResource(context, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (geom.BoneTransforms != null)
|
if (geom.BoneTransforms != null)
|
||||||
|
@ -323,6 +323,7 @@ namespace CodeWalker.Rendering
|
|||||||
|
|
||||||
|
|
||||||
uint windflag = 0;
|
uint windflag = 0;
|
||||||
|
uint tintflag = 0;
|
||||||
var shaderFile = geom.DrawableGeom.Shader.FileName;
|
var shaderFile = geom.DrawableGeom.Shader.FileName;
|
||||||
switch (shaderFile.Hash)
|
switch (shaderFile.Hash)
|
||||||
{
|
{
|
||||||
@ -335,13 +336,18 @@ namespace CodeWalker.Rendering
|
|||||||
case 4265705004://{trees_normal_diffspec.sps}
|
case 4265705004://{trees_normal_diffspec.sps}
|
||||||
windflag = 1;
|
windflag = 1;
|
||||||
break;
|
break;
|
||||||
|
case 231364109: //weapon_normal_spec_cutout_palette.sps
|
||||||
|
case 3294641629://weapon_normal_spec_detail_palette.sps
|
||||||
|
case 731050667: //weapon_normal_spec_palette.sps
|
||||||
|
tintflag = 2; //use diffuse sampler alpha for tint lookup! (ignore texture alpha in PS)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GeomVars.Vars.EnableTexture = usediff ? 1u : 0u;
|
GeomVars.Vars.EnableTexture = usediff ? 1u : 0u;
|
||||||
GeomVars.Vars.EnableTint = 0u;// usetint ? 1u : 0u;
|
GeomVars.Vars.EnableTint = tintflag;// usetint ? 1u : 0u;
|
||||||
GeomVars.Vars.IsDecal = 0u;// DecalMode ? 1u : 0u;
|
GeomVars.Vars.IsDecal = 0u;// DecalMode ? 1u : 0u;
|
||||||
GeomVars.Vars.EnableWind = windflag;
|
GeomVars.Vars.EnableWind = windflag;
|
||||||
GeomVars.Vars.WindOverrideParams = geom.WindOverrideParams;
|
GeomVars.Vars.WindOverrideParams = geom.WindOverrideParams;
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user