Sign in to follow this  
Deep314

HLSL Pixel Shader

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
[quote name='Deep314' timestamp='1317718851' post='4868910']
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?
[/quote]

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;[/size][/color]
[color=#1C2837][size=2]float4 PosForPS : TEXCOORD1;
}[/size][/color]


Cheers!

Share this post


Link to post
Share on other sites
[color=#1C2837][size=2] float4(In.Position.x,0,0,0);[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]wouldn't that be setting the alpha to 0[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2] float4(In.Position.x,0,0,1); is that what your after?[/size][/color]
[color=#1C2837][size=2]
[/size][/color]
[color=#1C2837][size=2]never used hlsl so just guessing here[/size][/color]

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