Sign in to follow this  
BlueChip

help con pixel shade (blend)

Recommended Posts

Hi... after few years, I am come back, in order to finish my work... for first thing, I should learn PS and VS.... I have seen tutorials, threads, papers... but I'm lost :( I have done it..
// Pixel shader input structure
struct PS_INPUT
{
    float4 Position   	  : POSITION;
    float2 Texture1    	  : TEXCOORD0;
    float2 Texture2       : TEXCOORD1;
};


// Pixel shader output structure
struct PS_OUTPUT
{
    float4 Color   : COLOR0;
};


// Global variables
sampler2D Tex0;
sampler2D Alpha1;

// Name: Simple Pixel Shader
// Type: Pixel shader

PS_OUTPUT ps_main( in PS_INPUT In )
{
   PS_OUTPUT Out;                             //create an output pixel

   float4 textureA= tex2D(texture1, In.TextureAlpha); 
   float4 textureB= tex2D(texture2, In.Texture1); 
   


   Out.Color = ???? what ??;

   return(Out);

}
but how I must to do in order to get a mix among 1st and 2nd texture?? thanks to everyone!! bye ps:Do you want see the vertex shader? is useful in order to resolve the problem? [Edited by - BlueChip on June 5, 2007 6:07:09 AM]

Share this post


Link to post
Share on other sites
Where is "In.TextureAlpha" coming from? Your sampling coordinates and code don't seem to match up...

But the general answer to your problem is the lerp() intrinsic. You could implement it easily enough with straight arithmetic but it's generally better practice to use intrinsic functions where available [smile]

hth
Jack

Share this post


Link to post
Share on other sites
hi jollyjeffers :)

sorry for syntax errors... I've changed some variables name, in order to make more clear my code.... but I've missed some changes..

Now I'm trying to do many tests, to understand PS and VS...
but I can't understand what operations make...

for example... now I load 4 textures (2 texture and 2 alphamap)
[code]
struct PS_INPUT
{
float4 Position : POSITION;
float2 Texture0 : TEXCOORD0;
float2 TextureAlpha0 : TEXCOORD1;
float2 Texture1 : TEXCOORD2;
float2 TextureAlpha1 : TEXCOORD3;
};
/code]

I've tried many cases, and the more near to my goal is


PS_OUTPUT ps_main( in PS_INPUT In )
{
PS_OUTPUT Out; //create an output pixel

float4 texture1 = tex2D(Texture0, In.Texture0);
float4 texture2 = tex2D(Texture1, In.TextureAlpha0);
float4 texture3 = tex2D(Texture2, In.Texture1);
float4 texture4 = tex2D(Texture3, In.TextureAlpha1);

Out.Color = (texture1 * texture2)+(texture3 * texture4) ;

return(Out);
}


but is not pretty like version without Ps and Vs...
And (maybe) the frame rate is lower than before...

There is a place where I can learn what '*' does, what '+' does ecc ecc??

today or tomorrow, I'll bring some picture in order to explain better my problem...

Share this post


Link to post
Share on other sites

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