Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
erbarratt opened this issue Jun 24, 2024 · 2 comments
Open

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

erbarratt opened this issue Jun 24, 2024 · 2 comments

Comments

@erbarratt
Copy link

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
Copy link
Owner

Sure.

@erbarratt
Copy link
Author

erbarratt commented Jun 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants