diff --git a/source/FRPG_FlverPBL/FRPG_Common_ForwardPBL.fxh b/source/FRPG_FlverPBL/FRPG_Common_ForwardPBL.fxh index faf0d2f..7807464 100644 --- a/source/FRPG_FlverPBL/FRPG_Common_ForwardPBL.fxh +++ b/source/FRPG_FlverPBL/FRPG_Common_ForwardPBL.fxh @@ -61,12 +61,20 @@ StructuredBuffer lightParamBuffer : register(t18); float3 Srgb2linear(float3 c) { +#ifdef WITH_GhostMap + return pow(max(float3(0, 0, 0), c), float3(2.2, 2.2, 2.2)); +#else return pow(abs(c), float3(2.2, 2.2, 2.2)); +#endif } float3 Linear2srgb(float3 c) { +#ifdef WITH_GhostMap + return pow(max(float3(0, 0, 0), c), float3(1 / 2.2, 1 / 2.2, 1 / 2.2)); +#else return pow(abs(c), float3(1 / 2.2, 1 / 2.2, 1 / 2.2)); +#endif } float4 Srgb2linear(float4 c) diff --git a/source/FRPG_FlverPBL/FRPG_FS_HemEnv.fx b/source/FRPG_FlverPBL/FRPG_FS_HemEnv.fx index 1b82700..dc1117f 100644 --- a/source/FRPG_FlverPBL/FRPG_FS_HemEnv.fx +++ b/source/FRPG_FlverPBL/FRPG_FS_HemEnv.fx @@ -225,13 +225,14 @@ GBUFFER_OUT FragmentMain(VTX_OUT In) {//Ghost lights #ifdef WITH_GhostMap - const float4 vecPnt = CalcGetGhostLightVec(In.VtxWld.xyz); //Calculate and obtain the direction and damping coefficient of ghost light - const float3 colPnt = gFC_GhostLightCol.rgb * vecPnt.w; //Attenuate point light source color - pointLightComponent += CalcGetGhostLightDifLightCol(Mtl.Normal, vecPnt.xyz, colPnt.rgb); //Diffuse - - #ifdef WITH_SpecularMap - pointLightComponent += CalcGetGhostLightSpcLightCol(Mtl.Normal, gFC_SpcParam, vecPnt.xyz, colPnt.rgb); //Specular - #endif + float3 L = gFC_GhostLightPos.xyz - In.VtxWld.xyz; + float distL = length(L); + + pointLightComponent += PointLightContribution( + Mtl.Normal, vertexNormal, L / distL, In.VecEye.xyz, + Mtl.DiffuseColor, Mtl.SpecularColor, specularF90, + Mtl.Roughness, gFC_GhostLightCol.rgb, distL, + gFC_GhostLightPos.w, gFC_GhostLightCol.w, 0); #endif // WITH_GhostMap }