[2.3] HLMS / Cleanest approach to add outline shading for Meshes with Skeletons?
Posted: Thu May 06, 2021 1:51 pm
Hello you all.
This topic might be asked around here previously. But my problem is a little bit different... at least I believe.
I would like to add an outline to objects. I'm aware that this can be performed using a normal offset on vertex positions.
This piece of code works with static meshes and I'm ok with the results.
But as soon as I would like to use this approach for animated meshes I get into trouble as these are animated using the Vertex Shader of Pbs.
I thought.... well then I just add this small piece of position altering code to a custom piece™ of HLMS. There is even this neatly custom_vs_preTransform right for that purpose. Or is it? I've read through https://ogrecave.github.io/ogre-next/api/2.3/hlms.html and while I do understand the theory behind this, I have problems actually doing something with this information in practice. There is a certain lack of sample code on howto I can add a custom piece for a single material. I've read through the Terrain Pbs code. But It's like spanish.
How do I integrate this outline shader code the cleanest?
Is this custom_vs_preTransform piece in every Pbs based shader? Or can I just put it in one material?
Where can I place a custom piece for a single project. Ressources2.cfg seems to not be used so I can't place it in my own materials folder.
Kind regards,
Slamy
This topic might be asked around here previously. But my problem is a little bit different... at least I believe.
I would like to add an outline to objects. I'm aware that this can be performed using a normal offset on vertex positions.
Code: Select all
#version 330 core
#extension GL_ARB_shader_viewport_layer_array : require
vulkan_layout( OGRE_POSITION ) in vec3 position;
vulkan_layout( OGRE_NORMAL ) in vec3 normal;
in int gl_InstanceID;
vulkan( layout( ogre_P0 ) uniform Params { )
uniform mat4 worldViewProj;
uniform mat4 worldView;
uniform mat4 projection;
vulkan( }; )
out vec4 vertexColor; // specify a color output to the fragment shader
void main()
{
gl_Position = worldViewProj * vec4(position + normal*0.1, 1.0);
vertexColor = vec4(0.9, 0.0, 0.0, 1.0);
gl_ViewportIndex = gl_InstanceID;
}
But as soon as I would like to use this approach for animated meshes I get into trouble as these are animated using the Vertex Shader of Pbs.
I thought.... well then I just add this small piece of position altering code to a custom piece™ of HLMS. There is even this neatly custom_vs_preTransform right for that purpose. Or is it? I've read through https://ogrecave.github.io/ogre-next/api/2.3/hlms.html and while I do understand the theory behind this, I have problems actually doing something with this information in practice. There is a certain lack of sample code on howto I can add a custom piece for a single material. I've read through the Terrain Pbs code. But It's like spanish.
How do I integrate this outline shader code the cleanest?
Is this custom_vs_preTransform piece in every Pbs based shader? Or can I just put it in one material?
Where can I place a custom piece for a single project. Ressources2.cfg seems to not be used so I can't place it in my own materials folder.
Kind regards,
Slamy