4lex4nder / ReshadeEffectShaderToggler-FFXIV

FFXIV specific ReshadeEffectShaderToggler configuration
MIT License
63 stars 4 forks source link

Camera position in world space? #19

Open liuxd17thu opened 4 months ago

liuxd17thu commented 4 months ago

In Endwalker REST extracts camPos and camDir as well as projection matrices from "Transform" group. What about these informations in Dawntrail?

I guess the float3 at 0x010 offset should be vec_CameraViewDir, but not sure of camera position data.

liuxd17thu commented 4 months ago

QQ_1721446309277 Looks like numbers in the red box is camPos, but my old StaticLayer.fx still gives out wrong results.

// ffxiv_common.fxh
    uniform float3 _camDir < source = "vec_CameraViewDir"; >;
    float3 camPos()
    {
        return float3(matViewProjInv[0][2], matViewProjInv[1][2], matViewProjInv[2][2]) / matViewProjInv[3][2];
    }
    float3 camDir()
    {
        return _camDir.xyz;
    }
// then replace all FFXIV::camPos by FFXIV::camPos() in StaticLayer
// ...

I'm not sure it is because I am using the wrong camDir source or the depth related calculations need to be refactored.

EDIT: Anyway now I fixed StaticLayer with some workarounds. new StaticLayer.fx