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
EDITED (2024-12-30): I initially thought all text and screenshots above were enough to fix my issue.
However I realized that they were not (solution was good to fix flickering but over time I restarted getting unexpected rotation behavior (sphere would initially rotate in the right direction but would eventually starts acting weird (going up when I want to go down idem with left right and depending on my code version it could also slow to almost a stop).
To rotate my sky sphere a bit like a ball turret, I think I faced mainly the two following issues.
- Rotation on 2 axis will go up and down (really similar to what I experienced with some version of my code): https://www.youtube.com/watch?v=_AV5JinSviE&t=6s
- Euler (gimbal lock) (also really similar to what I experienced with some version of my code): https://youtu.be/zc8b2Jo7mno?si=oWIaGI4RCwoPxysk
So finally what appears to be working is the following quaternions approach which are ideal to avoid gimbal lock and ease 3D rotation. This is not my official code but on what it was based on (thx bing, only really minor changes were required to work in my situation):
#include "YourActor.h"
#include "Components/StaticMeshComponent.h"
// Initialize current rotation as identity quaternion
FQuat CurrentRotation = FQuat::Identity;
// Apply incremental rotations
void AYourActor::ApplyRotation(const FQuat& DeltaRotation)
{
// Update current rotation
CurrentRotation = DeltaRotation * CurrentRotation;
// Convert quaternion to rotator
FRotator NewRotation = CurrentRotation.Rotator();
// Apply rotation to the sphere
YourMeshComponent->SetWorldRotation(NewRotation);
}
// Example of applying a delta yaw rotation
void AYourActor::RotateLeftRight(float DeltaYaw)
{
// Create a delta rotation quaternion for yaw
FQuat DeltaRotation = FQuat(FVector::UpVector, FMath::DegreesToRadians(DeltaYaw));
ApplyRotation(DeltaRotation);
}
// Example of applying a delta pitch rotation
void AYourActor::RotateUpDown(float DeltaPitch)
{
// Create a delta rotation quaternion for pitch
FQuat DeltaRotation = FQuat(FVector::RightVector, FMath::DegreesToRadians(DeltaPitch));
ApplyRotation(DeltaRotation);
}
// Tick function to reset delta values
void AYourActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// Apply rotations based on input
// For example, call RotateLeftRight and RotateUpDown with input values
// Reset delta values for next frame
DeltaPitch = 0.0f;
DeltaYaw = 0.0f;
}
// YourActor.h file
class AYourActor : public AActor
{
GENERATED_BODY()
public:
// Constructor and other functions
AYourActor();
virtual void Tick(float DeltaTime) override;
protected:
virtual void BeginPlay() override;
private:
UPROPERTY(VisibleAnywhere)
UStaticMeshComponent* YourMeshComponent;
// Current rotation quaternion
FQuat CurrentRotation;
// Delta values for rotation
float DeltaPitch;
float DeltaYaw;
// Functions to apply rotations
void ApplyRotation(const FQuat& DeltaRotation);
void RotateLeftRight(float DeltaYaw);
void RotateUpDown(float DeltaPitch);
};
Please note @ClockworkOcean was ideal to fix flickering of various actors when rotating the sphere (thx again) but this solution also include the 3D rotations issues fixes for the difficulties of rotating a skysphere properly.
Therefore this is now the accepted solution.