Archive 17/01/2023.

How to rotate Viewport !?

OMID-313

Hi,

I want to create a scene with several viewports.
Some of these viewports shall have a rotated initial position. I mean, I want a rotated rectangle.

I tried adding the following line to 09_MultipleViewports.as example, but it gives errors!

rearViewport.Rotate(Quaternion(180.0f, Vector3(0.0f, 1.0f, 0.0f)));

So, how can I achieve this !?

Eugene

Your video card cannot rotate viewports.
Use render to texture.

OMID-313

Thanks @Eugene for your reply.

Ok then. How can I rotate the camera’s picture that comes to the viewport?
Say, we have1 camera and 4 viewports in a scene.

Viewport1 -> Camera’s picture
Viewport2 -> Camera’s picture 90’ rotated
Viewport3 -> Camera’s picture horizontal flipped
Viewport4 -> Camera’s picture 180’ rotated + vertical flipped

How can I achieve this !?

1vanK

You can flip image in shader

Viewport2 -> Camera’s picture 90’ rotated

just create another camera and rotate camera

OMID-313

Thanks @1vanK for your reply.

Is it possible to use shader for rotation too?
Because I don’t want to create several cameras.

By the way, what is the correct syntax for flipping images using shader?

1vanK

What if texture not square?

You should mix rotated texture as post process

OMID-313

Actually, I don’t truly know the difference between shader, texture, …
This is similar to what I want to achieve:
Several viewports with the same image, but some rotated, flipped, etc.

The closest example code I found was 09_MultipleViewports.as. But I don’t know how to add rotation and flip.

I would be thankful if you help me do this.
(sorry for being amateur.)

1vanK

Flip vertically in shader: vScreenPos = vec2 (vScreenPos.x, 1 - vScreenPos.y);