24Bit Depth Texture Colorformat in 1.8?
-
- Posts: 48
- Joined: Sun Apr 22, 2012 11:55 pm
- Location: Vienna
- Contact:
24Bit Depth Texture Colorformat in 1.8?
Just a quick question or feature request: will a 24 bit colorformat be introduced with Irrlicht 1.8? As far as I know the only way to render depth information into a RTT is to use a 32 bit ECF_R16G16F colorformat and save the integer and fractional part into the red and green channel respectively.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: 24Bit Depth Texture Colorformat in 1.8?
Well, you can also use R32F to store the full value?! I guess that 24bit would be rather slow due to conversion and alignment of these values. But which format would you prefer?
-
- Posts: 48
- Joined: Sun Apr 22, 2012 11:55 pm
- Location: Vienna
- Contact:
Re: 24Bit Depth Texture Colorformat in 1.8?
Haha, you're right - don't know what I thought. xDhybrid wrote:Well, you can also use R32F to store the full value?!
The reason why I am asking is because there are cases, where you don't need full 32bit accuracy for depth information, because the internal depth-buffer format can be 24bit float.
I just thought of something like R24F or call it D24F (for depth). With OpenGL you can pass GL_DEPTH_COMPONENT24 to glRenderbufferStorage, so that you save 8bits of video memory per fragment. When I looked at the OpenGL renderer I saw that this is already done with Irrlicht, but the depth rendertarget is not made publicly available for users. If DirectX has nothing comparable to that you could just fall back to R32F.
Re: 24Bit Depth Texture Colorformat in 1.8?
24 bits for the depth buffer doesn't save actually anything, i believe. Because the rest to 32 bits is used for the stencil buffer, that is, 24bits depth, and 8 bit stencil.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
-
- Posts: 48
- Joined: Sun Apr 22, 2012 11:55 pm
- Location: Vienna
- Contact:
Re: 24Bit Depth Texture Colorformat in 1.8?
Hm, I guess you are right. The details can be found in the OpenGL Specs. There it says GL_UNSIGNED_INT_24_8, although I don't understand how depth-information is stored there (normalized coordinates scaled up by 2^24?). But seems to be Opengl 4.1 anyway.
Re: 24Bit Depth Texture Colorformat in 1.8?
There is a stencil-less format too, with D24, but it's aligned to 32 still, so no saving VRAM that way.
Re: 24Bit Depth Texture Colorformat in 1.8?
I also thought that an unaligned format was odd. Still, if you see the A8R8G8B8 format for example, is still almost the same, the alpha channel doesn't contain info about color really, only transparency
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
-
- Posts: 48
- Joined: Sun Apr 22, 2012 11:55 pm
- Location: Vienna
- Contact:
Re: 24Bit Depth Texture Colorformat in 1.8?
Yes, didn't think about memory alignment. -.-
So the right way to treat that special GL_UNSIGNED_INT_24_8 format is to use ECF_A8R8G8B8?
So the right way to treat that special GL_UNSIGNED_INT_24_8 format is to use ECF_A8R8G8B8?
Re: 24Bit Depth Texture Colorformat in 1.8?
No, you can't use any format for the Depth buffer. Not obstant, for a rendertarget, you can use any texture really to store the depth. R32F, R32G32F, and R32G32F32A32F are already available, and they are IEEE754 compliant (your average floats) so, storing the depth with them is perfectly posible.
Or else, you can store your depth information inside an integer format packing it inside the color components.
You just have to normalize your depth (convert it to the interval 0-1 by dividing the depth of your fragment by the maximum depth you are handling, that corresponds to the camera far value), and store it in a standard A8R8G8B8 texture distributing the precision among the color planes.
And when you need to unpack the depth, you can unpack it normalized, and multiply it by the max range of the depth you have stored. It isn't that slow, and works perfectly with integer formats.
http://www.gamedev.net/topic/442138-pac ... re-shader/ Take a look
Or else, you can store your depth information inside an integer format packing it inside the color components.
You just have to normalize your depth (convert it to the interval 0-1 by dividing the depth of your fragment by the maximum depth you are handling, that corresponds to the camera far value), and store it in a standard A8R8G8B8 texture distributing the precision among the color planes.
And when you need to unpack the depth, you can unpack it normalized, and multiply it by the max range of the depth you have stored. It isn't that slow, and works perfectly with integer formats.
http://www.gamedev.net/topic/442138-pac ... re-shader/ Take a look
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
-
- Posts: 48
- Joined: Sun Apr 22, 2012 11:55 pm
- Location: Vienna
- Contact:
Re: 24Bit Depth Texture Colorformat in 1.8?
But if depth- and stencilbuffers are packed together in one 32bit buffer, then I can't user R32F to access depth only, because I got this 8bit part of the stencil value in it. But I guess I am mistaking something here. ^^
Edit: Okay I got how to use R32F format, but I think it's easier to pack the values into the different channels of a A8R8G8B8 RTT.
Edit: Okay I got how to use R32F format, but I think it's easier to pack the values into the different channels of a A8R8G8B8 RTT.
-
- Posts: 115
- Joined: Mon May 17, 2010 7:42 am
Re: 24Bit Depth Texture Colorformat in 1.8?
depth values are scaled according to how far is far plane. I think that nearest values doesn't depend by near plane (I think in fact GUI can be drawed above the scene, usefull unless you want to use some post processing, to speed up things).
Re: 24Bit Depth Texture Colorformat in 1.8?
Nearest values are also taken into account. The Post Perspective projection Z value is always scaled either from -1 to 1 in Open GL or from 0 to 1 in DX, that is done adapting the ZValue between the near and the far plane, which is done by dividing everything by (FarValue-NearValue) so, you shouldn't neglect the near plane.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
-
- Posts: 66
- Joined: Sat Sep 29, 2012 11:58 am
Re: 24Bit Depth Texture Colorformat in 1.8?
hi everyone i'm new to irrlicht. Can any one explain me how to create DEPTH TEXTURE using irrlicht ? as i'm looking for shadow mapping i dono how to obtain depth texture ? there is no books too refer so sad
Thanks in advance
Thanks in advance
Re: 24Bit Depth Texture Colorformat in 1.8?
You could look at Ex 1 in XEffects.
Re: 24Bit Depth Texture Colorformat in 1.8?
GL_DEPTH_COMPONENT picks best bit depth automagically
AND using a glTexture as a depth buffer saves you from MRT, complex shaders and killing fillrate with writing depth values
AND using a glTexture as a depth buffer saves you from MRT, complex shaders and killing fillrate with writing depth values