Quick newbie question about using PLSplattingShaderLit

sklug

20-08-2006 01:19:04

Greetings,

I have been playing aroudn with PLSplattingShaderLit. However, I'm having trouble getting the landscape to look correct. I read in another post that setting the ambient light doesn't work very well with this shader, far the various reasons posted. However, just adding one directional light at full intensity, pointing directly down at my landscape seems to have results not consistent with what I think they should be.

The terrain still has many shadowed areas on it (that aren't in the textures) and looks fairly dim, as if in twilight. A simple untextured sphere object dropped into the scene looks exactly at you'd expect, with a nice bright white on top, changing to black on the bottom. This is all with white ambient light of .1.

Is there some step I'm missing? Some special way I need to prepare the terrain? I have no non-terrain objects (other than said sphere) so I'm assuming I don't need to worry about ogre shadowing modes? I gathered from other posts that the normals were calculated on the fly, so I don't need to create normal maps, but tell me if I'm wrong. I'm sure it's something stupid, but I'm still learning about this stuff.

Thanks.

Falagard

20-08-2006 02:26:16

I got good results with the shader myself. It works fine with ambient light, it just doesn't work fine (or make sense) to use a LIT shader and put the global ambient (set through sceneManager->setAmbientLight) to full brightness because that's making it basically an unlit shader - and if you do that the terrain ends up fully white.

If anything, the way ambient is done now the terrain will look slightly washed out but also brighter than it should (I think). The ambient pass is rendered before everything else and without a texture so it is purely ambient colour, and then the terrain splatting textures are rendered as additive passes. What should be happening instead is that the ambient pass should be rendered with the splatting textures as well, but this is costly so as a compromise it would be a decent idea to use the base texture instead. The base texture is a preblended version of the splatting textures.

I could be wrong about the lit splatting shader though - *shrug*.

Do you have any screenshots, sample code, demo I could look at?

sklug

20-08-2006 03:39:48

Wow, thanks for the quick reply! You're on top of things...

Here's a screenshot. Just ignore the sky. Notice the dark sections on the sides of the mountain, and scattered darker patches. With a light directly overhead should there be any shadows at all?



I'm creating the light in about as simple a way as you can imagine:

light_ = sceneMgr_->createLight( "MainLight" );

light_->setDiffuseColour( 1.0f, 1.0f, 1.0f );
light_->setAttenuation( 10000.0f, 1.0f, 1.0f, 0.0f );

light_->setType( Light::LT_DIRECTIONAL );
light_->setDirection( Vector3::NEGATIVE_UNIT_Y );



Any thoughts?

PatrickB3

20-08-2006 22:04:06

I have found that the dark spots appear at different angles of the directional light. Using an ambient helps make this go away. However, as Falagard stated, ambient doesn't work as is. You have to alter the shader to use it correctly.

If you don't want to or can't alter the shader try a different angle with the directional light till it goes away.

Falagard

21-08-2006 00:00:28

You're right, there shouldn't be any shaded areas if it is a directional light pointing straight down. There is clearly a problem here, either with the shader or with the normals generated by the terrain. Fixing it by playing with the ambient is not the solution, it's a hack.

I have no time to look into it - but here are some things to try:

Turn vertex compression off. See if it helps - if so, it's probably the normals generated by the terrain.

Another thing to try - turn off vertex compression and render the terrain using a fixed function material. There might be a texture "mode" that uses fixed function without any shaders, I'm not sure though. This is not completely going to tell you if it's the normals because it's possible (probable) the normals are calculated differently when vertex compression is enabled.

Tuan might have more input.

tuan kuranes

21-08-2006 17:48:55

Tuan might have more input.

All I can say is that Normal used Vertex should not be used in any Vertex shader on terrain because of LOD altering normals. It needs a normal map and that have to be used in a Pixel Shader.
(but I still didn't dig into shader provided by Falagard)

Falagard

21-08-2006 18:42:19

I'm using the normals from the vertices because I was under the impression that they would be valid most of the time and only not valid during LOD transitions for a short period of time.

tuan kuranes

21-08-2006 19:36:36

They're only valid at best LOD level which is not always the case. all others are wrong, and the worst case is stitching between a high LOD tile and a low LOD tile resulting in totally wrong normals.