OGRE Wiki
Support and community documentation for Ogre3D
Ogre Forums
ogre3d.org
Log in
Username:
Password:
CapsLock is on.
Remember me (for 1 year)
Log in
Home
Tutorials
Tutorials Home
Basic Tutorials
Intermediate Tutorials
Mad Marx Tutorials
In Depth Tutorials
Older Tutorials
External Tutorials
Cookbook
Cookbook Home
CodeBank
Snippets
Experiences
Ogre Articles
Libraries
Libraries Home
Alternative Languages
Assembling A Toolset
Development Tools
OGRE Libraries
List of Libraries
Tools
Tools Home
DCC Tools
DCC Tutorials
DCC Articles
DCC Resources
Assembling a production pipeline
Development
Development Home
Roadmap
Building Ogre
Installing the Ogre SDK
Setting Up An Application
Ogre Wiki Tutorial Framework
Frequently Asked Questions
Google Summer Of Code
Help Requested
Ogre Core Articles
Community
Community Home
Projects Using Ogre
Recommended Reading
Contractors
Wiki
Immediate Wiki Tasklist
Wiki Ideas
Wiki Guidelines
Article Writing Guidelines
Wiki Styles
Wiki Page Tracker
Ogre Wiki Help
Ogre Wiki Help Overview
Help - Basic Syntax
Help - Images
Help - Pages and Structures
Help - Wiki Plugins
Toolbox
Freetags
Categories
List Pages
Structures
Trackers
Statistics
Rankings
List Galleries
Ogre Lexicon
Comments
History: Create outline around a character
View page
Source of version: 5
(current)
Here is a script of user Telchar, which shows how to create an outline around a character, which works without shaders. Screenshot of this effect, used in the game Torchlight: {img fileId="2145"} {CODE(wrap="1", colors="c++")} material some/random/material/with/rim/effect { technique { pass { texture_unit { texture yourtexturehere.png } //rim lighting texture_unit { cubic_texture rim.dds combinedUVW tex_address_mode clamp colour_op_ex add src_texture src_current colour_op_multipass_fallback one one env_map cubic_normal } } } } {CODE} Here is the c++ code to do the same: {CODE(wrap="1", colors="c++")} /* rim lighting see: http://www.ogre3d.org/tikiwiki/Create+outline+around+a+character */ #pragma once #include <Ogre/OgreEntity.h> #include <Ogre/OgreSubEntity.h> #include <Ogre/OgreSubMesh.h> #include <Ogre/OgreString.h> #include <Ogre/OgreMaterial.h> /* add the rim lighting effect to an entity. */ void highlight (Ogre::Entity* entity) { unsigned short count = entity->getNumSubEntities(); const Ogre::String file_name = "rim.dds"; const Ogre::String rim_material_name = "_rim"; for (unsigned short i = 0; i < count; ++i) { Ogre::SubEntity* subentity = entity->getSubEntity (i); const Ogre::String& old_material_name = subentity->getMaterialName(); Ogre::String new_material_name = old_material_name + rim_material_name; Ogre::MaterialPtr new_material = MaterialManager::getSingleton().getByName (new_material_name); if (new_material.isNull()) { MaterialPtr old_material = MaterialManager::getSingleton().getByName (old_material_name); new_material = old_material->clone (new_material_name); Pass* pass = new_material->getTechnique(0)->getPass(0); Ogre::TextureUnitState* texture = pass->createTextureUnitState(); texture->setCubicTextureName (&file_name, true); texture->setTextureAddressingMode (TextureUnitState::TAM_CLAMP); texture->setColourOperationEx (Ogre::LBX_ADD, Ogre::LBS_TEXTURE, Ogre::LBS_CURRENT); texture->setColourOpMultipassFallback (Ogre::SBF_ONE, Ogre::SBF_ONE); texture->setEnvironmentMap (true, Ogre::TextureUnitState::ENV_NORMAL); } subentity->setMaterial (new_material); } } /* remove the rim lighting effect from an entity. */ void unhighlight (Ogre::Entity* entity) { unsigned short count = entity->getNumSubEntities(); for (unsigned short i = 0; i < count; ++i) { Ogre::SubEntity* subentity = entity->getSubEntity (i); Ogre::SubMesh* submesh = subentity->getSubMesh(); const Ogre::String& old_material_name = submesh->getMaterialName(); const Ogre::String& new_material_name = subentity->getMaterialName(); // if the entity is already using the original material then we're done. if (0 == stricmp (old_material_name.c_str(), new_material_name.c_str())) continue; // otherwise restore the original material name. subentity->setMaterialName (old_material_name); } } {CODE} __Download__ of file ''__rim.dds__'': http://www.ogre3d.org/forums/download/file.php?id=2022 The code was published here: http://www.ogre3d.org/forums/viewtopic.php?p=368918#p368918 Similar version: http://www.ogre3d.org/forums/viewtopic.php?f=8&t=59079 %help% For __questions and feedback__, please use this forum topic: http://www.ogre3d.org/forums/viewtopic.php?f=8&t=59079
Search by Tags
Search Wiki by Freetags
Latest Changes
Minimal Ogre Collision
Artifex Terra
OpenMB
Advanced Mogre Framework
MogreSocks
Critter AI
Mogre Add-ons
MOGRE
Mogre MyGUI wrapper
MOGRE Editable Terrain Manager
...more
Search
Find
Advanced
Search Help
Online Users
8 online users