Jump to content

Compressed normals


Rastar
 Share

Recommended Posts

I would like to stuff an additional parameter into the G buffer. The only place I can thin of (without adding an additional texture like fragData3) is to encode the normals compress the normals to two channels and reconstruct the in the lighting shaders. However, I can't seem to get this working without artifacts, and I am unsure if this is due to the compression algorithms. Question: Is the normals texture (fragData1) 8bit per channel or 16bit per channel? Could the multisampling somehow get in my way here?

Link to comment
Share on other sites

The normal texture is 8 bits per channel. The BFN texture is used to encode a compressed normal.

 

You can extract the z component with the X and Y but you will not have a sign for the value. Sometimes you actually want normals that face away from the camera, like for palm tree fronds.

 

I supposed it would be possible to encode the sign of the z component of the normal in an extra bitwise flag for the material properties, and thus free up that extra channel for new data.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Well, you can change the emission shaders, a abit, you will only loose some color control over emission

Pack emission color in one float, leaving fragData2 green and blue channel free.

 

In the model shaders for emission:

 

vec3 e = texture(texture4,ex_texcoords0).rgb;
fragData2 = vec4(((e.r+e.g+e.b)/3),metalness,roughness,materialflags/255.0);

 

all other model shaders:

fragData2 = vec4(0,metalness,roughness,materialflags/255.0);

 

 

and lighting shaders just add this below where emission is sampled :

float metalness = emission.g;
float roughness = emission.b;
emission.rgb = emission.r*diffuse.rgb;

 

Ofcource, your diffuse have to colorize the emission now instead of the emission texture.

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Link to comment
Share on other sites

Hej shadmar, thanks fpr the tip! Yes, that would work, although I actually just need one single extra channel since I can reuse the specularity in the normal's alpha. I got the normal compression working for the non-BFN case (looking OK, though I guess some additional bits in the normal buffer would help), still having artifacts for BFN and not don't understand why, but I won't budge... ;-)

Link to comment
Share on other sites

There is no more specular in PBR, only roughness and metalness combinations , i you are tempting some PBR system.

 

Yes, I know, what I meant is that I can reuse that channel to either store roughness or metalness.

 

By the way, I finally understood how the best fit normals work, and I guess that means I can't compress those to two channels since the vectors aren't normalized. So I'll probably go ahead and just store the metalness in the upper 6 bits of the material flags channels, since that value is usually 0 or 1 anyways.

Link to comment
Share on other sites

Metalness is not 0 or 1, but something varying from 0 to 100%.

Roughness = 15% Metal = 100% : it looks like a non reflective metal with low specular

Roughness = 15% Metal = 0% : it looks like rubber

 

Yes, I know, what I meant is that I can reuse that channel to either store roughness or metalness.

It depends if your software is able to store some metal or roughness on the Alpha. Substance Painter has many export options while 3D Coat simply uses plain bitmaps without using alpha.

Stop toying and make games

Link to comment
Share on other sites

There is no more specular in PBR, only roughness and metalness combinations , i you are tempting some PBR system.

Not true, YouGroove. Specularity is still used in PBR. Gloss or roughness maps define the microsurface of the material (and determine how rough or smooth a surface is), and do not replace a specular intensity map. :)

 

You can either have a specular or a metalness workflow for PBR. Depending on which one you use (or the engine you work with uses), your texture maps will differ.

 

ZBrush 4R7 64-bit - 3DCoat 4.5 BETA 12 - Fl Studio 12 64Bit - LE 3.2 Indie version - Truespace 7 - Blender 2.71 - iClone 5.51 Pro - iClone 3DXChange 5.51 pipeline - Kontakt 5 - Bryce 7 - UU3D Pro - Substance Designer/Painter - Shadermap 3 - PaintShop Photo Pro X7 - Hexagon - Audacity - Gimp 2.8 - Vue 2015 - Reaktor 5 - Guitar Rig 5 - Bitmap2Material 3

Link to comment
Share on other sites

I'm someone very practical , less theoric laugh.png

I use 3D coat and Substance painter : main PBR methods are roughness and metalness, i like that way of working as i can create any variety of surface, more roughness and less metalness will be visible but will keep a metal effect.

What matters is that you find the method that suits you, if you prefer specular go for it.

I was mainly pointing that metalness is not 0 or 1 but a variation between 0 an 1 (black and white bitmap if you understand better)

Stop toying and make games

Link to comment
Share on other sites

Ahh, I see.... I guess we're referring to different things here: you to DCC applications and textures, me to shaders and the G buffer. The material flags I was mentioning are stored in the alpha channel of the G buffer's fragData2 - per Pixel, not per material. By "0 or 1 anyway" I meant that since I only use 6 bits for metalness it can only have 64 different values but that doesn't hurt so much since it usually is set to 1 (metal) or 0 (insulator).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...