Sign in to follow this  

HLSL newbie: passing ps color output to next ps pass

This topic is 4857 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 started to look into the topic of pixel and vertex shaders. I am writing my first shader only using ps (1.1). I am calculating a new pixel value. Now in a new pass I'd like to continue my calculation based on the color value from the first pass. I couldn't find any examples which shows me clearly how to do this. Do i need to fill that color from pass1 into a struct? I though maybe it automatically gives me the color in the next pass if I declare: float ps_shader_pass2(float4 pixel : COLOR, .... but I am getting the compiler error X4530 - don't know if this is an error code from the engine or from the used 3rd party compiler (a dx error msg?). If somebody could post a simple example (in HLSL), that would be great. Thanks a lot Dom

Share this post


Link to post
Share on other sites
Either:

1. Set the previous pass's render target as a texture. Don't render to the same texture this pass (not valid to read and write a texture at the same time).

2. Setup your alpha blending to mix the two passes as necessary.

A sample of what alpha blending can do:
partially transparent layer (srcalpha, invsrcalpha)
additive (one, one)
scaledadditive (srcalpha, one)
modulate (destcolor, zero)
modulate2x (destcolor, srccolor)

Share this post


Link to post
Share on other sites

This topic is 4857 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this