1
votes

We have some media processing application, and we need ability for rotate frames.
We use GPU.
We have Vertex Shader in HLSL with follow code:

struct VS_INPUT
{
    float4 Pos : POSITION;
    float2 Tex : TEXCOORD;
    uint   TexIdx : TEXINDEX;
};

struct VS_OUTPUT
{
    float4 Pos : SV_POSITION;
    float2 Tex : TEXCOORD;
    uint   TexIdx : TEXINDEX;
};

VS_OUTPUT VS(VS_INPUT input)
{
   VS_OUTPUT output;
   float2 pos_rotate = input.Pos.xy;
   float rads = radians(45);
   float cFlare = cos(rads);
   float sFlare = sin(rads);
   output.Pos = input.Pos;
   output.Pos.xy = mul(pos_rotate, float2x2(cFlare, -sFlare, sFlare, cFlare));

   output.Tex = input.Tex;
   output.TexIdx = input.TexIdx;
   return output;
};

So, as I understand, sin and cos get angle in radians.
radians get angle in degrees.
But as we see, the frame came rotated to 90° and not 45°.

frame

1
What happens when you do radians(0), radians(10), radians(90) etc.? Also, can you include the C++ code that uses this shader? (See minimal reproducible example) Thanks! - Max Vollmer
ОК, the problem in C++ code, in other call stack the frame rotates as expected. But it difficult now to provide the C++ code... I think, I will put the frame just in right call stack. - Olga Pshenichnikova

1 Answers

0
votes

ОК, the problem in C++ code, in other call stack the frame rotates as expected. But it difficult now to provide the C++ code... I think, I will put the frame just in right call stack.