Closed aconstlink closed 3 years ago
The current solution sets a value of a system shader variable like sys_flipv_tex_name
. The value is 0.0 for no flip and 1.0 for flip. This allows to access the texture upside down. Here is an example:
Texture2D u_tex : register( t0 );
SamplerState smp_u_tex : register( s0 );
float sys_flipv_u_tex ; // set automatically by the run-time
...
{
float2 uv = input.tx ;
uv.y = lerp( uv.y, 1.0 - uv.y, sys_flipv_u_tex ) ;
return u_tex.Sample( smp_u_tex, uv ) * input.color ;
}
The fact that a d3d11 framebuffer render target renders in y upside down, make the usage render targets as ordinary textures for processing unavailable. This is very inconvenient.
A solution would be: In the d3d11 run-time send an additional float to the shader to allow for distinguishing between a normal texture and a render target texture. In that way the texture coordinate for that texture could just be flipped and the texture is accessed correctly.