Jump to content
  • Advertisement
Sign in to follow this  

About HLSL's Semantic

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

 

[attachment=14649:SSAO 1.jpg]

 

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

[attachment=14650:SSAO 2.jpg]

Edited by zonozz

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites

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?).

Share this post


Link to post
Share on other sites

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;

};

Share this post


Link to post
Share on other sites

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 ?

[attachment=14662:SSAO 3.jpg]

 

Pixel shader code :

[attachment=14663:SSAO 4.jpg]

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!