Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualLumz

Posted 17 February 2013 - 04:30 AM

RESOLVED : For the newbie's purpose, the problem was simply that i thought padding could occur anywhere (in this case at the end of the struct). But the packing has to be done every 16 bytes involving padding in the middle of the struct.

 

Hi,

 

I'm new to d3d11 so i apologies for this newbie question.

 

I'm trying to map data to several cbuffer but it seems that only the first (register(cb0)) cbuffer is actually getting correct data. I have no control what so ever on what is written in the next ones.

 

The problem appears only in the pixel shader. I've tried to add an extra cbuffer in the vertex shader and there's i no problem.

I think i have correctly aligned data to 16 bytes packing.

I use the same MatrixBuffer for both vertex shader and pixel shader.

Map() call sequence order is irrelevant and doesn't change anything.

 

EDIT : I've managed to reduce code to the following snippet. I'm using same buffer for cbuffer TestBuffer. And it works in the vertex shader but not in the pixel shader.

 

EDIT 2 : If i set TestBuffer : register(cb0) and MatrixBuffer : register(cb1) in the pixel shader i now get this strange compile error :

+        compile_error    0x001b80e8 "error X4567: maximum cbuffer exceeded. target has 14 slots, manual bind to slot 4294967295 failed\n"
 

 

 

VertexShader :


// Typedefs
//------------------------------------------------
struct VertexInputType
{
    float4 position : POSITION;
	float3 normal   : NORMAL;
};

struct PixelInputType
{
    float4 v_position : SV_POSITION;
	float3 w_normal   : NORMAL;
	float3 w_position : TEXCOORD0;
};

// Globals
//------------------------------------------------
cbuffer MatrixBuffer
{
	float4x4 world;
	float4x4 view;
	float4x4 projection;
};

cbuffer TestBuffer
{
	float4 test;
}

// Shader
//------------------------------------------------
PixelInputType SPMLVShader(VertexInputType input)
{
    PixelInputType output;
	output.v_position = input.position;
	output.w_normal = input.normal;

    // Change the position vector to be 4 units for proper matrix calculations.
	input.position.w = 1.0f;
	
	// Calculate the position of the vertex in world coordinates.
	output.w_position = mul(input.position, world);

    // Calculate the position of the vertex against the world, view, and projection matrices.
    output.v_position.xyz = output.w_position.xyz;
    output.v_position = mul(output.v_position, view);
    output.v_position = mul(output.v_position, projection);
    
    // Calculate the normal vector against the world matrix only.
    output.w_normal = mul(input.normal, (float3x3)world);
	
    // Normalize the normal vector.
    output.w_normal = normalize(output.w_normal);
	
	// CORRECT OUTPUT
	if(test.x == 222 && test.y == 223 && test.z == 224 && test.w == 225)
	{
		return output;	
	}
	
	// DO NOT DISPLAY ANYTHING
	output.v_position = float4(0, 0, 0, 0);
	return output;
}

 

PixelShader :


//	Typedefs
//------------------------------------------------
struct PixelInputType
{
    float4 v_position : SV_POSITION;
	float3 w_normal   : NORMAL;
	float3 w_position : TEXCOORD;
};

//	Globals
//--------------------------------------
cbuffer MatrixBuffer
{
	float4x4 world;
	float4x4 view;
	float4x4 projection;
};

cbuffer TestBuffer
{
	float4 test;
};

float4 SPMLPShader(PixelInputType input) : SV_TARGET
{
	if(test.x == 222 && test.y == 223 && test.z == 224 && test.w == 225)
	{
		return float4(0.0f, 1.0f, 0.0f, 1.0f);
	}
	else
	{
		return float4(1.0f, 0.0f, 0.0f, 1.0f);
	}
}
 

 

I've been searching a lot, but i have no clue yet on where it comes from.

 

Best regards.


#5Lumz

Posted 16 February 2013 - 10:01 AM

Hi,

 

I'm new to d3d11 so i apologies for this newbie question.

 

I'm trying to map data to several cbuffer but it seems that only the first (register(cb0)) cbuffer is actually getting correct data. I have no control what so ever on what is written in the next ones.

 

The problem appears only in the pixel shader. I've tried to add an extra cbuffer in the vertex shader and there's i no problem.

I think i have correctly aligned data to 16 bytes packing.

I use the same MatrixBuffer for both vertex shader and pixel shader.

Map() call sequence order is irrelevant and doesn't change anything.

 

EDIT : I've managed to reduce code to the following snippet. I'm using same buffer for cbuffer TestBuffer. And it works in the vertex shader but not in the pixel shader.

 

EDIT 2 : If i set TestBuffer : register(cb0) and MatrixBuffer : register(cb1) in the pixel shader i now get this strange compile error :

+        compile_error    0x001b80e8 "error X4567: maximum cbuffer exceeded. target has 14 slots, manual bind to slot 4294967295 failed\n"
 

 

 

VertexShader :


// Typedefs
//------------------------------------------------
struct VertexInputType
{
    float4 position : POSITION;
	float3 normal   : NORMAL;
};

struct PixelInputType
{
    float4 v_position : SV_POSITION;
	float3 w_normal   : NORMAL;
	float3 w_position : TEXCOORD0;
};

// Globals
//------------------------------------------------
cbuffer MatrixBuffer
{
	float4x4 world;
	float4x4 view;
	float4x4 projection;
};

cbuffer TestBuffer
{
	float4 test;
}

// Shader
//------------------------------------------------
PixelInputType SPMLVShader(VertexInputType input)
{
    PixelInputType output;
	output.v_position = input.position;
	output.w_normal = input.normal;

    // Change the position vector to be 4 units for proper matrix calculations.
	input.position.w = 1.0f;
	
	// Calculate the position of the vertex in world coordinates.
	output.w_position = mul(input.position, world);

    // Calculate the position of the vertex against the world, view, and projection matrices.
    output.v_position.xyz = output.w_position.xyz;
    output.v_position = mul(output.v_position, view);
    output.v_position = mul(output.v_position, projection);
    
    // Calculate the normal vector against the world matrix only.
    output.w_normal = mul(input.normal, (float3x3)world);
	
    // Normalize the normal vector.
    output.w_normal = normalize(output.w_normal);
	
	// CORRECT OUTPUT
	if(test.x == 222 && test.y == 223 && test.z == 224 && test.w == 225)
	{
		return output;	
	}
	
	// DO NOT DISPLAY ANYTHING
	output.v_position = float4(0, 0, 0, 0);
	return output;
}

 

PixelShader :


//	Typedefs
//------------------------------------------------
struct PixelInputType
{
    float4 v_position : SV_POSITION;
	float3 w_normal   : NORMAL;
	float3 w_position : TEXCOORD;
};

//	Globals
//--------------------------------------
cbuffer MatrixBuffer
{
	float4x4 world;
	float4x4 view;
	float4x4 projection;
};

cbuffer TestBuffer
{
	float4 test;
};

float4 SPMLPShader(PixelInputType input) : SV_TARGET
{
	if(test.x == 222 && test.y == 223 && test.z == 224 && test.w == 225)
	{
		return float4(0.0f, 1.0f, 0.0f, 1.0f);
	}
	else
	{
		return float4(1.0f, 0.0f, 0.0f, 1.0f);
	}
}
 

 

I've been searching a lot, but i have no clue yet on where it comes from.

 

Best regards.


#4Lumz

Posted 16 February 2013 - 09:55 AM

Hi,

 

I'm new to d3d11 so i apologies for this newbie question.

 

I'm trying to map data to several cbuffer but it seems that only the first (register(cb0)) cbuffer is actually getting correct data. I have no control what so ever on what is written in the next ones.

 

The problem appears only in the pixel shader. I've tried to add an extra cbuffer in the vertex shader and there's i no problem.

I think i have correctly aligned data to 16 bytes packing.

I use the same MatrixBuffer for both vertex shader and pixel shader.

Map() call sequence order is irrelevant and doesn't change anything.

 

EDIT : I've managed to reduce code to the following snippet. I'm using same buffer for cbuffer TestBuffer. And it works in the vertex shader but not in the pixel shader.

 

 

VertexShader :


// Typedefs
//------------------------------------------------
struct VertexInputType
{
    float4 position : POSITION;
	float3 normal   : NORMAL;
};

struct PixelInputType
{
    float4 v_position : SV_POSITION;
	float3 w_normal   : NORMAL;
	float3 w_position : TEXCOORD0;
};

// Globals
//------------------------------------------------
cbuffer MatrixBuffer
{
	float4x4 world;
	float4x4 view;
	float4x4 projection;
};

cbuffer TestBuffer
{
	float4 test;
}

