Sign in to follow this  
Alundra

Method for hidden objects.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 :
[CODE]
// 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 ) ) );
[/CODE]

Do I need to make a "back to front" rendering ?
Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this