8

Short answer: yes, that formula is correct. Longer answer: if you think of a texture as being a grid of little squares, one for each texel, the actual color value stored in the texture can be thought of as being located at a point at the center of each texel square. So, in UV coordinates where the texture ranges from (0, 0) to (1, 1), the color samples are ...


7

The fixed function pipeline doesn't involve many changes to shaders (there may even be only a single "fixed function" shader in the driver's fixed-function emulation path; up to the driver how it handles legacy APIs) which are one of the more expensive things to change. The driver also could be doing a bazillion different things to optimize or not depending ...


6

Well, I'm surprised about the stuff you can learn when researching stuff for answering a question. Short answer: you can't. This stuff you probably already know, but I'll cover it in case other people find it useful. At first I thought you can't share handles among Direct3D devices, let alone versions, but it turns out that you can actually do that! In ...


4

Preventing present waiting for a vsync is basically all you can do if you want to do other things with that thread or D3D9 in general. However what you could do is load your file from disk on another thread (or asynchronously with say overlapped IO) then create your texture from that on the main thread. If your using a compressed image format that will need ...


4

Now when using the discard presentation in a Win32 app it passes the render target to DWM which then blits the target to the screen and when in full screen mode (provided you have resized your back buffer and refresh rate correctly) it will disable DWM and perform flips to render the scene. Now with metro apps there's no such thing as full screen exclusive ...


4

For texture spaces, in Direct3D (0, 0) is top-left, in OpenGL (0, 0) is bottom-left. Therefore the v-coordinate will be upside down in one of these APIs. However, I wouldn't recommend negating the v-coordinate as this will only work if you're using a sampler with wrapping. You can fix the v-coordinate as follows: v = 1.0f - v;


3

There is a mesh convert tool in my directory of DXSDK. I can convert .x format from binary to text and text to binary (among other things). C:\Program Files\DXSDK\Utilities\bin\x86>MeshConvert.exe


3

In the past I've fixed this sort of problem using a dilation filter. Basically, the idea is to go over the lightmap after it's rendered and expand the borders of all the pieces by a few pixels, by copying the values of filled pixels into adjacent empty pixels. This can be done with a pixel shader in a full-screen pass or two over the lightmap.


3

Lets look at what your blend setup is actually doing: PDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA); PDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE); This means that your colors are calculated by: ScreenPixel = OldPixel + NewPixel * NewPixel.a So expanding your blend sequence gives you: color += texture1 * texture1.a; color += ...


3

This is documented on MSDN at: "Presenting Multiple Views in Windowed Mode (Direct3D 9)": The application typically creates one swap chain per view by using the IDirect3DDevice9::CreateAdditionalSwapChain method, and associates each swap chain with a particular window. What you're missing in your code is the "associates each swap chain with a particular ...


3

I just stumbled back on this question, so I figure I should supply an answer. :) The shader code I wrote in the question is almost right. I forgot that to convert a point with these transformations, the point needs to be in homogeneous coordinates. See: https://stackoverflow.com/questions/5066532/how-to-multiple-a-2d-point-with-a-4d-matrix So the correct ...


3

A smart bubble/insertion sort is faster than quick sort when the array is already mostly sorted (reused on the next frame). To speed up the copy of data rather than copying entire vertex values use an index buffer to sort the vertices. When you remove quads you can quickly degenerate them (set all vertices to the same value) instead of removing them and ...


3

Sprites in Direct3D are just textured triangles (or rather two triangles forming a quadrilateral). As such, the performance hit is because each time you change the source texture it has to flush the sprite batch and submit it as a Draw. The key to Direct3D performance is to get as much work into each Draw as possible. You are basically drawing two triangles ...


3

You generally want to use the latest version that is compatible with your target platform. For most people that means DirectX11, since DirectX12 is not supported on versions of Windows (i.e. Windows 7) that are still widely used. But, with every version, you need to make sure that you are using it in the most efficient way. Just swapping the calls for the ...


2

A good (also widely used) workaround to this problem is to create multiple render targets of a size that your GPU supports, render your scene in pieces, and assemble on your back buffer(s). The downside to this is, you'll effectively render your scene N times (where N is your # of render targets), but with proper scene preprocessing, this may not be as bad ...


2

See pseudo code First check if the current pixel is in range: if(current.x >= - max_distance + min(x0, x1) && current.x =< max_distance + max(x0, x1)) { if(current.y >= -max_distance + min(y0, y1) && current.y =< max_distance + max(y0, y1)) { result.color = some_color; float distance = ...


2

What you'll wind up doing David is creating a vertex buffer to hold the different transformation matrices for each instance of grass. You will need a vertex declaration that has your standard 'grass' vertex components( pos, norm, uv...etc ), and in that same declaration 4 additional 4-component floats to hold the 4x4 transformation matrix...the declaration ...


2

The DirectX SDK has samples on how to do this, and there are resources online you can find on how to do this. Look in C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\Direct3D\Instancing\Instancing.cpp. Here's a Nvidia GPU Gem article on Geometry Instancing. And here's an article on MSDN. This article shows you the two vertex ...


2

I can think of two obvious possibilities: You've hit the TDR timeout because the shader is taking ages to run. You can work round this locally by adjusting the timeout in the registry. You probably shouldn't adjust that setting for other people though - the general solution is to break the draw call up into multiple smaller draw calls - resizing is usually ...


2

I believe the answer is no, you cannot use SetLOD. As the documentation says, the texture must be managed which means D3DPOOL_MANAGED and which does not exist in Direct3D 9Ex. I have a sample app which uses Direct3D 9Ex, and tried calling SetLOD, and I got a return of 0 which means it failed according to the documentation which states This method ...


2

Batching will often lead to a performance gain, but this is only if you had a bottleneck being created by the multitude of draw calls being made to begin with. In this particular case you may have simply introduced a new bottleneck. I think it's likely that the CPU is now having to work overtime to transform and batch all that data. Keep in mind that all ...


2

You should do Output.Pos2 = Output.Position in the vertex shader, then in the pixel shader: float2 screenPos; screenPos.x = Input.pos2D.x/Input.pos2D.w/2.0f + 0.5f; screenPos.y = -Input.pos2D.y/Input.pos2D.w/2.0f + 0.5f; To get correct screen space coordinates you have to do your w divide in the pixel shader. After that your return should ...


Only top voted, non community-wiki answers of a minimum length are eligible