截圖:

參考對比下純D3D的實現(xiàn):
《精通DirectX 3D》第十二章 高級紋理應(yīng)用 06_SphericalEnvMapping
原理都是一樣的,都是有個環(huán)境貼圖,假的環(huán)境映射!
實現(xiàn)很簡單,override createScene成員函數(shù)就可以了
// Just override the mandatory create scene method
void createScene(void)
{
// Set ambient light
mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
// Create a point light
Light* l = mSceneMgr->createLight("MainLight");
// Accept default settings: point light, white diffuse, just set position
// NB I could attach the light to a SceneNode if I wanted it to move automatically with
// other objects, but I don't
l->setPosition(20,80,50);
Entity *ent = mSceneMgr->createEntity("head", "ogrehead.mesh");
// Set material loaded from Example.material
ent->setMaterialName("Examples/EnvMappedRustySteel");
// Add entity to the root scene node
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
}
對應(yīng)的材質(zhì)腳本在
ogrenew\Samples\Media\materials\scripts\Example.material
里,如下:
material Examples/EnvMappedRustySteel
{
technique
{
pass
{
texture_unit
{
texture RustySteel.jpg
}
texture_unit
{
texture spheremap.png
colour_op_ex add src_texture src_current
colour_op_multipass_fallback one one
env_map spherical // hew:這里指明環(huán)境映射的類型是球形環(huán)境映射
}
}
}
}
ogrenew\Samples\Media\materials\textures\spheremap.png
ogrenew\Samples\Media\materials\textures\RustySteel.jpg
posted on 2008-04-28 23:03
七星重劍 閱讀(1560)
評論(0) 編輯 收藏 引用 所屬分類:
Game Graphics 、
Game Engine 、
OGRE