www.quadsoftware.com
FAQ  FAQ   Search  Search   Memberlist  Memberlist   Usergroups  Usergroups
Register  ::  Log in Log in to check your private messages


Post new topic  Reply to topic
 Normal Map « View previous topic :: View next topic » 
Author Message
regress
PostPosted: Sat Dec 10, 2011 5:36 pm    Post subject: Normal Map Reply with quote



Joined: 10 Dec 2011
Posts: 3

I just started with Grome 3 yesterday and it looks fabulous -- looking forward to using what appears to be a very well designed piece of software!

While I'm getting up to speed, I'd like to throw some heightmaps, textures and normal maps in my engine exported from Grome. I have no problem quickly exporting the heightmap data and textures, however, a couple quick questions:

1. How can I export the full [single] baked texture *without* the lightmap baked in?

2. How can I easily export a normal map to go with my heighmap?

Could someone point me to or provide step-by-step instruction on these?

Cheers,
Ben
Back to top
View user's profile Send private message
ALicu
PostPosted: Sun Dec 11, 2011 4:03 pm    Post subject: Reply with quote



Joined: 12 Feb 2007
Posts: 1326

Hi,

I am glad that you like our program.

About your questions:

1. Just disable (press the little eye button at the left of the layer name) the lightmap layers. Exporters don't save the layers that are marked disabled. Then choose to bake layers upon export, they will not contain the lightmap which you can save later (disable all layers and disable the lightmap one and export again).

Or, if you create the baked texture in Grome (you can do that with Baked), you will assign a new layer (which will contain the baked texture), assign it to terrain zones, mark it in use (red button) and then mark enabled all the layers except the lightmap one. All the visible (enabled) layers will be baked into the one(s) in use (your new layer). All the disabled layers are ignored.

2. You create a new layer (usually at the bottom of the stack so it will not be visible on top of your normal layers - you can drag and drop the layer with the mouse left click and drag) and assign it to the selected zones. Press new at the first texture (in the Add new layer dialog) and then select Normalmap at Shading. At resolution you can choose the same size as the heightmap or double of it (we are using some special spline functions to catch great detail from the heightmap into the normalmap). Then mark it in use and use the Normalmap tool. In this tool, you should probably use "From interpolated surfaces" method and with the slider at the right to catch best details. The normalmap is created.

If you have the viewport put on Lit it will use the normalmap to compute the lighting and you will see an increase in the lighting details.

At export you just export the normals as any color image. You will see it on disk as a greenish image. This has the normals codded in it. Red channel is normal OX, Green is OY (up in Grome) and Blue is is OZ. Because the heightmap is almost always facing up the image has the green tint. OX and OZ are nornmalize to -0.5, 0.5 and OY is left unchanged (0..1) since it is always up.

So in your shaders, to decode the normals, you use something like this (HLSL code but GLSL is similar):

Code:

float3 normal;
normal.xzy = tex2D(NormalMapSampler,NormalMapUV.xy).xyz;
// Swap Y with Z since Blue is up in normalmap while on terrain OY is up.
// Put the normal in [-1, 1] space. Note: OY is always up (normal map is constructed from terrain) so we don't need to convert it.
normal.xz = normal.xz * 2.0 - 1.0;
normal = normalize(normal);


I hope this helps.

Kind Regards,
Adrian L.
Back to top
View user's profile Send private message
regress
PostPosted: Wed Dec 14, 2011 5:35 am    Post subject: Reply with quote



Joined: 10 Dec 2011
Posts: 3

Many thanks for the quick reply -- up and running and looking great. Looking forward to exploring Grome in much more detail.

I think the Help file claims that normals are already in (-1, 1), which I presume would mean some resolution is lost, except for OY? (-0.5, 0.5) looks right in my renderer.

Cheers,
Ben
Back to top
View user's profile Send private message
ALicu
PostPosted: Wed Dec 14, 2011 5:53 am    Post subject: Reply with quote



Joined: 12 Feb 2007
Posts: 1326

Hi,

The help is a little ambiguous there (we have to correct that). Basically all the normals components are taken from their original -1 ... 1 space and normalized (put in 0..1) inside the image. For OY we don't need to do anything since it is always between 0 .. 1. We need to do this normalization since the image can keep values only between 0 .. 1 (0 .. 255 internally, but in the shaders this translates to 0 .. 1). So then in the shader you need to bring the values back into -1 .. 1 space, as demonstrated by the previous code. But I think you've figured that out already.

Kind Regards,
Adrian L.
Back to top
View user's profile Send private message
ALicu
PostPosted: Wed Dec 14, 2011 5:57 am    Post subject: Reply with quote



Joined: 12 Feb 2007
Posts: 1326

Oh, and another of my mistake is that I've told you that OY is in the green component. It is actually in the blue channel as demonstrated by the shader code:

normal.xzy = tex2D(NormalMapSampler,NormalMapUV.xy).xyz;

Which reverses Y with Z. And the image has a bluish tint (and not green).

Regards,
Adrian L.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Based on a template by Dustin Baccetti
Powered by phpBB © 2001, 2005 phpBB Group