RavenSystem / VRPerfKit_RSF

OpenVR Performance Toolkit RavenSystem's Fork
Other
78 stars 5 forks source link

I've added a vertical offset, do you want to merge? #7

Open erbarratt opened 2 months ago

erbarratt commented 2 months ago

Hi there, I've added a vertical offset for FFR, for headsets like the Varjo Aero where the eye centre is actually computed as quite far down.

It's another parameter in the yaml, and is simply taken from the computed L/R eye centre Y. Seeing as these vals are 0 - 1, offsets work in the range 0 - 0.5. In the function for creating VRS pattern.

Can I send you code? I didn't fork, I cloned.

RavenSystem commented 2 months ago

Sure.

erbarratt commented 2 months ago
FixedFoveatedConfig &ffr = g_config.ffr;
ffr.enabled = ffrCfg["enabled"].as<bool>(ffr.enabled);
ffr.favorHorizontal = ffrCfg["favorHorizontal"].as<bool>(ffr.favorHorizontal);
ffr.innerRadius = ffrCfg["innerRadius"].as<float>(ffr.innerRadius);
ffr.midRadius = ffrCfg["midRadius"].as<float>(ffr.midRadius);
ffr.outerRadius = ffrCfg["outerRadius"].as<float>(ffr.outerRadius);
ffr.verticalOffset = ffrCfg["verticalOffset"].as<float>(ffr.verticalOffset); //<----------added this
ffr.overrideSingleEyeOrder = ffrCfg["overrideSingleEyeOrder"].as<std::string>(ffr.overrideSingleEyeOrder);

^ in config.cpp

std::vector<uint8_t> CreateCombinedFixedFoveatedVRSPattern( int width, int height, float leftProjX, float leftProjY, float rightProjX, float rightProjY ) {
    std::vector<uint8_t> data (width * height);
    int halfWidth = width / 2;

    for (int y = 0; y < height; ++y) {
        for (int x = 0; x < halfWidth; ++x) {
            float fx = float(x) / halfWidth;
            float fy = float(y) / height;
            float distance = 2 * sqrtf((fx - leftProjX) * (fx - leftProjX) + (fy - leftProjY - g_config.ffr.verticalOffset) * (fy - leftProjY - g_config.ffr.verticalOffset)); //<----------modified this
            data[y * width + x] = DistanceToVRSLevel(distance);
        }
        for (int x = halfWidth; x < width; ++x) {
            float fx = float(x - halfWidth) / halfWidth;
            float fy = float(y) / height;
            float distance = 2 * sqrtf((fx - rightProjX) * (fx - rightProjX) + (fy - rightProjY - g_config.ffr.verticalOffset) * (fy - rightProjY - g_config.ffr.verticalOffset)); //<----------modified this
            data[y * width + x] = DistanceToVRSLevel(distance);
        }
    }

    return data;
}

std::vector<uint8_t> CreateSingleEyeFixedFoveatedVRSPattern( int width, int height, float projX, float projY ) {
    std::vector<uint8_t> data (width * height);

    for (int y = 0; y < height; ++y) {
        for (int x = 0; x < width; ++x) {
            float fx = float(x) / width;
            float fy = float(y) / height;
            float distance = 2 * sqrtf((fx - projX) * (fx - projX) + (fy - projY - g_config.ffr.verticalOffset) * (fy - projY - g_config.ffr.verticalOffset)); //<----------modified this
            data[y * width + x] = DistanceToVRSLevel(distance);
        }
    }

    return data;
}

^modified these lines in d3d11_variable_rate_shading.cpp