bactino:
hello send your shader here already
I found 2 shader for ReShade that more or less do what I need. Below is the first of the two.
Positive points:
- allows 90° rotation (actually any angle you like) which is another option I needed
- allows you to position the image within the display area
- allows image scaling
Negative points:
-
the rotation completely stretches the image along the entire horizontal axis of the display. You completely lose the original aspect ratio (and this is normal), but the internal rotation of RA does not cause the same disaster
-
the positioning of the image does not occur by entering coordinates (which is what I would like) but with a parameter that I don’t quite understand how it works: it seems to be 1 pixel (min.) shift and this more or less applies to the X axis but for the Y axis the math doesn’t add up. In essence, it is not possible to determine the position of the image exactly (the exact number of pixels shifted). Moreover it moves the image starting from its current position, while the RA option places the initial position of the image on coordinates XY 0,0 (rightly!) allowing a convenient calculation of the pixels to be shifted to obtain the desired position
-
I don’t quite understand how the scaling is expressed…seems a sort of strange multiplier but the essence is that it makes the work of setting a precise aspect ratio unnecessarily laborious, furthermore I need to set not only the aspect ratio but the exact number of pixels of the displayed area (X,Y)
-
almost forgot to say that the worst thing is even after you have managed with a lot of patience to obtain more or less the desired result, when you change the core (or even just the game!) you get a completely different result, so in the end the work done becomes useless (at least for my purpose) and the shader as it is is unusable. RA option produce the same result (view) regardless of core and loaded game.
I don’t want to bother with percentages and multipliers but simply set direct and clear measurements: pixels
There you go:
#include "shared/cGraphics.fxh"
/*
[Shader Options]
*/
uniform float _Angle <
ui_label = "Rotation Angle";
ui_type = "drag";
> = 0.0;
uniform float2 _Translate <
ui_label = "Translation";
ui_type = "drag";
> = 0.0;
uniform float2 _Scale <
ui_label = "Scaling";
ui_type = "drag";
> = 1.0;
/*
[Vertex Shaders]
*/
VS2PS_Quad VS_Matrix(APP2VS Input)
{
// Calculate the shader's HPos and Tex0
// We modify the Tex0's output afterward
VS2PS_Quad Output = VS_Quad(Input);
float RotationAngle = radians(_Angle);
float2x2 RotationMatrix = float2x2
(
cos(RotationAngle), -sin(RotationAngle), // Row 1
sin(RotationAngle), cos(RotationAngle) // Row 2
);
float3x3 TranslationMatrix = float3x3
(
1.0, 0.0, 0.0, // Row 1
0.0, 1.0, 0.0, // Row 2
_Translate.x, _Translate.y, 1.0 // Row 3
);
float2x2 ScalingMatrix = float2x2
(
_Scale.x, 0.0, // Row 1
0.0, _Scale.y // Row 2
);
// Scale TexCoord from [0,1] to [-1,1]
Output.Tex0 = Output.Tex0 * 2.0 - 1.0;
// Do transformations here
Output.Tex0 = mul(Output.Tex0, RotationMatrix);
Output.Tex0 = mul(float3(Output.Tex0, 1.0), TranslationMatrix).xy;
Output.Tex0 = mul(Output.Tex0, ScalingMatrix);
// Scale TexCoord from [-1,1] to [0,1]
Output.Tex0 = Output.Tex0 * 0.5 + 0.5;
return Output;
}
/*
[Pixel Shaders]
*/
float4 PS_Matrix(VS2PS_Quad Input) : SV_TARGET0
{
return tex2D(CShade_SampleColorTex, Input.Tex0);
}
technique CShade_Transform
{
pass
{
SRGBWriteEnable = WRITE_SRGB;
VertexShader = VS_Matrix;
PixelShader = PS_Matrix;
}
}