problem about lighting

emre2345

26-09-2008 12:42:33

Hi everyone,

I have some problems about lighting. I copied PSLighting.cg to my own directory of the project. Below there is my material file:
material TerrainMaterial
{
technique
{
pass
{
lighting off

vertex_program_ref Shader/VSLodMorph2
{
}

fragment_program_ref Shader/PSSplat2
{
param_named splatScaleX float 20
param_named splatScaleZ float 20
}

texture_unit
{
texture Splatting0
}

texture_unit
{
texture Splatting1
}

texture_unit
{
texture Toprak_01_0.png
}

texture_unit
{
texture Toprak_01_1.png
}

}

pass
{
// lightmap texture pass

scene_blend modulate

vertex_program_ref Shader/VSLodMorph2
{
}

fragment_program_ref Shader/PSLighting
{
}

texture_unit
{
// dynamically created
texture ETLightmap
}

}
}
}


My shader program:


fragment_program Shader/PSSplat cg
{
source PSSplat.cg
entry_point main
profiles ps_1_1 arbfp1
}

fragment_program Shader/PSSplat2 cg
{
source PSSplat2.cg
entry_point main
profiles ps_2_0 arbfp1
}

vertex_program Shader/VSLodMorph cg
{
source VSLodMorph.cg
entry_point terrain_vp
profiles vs_1_1 arbvp1

default_params
{
param_named_auto morphFactor custom 77
param_named_auto worldViewProj worldviewproj_matrix
}
}

vertex_program Shader/VSLodMorph2 cg
{
source VSLodMorph.cg
entry_point terrain_vp
profiles vs_2_0 arbvp1

default_params
{
param_named_auto morphFactor custom 77
param_named_auto worldViewProj worldviewproj_matrix
}
}

fragment_program Shader/PSLighting cg
{
source PSLighting.cg
entry_point main
profiles ps_1_1 arbfp1
}

And lastly my code which creates the lightmap:
TexturePtr lightMapTex = TextureManager::getSingleton().createManual("ETLightmap", "General", TEX_TYPE_2D,
nHeightMapWidth - 1, nHeightMapHeight - 1, 1, PF_BYTE_RGB);
Image lightMap;
ET::createTerrainLightmap((*pTerrainInfo), lightMap, nHeightMapWidth - 1, nHeightMapHeight - 1,
Vector3(1, -1, 1), ColourValue::White, ColourValue(0.3, 0.3, 0.3), true);
lightMapTex->getBuffer(0, 0)->blitFromMemory(lightMap.getPixelBox(0, 0));

//updateLightMap() Function

Image lightMap;
createTerrainLightmap((*pTerrainInfo), lightMap, 128, 128, Vector3(1, -1, 1),
ColourValue(1, 1, 1), ColourValue(0.3, 0.3, 0.3), true);

TexturePtr lightMapTex = TextureManager::getSingleton().getByName("ETLightmap");
lightMapTex->getBuffer(0, 0)->blitFromMemory(lightMap.getPixelBox(0, 0));


This chunk of code does not work. I compare it with the example, everything is same as i see. What can be the problem?

SongOfTheWeave

05-10-2008 02:39:05

Please describe how it does not work.

Additionally read your ogre log for errors. If you have a name mismatch, which is a likely simple mistake, it will show up in your log.

emre2345

17-10-2008 08:34:14

there is no error, it just doesn't work.:?

CABAListic

17-10-2008 08:48:09

Please, you must specify what you mean by "it doesn't work". Does it show a white terrain, black terrain, rainbow terrain, ...? Or just a standard terrain with splatting textures working, but simply without lighting?
Are you using D3D or GL rendersystems? Please double-check your Ogre.log, or post it if in doubt.

emre2345

17-10-2008 09:18:19

I am using D3D, I meant lighting doesn't work with it. I does the splatting and mesh deformation. But it doesn't update lightmap and calculate the shadows