Hit A Snag with the tunnel Vision

On UE5:

When I play in the non-vr mode (Selected View Port). I can move forward and the tunnel is in the center, if I move anywhere else it shoots to the top left of the screen. Playing in VR its just completely black… On Standard Rift :frowning:

Edit: When I simulate (Not VR Mode) and go diagonally the tunnel moves to perfectly horizontal. So either (0,.5) or (1, 0.5). VR Mode is still black.

Edit 2: So I found the reason this is broken, but I don’t have a good fix for it. GetViewportSize, Y returns 1280, but X is Zero…it’s always zero. Manually putting something in here makes things a bit more stable but I shouldn’t have to hardcode viewport resolutions. Any idea’s?

My Code is as follows:

void AVRCharacter::UpdateBlinker()
{
	if (!RadiusVsVelocity) return;

	float Velocity = GetVelocity().Size();
	float Radius = RadiusVsVelocity->GetFloatValue(Velocity);
	BlinkerMaterialInstance->SetScalarParameterValue(TEXT("Focus Radius"), Radius);

	FVector2d Center = GetBlinkerCenter();
	BlinkerMaterialInstance->SetVectorParameterValue(TEXT("Center"), FLinearColor(Center.X, Center.Y, 0));
}

FVector2d AVRCharacter::GetBlinkerCenter()
{

	FVector MovementDirection = GetVelocity().GetSafeNormal();
	APlayerController* PC = Cast<APlayerController>(GetController());
	if (MovementDirection.IsNearlyZero() || !PC) return FVector2d(0.5, 0.5);

	FVector2d ScreenStationaryLocation;
	FVector WorldStationaryLocation = Camera->GetComponentLocation() + MovementDirection * 1000;
	PC->ProjectWorldLocationToScreen(WorldStationaryLocation, ScreenStationaryLocation);

	int32 SizeX, SizeY;
	PC->GetViewportSize(SizeX, SizeY);
	ScreenStationaryLocation.X /= SizeX;
	ScreenStationaryLocation.Y /= SizeY;

	return ScreenStationaryLocation;
}

Material is attached.

Couple of possibilities here.
1, you’re not handling when you’re Moving backwards - may be handled in a different lecture but it involves FVector::DotProduct.
2. SizeX and SizeY are ints, and you’re dividing a float which may result in 0,0 - when dividing, you may need to cast the SizeX and SizeY to a float to ensure it doesn’nt treat as an integer divide.

Give these a try first

I ended up replacing all my code with whats on GitHub. No dice.

Also check this out:

	int32 SizeX, SizeY;
	PC->GetViewportSize(SizeX, SizeY);
	ScreenStationaryLocation.X /= SizeX ;
	ScreenStationaryLocation.Y /= SizeY;

	UE_LOG(LogTemp, Warning, TEXT("Viewport Size: %f %f"), SizeX, SizeY );

Outputs:
Viewport Size: 0 1280

Which is strange as the Occulus should have a 1200 Y resolution not 1280. And the 0 is coming from the GetViewporSite.

Have you tried updating your GPU drivers?

Also, do you want to share your project with me so I can take a look. This is very strange.

If you do, delete the binaries from the project before zipping it up.