Operating System: Linux
Render System: GL3Plus
I have managed to implement clipping by adding the custom shader files for the Pbs shader:
CustomPassBuffer_piece_vs_piece_ps.glsl
CustomPost_piece_vs.glsl
I create vec4 planes in the custompassbuffer file:
Code: Select all
vec4 clipPlane0;
...
Code: Select all
float*OgreClippingHlmsListener::preparePassBuffer(const Ogre::CompositorShadowNode* shadowNode, bool casterPass, bool dualParaboloid, Ogre::SceneManager* sceneManager, float* passBufferPtr)
{
*passBufferPtr++ = clippingPlaneOne_.x;
*passBufferPtr++ = clippingPlaneOne_.y;
*passBufferPtr++ = clippingPlaneOne_.z;
*passBufferPtr++ = clippingPlaneOne_.w;
...
}
Code: Select all
gl_ClipDistance[0] = dot(float4(worldPos.xyz, 1.0), passBuf.clipPlane0.xyzw)
...
Edit: Found it: viewtopic.php?f=25&t=83081
As far as I can tell this part works, I can successfully set my planes in code and it clips.
I have only done this for the Pbs shader, but I would assume the same can be done for Unlit.
The above solution will clip everything which uses the shader, which I want to change to clip only specific objects.
Ideally I want to turn on/off specific planes for specific objects.
My first thought was simply enabling and disabling (glEnable(CLIP_DISTANCE0f for example) the clipping distances in different renderqueues.
While this isn't strictly "per object", it would at least be a compromise. Unfortunately this did not work at all.
For example doing something like this, and putting objects in renderqueue 4, does not work:
Code: Select all
void OgreClippingRenderqueueListener::renderQueueStarted(Ogre::RenderQueue* rq, Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation)
{
if (queueGroupId == 4)
{
glEnable(GL_CLIP_DISTANCE0);
}
else
{
glDisable(GL_CLIP_DISTANCE0);
}
}
Perhaps this is all obvious and I simply misunderstood the documentation for renderqueuelisteners, or modifying GL stuff here is a bad idéa.
I have considered one other option, embedding the plane data into each vertex somehow, but that sounds cumbersome/terrible if I want to update the plane (having to iterate through each vertex and update). I have not even bothered to try this, even though it should technically be "per object".
Either way I am looking for any help I can get in tackling this problem. I hope I have provided enough info.
tl;dr:
The question can be made general: Is it possible to pass information on a per "object/mesh" level to the vertex shader?
If yes, I'd love an example!