I'd like to display an outline around the object under the mouse for my projet so I tried to adapt this link http://wiki.ogre3d.org/Stencil+Glow for Ogre V2.
First of all, is it a good way to do it? (shader with inflate and color on a copy of the item, rendered on a separate render queue)
To try, I added the glow shader as a material, converted to HLSL :
Vertex program :
Code: Select all
void main( float4 position : POSITION,
float3 normal : NORMAL,
float2 uv : TEXCOORD0,
out float4 oPosition : SV_POSITION,
out float2 oUv : TEXCOORD0,
out float4 colour : COLOR,
uniform float4x4 worldViewProjMatrix,
uniform float size_value,
uniform float time)
{
float4 mypos = position;
mypos.xyz += size_value * (1.0 + (sin(time * 5.0) + 1.0) / 5.0 ) * normal;
oPosition = mul(worldViewProjMatrix, mypos);
//oPosition = mul(worldViewProjMatrix, position);
oUv = uv;
colour = float4(0, 0, 1, 1);
}
Code: Select all
float4 main(uniform float alpha_value,
uniform float time) : SV_Target
{
float4 color;
color.x = 1.0;
color.y = 1.0;
color.z = 0.0;
color.w = alpha_value * ((sin(time * 5.0) / 3.14 + 1.0) / 2.0 );
return color;
}
Code: Select all
// *** HLSL ***
vertex_program glow_vs_hlsl hlsl
{
source vs_glow.hlsl
entry_point main
target vs_4_0
}
fragment_program glow_ps_hlsl hlsl
{
source ps_glow.hlsl
entry_point main
target ps_4_0
}
material glow
{
technique
{
pass
{
scene_blend alpha_blend
depth_check on
lighting off
vertex_program_ref glow_vs_hlsl
{
param_named_auto worldViewProjMatrix worldviewproj_matrix
param_named size_value float 0.1
param_named_auto time time_0_x 100
}
fragment_program_ref glow_ps_hlsl
{
param_named alpha_value float 0.4
param_named_auto time time_0_x 100
}
}
}
}
Code: Select all
OGRE EXCEPTION(3:RenderingAPIException): D3D11 device cannot set rasterizer state
Error Description: ID3D11DeviceContext::DrawIndexedInstanced: The Pixel Shader expects a Render Target View bound to slot 0, but none is bound. This is OK, as writes of an unbound Render Target View are discarded. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Render Target View here.
in D3D11RenderSystem::_setHlmsMacroblock at OgreD3D11RenderSystem.cpp (line 2571)
Here's the compositor :
Code: Select all
compositor_node RenderingNode
{
in 0 renderwindow
target renderwindow
{
pass clear
{
colour_value 0.6 0 0.6 1
}
pass render_scene
{
rq_first 0
rq_last max
shadows ShadowNode
}
}
}
compositor_node_shadow ShadowNode
{
technique pssm
texture atlas 2048 7168 PFG_D32_FLOAT
num_splits 3
pssm_lambda 0.95
shadow_map 0 atlas uv 0.0 0.000000000000000 1.0 0.285714285714286 light 0 split 0
shadow_map 1 atlas uv 0.0 0.285714285714286 0.5 0.142857142857143 light 0 split 1
shadow_map 2 atlas uv 0.5 0.285714285714286 0.5 0.142857142857143 light 0 split 2
target atlas
{
pass clear
{
colour_value 1 1 1 1
}
}
shadow_map_target_type directional
{
shadow_map 0 1 2
{
pass render_scene
{
}
}
}
}
workspace ShadowAndShaderWorkspace
{
connect_output RenderingNode 0
}
I then tried to at least reproduce the outline effect without shadows and again, my tests on the compositor were not succesful. So any help please? Thanks.