Jump to content
  • Advertisement
Sign in to follow this  
MarvinSmisek

Render to rectangular area of texture

This topic is 2754 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there!

I'm programming a radiosity renderer where I use "hemicube look" which is then rendered to a texture.
The problem is the hemicube look is made of five camera looks (five directions) which are rendered separatedly.

Now I use framebuffer object where the textures are bound and one camera look is rendered to each of them. But since in the end I need these looks to be combined in just one texture, this seems to me as a performance killing way.

Is there a way to specify an area of texture and then render (using FBO) only to that area?

I would try to use [font="Courier New"]glTexSubImage2D[/font] to composite textures into a new one, but I guess that would be even slower, since the textures are already in the memory (loaded for FBO rendering).

Thanks for any thoughts smile.gif

Share this post


Link to post
Share on other sites
Advertisement
Is what you're doing different than a cubemap? You can create a cubemap texture and then render once into each face.

Share this post


Link to post
Share on other sites
Checking my old radiosity baker I see I was using scissor and viewport to render seperate views to a single texture (arranged like a cross):

[color="#008000"][color="#008000"]// Front
glViewport((GLint)(0.25f*width), (GLint)(0.25f*height), (GLsizei)(0.5f*width), (GLsizei)(0.5f*height));
RenderVBOFromPoint(position, position+target[0], newUp[0]);

[color="#008000"][color="#008000"]// Up
glScissor((GLint)(0.25f*width), (GLint)(0.75f*height), (GLsizei)(0.5f*width), (GLsizei)(0.25f*height));
glViewport((GLint)(0.25f*width), (GLint)(0.75f*height), (GLsizei)(0.5f*width), (GLsizei)(0.5f*height));
RenderVBOFromPoint(position, position+target[1], newUp[1]);

[color="#008000"][color="#008000"]// Down
glScissor((GLint)(0.25f*width), 0, (GLsizei)(0.5f*width), (GLsizei)(0.25f*height));
glViewport((GLint)(0.25f*width), (GLint)(-0.25f*height), (GLsizei)(0.5f*width), (GLsizei)(0.5f*height));
RenderVBOFromPoint(position, position+target[2], newUp[2]);

[color="#008000"][color="#008000"]// Left
glScissor(0, (GLint)(0.25f*height), (GLsizei)(0.25f*width), (GLsizei)(0.5f*height));
glViewport((GLint)(-0.25f*width), (GLint)(0.25f*height), (GLsizei)(0.5f*width), (GLsizei)(0.5f*height));
RenderVBOFromPoint(position, position+target[3], newUp[3]);

[color="#008000"][color="#008000"]// Right
glScissor(0, 0, width, height);
glViewport((GLint)(0.75f*width), (GLint)(0.25f*height), (GLsizei)(0.5f*width), (GLsizei)(0.5f*height));
RenderVBOFromPoint(position, position+target[4], newUp[4]);

It all messes up if I put it in code tags :/
If I recall RenderVBOFromPoint just moves the camera and renders. Width and height are the target textures width/height.

Share this post


Link to post
Share on other sites
I don't need cubemap textures because I'm not going to render it at all. (Well, maybe I will, but just as a dev info wheather the rendering is working fine.)
I'll read the texture data to get colors of objects which are visible from the point of rendering (which is why I need the camera to look in five directions around).

In fact this is really about optimizing - I want to render 5 different views into a single texture (not overlaying each other), because I think it'd be faster than working (bind, write, read) with 5 separated texture objects.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!