修复技能输入并更新战斗资源

This commit is contained in:
ud18010
2026-07-30 20:10:38 +08:00
parent d3c4bba5b2
commit 576aa6c14e
9077 changed files with 1322721 additions and 2648 deletions
@@ -0,0 +1,78 @@
#ifndef SGAME_VLIGHT_INCLUDED
#define SGAME_VLIGHT_INCLUDED
#if defined(_ANISOGGX_ON)
inline half D_GGXAniso_SGame(half TdotH, half BdotH, half mt, half mb, half nh)
{
half d = TdotH * TdotH / (mt * mt) + BdotH * BdotH / (mb * mb) + nh * nh;
return (1.0 / (3.14159 * mt * mb * d * d));
}
inline half V_SmithJointGGXAniso_SGame(half TdotV, half BdotV, half NdotV, half TdotL, half BdotL, half NdotL, half roughnessT, half roughnessB)
{
half lambdaV = NdotL * sqrt(roughnessT * TdotV * TdotV + roughnessB * BdotV * BdotV + NdotV * NdotV);
half lambdaL = NdotV * sqrt(roughnessT * TdotL * TdotL + roughnessB * BdotL * BdotL + NdotL * NdotL);
return 0.5 / max(1e-5f, (lambdaV + lambdaL));
}
inline half GGXSpecularTermAniso_SGame(half3 worldTangent, half3 worldBiTangent, half roughnessT,
half roughnessB, half3 halfDir, half3 lightDir, half3 viewDir, half nl, half nh, half nv)
{
half mt = roughnessT;
half mb = roughnessB;
half TdotH = dot(worldTangent, halfDir);
half BdotH = dot(worldBiTangent, halfDir);
half TdotV = dot(worldTangent, viewDir);
half BdotV = dot(worldBiTangent, viewDir);
half TdotL = dot(worldTangent, lightDir);
half BdotL = dot(worldBiTangent, lightDir);
half D = D_GGXAniso_SGame(TdotH, BdotH, mt, mb, nh);
half V = V_SmithJointGGXAniso_SGame(TdotV, BdotV, nv, TdotL, BdotL, nl, mt, mb);
half specularTerm = (V * D) * 3.14159;
return clamp(specularTerm, 0, 10);
}
#endif
#define VLIGHT_BY_PERCEPTUALROUGHNESS 1
inline half3 VLightDiffuse(half3 normal)
{
half3 lightDir = GetMainLight().direction;
half3 NDotL = saturate( dot(normal, lightDir) );
NDotL = 0.444 + NDotL * 0.556;
half3 lightColor = 1;
half3 vLightDiff = lightColor * NDotL;
return vLightDiff;
}
inline half3 Unreal4SpecBRDF_Simple(half roughness, half3 normal, half3 viewDir, half3 lightDir, half3 specularColor, half3 diffuseTerm )
{
roughness = max(0.08, roughness);
half3 H = normalize(viewDir + lightDir);
half NoH = saturate(dot(normal, H));
half m2 = roughness * roughness;
m2 *= m2;
half D = (NoH * m2 - NoH) * NoH + 1;
D = D * D + (1e-06);
D = (0.25 * m2) / D;
half3 specLighting = specularColor * D * diffuseTerm;
return specLighting;
}
#define SGameVLightDiffuse VLightDiffuse
#define VLightSpecular Unreal4SpecBRDF_Simple
inline half3 SGameVLightSpecular(half roughness, half3 normal, half3 viewDir, half3 specularColor, half3 diffuseTerm)
{
half3 lightDir = GetMainLight().direction;
roughness = max(roughness, 0.3);
return VLightSpecular(roughness, normal, viewDir, lightDir, specularColor, diffuseTerm);
}
#if defined(_ANISOGGX_ON)
inline half3 SGameVLightSpecularAniso(half roughness, half3 normal, half3 viewDir, half3 specularColor, half3 diffuseTerm, half3 worldTangent, half3 worldBitangent)
{
half3 lightDir = GetMainLight().direction;
half3 halfDir = normalize (lightDir + GetMainLight().direction);
half nl = dot(normal, lightDir);
half nh = saturate(dot(normal, halfDir));
half nv = dot(normal, viewDir);
return GGXSpecularTermAniso_SGame(worldTangent, worldBitangent, roughness, 0, halfDir, lightDir, GetMainLight().direction, nl, nh, nv);
}
#endif
#endif //SGAME_VLIGHT_INCLUDED