Jump to content

  • Log In with Google      Sign In   
  • Create Account


About HLSL's Semantic


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
8 replies to this topic

#1 zonozz   Members   -  Reputation: 158

Like
0Likes
Like

Posted 04 April 2013 - 07:13 AM

Hi everyone !

 

I use RenderMonkey to try SSAO effect, I need vertex shader output position normal structure like this :

 

struct VS_OUTPUT

{

      float4 position : POSITION0;

      float3 normal  : NORMAL0;

};

 

and I make structure for pixel shader to adapt to vertex shader output like this :

 

struct PS_INPUT

{

      float4 position : POSITION1 ;( Here is a problem, when compiled pixel shader, it told me POSITION index from 1 - 15 )

      float3 normal  : NORMAL0;

};

 

My question is : In vertex shader output structure position with POSITION0. But pixel shader input structure position is POSITION1.

How could pixel shader find vertex shader output variable - " position " ? They have different semantic !.?

 

I use RenderMonkey to implement SSAO, But when I check render target "Normal" and "Position" ( Next pass needs these vars ) , I just see 

 

Normal texture is correct result.

 

I dont know the figure is right or not ? But I try 2 PC have different GPU, they displayed the different pictures.

 

This can not display the position renderTexture & view renderTexture

 

SSAO 1.jpg

 

But on this computer displayed all (I dont know view renderTexture & normalTexture are correct ?)

SSAO 2.jpg


Edited by zonozz, 04 April 2013 - 07:14 AM.


Sponsor:

#2 kubera   Members   -  Reputation: 758

Like
1Likes
Like

Posted 04 April 2013 - 08:18 AM

Maybe you would fill the POSITION1 value as the vertex shader's output.

Is is possible, that the Monkey has a bug, and you can create a new project from scratch.



#3 phil_t   Crossbones+   -  Reputation: 2484

Like
2Likes
Like

Posted 04 April 2013 - 01:09 PM

You could also put the position into a TEXCOORD0 semantic when output from your vertex shader, and then use that for input into your pixel shader.

 

POSITION0 is meant to be output from the vertex shader for the rasterizer, it isn't meant for input into the pixel shader (though I guess it works on some graphics cards?).



#4 Racoonacoon   Members   -  Reputation: 439

Like
1Likes
Like

Posted 04 April 2013 - 01:10 PM

Yo zonozz,

 

From what I can remember, it is illegal in HLSL to pass the Position semantic to the pixel shader, at least in DirectX 9. Try creating a VS_OUTPUT that has a TEXCOORD semantic in addition to the POSITION semantic. Then, in your vertex shader, write the value of the position to both of the semantics. Have your PS_INPUT semantic read the TEXCOORD but not the position.

 

Something like this:

 

struct VS_OUTPUT

{

      float4 position : POSITION0;

      float4 pixelShaderPos : TEXCOORD1;

      float3 normal  : NORMAL0;

};

 

struct PS_INPUT

{

      float4 pixelShaderPos : TEXCOORD1;

      float3 normal  : NORMAL0;

};



#5 kubera   Members   -  Reputation: 758

Like
1Likes
Like

Posted 04 April 2013 - 02:06 PM

http://msdn.microsoft.com/en-us/library/windows/desktop/bb509647(v=vs.85).aspx#VPOS



#6 zonozz   Members   -  Reputation: 158

Like
0Likes
Like

Posted 04 April 2013 - 09:40 PM

Yo zonozz,

 

From what I can remember, it is illegal in HLSL to pass the Position semantic to the pixel shader, at least in DirectX 9. Try creating a VS_OUTPUT that has a TEXCOORD semantic in addition to the POSITION semantic. Then, in your vertex shader, write the value of the position to both of the semantics. Have your PS_INPUT semantic read the TEXCOORD but not the position.

 

Something like this:

 

struct VS_OUTPUT

{

      float4 position : POSITION0;

      float4 pixelShaderPos : TEXCOORD1;

      float3 normal  : NORMAL0;

};

 

struct PS_INPUT

{

      float4 pixelShaderPos : TEXCOORD1;

      float3 normal  : NORMAL0;

};

 

Thank you , I changed my code like your way, but I dont know this result is correct ? It looks odd ?

SSAO 3.jpg

 

Pixel shader code :

SSAO 4.jpg



#7 zonozz   Members   -  Reputation: 158

Like
0Likes
Like

Posted 04 April 2013 - 09:43 PM

http://msdn.microsoft.com/en-us/library/windows/desktop/bb509647(v=vs.85).aspx#VPOS

 

Thank you, I'll have a look



#8 phil_t   Crossbones+   -  Reputation: 2484

Like
0Likes
Like

Posted 04 April 2013 - 10:36 PM

I changed my code like your way, but I dont know this result is correct ? It looks odd ?

 

You're outputting the post-projection position, which should be in the range ([-1, 1], [-1, 1], [0, 1]). You're right, I wouldn't expect it to look quite like that.

 

What format is the render target you're using for position?

 

As for VPOS, that will work great if all you need is the (x, y) of the current pixel being rendered. If you also need the z, then it won't help you.



#9 zonozz   Members   -  Reputation: 158

Like
0Likes
Like

Posted 05 April 2013 - 12:51 AM

I changed my code like your way, but I dont know this result is correct ? It looks odd ?

 

You're outputting the post-projection position, which should be in the range ([-1, 1], [-1, 1], [0, 1]). You're right, I wouldn't expect it to look quite like that.

 

What format is the render target you're using for position?

 

As for VPOS, that will work great if all you need is the (x, y) of the current pixel being rendered. If you also need the z, then it won't help you.

 

I use A32B32G32R32F pixel format for all render targets.






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