Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


C++ Directx Ambient Light issue.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Migi0027 (肉コーダ)   Crossbones+   -  Reputation: 3522

Like
0Likes
Like

Posted 03 August 2012 - 09:39 AM

I'm currently having a problem with lighting in Directx 11, actually its ambient lighting. Here is the code:

cbuffer ConstantBuffer
{
	float4x4 final;
	float4x4 rotation;	// the rotation matrix
	float4 lightvec;	  // the light's vector
	float4 lightcol;	  // the light's color
	float4 ambientcol;	// the ambient light's color
}
struct VOut
{
	float4 color : COLOR;
	float4 position : SV_POSITION;
};
VOut VShader(float4 position : POSITION, float4 normal : NORMAL)
{
	VOut output;
	output.position = mul(final, position);
	// set the ambient light
	output.color = ambientcol;
	// calculate the diffuse light and add it to the ambient light
	float4 norm = normalize(mul(rotation, normal));
	float diffusebrightness = saturate(dot(norm, lightvec));
	output.color += lightcol * diffusebrightness;
	return output;
}
float4 PShader(float4 color : COLOR) : SV_TARGET
{
	return color;
}

Then i send the values to the shader:

ambLight.LightVector = D3DXVECTOR4(1.0f, 1.0f, 1.0f, 0.0f);
ambLight.LightColor = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f);
ambLight.AmbientColor = D3DXCOLOR(0.2f, 0.2f, 0.2f, 1.0f);

ShaderManager.UpdateSubresourceDiffuseShader(devcon);

And then i get the following:

Attached image

Why?

Attached Thumbnails

  • FAIL.png

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/cuboidzone.wordpress.com/


Sponsor:

#2 Migi0027 (肉コーダ)   Crossbones+   -  Reputation: 3522

Like
0Likes
Like

Posted 04 August 2012 - 03:52 AM

Bump, no one knows?

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/cuboidzone.wordpress.com/


#3 Ripiz   Members   -  Reputation: 529

Like
0Likes
Like

Posted 04 August 2012 - 04:03 AM

You didn't say what's the problem.

Your ambient light is D3DXCOLOR(0.2f, 0.2f, 0.2f, 1.0f); and box is almost black, seems right to me.

#4 Tordin   Members   -  Reputation: 604

Like
1Likes
Like

Posted 04 August 2012 - 04:49 AM

are you sure you are not reffering to that your directional light dosent work?
"There will be major features. none to be thought of yet"

#5 Migi0027 (肉コーダ)   Crossbones+   -  Reputation: 3522

Like
0Likes
Like

Posted 04 August 2012 - 07:22 AM

are you sure you are not reffering to that your directional light dosent work?


I'm following a tutorial from DIrectxtutorial.com you cant see it because you need to be premium, well if you are, its the dx11 lighting tutorial.
Its supposed to look like this:
Posted Image

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/cuboidzone.wordpress.com/


#6 Migi0027 (肉コーダ)   Crossbones+   -  Reputation: 3522

Like
1Likes
Like

Posted 04 August 2012 - 07:33 AM

Ohh snap, I've fixed it.

I forgot to send the rotation matrix. I feel very dumb xD

Well well, thank you for trying to help me!

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/cuboidzone.wordpress.com/


#7 Tordin   Members   -  Reputation: 604

Like
0Likes
Like

Posted 05 August 2012 - 01:59 PM

Things like that happens all the time :)
"There will be major features. none to be thought of yet"




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS