Draw overlay quad/shapes when background quad is zoomed in

Started by
13 comments, last by dave09cbank 7 years, 5 months ago
As to how to copy it over to back buffer as in my case Invalidate the surface as using D3DImage (part of WPF) ?

Can't help you there, I don't use WPF. Don't even know if WPF can do it. the DirectX API can for sure. But I'm not sure about Windows Presentation Foundation.

From:

https://msdn.microsoft.com/en-us/library/aa970268(v=vs.110).aspx

"Windows Presentation Foundation (WPF) in Visual Studio 2015 provides developers with a unified programming model for building modern line-of-business desktop applications on Windows."

So yeah, its a business app API. I'd be kind of surprised if it supported stuff like render to texture. You may have to use the underlying DirectX API.


How would my ortho camera work in this case.

No different really, render to offscreen surface is simply a way to give you multiple back buffers you can target. Once you set the target surface, everything else is normal rendering, IE set the view mat and lights, and draw everything (lights! camera! action!).

Of course then all you have is this "bitmap" sitting in ram (or vidram most likely), which you then have to do something with - which probably means copying it somewhere so it can then be used. So if you created an offscreen surface in sysram (slow!) it would most likely copy the back buffer to ram, then copy it back to video texture memory when you used the surface to create a texture. Obviously you want to used the fastest ram possible for offscreen surfaces - or that RAM which requires less copying of things from here to there.

And don't forget the inherent performance hit from the fact that each offscreen render is basically another entire call to render to draw a single frame. So you have to render TWICE! - or more if you use more than one offscreen surface in the scene. So if you render twice, your FPS will more of less drop by 50%, depending on how much you draw. That's usually the big performance hit of render to surface - its an additional call to render(). Somewhat similar to stencil buffer volume shadow techniques where you'd have to render THREE times - one to add it in, one to subtract it out, and one using the result as a bitmask - as i recall - well - something like that. <g>.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Advertisement

thanks for the reply @Norman Barrows

After reading and implementing it in the code, i can get the render to texture work with WPF (as i used previously), with DirectX API underneath the hood.

However i still have a issue when i zoom in.

Issue:

See image flashing and weird shaped quad being rendered.

i have attached a zip with the 3 videos in it. (just pretend you don't see watermark in the video)

Download Link: https://dl.dropboxusercontent.com/u/5196736/Users/Kartik/DirectX/Dx%20Capture.zip

Any ideas as to why the above issue would occur ?

OK i have figured out as to why the images were being rendered with weird shaped quad being rendered.

The reason for this is that my matrices for WVP were getting transposed incorrectly on every alternate render call (transposed matrix being transposed again) , since they need to be in "row major".

Ok i have progressed further with the rendering to texture.

At this moment my rendered texture isn't rendered of correct size. The size changes once i perform zoom by updating the Z value on the view-projection matrix which eventually stops updating its size once its reached the correct size.

For whatever reason the texture is not filling the entire quad and i dont know why.

How i know this: In my shader i just return a single colour [gray float4(0.5f, 0.5f, 0.5f, 1) ] instead of the sampled colour.

And from what i conclude is this: my texture is either of the not same size as the quad or something else is going on.

The issue seen is via this link

Any suggestions anyone ?

Ignore the previous post #14

It was cause of my stupidity.

the reason for the issue was that the texture to which i would render to my entire scene wasn't being initialised correctly for the correct size which had caused the issue above.

In case it helps someone else.

This topic is closed to new replies.

Advertisement