每天花30分钟看OGRE--(14)试验模型边缘高亮
15.试验模型边缘高亮
为什么只能看到绿色的呢?
Vertex_program没起作用?
注释掉vs还不行。
找到原因了,原来是被绿色盖住了。
void edgeHighLight_vp(float4 position : POSITION,
float3 normal : NORMAL,
out float4 oPosition : POSITION,
uniform float4x4 worldViewProj)
{
//oPosition = float4(position.xyz + normal * 0.6f, 1);
oPosition = float4(position.x + 70.0f, position.yzw);
oPosition = mul(worldViewProj, oPosition);
}
改了后就能看到两个pass都绘制了。
并不是没有法线,noramls true
改成cull_hardware anticlockwise就正常了。这个就是原因了!
放在Example.meterial里
代码
vertex_program Examples/EdgeHighLightVS hlsl
{
source EdgeHighLightVS.hlsl
entry_point edgeHighLight_vp
target vs_1_1
default_params
{
param_named_auto worldViewProj worldviewproj_matrix
}
}
fragment_program Examples/EdgeHighLightPS hlsl
{
source EdgeHighLightPS.hlsl
entry_point edgeHighLight_fp
target ps_2_0
default_params
{
}
}
material Examples/EnvMappedRustySteelEdgeHighLight
{
technique
{
pass
{
cull_hardware anticlockwise
vertex_program_ref Examples/EdgeHighLightVS
{
}
fragment_program_ref Examples/EdgeHighLightPS
{
}
}
pass
{
cull_hardware none
//polygon_mode wireframe
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
}
}
}
}
{
source EdgeHighLightVS.hlsl
entry_point edgeHighLight_vp
target vs_1_1
default_params
{
param_named_auto worldViewProj worldviewproj_matrix
}
}
fragment_program Examples/EdgeHighLightPS hlsl
{
source EdgeHighLightPS.hlsl
entry_point edgeHighLight_fp
target ps_2_0
default_params
{
}
}
material Examples/EnvMappedRustySteelEdgeHighLight
{
technique
{
pass
{
cull_hardware anticlockwise
vertex_program_ref Examples/EdgeHighLightVS
{
}
fragment_program_ref Examples/EdgeHighLightPS
{
}
}
pass
{
cull_hardware none
//polygon_mode wireframe
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
}
}
}
}
EdgeHighLightVS.hlsl
代码
void edgeHighLight_vp(float4 position : POSITION,
float3 normal : NORMAL,
out float4 oPosition : POSITION,
uniform float4x4 worldViewProj)
{
oPosition = float4(position.xyz + normal * 0.6f, 1);
//oPosition = float4(position.x, position.yzw);
oPosition = mul(worldViewProj, oPosition);
}
float3 normal : NORMAL,
out float4 oPosition : POSITION,
uniform float4x4 worldViewProj)
{
oPosition = float4(position.xyz + normal * 0.6f, 1);
//oPosition = float4(position.x, position.yzw);
oPosition = mul(worldViewProj, oPosition);
}
EdgeHighLightPS.hlsl
void edgeHighLight_fp(out float4 colour : COLOR)
{
colour = float4(0, 1, 0, 1);
}
代码
// 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/EnvMappedRustySteelEdgeHighLight");
// Add entity to the root scene node
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
}
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/EnvMappedRustySteelEdgeHighLight");
// Add entity to the root scene node
mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
}
Reference:
物件的边缘高亮(Entity edge highlight)