New lesson reques
In old games, even in some of new ones there is cool looking effect of portals, when some surface is textured with picture of other place created in realtime.
I'm not sure how that can be done fast, and even is that possible, when i tried that process of "downloading" picture from GL to real memory and then use as texture (therefore download it back) taked lot of time and slows cpu greatly. There should be a faster way, could we get tutorial on that ? =)
If I understood correctly, that sounds like pretty standard render-to-texture. There are tutorials available readily. You can copy the current frame buffer to a texture using glCopySubTexImage2D or something like it. You can also "download" the screen to "real" CPU memory and use it as a texture, but that's darned slow.
So if you want to do "a portal into another world" or whatever, you do this:
1) Render "the another world" end of the portal, like there is a camera in the other end
2) Copy it to texture
3) Render the "this world" end of the portal, using the texture copied above as a texture to draw the portal. Perhaps add some effects or a magic'ey eerie glow texture or something to add up the illusion.
4) You're done
If the other end of the portal never changes, you don't have to render it every frame, just once when the level/whatever is loaded.
You can use this same method to create nice security cameras with monitoring rooms, mirrors and reflections (cube mapping), etc etc.
Hope this helps,
-Riku
So if you want to do "a portal into another world" or whatever, you do this:
1) Render "the another world" end of the portal, like there is a camera in the other end
2) Copy it to texture
3) Render the "this world" end of the portal, using the texture copied above as a texture to draw the portal. Perhaps add some effects or a magic'ey eerie glow texture or something to add up the illusion.
4) You're done
If the other end of the portal never changes, you don't have to render it every frame, just once when the level/whatever is loaded.
You can use this same method to create nice security cameras with monitoring rooms, mirrors and reflections (cube mapping), etc etc.
Hope this helps,
-Riku
Exactly what i'm asking for.
I understand algorithm is that i
1)first render portal viewpoint
2)then somehow i convert it to texture
3)then i finish with rendering player viewpoint.
What i was exactly asking is how to do step 2 ??? taking "snapshot" to pc memory to transfer it back to video memory is crazy and slow. There should be a easier way... I found nothing like "CopySubTexImage" not in my CsGL library, not even in red book =(((
And therefore it will be great to make a tutorial about this, because nothing of allready existing tutorials covers that, and it's for my mind is very usefull trick. Anyway just for now i'm interested in how i make step 2 ?
I understand algorithm is that i
1)first render portal viewpoint
2)then somehow i convert it to texture
3)then i finish with rendering player viewpoint.
What i was exactly asking is how to do step 2 ??? taking "snapshot" to pc memory to transfer it back to video memory is crazy and slow. There should be a easier way... I found nothing like "CopySubTexImage" not in my CsGL library, not even in red book =(((
And therefore it will be great to make a tutorial about this, because nothing of allready existing tutorials covers that, and it's for my mind is very usefull trick. Anyway just for now i'm interested in how i make step 2 ?
Omg, i found this command in compiled library, but nothing about it in red book and even blue book.... strange =).
1. It's definitly possible, there is video from valve(it's availible from steam) called portal, it's wicked cool.
or the youtube version ">
2. There is a few planed lessons that deals with a parts of this effect, just not the whole thing, i will look into it if such a lesson can be added into the planning.
There is more to it than just copy the texture such as getting the camera angle right and cliping the portal window to improve preformance.
or the youtube version ">
2. There is a few planed lessons that deals with a parts of this effect, just not the whole thing, i will look into it if such a lesson can be added into the planning.
There is more to it than just copy the texture such as getting the camera angle right and cliping the portal window to improve preformance.
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
I found command explanation inside MSDN, therefore i'm not tried it yet, and the tutorial would be great. (Where should we find such a good guy to make it for us ? ^^)
it's not that difficult as you think:
you have to create an empty texture which you can render to:
Where width and height are the size of your renderTexture and you have to set your Veiwport to this size while rendering to the texture.
And then, after having rendered the "portal" to the screen you bind the texture you want to render to and call:
glCopyTexImage2D(GL_TEXTURE_2D,0,GL_RGB,0,0,width,height,0);
That's it!
Then clear the screen and draw your world including a "portal" with this texture...
you have to create an empty texture which you can render to:
GLuint textureID; // Create a pointer to store the blank image data unsigned int *pTexture = NULL; // Allocate and init memory for the image array and point to it from pTexture pTexture = new unsigned int [width*height*bpp]; memset(pTexture, 0, width*height*bpp * sizeof(unsigned int)); // Register the texture with OpenGL and bind it to the texture ID glGenTextures(1, &textureID); glBindTexture(GL_TEXTURE_2D, textureID); // Create the texture and store it on the video card glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width,height, 0, type, GL_UNSIGNED_INT, pTexture);
Where width and height are the size of your renderTexture and you have to set your Veiwport to this size while rendering to the texture.
And then, after having rendered the "portal" to the screen you bind the texture you want to render to and call:
glCopyTexImage2D(GL_TEXTURE_2D,0,GL_RGB,0,0,width,height,0);
That's it!
Then clear the screen and draw your world including a "portal" with this texture...
Member of the NeHe team | PhD Student at Heidelberg Collaboratory for Image Processing | ProCamera Developer
That's definitely not it.
I would say that the hardest part would be not rendering to a texture, but positioning the new world to be correctly aligned, and also dealing with the fringe cases (What if the new world also has a portal?)
I would say that the hardest part would be not rendering to a texture, but positioning the new world to be correctly aligned, and also dealing with the fringe cases (What if the new world also has a portal?)
Quote: Original post by AKrotkov also dealing with the fringe cases (What if the new world also has a portal?)
Hold on a minute, there is a definite infinite recursion issue here along with a preformance issue.
If you are doing a third gen engine only one portal should be alowed at one time for now, for the rest only 10.
The positioning of the portal camera should not be that hard.
1. get the relative position between the camera and the portal.
2. translate, the portal camera acording to step 1.
3. rotate the camera normal + the rotation of the source portal.
4. configure the scissor op
I think, i havn't tried it.
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement