Jump to content
  • Advertisement
Sign in to follow this  
Jofo

DirectX11/HLSL issue

This topic is 2604 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone!

I'm quite new to DirectX and I'm making a school project in DX11. I have some issues with constants in HLSL...


Could anyone pls explain to me, how do constants/global variables in HLSL work? Because I'm making a simple demo, and want to access constants in cbuffer from pixel shader. But it doesn't work! I tried to even put them outside the cbuffer and set it manually in .fx source - same result.

snippet from .fx file:

cbuffer ConstantBuffer : register (b0)
{
matrix mWorld;
matrix mView;
matrix mProj;
float4 cColor; // - always black
}

float4 gColor = float4(1.0f,0.0f,0.0f,1.0f); //same here

... VS.....

float4 PS_Main( PS_Input frag ) : SV_TARGET
{
//return cColor; // - doesn't work, always black
//return gColor; // - same here
//return frag.color; //works, but not elegant
return float4( 1.0f,0.0f,0.0f,1.0f); //works, also not nice
}


Any answer greatly appreciated


EDIT1: partially solved, forgot to call PSSetConstantBuffers.... jeez
EDIT2: the global stuff still not working

Share this post


Link to post
Share on other sites
Advertisement

This topic is 2604 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!