Questions about normals & shaders

MrCarbohydrate

11-11-2005 20:55:37

I think it's my first post in the PLSM2 forum, so first thanks for this great plugin! :D
I've already got it working with just a basic texture, and now I'd like to implement real-time lighting with shaders as in the August 2002 GameDeveloper magazine. Currently I've made a shader that renders the terrain texture + detail correctly, so now I'd like to access the normals to compute lighting. But when I look at what the NORMAL vertex shader variable gives me for the terrain mesh, it seems to be random garbage. Do I need to generate a normal map, and if so, how do I reference it in the terrain template material? I've already tried to generate a normal map with MapSplitter (just added "NormalMap=yes" in .gen.cfg) : it generates NSmall.x.y.png files correctly, but crashes while generating N.x.y.png files (what's the difference between NSmall and N? NSmall seem to have the same size as the height map so what's the point of the N files?).

tuan kuranes

12-11-2005 06:58:36

This one http://www.ati.com/developer/samples/Scattering.zip ?

yes you need to generate normal map. But you should rather generate horizon map, that mixes with normal map. you should use NH an NS files, in which alpha byte is horizon. so you can put normalmap=no and horizonmap=yes.

Normal computing should work. CVS or SDK ?

Nsmall is in use when having big maps and using impostors for terrain at huge distance. your map is too smal to get a really smaller map.


Try 'instantbasetextureshadowed' TextureMode.
It's horizon mapping using those files.
(no scattering tough)

MrCarbohydrate

12-11-2005 17:54:09

Yes, it's the ATI scattering one. Thanks for the tip about horizon mapping, I'll take a look at that.
I'm using latest CVS, MapSplitter crashes while generating the .N.1.3 file. The files already generated looks OK but they don't seem to have the same scale as the others (N.0.0 covers my 0-0, 1-0, 0-1 and 1-1 pages) and N.0.2 is the same as N.0.0. I'll try to debug into to see what's going wrong, here is my .gen.cfg if you want to have a look :

### WARNING
## read Data2dLoader.txt, Mapsplitterreadme.txt
## in ogreaddons paginglandscape root folder before anything here.
##

# resource group name
GroupName=PLSM2

# Base file name for the landscape heightfield data
# The file name MUST be LandScapeFileName.LandScapeExtension (ex: landscape.png)
LandScapeFileName=height
LandScapeExtension=raw
RawWidth=2049
RawHeight=2049

# for textures. (raw is possible but raw texture isn't supported directly for Ogre so it's experimental)
# jpg or anything else ?
## For heightmap only
LandScapeExportExtension=png
## For Texturing heightmap only (all but pure heightmap data.)
TextureExtension=png
## scale factor bettween pagesize and textursize
TextureStretchFactor=2

#
# If you intend to use it with
# Paginglandscape scenemanager Paged=yes
# or with Terrain scenemanager Paged=no
Paged=yes


#
# Scale values
ScaleX=1
ScaleY=1
ScaleZ=1


# Directory where to store files
# absolute or related to maptool directory
# if OutDirectory=LandScapeFileName will use filename of your input data
OutDirectory=media/testplsm/result



###########
###########
# Options only useful for paging landscape scene manager paged=yes
#
# Size of the Heightfiled in pixels (must be 2^n + 1)
PageSize=513
TileSize=65



# Especialized 2D data loader.
# Currently the only available loaders are
# 'HeightField', 'HeightFieldTC' and 'SplineField'.
# More to come. (For Terrainscene (paged =yes HeightField is used by default)
#

Data2DFormat=HeightField
#Data2DFormat=HeightFieldTC

# The HeightField TC is a compresed format and need to know the value range from where the
# heightfield file was compresed (if it's paged, and Data2DFormat=HeightFieldTC)
#MaxValue=500
#MinValue=0

# don't work with mapsplitter for now
#Data2DFormat=SplineField


#############COLOR MAP

# Map that user have generated before, using terragen,
#and want to split or to light (Textureformat=Image)
ColorMapName=texture.png
# Split your color map
ColorMapSplit=yes
# same but with modulated with light
LitColorMapSplit=no


#########HEIGTHMAPS
#
# What to generate
# HERE IS WHERE YOU SPECIFY YOUR NEEDS
#
# usual HeightMap (but splitted)
HeightMap=yes
# If you want your map to be infinitizable
InfiniteMap=no

# If you want smooth your heightmap
HeightMapBlurFactor=0.0f
# Make sure heights use the whole range (0-255 or 0-65535)
Equalize=no
# Creates a MiniMap (width=numpageswidth*numtiles and height=numpagesheight*numtiles)
# (as the name don't tell, it's creates a file.small.png image...)
MiniMap=no
MiniMapWidth=512
MiniMapHeight=512

#########NORMALS
#
# Normal Map
NormalMap=yes
# RGB as XYZ normal and Alpha as 8 bits HeightMap (paging scene manager)
HeightNormalMap=no


#
# Map that can be used on not too much scaled terrain or old hardware
# no enough texture units or too slow multipass (Textureformat=Image)
ColorMapGenerated=no
# same but with modulated with light
LitColorMapGenerated=no

####################LIGHTING

# Shadows on terrains (lightmap is used, shadowmap is mainly for debugging)
# (Textureformat=splatting4)
LightMap=no
ShadowMap=no

Sunx=0.0f
Suny=0.26f
Sunz=0.96f

Ambient=0.5f
Diffuse=0.5f
Blur=0.0f

tuan kuranes

13-11-2005 08:54:38

add this at the end of the gen.cfg

# trick Real-Time mapping : sun is constricted in Z axis. Fastest Horizon mapping possible with and without shaders.
ZHorizon=yes

and change
normalmap=yes to no. (Zhorizon should generates NH and NS files.)
and add
LandScapeExportExtension=png
so that you get 16 bits png in results instead of big splitted raw files

about the crash :
are yous sure Raw file is 16 bits and exact dimension ?
could you try with a 8 or 16 bits png ?