Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

can 'SetTextureStageState' be used with pixel shader

4: Adsense

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

#1 tcige   Members   

206
Like
0Likes
Like

Posted 16 June 2013 - 09:35 AM

i test if using pixel shader, SetTextureStageState has no effect

 

so how to use the texture's alpha value in pixel shader, i can not find any instruction



#2 belfegor   Members   

2833
Like
1Likes
Like

Posted 16 June 2013 - 10:47 AM

I think that SetTextureStageState is FFP thing and it won't work with shaders.


...so how to use the texture's alpha value in pixel shader.

You must set some render states to enable alpha blending.

Look here for example.

 

To set alpha blending based on texture alpha channel you could do this:

device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);


#3 BornToCode   Members   

1185
Like
0Likes
Like

Posted 16 June 2013 - 10:51 AM

Like belfegor mention. In DirectX9 some of the render state still works while others no longer do anything once you use shaders.



#4 mhagain   Members   

13162
Like
0Likes
Like

Posted 16 June 2013 - 10:56 AM

Pixel shaders completely replace the old SetTextureStageState calls; see http://msdn.microsoft.com/en-us/library/windows/desktop/bb944006%28v=vs.85%29.aspx#Pixel_Shader_Basics

 

If you want to set a specific alpha value for use in a shader you either send it as a shader constant or pass it through from the vertex shader as a color attribute.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#5 tcige   Members   

206
Like
0Likes
Like

Posted 16 June 2013 - 11:02 AM

 

I think that SetTextureStageState is FFP thing and it won't work with shaders.

 


...so how to use the texture's alpha value in pixel shader.

You must set some render states to enable alpha blending.

Look here for example.

 

To set alpha blending based on texture alpha channel you could do this:

device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

 

 

i mean D3DTSS_ALPHAOP, how pixel shader gets texture's alpha



#6 tcige   Members   

206
Like
0Likes
Like

Posted 16 June 2013 - 11:04 AM

Pixel shaders completely replace the old SetTextureStageState calls; see http://msdn.microsoft.com/en-us/library/windows/desktop/bb944006%28v=vs.85%29.aspx#Pixel_Shader_Basics

 

If you want to set a specific alpha value for use in a shader you either send it as a shader constant or pass it through from the vertex shader as a color attribute.

 

i want to get the picture's alpha channel value



#7 belfegor   Members   

2833
Like
2Likes
Like

Posted 16 June 2013 - 11:39 AM

In pixel shader:

float4 textureColor = tex2D( samp, texCoord );
float alpha = textureColor.a; 



Edited by belfegor, 16 June 2013 - 11:44 AM.


#8 tcige   Members   

206
Like
1Likes
Like

Posted 16 June 2013 - 12:45 PM

 

In pixel shader:

float4 textureColor = tex2D( samp, texCoord );
float alpha = textureColor.a; 


 

yeah, pixel shader is so convenient






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.