Jump to content
  • Advertisement
Sign in to follow this  
wildboar

OpenGL Texture projection method for lots of projectors

This topic is 647 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to implement unit selection circles, like the ones you see in starcraft 2 when you select a bunch of units.

I am doing this for a mobile phone game so I have access to OpenGL ES 3.0.

 

I know there is some technique called deferred decals but since I am not using deferred rendering it seems like it's not for me.

I mean if it was faster to do it with deferred I could go ahead and implement it using pixel local storage or something? but that's another idea.

 

So I narrowed it down to 2 ideas but I am not sure which one makes more sense:

 

1) Take a 2048x2048 texture and draw quads into it at the unit positions from a camera thats looking down at it. Basically same as a shadowmap but writing circles into a color buffer instead of only using the depth buffer. When drawing the scene just sample this texture as I would a shadowmap.

 

2) Draw the scene and pass into it an array of matrices which are like the cameras looking down onto the unit position. In the fragment shader do a loop over these matrices and perform some kind of projection technique to see if that pixel is sampling a circle. This would limit the amount of circles by 32 maximum in a scene.

 

Any other ideas? I really have no clue how starcraft 2 implements this but they could very likely be using the deferred decal technique.

I don't want to just draw circles as quads as it looks bad when they intersect the floor and stuff, and with depth test disabled it also looks bad.

If its a huge resource hog for current mobile devices maybe I should abandon this idea altogether? really stuck at the moment.

Share this post


Link to post
Share on other sites
Advertisement

just draw quads below the units with slightly adjusted depht (do not use fragment shader depth output for this, fake it in pixel shader (calculate 'real' z (z/w), adjust a little (like *= 0.95) and mult by .w))

this trick is very quick, and gives you the ability to draw quad at the position of terrain, but not zfighting with terrain.

 

your second idea is realy bad for performance, while the first idea might actually work

(I would project the big texture only on terrain, projecting it on all meshes does not make much sesne, and will increase per pixel cost)


just draw quads below the units with slightly adjusted depht (do not use fragment shader depth output for this, fake it in pixel shader (calculate 'real' z (z/w), adjust a little (like *= 0.95) and mult by .w))

this trick is very quick, and gives you the ability to draw quad at the position of terrain, but not zfighting with terrain.

 

your second idea is realy bad for performance, while the first idea might actually work

(I would project the big texture only on terrain, projecting it on all meshes does not make much sesne, and will increase per pixel cost)

** I menant fake it in VERTEX shader ... 

Share this post


Link to post
Share on other sites

Hi, thanks for the reply. The reason I want projective textures is because it looks a lot more proffesional and not a quad that intersects the terrain that is used in older games. Presentation goes a long way for me and having the circles bend shape with the terrain is the effect I want. WoW was doing this back in 2004? At this point I am considering implementing deferred rendering.

Share this post


Link to post
Share on other sites

I am trying to implement unit selection circles, like the ones you see in starcraft 2 when you select a bunch of units.
I am doing this for a mobile phone game so I have access to OpenGL ES 3.0.

I know there is some technique called deferred decals but since I am not using deferred rendering it seems like it's not for me.
I mean if it was faster to do it with deferred I could go ahead and implement it using pixel local storage or something? but that's another idea.

So I narrowed it down to 2 ideas but I am not sure which one makes more sense:

1) Take a 2048x2048 texture and draw quads into it at the unit positions from a camera thats looking down at it. Basically same as a shadowmap but writing circles into a color buffer instead of only using the depth buffer. When drawing the scene just sample this texture as I would a shadowmap.

2) Draw the scene and pass into it an array of matrices which are like the cameras looking down onto the unit position. In the fragment shader do a loop over these matrices and perform some kind of projection technique to see if that pixel is sampling a circle. This would limit the amount of circles by 32 maximum in a scene.

Any other ideas? I really have no clue how starcraft 2 implements this but they could very likely be using the deferred decal technique.
I don't want to just draw circles as quads as it looks bad when they intersect the floor and stuff, and with depth test disabled it also looks bad.
If its a huge resource hog for current mobile devices maybe I should abandon this idea altogether? really stuck at the moment.

