Visualise normals based on camera space/view vector?

Started by KirillK, February 21, 2013, 04:26:38 PM

Previous topic - Next topic

KirillK

Is it possible somehow in Terragen?  Looks like the existing node visualizes normals based on the world xyz coordinates.    I need basically the same but  based on camera/frame coordinate system.

ps. I need to make a normal map for a background in a game engine 

Matt

This can be done with function nodes, if you don't mind entering camera rotation values by hand each time you change your camera. I'll post an example shortly.

Matt
Just because milk is white doesn't mean that clouds are made of milk.

Matt

Here it is. I'm not sure it's exactly what you're looking for, but this setup maps the blue channel to the axis pointing directly out of the screen, and red and green are screen right and screen up respectively, as long as you manually enter the camera rotations into the appropriate nodes.

Please make sure to read 'Note 01' carefully. You need to copy the camera rotation values in a very specific way.

The render node has gamma set to 1 and other tone-mapping operators turned off. This is in case you want to use the 8-bit output directly, where I think you need raw values.

Matt
Just because milk is white doesn't mean that clouds are made of milk.

TheBadger

Excuse me but, THis is a normal generated of the terrain, as the camera see it?
And if so could one set up a camera path to follow that would allow for a series of normals to be created that then could be stitched together to form something like this :  http://www.planetaryvisions.com/Texture_map.php?pid=4128

It has been eaten.

Matt

Hi Badger,

Would you want a normal map for that? I think you'd only need a simple elevation map. That can be done by replacing the normal-generating nodes with a Get Altitude node. If you did want a normal map for the whole globe then you would probably want the normals in world space, and for that you'd use the built-in Visualise Normal Shader. The setup I provided is more complex because I'm trying to convert the normals into camera space.

Matt
Just because milk is white doesn't mean that clouds are made of milk.

Matt

Oh, I guess you mean the way it's shaded? In that case yes, it might be able to produce a map that you could use to shade it how you like in Photoshop etc. There would be slight seams at the edges of each tile; the difference would depend on how much you rotate the camera between each tile.

Matt
Just because milk is white doesn't mean that clouds are made of milk.

TheBadger

Hi mat. I think Im hijacking now. But your first response sounds like what I am looking for. Its in relation to http://www.planetside.co.uk/forums/index.php/topic,15719.0.html I need two maps, one for color and one for bump or displacement.

It sounds like if I look through the file you provided and use the other nodes you mention, I may be able to learn how to do this?
It has been eaten.

TheBadger

Additionally. I had thought I read in these forums that what I wanted was not possible, exactly. But when I saw your first response and image, I guess it is.
It has been eaten.

KirillK

Thank you very much. It works perfect.  Exactly what I need and hoped for.

  I have one more issue. I want to render  distant mountains covered by a forest for in-game flat background. As it's seen on the picture the tree population looks a bit too uniformly hiding completely the underlying surface normals.  While I would still expect some visible normal color( red mostly) variation due to a mountain shape.
  I understand the trees are just a mess of polygons  although I expected from X-frog trees to be closer to real thing than Vue ones.
Perhaps I should rotate down leafs a bit or something.  It's probably just impossible to reach a realistic looking shading from normals only on so complex thing like trees. 
Still wonder whether there may be a render setting that could fix it and make the forest part more matching the mountain surface?


 





Matt

Quote from: KirillK on February 25, 2013, 07:43:19 AM
Thank you very much. It works perfect.  Exactly what I need and hoped for.

Great.

Quote
I understand the trees are just a mess of polygons... It's probably just impossible to reach a realistic looking shading from normals only on so complex thing like trees.

That's true. So much of the shading comes from self shadows, not just raw surface normals. I would think about what you want the normals to look like to simulate some of that shading. If the trees are smaller than a pixel then you can just use the normals from the terrain pass without any trees. But since your trees are large enough to create some additional shading, I would try rendering some "fake" normal passes using red, green and blue lights, and allow them to cast shadows to produce shading. If you use soft shadows with a large soft shadow diameter (maybe 90 degrees?) maybe you could get something reasonable.

Matt
Just because milk is white doesn't mean that clouds are made of milk.

KirillK

Thanks for the advise.  I'll definitely try that solution with colored lights.  Meanwhile i have some other idea that i would like to try also. I think  a kind of separate tree model with a kind of approximated sphere based shape instead of leaves probably would look more appropriate for the normal map render. 

I wonder is it possible somehow to replace populated trees with an other object keeping all the transform operations , seed etc.?

Tangled-Universe

Quote from: KirillK on February 26, 2013, 11:05:00 AM
Thanks for the advise.  I'll definitely try that solution with colored lights.  Meanwhile i have some other idea that i would like to try also. I think  a kind of separate tree model with a kind of approximated sphere based shape instead of leaves probably would look more appropriate for the normal map render. 

I wonder is it possible somehow to replace populated trees with an other object keeping all the transform operations , seed etc.?

Yes you can do that. For that you would need to 'clone' the population. Open the tree populator and click on "keep open".
Create a population for the other object and copy all the settings from the tree population to that.
Also use "keep open" for that population so that the nodes will keep its focus.

You can also duplicate the tree population and change the object to be loaded into the object maker of that population.
In a way that's definitely easier, but it doesn't matter that much in time needed.

KirillK