View more

View more

View more

Image of the Day Submit

IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

render texture smaller then screen

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

#1hdxpete  Members

Posted 02 May 2013 - 02:09 AM

currently using direct x 11

i'm trying to generate a render texture smaller then the screen size, and then stretch it across the entire screen.

my problem is that the texture is only taking up the equivalent amount of space on the screen.

I.E. is i make my render texture 1/2 the width, height of the screen, then when i render it to the screen it will appear in 1/4 the screen.

my pixel/vertex shader are in screen coordinates.

does anyone have a clue what might be going on? or an example for making render textures smaller then the screen? my render texture works perfectly if the render texture size is the same as the screen size.

thanks

#2unbird  Members

Posted 02 May 2013 - 03:26 AM

You got plenty of possibilities:
• Use the transformation matrices. Though it's 2D the same logic applies, i.e. use the so-called world transformation to position and scale your quad.
• Set up a vertex buffer covering the whole screen (clip space from -1 to 1 for both x and y, z = 0, w = 1) and just pass them through in the vertex shader
• For a fullscreen quad you don't even need transformations or vertex buffers at all. You can setup a vertex shader which generates the position/texcoords automatically, see below.

void FullScreenTriangleFromIndex(uint index, out float4 position, out float2 tex)
{
tex = float2((index << 1) & 2, index & 2);
position = float4(tex * float2(2,-2) + float2(-1,1), 1, 1);
}

// Call with Draw(3,0)
void FullScreenTrianglePositionOnlyVS(uint id : SV_VertexID,
out float4 position: SV_Position)
{
float2 tex;
FullScreenTriangleFromIndex(id, position, tex);
}

void FullScreenTrianglePositionTexVS(uint id : SV_VertexID,
out float4 position: SV_Position,
out float2 tex: TEXCOORD)
{
FullScreenTriangleFromIndex(id, position, tex);
}

static uint fsqids[] = {0,1,2,1,3,2};
void FullScreenQuadFromIndex(uint index, out float4 position, out float2 tex)
{
uint id = fsqids[index];
tex = float2(id & 1, (id >> 1) & 1);
position = float4(tex * float2(2,-2) + float2(-1,1), 1, 1);
}

// Call with Draw(6,0)
out float4 position: SV_Position)
{
float2 tex;
}

out float4 position: SV_Position,
out float2 tex)
{
FullScreenTriangleFromIndex(id, position, tex);
}


#3hdxpete  Members

Posted 02 May 2013 - 03:46 AM

i'm doing the second option. and what i find is that if the render texture is not the same size as the display size then it takes up the equilivent space.

so

displaywidth = texturewidth

displayheight = textureheight * 2

then my texture will appear across the entire screen but will take up 1/2 the height.

appreciate the help.

#4kauna  Members

Posted 02 May 2013 - 06:14 AM

Are you setting your viewport correctly when drawing the full screen quad / rendering to render target etc?

Cheers!

#5hdxpete  Members

Posted 02 May 2013 - 07:29 AM

that is interesting... i do set the viewport but i don't set the viewport when i change render textures... i had not thought of that.

i'll have to look more into that after the long japanese weekend. thank you Kauna.

#6hdxpete  Members

Posted 06 May 2013 - 07:49 PM

Kauna,

Sorry for the delayed response (Japanese holiday and all...) thanks for the assist, got my project perfect now.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.