I've posted about this in this thread http://www.gamedev.net/topic/683796-decal-projection-quick-question-on-direction-of-implementation/

As per your option 1. Tip. As the circles are a distance away from the camera plane. You can use a render target resolution for your circles which is less than your display resolution workout loss of quality.

Share this post


Link to post
Share on other sites

 

I am trying to implement unit selection circles, like the ones you see in starcraft 2 when you select a bunch of units.
I am doing this for a mobile phone game so I have access to OpenGL ES 3.0.

I know there is some technique called deferred decals but since I am not using deferred rendering it seems like it's not for me.
I mean if it was faster to do it with deferred I could go ahead and implement it using pixel local storage or something? but that's another idea.

So I narrowed it down to 2 ideas but I am not sure which one makes more sense:

1) Take a 2048x2048 texture and draw quads into it at the unit positions from a camera thats looking down at it. Basically same as a shadowmap but writing circles into a color buffer instead of only using the depth buffer. When drawing the scene just sample this texture as I would a shadowmap.

2) Draw the scene and pass into it an array of matrices which are like the cameras looking down onto the unit position. In the fragment shader do a loop over these matrices and perform some kind of projection technique to see if that pixel is sampling a circle. This would limit the amount of circles by 32 maximum in a scene.

Any other ideas? I really have no clue how starcraft 2 implements this but they could very likely be using the deferred decal technique.
I don't want to just draw circles as quads as it looks bad when they intersect the floor and stuff, and with depth test disabled it also looks bad.
If its a huge resource hog for current mobile devices maybe I should abandon this idea altogether? really stuck at the moment.

I've posted about this in this thread http://www.gamedev.net/topic/683796-decal-projection-quick-question-on-direction-of-implementation/

As per your option 1. Tip. As the circles are a distance away from the camera plane. You can use a render target resolution for your circles which is less than your display resolution workout loss of quality.

 

Ah nice project you have! So you ended up doing the shadowmap method? Do you think that's the perfect way to do it or do you think deferred decals are an improvement to that technique?

Share this post


Link to post
Share on other sites

A trick I used in Unity once was to render a hollow cylinder like a deferred light. That is... the inner most cylinder creates a mask, the outer most cylinder will render the actual light.

Edited by Tangletail

Share this post


Link to post
Share on other sites

 

 

I am trying to implement unit selection circles, like the ones you see in starcraft 2 when you select a bunch of units.
I am doing this for a mobile phone game so I have access to OpenGL ES 3.0.

I know there is some technique called deferred decals but since I am not using deferred rendering it seems like it's not for me.
I mean if it was faster to do it with deferred I could go ahead and implement it using pixel local storage or something? but that's another idea.

So I narrowed it down to 2 ideas but I am not sure which one makes more sense:

1) Take a 2048x2048 texture and draw quads into it at the unit positions from a camera thats looking down at it. Basically same as a shadowmap but writing circles into a color buffer instead of only using the depth buffer. When drawing the scene just sample this texture as I would a shadowmap.

2) Draw the scene and pass into it an array of matrices which are like the cameras looking down onto the unit position. In the fragment shader do a loop over these matrices and perform some kind of projection technique to see if that pixel is sampling a circle. This would limit the amount of circles by 32 maximum in a scene.

Any other ideas? I really have no clue how starcraft 2 implements this but they could very likely be using the deferred decal technique.
I don't want to just draw circles as quads as it looks bad when they intersect the floor and stuff, and with depth test disabled it also looks bad.
If its a huge resource hog for current mobile devices maybe I should abandon this idea altogether? really stuck at the moment.

I've posted about this in this thread http://www.gamedev.net/topic/683796-decal-projection-quick-question-on-direction-of-implementation/

As per your option 1. Tip. As the circles are a distance away from the camera plane. You can use a render target resolution for your circles which is less than your display resolution workout loss of quality.

 

Ah nice project you have! So you ended up doing the shadowmap method? Do you think that's the perfect way to do it or do you think deferred decals are an improvement to that technique?

 

 

Yes, I think it was great, and if I had added Z Buffer testing then it also works well projecting onto models as well.  I use it for both static and dynamic decals and works well.  Im not sure you get much more out of deferred, it does offer some advantages but for a top down situation its not very much.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!