Jump to content
  • Advertisement
Sign in to follow this  
dave09cbank

Draw overlay quad/shapes when background quad is zoomed in

This topic is 708 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

Hi,

 

I'm trying to draw an overlay quad/shape on top of another quad.

 

Now i could have my background quad zoomed in (using ortho camera) while i'm trying to draw my overlay object. 

Thus, what i really want is to draw the overlay shape which takes into consideration how much i'v already zoomed in.

 

As currently it doesn't expand/enlarge when i zoom in and thus keeps the overlay shape of the same size.

 

Do i need to manually enlarge the shape and then draw or could it be all done in shader ?

 

Any suggestion how i could approach this.

 

Note: Using SharpDx & C# & Directx11

Share this post


Link to post
Share on other sites
Advertisement

A picture of what you're trying to do might help.

 

But, if I'm picturing this in my head correctly, you could use a Scaling Matrix on the quad, in which the amount of scaling would be correlative to the difference between the last frames zoom value, and the current frames zoom value. (Really anything to use as a scalar for the scaling of the overlay)

 

Using a scaling matrix is pretty simple to. Something like this:

worldMatrix = scale() * rotation() * translation();

Marcus Hansen

Edited by markypooch

Share this post


Link to post
Share on other sites

Thanks for the reply @markypooch

 

I tried to upload some screenshots but for some reason they wont upload (no specific reason)

so i have uploaded them to my dropbox.

 

Screenshot 1 Link: Scenario where the overlay quad (in yellow) are drawn on background quad

 

Screenshot 2 Link: Scenario where i have zoomed in and then drawn my overlay (in yellow)

 

Also,

 

My quads are drawn using actual screen co-ordinates which are transformed to world space in the shader file.

All the quad i.e both background and overlay use the same matrices.

 

However, at this point I cant understand how would the scaling matrix fit as a solution ?

Would you kindly explain/elaborate.

 

Thanks

Share this post


Link to post
Share on other sites

Well now that I see what you're trying to do. Than, yeah a scaling matrix isn't much of a solution. I was kinda going off this:

 

 

Thus, what i really want is to draw the overlay shape which takes into consideration how much i'v already zoomed in

As currently it doesn't expand/enlarge when i zoom in and thus keeps the overlay shape of the same size.

 

A scaling matrix will scale the quad by some magnitude of your choosing. This is, it can enlarge the quad itself the more you zoom up on the license plate. But, it all depends on what you're trying to do. 

 

If your expecting an algorithm to run through all sorts of different pictures of cars with license plates, and occlude them, you may want to look into an image detection algorithm, which if that's the case, i'll pass this topic off to someone else who has more knowledge in this area.

 

Marcus Hansen

Share this post


Link to post
Share on other sites

The way i zoom is i try to keep the point under the mouse at the same position by moving quad left/right/top/bottom if it needs to.

 

Also, i wasn't expecting an image detection algorithm.  The background image used was from live camera feed.

Share this post


Link to post
Share on other sites

Why not just render the image background image to an offscreen texture, add the yellow boxes, and then use this new image to zoom in on?

Share this post


Link to post
Share on other sites
I haven't rendered to offscreen texture before but can look into it.

However that brings me to next question.
The yellow quads which I draw were simple example of quads filled with color as I do use different effects such as pixelated or blur the quad represented by yellow color.

Could they still be achieved when trying to render offscreen texture as per your suggestion ?

Currently how I render:
1. Draw background quad
2. Draw my yellow quads
3. Present the buffer or invalidate surface as using D3DImage part of WPF

In order to do render to offscreen texture:
1. Have 2 render targets
2. Draw background quad on texture render target which not my main back buffer
3. Draw my yellow quad as above
4. Convert the offscreen render target to shader resource view
5. Map this shader resource view to update my back buffer which my main render target
6. Present the back buffer or invalidate surface as above

Are my steps correct or am I approaching this completely in a wrong way.

Share this post


Link to post
Share on other sites
Could they still be achieved when trying to render offscreen texture as per your suggestion ?

 

By and large, "offscreen" is simply another "surface" you can render to, just like the back buffer. There's a little work in setting it up, and copying it over to the back buffer, but that's about it.

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

thanks for the update @Norman Barrows

 

Yes i agree as after researching & reading on it.

 

However from what i read rendering to texture can have performance issues. 

If this is the case then whats the main reason/best case scenario for its usage ?

 

Also the confusion i  still have :

1. As to how to copy it over to back buffer as in my case Invalidate the surface as using D3DImage (part of WPF) ?

2.  How would my ortho camera work in this case.

 

Though i'm still investigating the above two points, since i've just started to implement it in code.

Share this post


Link to post
Share on other sites
If this is the case then whats the main reason/best case scenario for its usage ?

 

when its the best / only way to achieve the desired effect, whatever the desired effect in question may be.  

 

Often times its used to render to texture, where you render to an offscreen surface, then use that surface to create a texture, then use that texture in a subsequent draw call to texture a mesh.   A rear view mirror in a car driving simulator would be an example of this.  They create an offscreen surface, point the camera looking back, render the scene to the offscreen surface, then point the camera back forward again and render the scene,  and use the offscreen surface as the texture for the rear view mirror. And Voila!  you have real working rear view mirrors!  Pretty cool huh?

 

But just from that brief description, you can see that its jumping through a number of hoops to do all that - thus the performance hit.  Its usually an effect that is used sparingly.

 

As with everything , the proof is in the pudding, you won't know if it will work for you until you try it. All you can do is do your research, and become familiar with the methods available, and try those that look promising.

Edited by Norman Barrows

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!