// Shader
//------------------------------------------------
PixelInputType SPMLVShader(VertexInputType input)
{
    PixelInputType output;
	output.v_position = input.position;
	output.w_normal = input.normal;

    // Change the position vector to be 4 units for proper matrix calculations.
	input.position.w = 1.0f;
	
	// Calculate the position of the vertex in world coordinates.
	output.w_position = mul(input.position, world);

    // Calculate the position of the vertex against the world, view, and projection matrices.
    output.v_position.xyz = output.w_position.xyz;
    output.v_position = mul(output.v_position, view);
    output.v_position = mul(output.v_position, projection);
    
    // Calculate the normal vector against the world matrix only.
    output.w_normal = mul(input.normal, (float3x3)world);
	
    // Normalize the normal vector.
    output.w_normal = normalize(output.w_normal);
	
	// CORRECT OUTPUT
	if(test.x == 222 && test.y == 223 && test.z == 224 && test.w == 225)
	{
		return output;	
	}
	
	// DO NOT DISPLAY ANYTHING
	output.v_position = float4(0, 0, 0, 0);
	return output;
}

 

PixelShader :


//	Typedefs
//------------------------------------------------
struct PixelInputType
{
    float4 v_position : SV_POSITION;
	float3 w_normal   : NORMAL;
	float3 w_position : TEXCOORD;
};

//	Globals
//--------------------------------------
cbuffer MatrixBuffer
{
	float4x4 world;
	float4x4 view;
	float4x4 projection;
};

cbuffer TestBuffer
{
	float4 test;
};

float4 SPMLPShader(PixelInputType input) : SV_TARGET
{
	if(test.x == 222 && test.y == 223 && test.z == 224 && test.w == 225)
	{
		return float4(0.0f, 1.0f, 0.0f, 1.0f);
	}
	else
	{
		return float4(1.0f, 0.0f, 0.0f, 1.0f);
	}
}
 

 

I've been searching a lot, but i have no clue yet on where it comes from.

 

Best regards.


#3Lumz

Posted 16 February 2013 - 09:44 AM

Hi,

 

I'm new to d3d11 so i apologies for this newbie question.

 

I'm trying to map data to several cbuffer but it seems that only the first (register(cb0)) cbuffer is actually getting correct data. I have no control what so ever on what is written in the next ones.

 

The problem appears only in the pixel shader. I've tried to add an extra cbuffer in the vertex shader and there's i no problem.

I think i have correctly aligned data to 16 bytes packing.

I use the same MatrixBuffer for both vertex shader and pixel shader.

Map() call sequence order is irrelevant and doesn't change anything.

 

The following code snippet is very similar to several tutorials. Yet i get this weird bug.

// Defines
//------------------------------------------------

#define MAX_LIGHTS 5
#define M_PI 3.14159265359

//	Typedefs
//------------------------------------------------
struct PixelInputType
{
    float4 v_position : SV_POSITION;
	float3 w_normal   : NORMAL;
	float3 w_position : TEXCOORD;
};

struct Light
{
	float4 position;
	float3 direction;
	float1 angle;
	float1 radius;

	float4 ambient;
	float4 diffuse;
	float4 specular;

	float1 constant_attenuation;
	float1 linear_attenuation;
	float1 quadratic_attenuation;

	float1 exponent;
	
	float3 padding;
};

struct Material
{
	float4 ambient;
	float4 diffuse;
	float4 specular;

	float1 shininess;

	float3 padding;
};

//	Globals
//--------------------------------------
cbuffer MatrixBuffer
{
	float4x4 world;
	float4x4 view;
	float4x4 projection;
};

cbuffer LightBuffer
{
	int1  count;
	Light lights[MAX_LIGHTS];

	int3  padding;
};

cbuffer materialBuffer
{
	Material material;
};

 

Here are the struct i use for filling the memory.

	typedef struct
	{
		FLOAT world[16];
		FLOAT view[16];
		FLOAT projection[16];
	} MatrixBuffer;

	typedef struct
	{
		FLOAT position[4];
		FLOAT direction[3];
		FLOAT angle;
		FLOAT radius;
		
		FLOAT ambient[4];
		FLOAT diffuse[4];
		FLOAT specular[4];
		
		FLOAT constant_attenuation;
		FLOAT linear_attenuation;
		FLOAT quadratic_attenuation;

		FLOAT exponent;

		BYTE  padding[3 * 4];
	} Light;

	typedef struct
	{
		INT count;
		SPMLShader::Light lights[MAX_LIGHTS];

		BYTE padding[3 * 4];
	} LightBuffer;

	typedef struct
	{
		FLOAT ambient[4];
		FLOAT diffuse[4];
		FLOAT specular[4];

		FLOAT shininess;

		BYTE  padding[3 * 4];
	} MaterialBuffer;

 

