Tag Info

Hot answers tagged

15

Your dilemma hints at a larger problem that's well-known to the graphics programming community, commonly referred to as "combinatorial shader explosion." As the name implies, it's usually considered in the context of very large numbers of shader permutations, but the basic principle is the same. Solutions geared toward solving the overarching problem are ...


8

In DirectX 10 the cards all have the same capabilities: this means that they guarantee that all features are available and implemented. However, they are free to do driver-level optimizations. Take, for example, the major difference in the way that they do anisotropic filtering (this article contains sources). Not only is the output of each vendor different ...


8

You're basically running into the kind of situation that makes NVIDIA Cg such an attractive piece of software (aside from the fact that it doesn't support GL|ES, which you said you're using). Also note that you really shouldn't use glGetAttribLocation. That function is bad juju from the initial days of GLSL before the folks in charge of GL really started ...


7

ID3DXFont can be used to render 2D text, and D3DXCreateText can be used to generate a 3D text mesh you could render as well. In general I would think the 2D approach is preferable, unless you want the text to do something odd like spin in 3D space. To find the appropriate place to start rendering the text (for the 2D case), you'll want to use the ...


6

OpenGL and freeglut will do what you're looking for. Freeglut can create the spheres, cubes, cylinder, cone, donuts, teapots, etc. GLUT (and hence freeglut) allows the user to create and manage windows containing OpenGL contexts on a wide range of platforms and also read the mouse, keyboard and joystick functions. http://freeglut.sourceforge.net/


6

The document just describes a particle system. Particle systems are nothing new, the difference with the demo is just that it uses the geometry shader to generate the geometry needed for the single partices. You can do the same on the CPU, the only drawback is that it is slower. Everything else can be done on SM 3.0 in a similar way as described in the ...


6

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 ...


6

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 ...


5

For each light do one render pass and use Additive blending. It is called forward rendering. Question is: Why to do it this way and not just send all of the light positions and params in few arrays? Answer is that this is much easier to handle once you start making some more complex effects. And there is one plus more. You can use your current shader. ...


5

It sounds like the bulk of what you're doing when you say "... A bunch of GetRenderTarget to store the old render target, then SetRenderTarget to set a new surface, and then things like CreateVertexBuffer, SetTexture, etc to draw on the new render target. Then resetting to the old render target." is actually stuff that needs to be done outside of a ...


5

The GDI approach: Create a bitmap and a device context Render your 3d graphics into the bitmap using GDI StretchBlit the bitmap onto the texture The Pixel approach: Lock the texture and fill the pixels using e.g. Bresenham's algorithm. The Render approach: Use DrawPrimitiveUP with D3DPT_LINELIST or D3DPT_LINESTRIP for drawing lines. Arcs, circles ...


5

Ah performance optimisation! The first question is, of course, what are you limited by? Are you pixel-shader limited? If you are, then obviously you should spend some time on this. If you are not, then simply calculate 10 lights and be done with it. What I would probably do is implement just two shaders. One that calculates 3 lights (which is fairly ...


5

Use the DirectX Error Lookup tool that's found in the SDK. Passing this value in it returns the following result: HRESULT: 0x80070057 (2147942487) Name: E_INVALIDARG Description: An invalid parameter was passed to the returning function Severity code: Failed Facility Code: FACILITY_WIN32 (7) Error Code: 0x0057 (87) You have an invalid argument passed ...


5

Firstly, I'd suggest using VertexBuffer<T> to improve type safety, but secondly, I think the differences between the two APIs are too much at this level. I personally would fully encapsulate the renderers behind an interface which does not deal with things like vertex declarations or setting shader attributes.


5

The way I do this is as follows. IDirect3DDevice9::GetBackBuffer: Get access to the IDirect3DSurface9 representing the back buffer, same as you've currently got. Don't forget to Release this surface when done as this call will increment the reference count! IDirect3DSurface::GetDesc: Get the description of the back buffer surface, which will give you it's ...


5

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

Yes, it would be more scalable in the long run to write a system could wrap and handle what your shaders need for you. There are several ways to do this, such as having a "Shader" class like you mentioned that inspects the underlying D3D Effect object for semantic annotations that let your wrapper class determine things like which kinds of vertex or texture ...


4

A talented programmer (Iq from from rgba) has written good articles: ssao: http://www.iquilezles.org/www/articles/ssao/ssao.htm global illumination: http://www.iquilezles.org/www/articles/simplegi/simplegi.htm ambient illumination: http://www.iquilezles.org/www/articles/ao/ao.htm


4

Check out this simple fragment shader implementation with explanation on why's and how's http://www.coniserver.net/wiki/index.php/Screen_Space_Ambient_Occlusion_Shader Although it is fragment/GL and not D3d9, it's simple as it gets, so you should be able to understand what you need to do.


4

The name "Draw" is somewhat misleading. It should better be called "AddToBatch". What it actually does is batch your Draw calls. Only when you call ID3DXSprite::Flush or Id3DXSprite::End it fills the sprites into one big vertex buffer and renders that onto the current render target. So if you want to switch render targets in between, you will have to do ...


4

I built a generic transition system for a 2d engine for iPhone. I'm going to try to explain it. This is only an approach, the implementation has more things that are not relevant. Suppose that your engine is hierarchical, if it is not, there are a lot of of reasons why a game engine must be hierarchical. We can have two interfaces IState and ITransition ...


4

But the problem is that the 3D graphics arent working with the Physics correctly... Pretty much any pair of graphics and physics libraries will work together. If you haven't managed to get OpenGL graphics and Bullet physics working, you probably just have a bug there which can be fixed.


4

Specifying the default pool does not instruct Direct3D to put the resource on the GPU. It instructs Direct3D to put the resource in the best pool for the usage you specified for the resource. The task manager is a very poor way of measuring performance, in general. It's possible the allocation is transient and done by the D3D API in order to transfer some ...


4

You need a DirectX 10 compatible GPU for running HiDef XNA games. Just change your project settings to Reach or get a compatible graphics card. You can find more info on the differences between HiDef and Reach on this post from Shawn Hargreaves.


4

The latest SDK version, as of this writing, is the June 2010 SDK. It contains what you'd need to build against both 9.0c and 11.


4

The answer doesn't have to do with DoubleBuffered, but rather with the default behaviour of System.Windows.Forms.Forms, which paint their own background when they need to paint. The answer is to add an override in the form: protected override void OnPaintBackground(PaintEventArgs e) { } Which fixes the problem.


4

You should use the latest (non-beta) version of the SDK (which is the June 2010 SDK as of this writing). It will be the most well-supported. Really, the only reason to use an older release of the SDK is if you are working on maintaining a legacy project that has a dependency on a technology that has been deprecated, such as DirectPlay.


4

Agreed, the latest release of the SDK is generally the best one to use, but there are other considerations. From sometime in 2004 (IIRC) onwards the D3DX stuff moved from being statically linked to dynamically linked. In order to handle this, the player needs a version of D3D that is up to date. In a fit of ingenuity, MS didn't include these up to date ...


4

When targeting the 9_1, 9_2 and 9_3 feature levels, the shader profiles you should use are: vs_4_0_level_9_1/ps_4_0_level_9_1 for levels 9_1 and 9_2, and; vs_4_0_level_9_3/ps_4_0_level_9_3 for the 9_3 level. This is hidden quite deeply in the MSDN documentation at ...



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