Jump to content
  • Advertisement
Sign in to follow this  
theScore

DX11 What semantic(s) to use in order to rendre in multiple targets ?

This topic is 1941 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 !

I compile my pixel shader with the version : ps_5_0 as a parameter in the instruction :

if(FAILED(D3DX11CompileFromFileA("./Shaders/GBuffer.hlsl",NULL, NULL, "pixel_main", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, &blobPixelGBuffer, &errorBlob, NULL )))

 

But at the compilation, I get these errors if I put the semantics COLOR0, COLOR1, and COLOR2 or SV_Target0, SV_Target1, SV_Target2, 

both generates compilation errors.

 

The shader is here :

struct psIn
{
	float4 color		: COLOR0 ;
	float4 RTposition	: POSITION1 ;
	float2 texCoord		: TEXCOORD0 ;
	float3 normal		: NORMAL ;
	float4 posInLightSpace	 : TEXCOORD1 ;
};

struct psOut
{
	float4 color		: SV_Target ;
	float4 RTposition	: SV_Target1 ;
	float4 RTnormal		: SV_Target2 ;
};

SamplerState colorMap : register( s[0] ) ;
SamplerState specularMap : register( s[1] ) ;
SamplerState shadowMap  : register( s[2] );

cbuffer GBufferConstants
{
	bool texturedMesh ;
	bool isSpecular ;
	float epsilon ;
}
Texture2D texObj2D ;


float4 getColor(psIn IN)
{
   if(texturedMesh == true)
   {

	return texObj2D.Sample(colorMap, IN.texCoord) ;
   }
	else
	   return IN.color ;
}



/* pixel shader */
psOut pixel_main(psIn IN, psOut OUT )
{
    OUT.color = getColor(IN) ; ;
    OUT.RTposition = IN.RTposition ;
    OUT.RTnormal = float4(IN.normal, 1.0) ;
    return OUT ;
}

Do you have an idea ? I looked in the directx documantation and it seems that it is SV_Target but it don't work unsure.png

Share this post


Link to post
Share on other sites
Advertisement

In the future it would be helpful if you post the compilation errors, since it would help people to quickly figure out what's wrong with your code.

Your problem is that you're taking your "psOut" structure as an input parameter to your pixel shader, and SV_Target is an invalid input semantic for a pixel shader. Just remove it as a parameter, and declare it locally to your function:

 

 

psOut pixel_main(psIn IN)
{
    psOut OUT;
    OUT.color = getColor(IN) ; ;
    OUT.RTposition = IN.RTposition ;
    OUT.RTnormal = float4(IN.normal, 1.0) ;
    return OUT ;
}
Edited by MJP

Share this post


Link to post
Share on other sites

Thanks it works ! Alright, next time I put errors from compiler. smile.png

Edited by theScore

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!