Welcome, Guest.
Username: Password: Remember me

TOPIC: Displaying a texture on one part of the screen

Displaying a texture on one part of the screen 8 months 3 weeks ago #1

Is there a way to display a texture only on one part of the screen?

Currently, any non-screen-resolution texture will simply stretch to fit the entire screen. Is there a way to make it so it doesn't do that?
The administrator has disabled public write access.

Displaying a texture on one part of the screen 8 months 3 weeks ago #2

Sure. Simple:
float4 Main(in float4 vpos : SV_POSITION, in float2 texcoord : TEXCOORD) : SV_TARGET
{
    const float2 overlay_pos = float2(10, 10); // Position in pixels from top left on the screen.
    const float2 overlay_size = float2(200, 200); // Size of the overlay texture in pixels on the screen.

    if (vpos.x > overlay_pos.x && vpos.x < (overlay_pos.x + overlay_size.x) &&
        vpos.y > overlay_pos.y && vpos.y < (overlay_pos.y + overlay_size.y))
    {
        return tex2D(overlay_texture, (vpos.xy - overlay_pos) / overlay_size);
    }
    else
    {
        return tex2D(ReShade::BackBuffer, texcoord);
    }
}
Instead of "vpos", you can also use "texcoord" and do the same in texture coordinate space (between 0 and 1), rather than screen space (between 0 and screen width/height in pixels).
Cheers, crosire =)
Last Edit: 8 months 3 weeks ago by crosire.
The administrator has disabled public write access.
The following user(s) said Thank You: moriz1

Displaying a texture on one part of the screen 8 months 1 week ago #3

You can also change texture sampler settings:
sampler CursorSampler
{
	Texture = CursorTex;
	AddressU = BORDER;
	AddressV = BORDER;
};
The administrator has disabled public write access.