Tag Info

New answers tagged

0

you have to update your subresource (if i'm not mistaken): md3dDeviceContext->UpdateSubresource(mMatrixBuffer, 0, NULL, &worldViewProjM, 0, 0);


3

Use several constant buffers and group variables together based on how often they change. If your variables are fairly static ( or just huge ) you may be better off converting values into a texture and extracting them in the shader.


0

It looks like you can use the MarshalAs attribute like so [StructLayout(LayoutKind.Sequential, Pack = 16)] public struct cb0_t { public Matrix mWorld; public Matrix mView; public Matrix mProj; [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)] public Vector4[] vLightDir; [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)] public ...


0

StretchRect function does not execute the pixel shader. Instead: Set up your render target and draw a polygon to cover the entire screen. This is the common way to perform a "full screen shader" pass. Anecdotally, My personal recommendation is to investigate the Compute Shader.


4

Non-array struct members for constant buffers in HLSL are packed on four byte offsets, as many as it can into 16-byte vectors. If a member would straddle a vector boundary, it starts a new vector. You cannot achieve this with just an alignment and pack directive, you need to have explicit padding in your CPU-side structure to emulate the CB layout rules. ...


0

I believe your DEAOColor crosses the 16 byte alignment boundary. Your first bool is 4 bytes so DEAOColor get's cut in two. Try switching them (and any other variable that doesn't fit within the 16 byte steps).


7

Out of curiosity (and peace of the mind...) I wondered how DirectX decides which attribute from a struct corresponds to the right variable inside an HLSL cbuffer-register(x) (apart from the order/type they are declared with). Purely through memory layout. You give D3D a pointer to a chunk of memory which you claim to be organized in a certain ...


1

My assumption based on my experiences with shader reflection in DX11 is that it's mapped by name. If you check out the DX11 shader reflection API you'll see that there is a D3D11_SHADER_VARIABLE_DESC struct that you can rip from the shader. Notice the LPCSTR for the name of the variable. OpenGL also handles variable mapping by name. Of course the best way ...


1

VSSetConstantBuffers stands for VertexShaderSetConstantBuffers. Hence you also got PSSetConstantBuffers for the pixel shader.


2

There are additional alignment and layout rules for constant buffers. The float3 probably needs padding on the CPU side to get the right stride. Roughly paraphrased, things need to be on 16-byte boundaries.


1

Since you override SpriteBatch's default effect with your own, you are now responsible for setting effect parameters, especially matrices. You probably would like to replicate default SpriteBatch behaviour, so set effect.World to identity, and for projection default SpriteBatch effect uses effect.Projection = Matrix.CreateTranslation(-0.5f, -0.5f, 0) * ...


0

This problem may be related to mipmapping. The pixels along the edge are being mapped to a much more copressed LOD than the rest of the sphere, so the entire map is actually being compressed into that line. You may try putting in a tex2Dlod call in the shader and forcing the LOD to 0: return tex2Dlod(TextureSampler, float4(u, v, 0, 0)); Explanation and ...


1

Do not use full screen quads for your light volumes. A simple way is to draw a sphere for each light, in the position that the light occupies and of the same radius. This way, only the fragments actually affected by the light will be affected and your fragment shader will not be executed for the entire screen surface.



Top 50 recent answers are included