outline shader in ogre3d

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
Posts: 38
Joined: Wed Dec 31, 2014 2:26 am
x 2

outline shader in ogre3d

Post by andreahmed »

I'm trying to do outline shader using GLSL and ogre3d

I'm first transforming the normals using the normal matrix which ogre3d calculate.

I'm doing two passes, one to cull front faces and the other one to cull the back faces, and I'm doing alpha blending also enter image description here


Here is the Material

material Chassis

cull_software back

scene_blend zero one

cull_software front

vertex_program_ref reflection_cube_specularmap_normalmap_vs100
param_named_auto modelViewProjectionMatrix worldviewproj_matrix
param_named_auto normalMatrix inverse_transpose_world_matrix
param_named_auto modelView worldview_matrix
param_named_auto camera_world_position camera_position
param_named_auto inverse_projection_matrix inverse_projection_matrix
param_named_auto projection_matrix projection_matrix
param_named_auto p_InverseModelView inverse_worldview_matrix
param_named_auto world_matrix world_matrix
param_named_auto view_matrix view_matrix
fragment_program_ref reflection_cube_specularmap_normalmap_fs100


The model is exploded and stretched

#version 150
#define lowp
#define mediump
#define highp
in vec4 vertex;
in vec3 normal;

uniform mat4 normalMatrix;
uniform mat4 modelViewProjectionMatrix;
uniform mat4 modelView;
uniform mat4 world_matrix;
uniform mat4 view_matrix;
uniform vec3 camera_world_position;
uniform mat4 projection_matrix;
uniform mat4 inverse_projection_matrix;
uniform mat4 p_InverseModelView;
void main()
vec4 pos = modelViewProjectionMatrix * vertex;
vec3 norm = mat3(normalMatrix) * normal;
vec2 offset = vec2( norm.x * projection_matrix[0][0], norm.y * projection_matrix[1][1] ) ;
pos.xy += pos.z * offset* 0.2;

gl_Position = pos;

Post Reply