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
drop the ambient light for geometry exposure, still pretty good fps for intel HD 4400
thanks
color format with varying channel depth
-
- Competition winner
- Posts: 189
- Joined: Tue Oct 16, 2007 3:53 am
- Location: Indonesia
- Contact:
Re: color format with varying channel depth
You can set a separate render target for the depth.
Re: color format with varying channel depth
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.
-
- Competition winner
- Posts: 189
- Joined: Tue Oct 16, 2007 3:53 am
- Location: Indonesia
- Contact:
Re: color format with varying channel depth
Foaly wrote:You can set a separate render target for the 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 hinthendu 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.
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?
-
- Competition winner
- Posts: 189
- Joined: Tue Oct 16, 2007 3:53 am
- Location: Indonesia
- Contact:
Re: color format with varying channel depth
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
i can store it as below right?
Code: Select all
float depth = 0.111222333444;
vec4 depth(0.111, 0.222, 0.333, 0.444);
Re: color format with varying channel depth
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.
-
- Competition winner
- Posts: 189
- Joined: Tue Oct 16, 2007 3:53 am
- Location: Indonesia
- Contact:
Re: color format with varying channel depth
thanks hendu. i found that article. an also i found this ECF_G32R32F you mention earlier, strange cant find it before, camouflage may be . 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 .thanks again.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.
[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
the buffers (see depth and normal being voxelized)
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?
-
- Competition winner
- Posts: 189
- Joined: Tue Oct 16, 2007 3:53 am
- Location: Indonesia
- Contact:
Re: color format with varying channel depth
thanks again hendu. actually pretty obvious isn't it. i was hopping for "a hidden trick" . thanks again.