At first this seem to work but eventually I realized that at some point my up/down rotation are switched gradually overtime (almost like a slow sinus).
Any idea on how to rotate both x and y without distorting the image?
I have tried another approach where I try to simply use a mesh with a material based on objectOrientation (I use a sphere mesh to do a skysphere). This works well for the sky itself but now all my other actors flickers which was not the case with the dynamic texture (the niagara effects are the most afffected by the flickering).
In the end, the best option, is to make your own sky dome ( not sphere ), because it is possible to project the UVs down from a plane, and avoid almost all problems
Regarding
“The reason you’re getting distortion, is because the typical sphere has distorted UVs, especially pinched at the top”
I get what you mean but in my case the distortion was kind of dynamic (like a deflating or inflating balloon, but now with the screenshot from main post I don’t have any distortion, only up/down rotation degradation). I suspected my pivot point at first but it does not seem to be the issue.
The distortion from the sphere is really not that bad I can see it in the viewport with another non dynamic version of my texture.
PROS: Fluid rotation of the background at runtime
CONS: High flickering of actors (especially niagara systems)
Solution#2:
Code solution mixed to perform Angles to Quaternions transformation (to mix X axis and Y axis together, thx Bing Copilot) mixed with the solution presented in https://www.youtube.com/watch?v=IQ3wKSzAEG4. (This one use a /Engine/EngineSky/SM_SkySphere.SM_SkySphere instead of /Engine/BasicShapes/Sphere.Sphere)
f_YBasicRotation = 0 + 0.1 * f_Counter;
f_XBasicRotation = 0 + 0.1 * f_Counter;
f_Counter++;
// Define the rotations
FRotator RotationX(f_YBasicRotation, 0.0f, 0.0f);
FRotator RotationY(0.0f, 0.0f , f_XBasicRotation);
// Convert to quaternions
FQuat QuatX = FQuat(RotationX);
FQuat QuatY = FQuat(-1 * RotationY);
// Combine the quaternions
FQuat CombinedQuat = QuatY * QuatX;
// Ensure stability for small angles
if (CombinedQuat.IsIdentity())
{
CombinedQuat = FQuat::Identity;
}
// Get the axis and angle from the combined quaternion
FVector RotationAxis = CombinedQuat.GetRotationAxis();
float RotationAngle = CombinedQuat.GetAngle();
RotationAngle = FMath::RadiansToDegrees(RotationAngle); // Convert to degrees
// Output the axis and angle
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::Printf(TEXT("N Rotation Axis: %s , Rotation Angle: %f degrees "), *RotationAxis.ToString(), RotationAngle));
// Create a vector with rotation angle
FVector MyVector(RotationAngle, 0.0f, 0.0f);
// Set the material parameters
UMID_DynamicSkyMaterial->SetVectorParameterValue(TEXT("AxisToSet"), RotationAxis);
UMID_DynamicSkyMaterial->SetVectorParameterValue(TEXT("XYZMapRotation"), MyVector * 0.001);
USMC_SkyDomeMesh->SetMaterial(0, UMID_DynamicSkyMaterial);
Because all the things in my view (within the sphere) (mainly niagara systems) flickers more with the mesh rotation approach than with the dynamic material approach
When I rotate the mesh (stuff in my game (within the sphere) flicker more)
When I rotate the material (stuff in my game (within the sphere) flicker less)
My hero! so finally Solution#1
(Mesh, material with object rotation) with your sky fix to the material does exactly what I am looking for and I have no more flickering! THX