Depth buffer texture

Started by Thomas., June 30, 2012, 01:58:21 AM

Previous topic - Next topic

Thomas.

What is the best solution for render zbuffer? shader is not problem, but if I have screen resolution 1280*720, do I need texture resolution 2048*1024? I don't know how exactly working GPU with texture, but when I understand correctly power of 2 is needed for mip-mapping?

edit: and what is the best way to implement depth of field? I need three rendering, normal, zbuffer and plane, but how this does intelligently? :D

EgonOlsen

You have to render the depth buffer into a texture. The actual screen resolution isn't important. To render a depth map into a texture, you can use this method: http://www.jpct.net/jpct-ae/doc/com/threed/jpct/Texture.html#setAsShadowMap(boolean) and make this texture a render target of your frame buffer. However, the resulting texture doesn't contain the depth values directly but packed into ARGB format. The reason is, that i couldn't get depth textures to work on Android at least on my device. So you have to unpack the values before using them.
You can can find the code for this if you unzip the jpct_ae.jar and look at the file defaultFragmentShaderDepth.src. It contains the code to unpack the values within some comments.

About how to do depth of field...i have absolutely no clue how to do this because it never interested me in the slightest... :(


Thomas.

#2
Ok, I'll try to implement depth of field. Probably I'll have to switch IRenderHook several times on one object in one frame.

edit: And what you mean "The actual screen resolution isn't importan."? how it's working?

EgonOlsen

I've no idea how it is working, because i don't know how to do depth of field. What i meant was that for rendering into a texture, the screen resolution isn't important because the target texture has a resolution of its own.

Thomas.

So, if I understood correctly, I can use texture 16x16, but when I'll use it as render target, doesn't matter on it?

EgonOlsen

You will be rendering into a 16*16 texture then. All i was trying to say is that the texture resolution has nothing to do with the screen resolution....

Thomas.

#6
How can I calculate FOV to degree?

edit: solved, in java doc is formula

Thomas.

#7
Could you add method for create texture with any dimension, please? I have "out of memory error" with two texture with size 2048*1024. Or no storing copies in main memory.

EgonOlsen

Just create one with a color of null.

Edit: 2048*1024 is insane on a mobile device anyway IMHO...

Thomas.

NullPointerException... I agree, but I can not create texture with size 1280*720. I need two textures, first with zbuffer, second with image buffer and in third render is applied effect.

EgonOlsen

Oops...that used to work. I'll fix it...

Thomas.

omg, I'm very complicated counted size of plane, that has same size like the screen and I forgot on model view projection matrix in shader :D ok, thanks :)

EgonOlsen

Anyway, the null pointer might be fixed in the version that i've just uploaded (look the other thread for more info).

Thomas.

NullPointerException still bother... did you mean "new Texture(512, 256, null);"?

EgonOlsen

Yes...can you post the exception?