I am using pixel shader to apply some effects to a material´s texture.
Now, I also need to make some blending stuff (addition and substractions) wich involves using a material like EMT_ONETEXTURE_BLEND, but if I use that material, I can´t use my shader
The question is:
Is there any way to:
Combine EMT_ONETEXTURE_BLEND with my Pixel shader material?
or
apply blending effects using only pixel shader?
thanks.
Blend and shaders
But, how do I get Color2 ?color=blend*color1+(1.0-blend)*color2
My shader is somethig like :
Code: Select all
"[... extern variables for color effects...] \
sampler2D tex0; \
\
float4 main( float2 texCoord : TEXCOORD0): COLOR0 \
{ \
float4 color = tex2D( tex0, texCoord.xy ); \
[...operations with variables, for color effects...] \
return color; \
}";
No, I´m trying to implement some 2D stuff, using 3D.
I´m using a shader to mix opacity control, color adding, and an effect called tone, wich is similar to color adding, but calculations are different and adds a Grey component to the texture.
Now, I need to set 3 blending options:
None: texture is shown "as is"
Additive : colors of the texture are added to colors of wathever is behind
Substractive: colors of wathever is behind are substracted by colors of the texture
You talk abuou color1 and color2.
In my case, color1 "are" color of every pixel in the texture, and color2 (wich I don´t kwnow how to get) is the color of pixels wish are behind of my texture.
I´m using a shader to mix opacity control, color adding, and an effect called tone, wich is similar to color adding, but calculations are different and adds a Grey component to the texture.
Now, I need to set 3 blending options:
None: texture is shown "as is"
Additive : colors of the texture are added to colors of wathever is behind
Substractive: colors of wathever is behind are substracted by colors of the texture
You talk abuou color1 and color2.
In my case, color1 "are" color of every pixel in the texture, and color2 (wich I don´t kwnow how to get) is the color of pixels wish are behind of my texture.
I think you would have to use rendertargets for that. Just render every image individual into the rtt and also use the rtt for a texture layer > 0. In glsl (I don't know if there's an equivalent in hlsl) you can use gl_FragCoord to get the screen coordinates of the current fragment/pixel. You can get the texture coordinates on the rtt by dividing the x and y components by the screen's width-1 and height-1. That means you can get color2 from the rtt at the coordinates (x/(width-1),y/(height-1)).