And here comes the mapping.

	// Map matrices.
	D3D11_MAPPED_SUBRESOURCE mapped;
	
	HRESULT result = GetContext()->Map(m_matrix_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);

	assert(SUCCEEDED(result));

	MatrixBuffer* matrix_buffer = reinterpret_cast< MatrixBuffer* >(mapped.pData);

	for(UINT i = 0; i < 16; ++i)
	{
		UINT row = i / 4;
		UINT col = i % 4;

		matrix_buffer->world[i] = world(row, col);
		matrix_buffer->view[i] = view(row, col);
		matrix_buffer->projection[i] = projection(row, col);
	}

	GetContext()->Unmap(m_matrix_buffer, 0);

	// Set matrices constant buffer.
	GetContext()->VSSetConstantBuffers(0, 1, &m_matrix_buffer);
	GetContext()->PSSetConstantBuffers(0, 1, &m_matrix_buffer);

 

And ...

	D3D11_MAPPED_SUBRESOURCE mapped;
	
	HRESULT result = GetContext()->Map(m_material_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);

	assert(SUCCEEDED(result));

	MaterialBuffer* material_buffer = reinterpret_cast< MaterialBuffer* >(mapped.pData);

	Vector4 ambient = material.GetAmbientFactor();

	material_buffer->ambient[0] = ambient.GetX();
	material_buffer->ambient[1] = ambient.GetY();
	material_buffer->ambient[2] = ambient.GetZ();
	material_buffer->ambient[3] = ambient.GetW();

	Vector4 diffuse = material.GetDiffuseFactor();

	material_buffer->diffuse[0] = diffuse.GetX();
	material_buffer->diffuse[1] = diffuse.GetY();
	material_buffer->diffuse[2] = diffuse.GetZ();
	material_buffer->diffuse[3] = diffuse.GetW();

	Vector4 specular = material.GetSpecularFactor();

	material_buffer->specular[0] = specular.GetX();
	material_buffer->specular[1] = specular.GetY();
	material_buffer->specular[2] = specular.GetZ();
	material_buffer->specular[3] = specular.GetW();

	material_buffer->shininess = material.GetShininess();

	GetContext()->Unmap(m_material_buffer, 0);

	// Set material constant buffer.
	GetContext()->PSSetConstantBuffers(2, 1, &m_material_buffer);

 

I've been searching a lot, but i have no clue yet on where it comes from.

 

Best regards.


#2Lumz

Posted 16 February 2013 - 08:59 AM

Hi,

 

I'm new to d3d11 so i apologies for this newbie question.

 

I'm trying to map data to several cbuffer but it seems that only the first (register(cb0)) cbuffer is actually getting correct data. I have no control what so ever on what is written in the next ones.

 

The problem appears only in the pixel shader (i have only one cbuffer in the vertex shader).

I think i have correctly aligned data to 16 bytes packing.

I use the same MatrixBuffer for both vertex shader and pixel shader.

Map() call sequence order is irrelevant and doesn't change anything.

 

The following code snippet is very similar to several tutorials. Yet i get this weird bug.

// Defines
//------------------------------------------------

#define MAX_LIGHTS 5
#define M_PI 3.14159265359

//	Typedefs
//------------------------------------------------
struct PixelInputType
{
    float4 v_position : SV_POSITION;
	float3 w_normal   : NORMAL;
	float3 w_position : TEXCOORD;
};

struct Light
{
	float4 position;
	float3 direction;
	float1 angle;
	float1 radius;

	float4 ambient;
	float4 diffuse;
	float4 specular;

	float1 constant_attenuation;
	float1 linear_attenuation;
	float1 quadratic_attenuation;

	float1 exponent;
	
	float3 padding;
};

struct Material
{
	float4 ambient;
	float4 diffuse;
	float4 specular;

	float1 shininess;

	float3 padding;
};

//	Globals
//--------------------------------------
cbuffer MatrixBuffer
{
	float4x4 world;
	float4x4 view;
	float4x4 projection;
};

