Recalculating terrain normals

Started by
14 comments, last by kauna 9 years, 10 months ago

Hi!

Pre-calculating these normals would be done by the D3DX9 API.


D3DXComputeNormals() 

I know that is the obsolete function, but it works and would be called while assets are being built (not in the release app).

This API implements a good algorithm.

Advertisement

Well, as I told, the method has been used in a AAA level game, so I guess that they did the profiling. Of course hardware changes and everything changes, so you can always redo the profiling.

With CPU calculated normals, you'll still do texture read in the shader and probably some unpacking depending on the texture format. With the GPU version you'll do 4 texture reads, but probably they won't be much slower. The amount of ALUs in the GPU version is so small that it won't change much.

So, probably calculating the normals on the GPU won't be any slower than the CPU version.

Cheers!

Tom KQT has it right here - if you terrain isn't changing over time, then you should just calculate the normal on the CPU and store it with the terrain vertices. Otherwise you are recalculating the same thing every frame on the GPU, which is a huge waste of computation and bandwidth. If there is a AAA game that does this, I would be interested to know which game you are referring to - maybe their terrain was destructible or something like that...

Did you see my question from above - have you tried to remove the world matrix from the calculation to see if it helps?

http://dice.se/wp-content/uploads/Chapter5-Andersson-Terrain_Rendering_in_Frostbite.pdf

Page 42.

"Over the last decade, the computational power of consumer GPUs has been exceeding

the Moore’s law, graphics chips becoming faster and faster with every generation. At the
same time, memory size and bandwidth increases do not match the jumps in GPU
compute. Realizing this trend, it makes sense to try to calculate much of the terrain
shading and texture compositing in the shaders instead of storing it all in textures."
Anyway, I think that this thread is dead since the OP hasn't posted any new information.
Cheers!

Sorry for not replying and thanks for the ideas everyone, since my terrain is static and isn't changing per-frame, I think the best idea may be to create another texture-based container to store the normals which can then be looked up in the shader. I'll see how it goes :)

Well, as I told, the method has been used in a AAA level game, so I guess that they did the profiling.

Just a small note on this. Don't take AAA games in general as your holy grail as far as technology is concerned. Sure, there are some developers that push the boundaries further and produce extremely optimized and technicaly advanced games. But there are plenty of AAA games that are made in very short time and with focus on other elements, not optimizations.

For example, I think it was on this forum - somebody showed how incredible hight was the amount of draw calls in the early version of Civilisation V. They had a separate draw call for every single icon on the screen, including all those food/wealth/production icons on each tile (if you know the game). That probably won't be the best way, will it? And btw I think this changed in the later versions of the game.

The draw call problem with CIV 5 and terrain normal calculating are two quite different thing, the first is caused by artists not having optimized engine for the purpose and second by programmers optimizing certain aspects of the game engine.

I agree that a certain amount of criticism is always good when learning new things. The normal calculating method was described in the engine documentations which was about_new tech and new ways of doing things, not in the hobby sections of some discussion area. My point here, those people publishing things on the net have quite solid understanding of what they are writing.

Indeed, in the later versions of the game, they changed the terrain rendering code and what is stored in textures etc. But once again, it was a question needs. The BFBC2 terrain rendering could go only so far. They improved / changed the code because mixing so many terrain layers became prohibitive in the sense of performance. I used exactly the same code earlier in my hobby projects and I was pleased in it's performance. However, later my needs became different and I adopter another method where I couldn't use the code anymore. Anyhow, a GPU, when correctly used has pretty much computing power and few used ALUs won't affect the performance pretty much at all.

Cheers!

This topic is closed to new replies.

Advertisement