Jump to content
  • Advertisement
Sign in to follow this  
Deep314

HLSL Pixel Shader

This topic is 2480 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

Hi all.

Why it doesnt work?

struct VS_OUTPUT
{
float4 Position : POSITION; // vertex position
float4 Diffuse : COLOR0;
float2 TextureUV : TEXCOORD0;
}


PS_OUTPUT RenderScenePS( VS_OUTPUT In, uniform bool bTexture )
{
PS_OUTPUT Output;

Output.RGBColor = float4(In.Position.x,0,0,0);

return Output;
}


But if i change Output.RGBColor = float4(In.Position.x,0,0,0); to Output.RGBColor = float4(0,0,0,0); all work great!

Where im wrong?

Share this post


Link to post
Share on other sites
Advertisement

Hi all.

Why it doesnt work?

struct VS_OUTPUT
{
float4 Position : POSITION; // vertex position
float4 Diffuse : COLOR0;
float2 TextureUV : TEXCOORD0;
}


PS_OUTPUT RenderScenePS( VS_OUTPUT In, uniform bool bTexture )
{
PS_OUTPUT Output;

Output.RGBColor = float4(In.Position.x,0,0,0);

return Output;
}


But if i change Output.RGBColor = float4(In.Position.x,0,0,0); to Output.RGBColor = float4(0,0,0,0); all work great!

Where im wrong?


Hi,

Does your shader compile? if not, what is the error? The error messages usually tell what is wrong with the shader.

However, If I remember correctly, you may not read a variable with position semantic. You'll need to have another variable outputted from the vertex shader declared as texture coordinate (keep in mind that you still need to output the position too). You may put a copy of your position to that other variable.

Something like:

[color=#1C2837][size=2]struct VS_OUTPUT
{
float4 Position : POSITION; // vertex position
float4 Diffuse : COLOR0;
float2 TextureUV : TEXCOORD0;
[color=#1C2837][size=2]float4 PosForPS : TEXCOORD1;
}


Cheers!

Share this post


Link to post
Share on other sites
[color=#1C2837][size=2] float4(In.Position.x,0,0,0);
[color=#1C2837][size=2]

[color=#1C2837][size=2]wouldn't that be setting the alpha to 0
[color=#1C2837][size=2]

[color=#1C2837][size=2] float4(In.Position.x,0,0,1); is that what your after?
[color=#1C2837][size=2]

[color=#1C2837][size=2]never used hlsl so just guessing here

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!