cbuffer LightBuffer
{
	int1  count;
	Light lights[MAX_LIGHTS];

	int3  padding;
};

cbuffer materialBuffer
{
	Material material;
};

 

Here are the struct i use for filling the memory.

	typedef struct
	{
		FLOAT world[16];
		FLOAT view[16];
		FLOAT projection[16];
	} MatrixBuffer;

	typedef struct
	{
		FLOAT position[4];
		FLOAT direction[3];
		FLOAT angle;
		FLOAT radius;
		
		FLOAT ambient[4];
		FLOAT diffuse[4];
		FLOAT specular[4];
		
		FLOAT constant_attenuation;
		FLOAT linear_attenuation;
		FLOAT quadratic_attenuation;

		FLOAT exponent;

		BYTE  padding[3 * 4];
	} Light;

	typedef struct
	{
		INT count;
		SPMLShader::Light lights[MAX_LIGHTS];

		BYTE padding[3 * 4];
	} LightBuffer;

	typedef struct
	{
		FLOAT ambient[4];
		FLOAT diffuse[4];
		FLOAT specular[4];

		FLOAT shininess;

		BYTE  padding[3 * 4];
	} MaterialBuffer;

 

And here comes the mapping.

	// Map matrices.
	D3D11_MAPPED_SUBRESOURCE mapped;
	
	HRESULT result = GetContext()->Map(m_matrix_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);

	assert(SUCCEEDED(result));

	MatrixBuffer* matrix_buffer = reinterpret_cast< MatrixBuffer* >(mapped.pData);

	for(UINT i = 0; i < 16; ++i)
	{
		UINT row = i / 4;
		UINT col = i % 4;

		matrix_buffer->world[i] = world(row, col);
		matrix_buffer->view[i] = view(row, col);
		matrix_buffer->projection[i] = projection(row, col);
	}

	GetContext()->Unmap(m_matrix_buffer, 0);

	// Set matrices constant buffer.
	GetContext()->VSSetConstantBuffers(0, 1, &m_matrix_buffer);
	GetContext()->PSSetConstantBuffers(0, 1, &m_matrix_buffer);

 

And ...

	D3D11_MAPPED_SUBRESOURCE mapped;
	
	HRESULT result = GetContext()->Map(m_material_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);

	assert(SUCCEEDED(result));

	MaterialBuffer* material_buffer = reinterpret_cast< MaterialBuffer* >(mapped.pData);

	Vector4 ambient = material.GetAmbientFactor();

	material_buffer->ambient[0] = ambient.GetX();
	material_buffer->ambient[1] = ambient.GetY();
	material_buffer->ambient[2] = ambient.GetZ();
	material_buffer->ambient[3] = ambient.GetW();

	Vector4 diffuse = material.GetDiffuseFactor();

	material_buffer->diffuse[0] = diffuse.GetX();
	material_buffer->diffuse[1] = diffuse.GetY();
	material_buffer->diffuse[2] = diffuse.GetZ();
	material_buffer->diffuse[3] = diffuse.GetW();

	Vector4 specular = material.GetSpecularFactor();

	material_buffer->specular[0] = specular.GetX();
	material_buffer->specular[1] = specular.GetY();
	material_buffer->specular[2] = specular.GetZ();
	material_buffer->specular[3] = specular.GetW();

	material_buffer->shininess = material.GetShininess();

	GetContext()->Unmap(m_material_buffer, 0);

	// Set material constant buffer.
	GetContext()->PSSetConstantBuffers(2, 1, &m_material_buffer);

 

I've been searching a lot, but i have no clue yet on where it comes from.

 

Best regards.


#1Lumz

Posted 16 February 2013 - 08:58 AM

Hi,

 

I'm new to d3d11 so i apologies for this newbie question.

 

I'm trying to map data to several cbuffer but it seems that only the first (register(cb0)) cbuffer is actually getting correct data. I have no control what so ever on what is written in the next ones.

 

The problem appears only in the pixel shader (i have only one cbuffer in the vertex shader).

I think i have correctly aligned data to 16 bytes packing.

I use the same MatrixBuffer for both vertex shader and pixel shader.

 

The following code snippet is very similar to several tutorials. Yet i get this weird bug.

// Defines
//------------------------------------------------

#define MAX_LIGHTS 5
#define M_PI 3.14159265359

