Thursday, October 16, 2008

My First International Conference--ICSC'2008

Congratulations to RickChang and myself!!! Last Sat., we have the fistr experience for attending International Conference, haha!!

The conference was originally hold in Sichuan Province. Because of the big earth quake in May, the venue was changed to Fragrant Hill Hotel, Beijing. What what what a pity, my side-trip to JiuZhai is gone. Anyway, it's still exciting, some pictures for memory.

IMG.1 Doing my presentation, ~~nervous

IMG.2 Doing my presentation

IMG.3 Waiting for lunch, so relax^_^

IMG.4 Smile & Sunshine

Wednesday, October 15, 2008

Shadow for Ogre

Additive shadow in Ogre can generate more realistic effect than other shadow technic. When I adopt it in my project, there're so many problem. Now, i've got rid of them^_^, just share the experience with whoever being in trouble with the same problem.

Description:
The scene is composed of a runtime generated terrain, and a lander. I want the lander can cast shadow on terrain. The lander and terrain are rendered by custom CG shader. The main light of the scene is a directional light, and on the top of lander, there're two small indicator light, which are simulated by two directional light. You can see from the followed graphic

Problem:
At first, after setting the standard parameter for additive shadow, i can not generate any shadow on terrain.
Laterly, although there are shadow on the terrain, but when the lander move to the terrain, a white plane will flicker on the terrain. My Gosh!!!

Solution:
For the first problem, if the object is rendered with custom shader, some changes for the object's material must be involved:
If the cast shadow object using hardware skinned technich, you must define the vertex program for rendering the shdow texture. Otherwise, Ogre will return to use fixed function, and any change of vertext will be eliminated. But if the custom shader do not change the vertex data, just for lighting effect, there's no need to define "shadow_caster_vertex_program_ref".
shadow_caster_vertex_program_ref myShadowCasterVertexProgram
{
param_indexed_auto 0 worldviewproj_matrix
param_indexed_auto 4 ambient_light_colour
}

If the receive shadow object using custom shader, while you need to define both the vertex and fragment shader. Please remember you should do it under any situation. The previous one is generate the texcoord for shadow texture, and the later one is sample the shadow texture to modulate the lighting effect of the object.
shadow_receiver_vertex_program_ref myShadowReceiverVertexProgram
{
param_indexed_auto 0 worldviewproj_matrix
param_indexed_auto 4 texture_viewproj_matrix
}
and
shadow_receiver_fragment_program_ref myShadowReceiverFragmentProgram
{
param_named_auto lightDiffuse light_diffuse_colour 0
}

The second problem is very boring. I spend three days to solved it. I just want the direction main light can generate shadwo, so I turn on the setCastsShadows character of this light, and turn off the correspondence character of the other two spot light. But in actually when excute the diffuse pass rendering, all the light was iterated, so the material is change to "iteration once_per_light directional". "directional" means only the directional light will be iterated.

Well, some pictures of final effect, haha