Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (404)
games submitted by our members
Games in WIP (289)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Compressing vertex normals  (Read 1353 times)
0 Members and 1 Guest are viewing this topic.
Offline theagentd
« Posted 2012-07-30 01:18:43 »

Thought I could cross post this here too... http://www.gamedev.net/topic/628778-compressing-vertex-attribute-normals/

My question is this: Is it possible to compress a 3-float world space vertex normal to only 4 bytes and quickly unpack it to in a vertex shader?

Myomyomyo.
Offline lhkbob

JGO Knight


Medals: 32



« Reply #1 - Posted 2012-07-30 04:11:25 »

Reading your problem from gamedev.net, it sounds like compressing normals isn't really the best solution to your problem.  If you have that much terrain data, but only a small amount of it is visible, you have a prime candidate for culling and LOD.  That way you only really have to swap in the high-detail geometry for the small area around the player and the distance rendering uses a simpler mesh.  If you combine this with normal mapping, it will be very likely nobody can notice it.

If you're set on compressing the coordinates, you might look into using the integer vertex attribute types, but that might require masks and shifts and I can't recall how well that's supported (or if it's even available in the newer shader models).  I'm pretty sure that the floating point attributes are a fixed size, unlike with texture formats.

If you use object space normals in a normal map, then you don't need vertex normals, and then you can compress those into a 2 component texture and reconstruct the z value.

Offline Damocles
« Reply #2 - Posted 2012-07-30 06:17:05 »

Some fancy-pants precalculated lookup table might be usable.
Should be rather fast.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Roquen

JGO Ninja


Medals: 66



« Reply #3 - Posted 2012-07-30 08:59:11 »

I'm heading out for awhile...search for m. Deering compression.
Offline jezek2
« Reply #4 - Posted 2012-07-30 11:10:36 »

You're doing it wrong. Focus on high-level optimizations first (like culling), only if you're out of any useable high level optimizations and the design is 'finished' go crazy with low-level optimizations. There are of course exceptions to this advice, but this is not the case.

After doing proper optimizations you may also realize it doesn't require high end GPU you're developing for and could be useable also for mere mortals too.
Offline princec
« League of Dukes »

JGO Kernel


Medals: 194
Projects: 3


Eh? Who? What? ... Me?


« Reply #5 - Posted 2012-07-30 11:36:43 »

As your normal data is all largely composed of 45 degree or 90 degree angles it would be reasonable to compress them down to just 3 bits each wouldn't it? So that's 9 bits for a normal.

Cas Smiley

Offline Roquen

JGO Ninja


Medals: 66



« Reply #6 - Posted 2012-07-30 11:58:45 »

That's roughly the base of deering's.  3 (or 2 bits) for sign - map to first octant.  Polar form is now [0,pi/2],[0,pi/2].  Next you can sort into a>=b>=c and keep the permutation. You now have polar form on [0,pi/4] & [0,~.6].  Approx sin/cos on this narrow range is easy and you can fit a pretty reasonable quality normal (of singles) in a 16-bits and really good in 32.
Offline Danny02

JGO Knight


Medals: 36



« Reply #7 - Posted 2012-07-30 12:35:46 »

as princec said, if you have only a bunch of possibilities just encode these.

If you want to use a more general optionen, take a look at some papers from crytek. They used 3bytes instead of 12(3xfloat) I think.
They used some
Some fancy-pants precalculated lookup table

The Idea behind this was, that with a normal you only use like 1% of the possible values when using 12bytes, because your normals are normalized.

the paper:
http://advances.realtimerendering.com/s2010/Kaplanyan-CryEngine3%28SIGGRAPH%202010%20Advanced%20RealTime%20Rendering%20Course%29.pdf
some log post about the technic:
http://sebh-blog.blogspot.de/2010/10/best-fit-normal-map-generator.html
there are som more articles about this technic on that blog
Offline Roquen

JGO Ninja


Medals: 66



« Reply #8 - Posted 2012-07-30 12:39:08 »

There's also this page: http://aras-p.info/texts/CompactNormalStorage.html
Offline theagentd
« Reply #9 - Posted 2012-07-30 17:58:54 »

You're doing it wrong. Focus on high-level optimizations first (like culling), only if you're out of any useable high level optimizations and the design is 'finished' go crazy with low-level optimizations. There are of course exceptions to this advice, but this is not the case.

After doing proper optimizations you may also realize it doesn't require high end GPU you're developing for and could be useable also for mere mortals too.
This isn't focused on FPS performance but on VRAM usage. Your point still stands though. I'll focus on other more important stuff. Thanks to everyone.

Myomyomyo.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Try the Free Demo of Revenge of the Titans

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (34 views)
2013-05-17 21:29:12

alaslipknot (42 views)
2013-05-16 21:24:48

gouessej (72 views)
2013-05-16 00:53:38

gouessej (71 views)
2013-05-16 00:17:58

theagentd (79 views)
2013-05-15 15:01:13

theagentd (74 views)
2013-05-15 15:00:54

StreetDoggy (116 views)
2013-05-14 15:56:26

kutucuk (139 views)
2013-05-12 17:10:36

kutucuk (140 views)
2013-05-12 15:36:09

UnluckyDevil (147 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.1 seconds with 21 queries.