//	Typedefs
//------------------------------------------------
struct PixelInputType
{
    float4 v_position : SV_POSITION;
	float3 w_normal   : NORMAL;
	float3 w_position : TEXCOORD;
};

struct Light
{
	float4 position;
	float3 direction;
	float1 angle;
	float1 radius;

	float4 ambient;
	float4 diffuse;
	float4 specular;

	float1 constant_attenuation;
	float1 linear_attenuation;
	float1 quadratic_attenuation;

	float1 exponent;
	
	float3 padding;
};

struct Material
{
	float4 ambient;
	float4 diffuse;
	float4 specular;

	float1 shininess;

	float3 padding;
};

//	Globals
//--------------------------------------
cbuffer MatrixBuffer
{
	float4x4 world;
	float4x4 view;
	float4x4 projection;
};

cbuffer LightBuffer
{
	int1  count;
	Light lights[MAX_LIGHTS];

	int3  padding;
};

cbuffer materialBuffer
{
	Material material;
};

 

Here are the struct i use for filling the memory.

	typedef struct
	{
		FLOAT world[16];
		FLOAT view[16];
		FLOAT projection[16];
	} MatrixBuffer;

	typedef struct
	{
		FLOAT position[4];
		FLOAT direction[3];
		FLOAT angle;
		FLOAT radius;
		
		FLOAT ambient[4];
		FLOAT diffuse[4];
		FLOAT specular[4];
		
		FLOAT constant_attenuation;
		FLOAT linear_attenuation;
		FLOAT quadratic_attenuation;

		FLOAT exponent;

		BYTE  padding[3 * 4];
	} Light;

	typedef struct
	{
		INT count;
		SPMLShader::Light lights[MAX_LIGHTS];

		BYTE padding[3 * 4];
	} LightBuffer;

	typedef struct
	{
		FLOAT ambient[4];
		FLOAT diffuse[4];
		FLOAT specular[4];

		FLOAT shininess;

		BYTE  padding[3 * 4];
	} MaterialBuffer;

 

And here comes the mapping.

	// Map matrices.
	D3D11_MAPPED_SUBRESOURCE mapped;
	
	HRESULT result = GetContext()->Map(m_matrix_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);

	assert(SUCCEEDED(result));

	MatrixBuffer* matrix_buffer = reinterpret_cast< MatrixBuffer* >(mapped.pData);

	for(UINT i = 0; i < 16; ++i)
	{
		UINT row = i / 4;
		UINT col = i % 4;

		matrix_buffer->world[i] = world(row, col);
		matrix_buffer->view[i] = view(row, col);
		matrix_buffer->projection[i] = projection(row, col);
	}

	GetContext()->Unmap(m_matrix_buffer, 0);

	// Set matrices constant buffer.
	GetContext()->VSSetConstantBuffers(0, 1, &m_matrix_buffer);
	GetContext()->PSSetConstantBuffers(0, 1, &m_matrix_buffer);

 

And ...

	D3D11_MAPPED_SUBRESOURCE mapped;
	
	HRESULT result = GetContext()->Map(m_material_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);

	assert(SUCCEEDED(result));

	MaterialBuffer* material_buffer = reinterpret_cast< MaterialBuffer* >(mapped.pData);

	Vector4 ambient = material.GetAmbientFactor();

	material_buffer->ambient[0] = ambient.GetX();
	material_buffer->ambient[1] = ambient.GetY();
	material_buffer->ambient[2] = ambient.GetZ();
	material_buffer->ambient[3] = ambient.GetW();

	Vector4 diffuse = material.GetDiffuseFactor();

	material_buffer->diffuse[0] = diffuse.GetX();
	material_buffer->diffuse[1] = diffuse.GetY();
	material_buffer->diffuse[2] = diffuse.GetZ();
	material_buffer->diffuse[3] = diffuse.GetW();

	Vector4 specular = material.GetSpecularFactor();

	material_buffer->specular[0] = specular.GetX();
	material_buffer->specular[1] = specular.GetY();
	material_buffer->specular[2] = specular.GetZ();
	material_buffer->specular[3] = specular.GetW();

	material_buffer->shininess = material.GetShininess();

	GetContext()->Unmap(m_material_buffer, 0);

	// Set material constant buffer.
	GetContext()->PSSetConstantBuffers(2, 1, &m_material_buffer);

 

I've been searching a lot, but i have no clue yet on where it comes from.

 

Best regards.


PARTNERS