Tag Info

New answers tagged

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


0

Keep in mind that in XNA (and all other 3D libraries), 2D is 3D! In XNA, sprites are just 3D planes drawn to the screen. Any shader you use in 3D will work just as well with the spritebatch. Spritebatch.Begin() has a parameter for the shader to pass in. If I'm following you, you want to use the depth image to blend between two images. Here's what I would ...


1

You can't rewrite that loop so that it can't be unrolled. GPUs do not in general support a varying number of attributes to be passed between stages. You can, however, eliminate the loop entirely. Just pass vPosWS to the fragment shader, and do the loop there. Then the unrolling will actually be helpful. Bonus: You don't waste an absurd amount of bandwidth ...


0

Unroll. The instruction cost is minimal - just a subtraction! You can try and put "[unroll]" (without quotes) just above the "for" line, or just unroll manually, but, really, unroll. You won't even have the comparison instruction for the for loop check.


1

I'm a newb to DirectX myself, but from what I've read, in HLSL, this: Texture textures[3]; Will actually be compiled like this: Texture textures0; Texture textures1; Texture textures2; So indexing into the array won't work.


2

The compiler won't always put the ".xyz" of a hlsl variable into ".xyz" of a register, if that's what you're referring to - sometimes it will move between .xyz, .xyw, .yzw, or even between components in separate registers, depending on if it's some intermediate calculation value or not and how much register pressure there is. As far as I'm aware there's no ...


1

I do it like this, so no divide in the PS. Vertex Shader code follows: struct VertextoPixel { float4 pos : SV_POSITION; float2 tex : TEXCOORD0; }; VertextoPixel main(uint vI : SV_VERTEXID) { float2 inTex = float2(vI%2,vI%4/2); VertextoPixel Out = (VertextoPixel)0; ...


0

Conservative rasterization is a fix for this problem. Thanks to Nathan Reed's comments, in preparation for the generation of a lightmap, I dilate the uv coordinates and recalculate they're associated positions based on the dilation. For each triangle: Compose an array of edges in uv space. For each edge: a. Compute the cross product using the edge ...


1

The key step that you're missing is the implicit slot assignment that occurs when you compile a shader. When you compile an HLSL shader that contains a bindable object (be it a Texture2D, RWStructuredBuffer, or cbuffer), each object must be assigned a slot number. This corresponds to the UINT StartSlot parameter to e.g. VSSetConstantBuffers. You can ...


1

You don't specify what rendering method you want to use. Standard rasterisation of a 3D mesh? Or do you have a volume representation of the model and your renderer uses that directly? If you render a volume, check this: http://http.developer.nvidia.com/GPUGems/gpugems_ch39.html especially 39.2. The effect in the picture you provide is mainly subsurface ...


0

That is explained here by Shawn Hargreaves, the Xna lead coder http://blogs.msdn.com/b/shawnhar/archive/2010/04/05/spritebatch-and-custom-shaders-in-xna-game-studio-4-0.aspx



Top 50 recent answers are included