View Full Version : Texture3d ?
02-18-2000, 01:17 AM
What the use of 3d texture ? Is it used for bump mapping or what ? And how do i use it ?
02-18-2000, 02:00 AM
Some example uses of 3d textures:
1) Volume rendering. Draw a stack of quads with a slight offset between each one. Each quad bumps up the r texcoord, and so displays the next "slice" of the volume.
2) Lightmapping. If you've got a point lightsource with a fairly small illumination area, build a 3d texture, bright at the centre fading to dim at the edges, and map it onto nearby polygons. That way you can move the lightsource around and still get good lightmapping on polys at any angle.
3) Terrain rendering; change terrain types over r, and get smooth blending based on the y coord of terrain verts.
Just a few possibilities - there are many more. Not bumpmapping though - that's a different technique.
02-18-2000, 11:08 AM
So the 3D texture is an array of 2d textures if I understand ? A kind of cube with pixels in it instead of a plane, isn't it ?
02-18-2000, 11:40 AM
Right, in the same way that 2d textures are arrays of 1d textures, and 1d textures are arrays of 0d textures (i.e. pixels).
Another use just occurred to me - 2d cel animation. One r-layer per animation frame, with the texture filter doing subpixel interpolation between frames. Cute...
(Side note - the "arrays of arrays" concept is useful for visualizing things, but if you're creating 3d or 2d textures on the heap, it's better to allocate one big block of memory for the whole thing than to create a multidimensional array. Some compilers, including MSVC, insert "guard bytes" before and after heap-allocated arrays when building in debug mode, in order to detect subscripting overruns. Unfortunately this means that the lines/planes of the texture are no longer contiguous in memory, so when you upload them the results may not be quite what you expected...)
02-18-2000, 11:53 AM
And can i use a floating value for r so as to make a transition between 2 textures ? this could be *very* useful !
02-18-2000, 12:14 PM
Yup, r is just like the s and t coords for 2-dimensional textures. Floats are fine.
Do bear in mind that 3d textures aren't in core OpenGL 1.1 - they were only available as an extension - and driver support for OpenGL 1.2 is still extremely patchy. So be prepared for the fact that 3d textures might not work on your system, and that there's a severe dearth of example code.
I agree, though; I've only starting thinking about 3d textures in the last couple of days, but they just keep looking better and better.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.