[SOLVED] Shadows over terrain
-
- Goblin
- Posts: 279
- Joined: Tue Oct 04, 2005 4:28 pm
[SOLVED] Shadows over terrain
Hello everybody,
How could it be possible to do the character casts shadows over the terrain?.
In the tutorial is explained how to do it defining a plane. But, what about when we have an irregular terrain? (mSceneMgr->setWorldGeometry( "terrain.cfg" );)
Thanks.
How could it be possible to do the character casts shadows over the terrain?.
In the tutorial is explained how to do it defining a plane. But, what about when we have an irregular terrain? (mSceneMgr->setWorldGeometry( "terrain.cfg" );)
Thanks.
Last edited by Buckcherry on Sat Dec 10, 2005 3:15 pm, edited 1 time in total.
- celic
- Gnome
- Posts: 363
- Joined: Wed Mar 23, 2005 11:05 am
- Location: Chisinau/Moldova
- Contact:
-
- Goblin
- Posts: 279
- Joined: Tue Oct 04, 2005 4:28 pm
receive_shadows
Where should I have to put the "receive_shadows" attribute?.
I am using the map by default: terrain.cfg
I am using the map by default: terrain.cfg
- celic
- Gnome
- Posts: 363
- Joined: Wed Mar 23, 2005 11:05 am
- Location: Chisinau/Moldova
- Contact:
-
- Goblin
- Posts: 279
- Joined: Tue Oct 04, 2005 4:28 pm
terrain.cfg
Well... I am quite newbie managing terrain.
This is the terrain.cfg:
I don't know the name of the .material file where it should be the script. Do I have to look for 'TestTerrainMaterial' within the .material files?.
Thanks
This is the terrain.cfg:
Code: Select all
# The main world texture (if you wish the terrain manager to create a material for you)
WorldTexture=terrain_texture.jpg
# The detail texture (if you wish the terrain manager to create a material for you)
DetailTexture=terrain_detail.jpg
#number of times the detail texture will tile in a terrain tile
DetailTile=3
# Heightmap source
PageSource=Heightmap
# Heightmap-source specific settings
Heightmap.image=terrain.png
# If you use RAW, fill in the below too
# RAW-specific setting - size (horizontal/vertical)
#Heightmap.raw.size=513
# RAW-specific setting - bytes per pixel (1 = 8bit, 2=16bit)
#Heightmap.raw.bpp=2
# Use this if you want to flip the terrain (eg Terragen exports raw upside down)
#Heightmap.flip=true
# How large is a page of tiles (in vertices)? Must be (2^n)+1
PageSize=513
# How large is each tile? Must be (2^n)+1 and be smaller than PageSize
TileSize=65
# The maximum error allowed when determining which LOD to use
MaxPixelError=3
# The size of a terrain page, in world units
PageWorldX=1500
PageWorldZ=1500
# Maximum height of the terrain
MaxHeight=100
# Upper LOD limit
MaxMipMapLevel=5
#VertexNormals=yes
#VertexColors=yes
#UseTriStrips=yes
# Use vertex program to morph LODs, if available
VertexProgramMorph=yes
# The proportional distance range at which the LOD morph starts to take effect
# This is as a proportion of the distance between the current LODs effective range,
# and the effective range of the next lower LOD
LODMorphStart=0.2
# This following section is for if you want to provide your own terrain shading routine
# Note that since you define your textures within the material this makes the
# WorldTexture and DetailTexture settings redundant
# The name of the vertex program parameter you wish to bind the morph LOD factor to
# this is 0 when there is no adjustment (highest) to 1 when the morph takes it completely
# to the same position as the next lower LOD
# USE THIS IF YOU USE HIGH-LEVEL VERTEX PROGRAMS WITH LOD MORPHING
#MorphLODFactorParamName=morphFactor
# The index of the vertex program parameter you wish to bind the morph LOD factor to
# this is 0 when there is no adjustment (highest) to 1 when the morph takes it completely
# to the same position as the next lower LOD
# USE THIS IF YOU USE ASSEMBLER VERTEX PROGRAMS WITH LOD MORPHING
#MorphLODFactorParamIndex=4
# The name of the material you will define to shade the terrain
#CustomMaterialName=TestTerrainMaterial
Thanks
- snipexv
- Halfling
- Posts: 66
- Joined: Thu Jan 27, 2005 3:20 pm
Code: Select all
#CustomMaterialName=TestTerrainMaterial
-
- Goblin
- Posts: 279
- Joined: Tue Oct 04, 2005 4:28 pm
TerrainMaterial
Ok, I have uncommented that line, so in my terrain.cfg apperas the following line:
And I have created a file called TerrainMaterial.material which has the following code inside:
But nothing happens... (The program works as always: without shadows)
What is wrong?
Code: Select all
CustomMaterialName=TerrainMaterial
Code: Select all
material TerrainMaterial
{
receive_shadows on;
}
What is wrong?
- celic
- Gnome
- Posts: 363
- Joined: Wed Mar 23, 2005 11:05 am
- Location: Chisinau/Moldova
- Contact:
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
Make sure you're using a directional light. There is a known issue that spotlights don't work for casting texture shadows on the terrain at the moment if you have vertex program morphing enabled. Using a directional light or turning off the morphing should work.
That material script isn't valid (it has no techniques or passes), get rid of it or read the manual or refer to existing material scripts to see how to write a correct material script.
That material script isn't valid (it has no techniques or passes), get rid of it or read the manual or refer to existing material scripts to see how to write a correct material script.
-
- Goblin
- Posts: 279
- Joined: Tue Oct 04, 2005 4:28 pm
Ok
Ok, thanks. I will try with a directional light.
- SuperMegaMau
- Greenskin
- Posts: 104
- Joined: Mon Mar 21, 2005 3:31 am
- Location: Portugal
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
- SuperMegaMau
- Greenskin
- Posts: 104
- Joined: Mon Mar 21, 2005 3:31 am
- Location: Portugal
- Falagard
- OGRE Retired Moderator
- Posts: 2060
- Joined: Thu Feb 26, 2004 12:11 am
- Location: Toronto, Canada
- x 3
- Contact:
-
- Goblin
- Posts: 279
- Joined: Tue Oct 04, 2005 4:28 pm
Ok
I have done the following:
- set an Ambient light
- set a directional light
- mSceneMgr->setShadowTechnique(ADDITIVE_STENCIL)
- set receive_shadows on in the .material file associated to the terrain.cfg
After doing this shadows appear over the character rather than casting over the terrain.
What is wrong?.
You mention something about tangents. What is that?. What do I need to generate tangents?.
Thanks.
- set an Ambient light
- set a directional light
- mSceneMgr->setShadowTechnique(ADDITIVE_STENCIL)
- set receive_shadows on in the .material file associated to the terrain.cfg
After doing this shadows appear over the character rather than casting over the terrain.
What is wrong?.
You mention something about tangents. What is that?. What do I need to generate tangents?.
Thanks.
-
- Goblin
- Posts: 279
- Joined: Tue Oct 04, 2005 4:28 pm
Come on
This topic has been posted a lot of time ago and I do not believe that nobody knows how to use shadows over a terrain created using:
setWorldGeometry("terrain.cfg");
Please, help!.
Thanks
setWorldGeometry("terrain.cfg");
Please, help!.
Thanks
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
Shadows over terrain works out of the box with modulative stencil and texture shadows (from directional lights).
You're using additive shadows, which means you should have read the manual: http://www.ogre3d.org/docs/manual/manual_61.html#SEC235
This explains how additive lighting works, and reveals that it only works if the objects being shadowed are dynamically lit, because it works by masking out light, not by darkening areas. Since terrain is not dynamically lit out of the box (vertex lighting looks awful on LODed terrain, although you can use pixel shaders to do a better job with a custom material), it won't work. Use modulative shadows.
You're using additive shadows, which means you should have read the manual: http://www.ogre3d.org/docs/manual/manual_61.html#SEC235
This explains how additive lighting works, and reveals that it only works if the objects being shadowed are dynamically lit, because it works by masking out light, not by darkening areas. Since terrain is not dynamically lit out of the box (vertex lighting looks awful on LODed terrain, although you can use pixel shaders to do a better job with a custom material), it won't work. Use modulative shadows.