Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
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 1993 times)
0 Members and 1 Guest are viewing this topic.
Offline theagentd

« JGO Bitwise Duke »


Medals: 366
Projects: 2
Exp: 8 years



« Posted 2012-07-29 23: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 02: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 04: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
« Reply #3 - Posted 2012-07-30 06:59:11 »

I'm heading out for awhile...search for m. Deering compression.
Offline jezek2
« Reply #4 - Posted 2012-07-30 09: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

« JGO Spiffy Duke »


Medals: 435
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #5 - Posted 2012-07-30 09: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
« Reply #6 - Posted 2012-07-30 09: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
« Reply #7 - Posted 2012-07-30 10: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
« Reply #8 - Posted 2012-07-30 10:39:08 »

There's also this page: http://aras-p.info/texts/CompactNormalStorage.html
Offline theagentd

« JGO Bitwise Duke »


Medals: 366
Projects: 2
Exp: 8 years



« Reply #9 - Posted 2012-07-30 15: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.

 

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

The first screenshot will be displayed as a thumbnail.

rwatson462 (38 views)
2014-12-15 09:26:44

Mr.CodeIt (31 views)
2014-12-14 19:50:38

BurntPizza (62 views)
2014-12-09 22:41:13

BurntPizza (99 views)
2014-12-08 04:46:31

JscottyBieshaar (60 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (77 views)
2014-11-29 21:32:03

toopeicgaming1999 (138 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36

toopeicgaming1999 (38 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!