Sign in to follow this  

[SlimDX] Constant Buffers with Matrices

Recommended Posts

Hello folks, I got an issue with constant buffers with some matrices defined as element(s). The problem seems that when update a cbuffer the matrices don't get set or get set properly. Here is are a few snippets that explain how I am trying to do it. This is the HLSL code of my shader. Please note the unbuffered Projection matrix in the top aswell.
float4x4 Projection;

// Constant buffer definition
cbuffer Screen
	float4x4	Projection2;	
	float4x4	InverseProjection;

// Vertex Shader
void VS_Geometry
	in	IA_VS_Geometry	input,
	out	VS_PS_Geometry	output
	output.Position	= mul(float4(input.Position, 1), mul(World, View));
	output.Depth	= output.Position.z;
	output.Position	= mul(output.Position, Projection);
	//output.Position	= mul(output.Position, Projection2);
	output.Normal	= mul(input.Normal, World);
	output.Binormal	= mul(input.Binormal, World);
	output.Tangent	= mul(input.Tangent, World);
	output.Texture	= input.Texture;

This code explains how I instantiate the variables used in my code below.
// Screen (c-buffer) variable of type EffectConstantBuffer (SlimDX)
ScreenVariable = Effect.GetConstantBufferByName("Screen");

// Screen (c-buffer) buffer of type Buffer (SlimDX)
ScreenBuffer = new SlimDX.Direct3D10.Buffer(
	Marshal.SizeOf(typeof(Matrix)) * 2,

This code explains how I update my c-buffers.
using (DataStream stream = ScreenBuffer.Map(MapMode.WriteDiscard, MapFlags.None))
	stream.Position = 0;

// Update the buffer

// Update the unbuffered 

The issue is, when I use the vertex shader as it now is, with the same lines uncommented, every thing works fine. My problem is when I uncomment the line where Projection2 is used instead of Projection, I get to see a blank screen. Has anyone had similar issues and can tell me what I am doing wrong? Kind regards, Xeile

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this