Sign in to follow this  

HLSL storing for the next step

This topic is 3295 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 am not sure to understand how shaders work. But I am in trouble to make a lot of effect. For exemple I have texture and I want that one becomes progressively blue. So I woud write something like that:

float4 texColor = texture.Sample(samLinear, psInput.Tex);
texture.Sample(samLinear, psInput.Tex).b += 0.1f;
return texColor;


Basicly my problem is to modify a texture and use at the next step the texture modified. I need it to do water effect, clouds effect and so... How can I do thiskind of effect? Any help will be apprecited, Thanks

Share this post


Link to post
Share on other sites
You cannot modify a texture you are reading from in a pixel shader. It seems that you are always adding a constant value to the texture pixel. In this case, you can upload a shader constant from your applicaiton. Your applicaiton can increase this constant over time. The code would look something like this.

// I assume you're using D3D10 due to your shader syntax...
// Main applicaiton init
D3DXVECTOR4 gColorIncrement(0.0f, 0.0f, 0.1f, 0.0f);
...
// During rendering.
gColorIncrement.b += 0.1f;
pEffectColorIncrementVariable->SetFloatVector( &g_ColorIncrement );
// Draw mesh...


//Shader
float4 colorIncrement;
float4 main( PS_INPUT psInput )
{
....
float4 texColor = texture.Sample(samLinear, psInput.Tex);
return texColor + colorIncrement;
}


neneboricua

Share this post


Link to post
Share on other sites
Thanks for your reply,

Ok so there are no way to modify a texture from a shader, so to implement water effect

I see two solutions:
1- I have to give waterTextureArray[width*heigh] to the shader and use it in function of the Tex coordinate.
2- Create a texture and fill it directly, this method will not use shader.

I really have the feeling to miss something with the shader, I did light and fog effects.
I didn't manage to do bump mapping because noise function does't seem working. A bit desapointed with shader.

Anyway, I think the 1- is a better metod, isn't it?

Vincent

Share this post


Link to post
Share on other sites

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