Jump to content
  • Advertisement
Sign in to follow this  

a question about pixel shader

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

I have a question about post processing. How can I get the one pixel left of my original position in the rendered texture. all position values are between 0.0 and 1.0. for example if the current pixel is 0.5, 0.5 what is the x, y values for the pixel on the right? I am expecting it should be 0.5 + 1/1280.0, 0.5 but it seems a bit wrong to me when I test it. (my window's width is 1280 btw) maybe I should 1279.0 ? because there are 1280 pixel, there are 0-1279 pixels and 0=0.0 1279=1.0 so interval is 1/1279.0 right ? Which one is true? And more importantly can I get these values as integer? Or is there a better solution to this?

Share this post

Link to post
Share on other sites
never mind guys, I will just go for 1/1279.0

I have a bigger problem now =D

I am using a pixel shader, I tried to add a stencil test but it does not work. is stencil test disabled while using a pixel shader?

I want to do something similar glow effect in this ss

So I managed to create glow effect in a texture, here is what I should next

*draw the real object, while drawing it shouldn't use stencil test but set to pixels in 0x01 while drawing object

*draw the glow effect if stencil value is 0

here is my code


D3DDevice->SetRenderState( D3DRS_STENCILREF, 0x01 );

D3DDevice->SetRenderState( D3DRS_STENCILMASK, 0xFF );
D3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK,0xFF );

D3DDevice->Clear( 0, NULL, D3DCLEAR_STENCIL, D3DCOLOR_XRGB(0, 0, 0), 0.0f, 0);

effect->Begin(0, 0);

D3DDevice->SetRenderState(D3DRS_STENCILREF, 0x01);

RefractionEffect->SetTechnique( "Test");
RefractionEffect->SetTexture("ColorTex", TempTexture2);
RefractionEffect->Begin(0, 0);

QuadMesh contains the glow affect. I think this should work, but it does not :/ Here is my result.

I think problem is stencil is disable because I am using shaders. What are the equivalents for D3DRS_STENCILREF, D3DRS_STENCILFUNC... etc in HLSL?

Share this post

Link to post
Share on other sites
ok,it seems that equivalents are D3DRS_STENCILFUNC = STENCILFUNC etc

but I still have same problem :/

I add this to my technique


this shader should never draw the glow right? but it still does :S what is the problem?

Share this post

Link to post
Share on other sites
never mind guys, I forgot to change this line

d3dpp.AutoDepthStencilFormat = D3DFMT_D24X8;

of course stencil test does not work if there are no stencil buffer at all:/

pardon my stupidity

cool eh? =D

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!