#Extracting normal from height vs sampling a normal map?

1 messages · Page 1 of 1 (latest)

floral lake
#

I was wondering what the difference was in terms of performance. I'm assuming sampling from height won't help and it will probably in fact need to sample the height AND the normal map.

Best case scenario, same performance if the height map is channel packed somewhere and not used as a separate unneeded sample.

This is my assumption as probably everyone would be using height for normals otherwise.

frail totem
#

It depends on many things. For example the target platform. On mobile reads from memory are a lot more impactful than on pc and consoles.

Also, are we comparing 2 samples(height + normal) vs 1 sample and normal calc, or sampling normal vs sampling height and calculating normal?

#

It's also not just performance that you should be considering, but precision as well. Calculating from height map is gonna be way less precise, especially in some edge cases, since you need to rely on ddx/ddy

floral lake
frail totem
#

It might be slightly faster. But then again, depends heavily on the target platform and other stuff. And there's still the precision consideration.

#

Texture sampling can vary widely as well. If it hits the cache, it's pretty fast, but there's also the filtering mode and such.

tawny smelt
#

Also, the benefit of saving texture loads counts more if you have a lot of different materials using different textures

hollow ingot
#

Probably also worth mentioning, if the height map is for parallax mapping then that needs to alter the UV coords when sampling other textures, so needs separate samples.
Channel packing might still be good for memory & cache though.

floral lake
#

It would primarily replace using 3 channels for nornal maps (or rather, 2 if you know what you're doing)

#

But I guess it wouldn't reqlly make a difference if I used 2 channels of normal map then pack 2 of something else in the remaining channels (after remapping) or using normal from height, assuming that I'm not saving an additional texture sample from it

tawny smelt
#

The accuracy of height generated normals is so much lower I think generally you'd only consider them if the bump mapping has to be procedural in a way that can't be done with normal maps

#

Maybe there's some way around it but Unity's height to normal creates a very pixelated result which can't be more than half the resolution of the texture

#

If the pixelation can be fixed, it'd be blurry instead

floral lake
#

Generating nornals from height externally should be better

tawny smelt
floral lake
#

Cause if I were to sample the normal map, I would have the alpha from albedo free and technically 2 channels in the normal map free

#

It would result in 2 texture samples either eay

#

So if a "normal" normal is higher quality, that seems like a better option, no?

tawny smelt
#

You can save a texture sample if you use albedo alpha for height, or repurpose mask map AO or detail mask channel for height

#

But is it really worth the trouble? That'd be something to test

floral lake
#

Well, not my solo game. I work for a smallish team now too and it's bbeen hard convincing them to channel pack

#

They think if you don't use standard unity shaders, everything will explode or something

#

I could save them a texture sample in any case

#

And we don't need detail maps or detail nornals and some other stuff is not needed

tawny smelt
#

That's why testing is important
Convince them with results
And then you'll also know if it can be worth the extra effort

floral lake
#

However

#

We're testing on higher end hardware so it might not make a difference there

tawny smelt
#

Doesn't really qualify as "testing" if only using high end hardware and gauging how it feels

floral lake
#

Will do

frail totem