Method for hidden objects.

Started by
2 comments, last by Alundra 11 years, 10 months ago
Hi,
Currently working on a game, i would add the feature to see the player when they are hidden by the map.
The effect could be edge detection or simply a transparency effect.
First, I was thinking about stencil buffer used with depth buffer but the idea goes wrong.

Maybe one good solution could you suggest ?

Thanks
Advertisement
If your are content with the 'behind the wall' effect having the same silhouette as the actual player geometry, then you can use the following three pass algorithm:

1) render all opaque objects with depth tests and writes enabled, except player characters.
2) render all player characters with a special 'behind a wall' shader, with depth tests and writes disabled. This shader could e.g. render the characters with a yellow color.
3) render all player characters with the normal shader, with depth tests and writes enabled. This causes the parts from the above special fx render to disappear where the character is actually visible.

If you want to apply a glow 2D postprocess effect with this mechanism, render the second and third steps into a separate color target instead of the main target, and in the third step, use a black color to mask off the glowy areas. Then apply the glow shader to the off-screen render target, and composite it on top of the main screen.
Hi,
Using this code, all is working good but when player are "one next to other", it seams to have some problem.
The code used :

// HiddenVisible.
if( Object->GetHiddenVisible() )
{
glDepthFunc( GL_GREATER );
glDepthMask( GL_FALSE );
glEnable( GL_BLEND );
glBlendFunc( GL_ONE, GL_ONE );
glDrawElements( GL_TRIANGLES, Subset.IndexCount, GL_UNSIGNED_INT, BUFFER_OFFSET( Subset.IndexStart * sizeof( UInt32 ) ) );
glDisable( GL_BLEND );
glDepthMask( GL_TRUE );
glDepthFunc( GL_LESS );
}
glDrawElements( GL_TRIANGLES, Subset.IndexCount, GL_UNSIGNED_INT, BUFFER_OFFSET( Subset.IndexStart * sizeof( UInt32 ) ) );


Do I need to make a "back to front" rendering ?
Thanks
All is ok now, i have done the 3 pass method as you said.
Thanks for the help.

This topic is closed to new replies.

Advertisement