Tag Info

Hot answers tagged

4

For best performance you should avoid changing uniforms as well as shaders by using vertex attributes. Ideally pack all your 2D object textures into 1 single large texture (called an atlas) so you can render all your 2D objects in one call using a single vertex buffer. In your large texture you also put a 4x4 white area and map the texture coordinates of ...


2

There are two main ways to do this. First way is to do exactly what you're trying to avoid doing, and use a render target. This is the way used by the Shadow Mapping sample for D3D9 in the old DirectX SDK, although it needn't be 32-bit (D3DFMT_R16F may well be sufficient). As a possible optimization you could use a NULL depth/stencil target, enable ...


2

COLOR0 is DX9. Since you're dealing with DX11 (ps_5_0) you need to replace COLOR0 with SV_Target.


1

World position is vertex position multiplied by world matrix, not view matrix. So it should be like this in the vertex shader: output.WorldPos = mul(input.Pos,World); Unless you want View position to work with. I haven't checked the code for bugs if you want to use that.


1

It turns out that an effect passed to SpriteBatch.Begin must follow specific conventions: Texture2D<float4> Texture : register(t0); // SpriteBatch expects that default texture sampler parameter will have name 'TextureSampler' sampler TextureSampler : register(s0); // SpriteBatch expects that default vertex transform parameter will have name ...


1

It basically doesn't matter. #define uses token-pasting to insert the specified value into the shader code whereever it occurs; the shader itself will see the token as if you simply hard-coded it at every occurrence instead. A static const variable in, in actuality, a variable. Specifically, it is a variable that is initialized once, whose value persists ...



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