color format with varying channel depth

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

color format with varying channel depth

Post by kornwaretm »

hi every one. i'm trying to make a ray marching based rendering. the idea is ray traced super complex geometry, and a good deffered shading for lighting. the default texture format a8r8g8b8 is causing glitches. i store depth in alpha channel, so by changing color format to a32r32g32b32 glitches almost gone. mainly i generate normalmap from the depth map which i store in alpha channel. the problem of 32bit for each channel is too much performance hit. is possible to have color format with varying channel depth? i need to have a render target with 8 bit red green blue, and 32 bit for alpha. is it possible?

my gbuffer
Image
drop the ambient light for geometry exposure, still pretty good fps for intel HD 4400 :lol:
Image

thanks
Foaly
Posts: 142
Joined: Tue Apr 15, 2014 8:45 am
Location: Germany

Re: color format with varying channel depth

Post by Foaly »

You can set a separate render target for the depth.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: color format with varying channel depth

Post by hendu »

Not without packing. You can use R32G32, store the depth in green, and colors packed in red. Alternatively, use two rgba8 textures, with one having normal colors, and one having packed depth.
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Re: color format with varying channel depth

Post by kornwaretm »

Foaly wrote:You can set a separate render target for the depth.
hendu wrote:Not without packing. You can use R32G32, store the depth in green, and colors packed in red. Alternatively, use two rgba8 textures, with one having normal colors, and one having packed depth.
thanks Foaly and hendu. i'm aware of this two out texture thingy, i've heard that it is possible to have multiple output from a fragment program, but never found and example or tutorial that actually did that. i'd be very happy for an example or a hint :wink:
hendu i can't find R32G32 color format. is it literally means a color format, or treat r16g16b16a16 channels as 2 channels ? either way, is that means bitwise operation are possible inside shader?
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Re: color format with varying channel depth

Post by kornwaretm »

correct me if i'm wrong. i think i know how to use several vector components to store single value. and it doesn't involve bitwise. for example

Code: Select all

 
float depth = 0.111222333444;
vec4 depth(0.111, 0.222, 0.333, 0.444);
 
i can store it as below right?
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: color format with varying channel depth

Post by hendu »

There's a blog post by Unity that explains how to do float packing in shaders. Try to look it up, can't remember what the title was. IIRC it was by Aras P, like most useful things there.
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Re: color format with varying channel depth

Post by kornwaretm »

hendu wrote:There's a blog post by Unity that explains how to do float packing in shaders. Try to look it up, can't remember what the title was. IIRC it was by Aras P, like most useful things there.
thanks hendu. i found that article. an also i found this ECF_G32R32F you mention earlier, strange cant find it before, camouflage may be :lol: . i though gl_fragColor will use vec2 instead of vec4 . but gl_FragColor = vec2(r,g) throws error. then i write the fragment color this way gl_fragColor = vec4(depth, encodedColor, 0.0, 0.0). as expected no error. depth map are fine, performance literally doubled, but somehow color map turn into pure noise. i try to encode full white color just for testing, it turn green :lol: .thanks again.

[edited]
i found the culprit. it is the bilinear filtering on texture layers. so i disable them, and the ray marching result turned voxelized. i think it is because the cube distance function i'm using. estimating the geometry using cubes. here is how it looks now
Image
the buffers (see depth and normal being voxelized)
Image

another question. so i read about this gl_FragDepth and try to use it, turn on the enablezwrite that i disable previously. doesn't seems to do anything. i just think i might get rid of the need to do rendertarget volley with it. is the gl_FragDepth writable and readable at the same time? if not, are there something that do so, having the ability to be written on to and being read from at the same time?
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: color format with varying channel depth

Post by hendu »

https://www.opengl.org/sdk/docs/man4/ht ... epth.xhtml

"is an output variable", it cannot be read.
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Re: color format with varying channel depth

Post by kornwaretm »

thanks again hendu. actually pretty obvious isn't it. i was hopping for "a hidden trick" :lol: . thanks again.
Post Reply