Sign in to follow this  

Help how to use effect file

This topic is 4401 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 manage to draw a texture with alpha-value of vertex rather than that of texture pixel.My effect file as follow:
float4x4 g_mWorldViewProjection;	// World * View * Projection matrix

texture g_tDiffuse;

sampler PointSampler =
sampler_state
{
    Texture = <g_tDiffuse>;
    MinFilter = Point;
    MagFilter = Point;
};

sampler LinearSampler =
sampler_state
{
    Texture = <g_tDiffuse>;
    MinFilter = Linear;
    MagFilter = Linear;
};

sampler AnisotropicSampler =
sampler_state
{
    Texture = <g_tDiffuse>;
    MinFilter = Anisotropic;
    MagFilter = Anisotropic;
    
    MaxAnisotropy = 4;
};

//--------------------------------------------------------------------------------------
// Vertex shader
//--------------------------------------------------------------------------------------
struct VS_OUTPUT
{
    float4 Position : POSITION;
    float4 Diffuse : COLOR0;
    float2 TexCoords : TEXCOORD0;
};

VS_OUTPUT ColorVS( float3 Position : POSITION,
                   float4 Diffuse : COLOR0 )
{
    VS_OUTPUT Output;
    
    Output.Position = mul( float4(Position, 1), g_mWorldViewProjection );
    Output.Diffuse = Diffuse;
    Output.TexCoords = 0;
    
    return Output;
}

VS_OUTPUT TextureVS( float3 Position : POSITION,
float4 Diffuse : COLOR0,
                     float2 TexCoords : TEXCOORD0 )
{
    VS_OUTPUT Output;
    
    Output.Position = mul( float4(Position, 1), g_mWorldViewProjection );
    Output.Diffuse = Diffuse;
   // Output.Diffuse  = float4(1.0f, 1.0f, 1.0f, 0.5f);
    Output.TexCoords = TexCoords;
    
    return Output;
}


//--------------------------------------------------------------------------------------
// Color fill
//--------------------------------------------------------------------------------------
float4 ColorPS( float4 vDiffuse : COLOR0 ) : COLOR0
{
    return vDiffuse;
}


technique Color
{
    pass P0
    {
        CullMode = NONE;
        
        VertexShader = compile vs_1_1 ColorVS();
        PixelShader = compile ps_1_1 ColorPS();          
    }
}


//--------------------------------------------------------------------------------------
// Texture - Point sampled
//--------------------------------------------------------------------------------------
float4 TexturePointPS( float4 TexCoord : TEXCOORD0 ) : COLOR0
{
    return tex2D( PointSampler, TexCoord );
}


technique TexturePoint
{
    pass P0
    {
        CullMode = NONE;
        
        VertexShader = compile vs_1_1 TextureVS();
        PixelShader = compile ps_1_1 TexturePointPS();
    }
}


//--------------------------------------------------------------------------------------
// Texture - Point sampled (centroid)
//--------------------------------------------------------------------------------------
float4 TexturePointCentroidPS( float4 TexCoord : TEXCOORD0_centroid ) : COLOR0
{
    return tex2D( PointSampler, TexCoord );
}


technique TexturePointCentroid
{
    pass P0
    {
        CullMode = NONE;
        
        VertexShader = compile vs_2_0 TextureVS();
        PixelShader = compile ps_2_0 TexturePointCentroidPS();          
    }
}


//--------------------------------------------------------------------------------------
// Texture - Linear sampled
//--------------------------------------------------------------------------------------
float4 TextureLinearPS( float4 TexCoord : TEXCOORD0 ) : COLOR0
{
    return tex2D( LinearSampler, TexCoord );
}


technique TextureLinear
{
    pass P0
    {
        CullMode = NONE;
        
        VertexShader = compile vs_1_1 TextureVS();
        PixelShader = compile ps_1_1 TextureLinearPS();          
    }
}


//--------------------------------------------------------------------------------------
// Texture - Linear sampled (centroid)
//--------------------------------------------------------------------------------------
float4 TextureLinearCentroidPS( float4 TexCoord : TEXCOORD0_centroid ) : COLOR0
{
    return tex2D( LinearSampler, TexCoord );
}


technique TextureLinearCentroid
{
    pass P0
    {
        CullMode = NONE;
        
        VertexShader = compile vs_2_0 TextureVS();
        PixelShader = compile ps_2_0 TextureLinearCentroidPS();          
    }
}


//--------------------------------------------------------------------------------------
// Texture - Anisotropic sampled
//--------------------------------------------------------------------------------------
float4 TextureAnisotropicPS( float4 TexCoord : TEXCOORD0 ) : COLOR0
{
    return tex2D( AnisotropicSampler, TexCoord );
}


technique TextureAnisotropic
{
    pass P0
    {
        CullMode = NONE;
        
        VertexShader = compile vs_1_1 TextureVS();
        PixelShader = compile ps_1_1 TextureAnisotropicPS();          
    }
}


//--------------------------------------------------------------------------------------
// Texture - Anisotropic sampled (centroid)
//--------------------------------------------------------------------------------------
float4 TextureAnisotropicCentroidPS( float4 TexCoord : TEXCOORD0_centroid ) : COLOR0
{
    return tex2D( AnisotropicSampler, TexCoord );
}


technique TextureAnisotropicCentroid
{
    pass P0
    {
        CullMode = NONE;
        
        VertexShader = compile vs_2_0 TextureVS();
        PixelShader = compile ps_2_0 TextureAnisotropicCentroidPS();          
    }
}

Please help me; How to modify it. [Edited by - Muhammad Haggag on November 29, 2005 8:36:11 AM]

Share this post


Link to post
Share on other sites

Thats a lot of techniques, however in the pixel shader you get the pixel like this: float rgba = tex2D( PointSampler, TexCoord ).rgba;
now, set rgba.a = 0.5f. and return rgba, then if you enabled alpha blending, I guess you get the result you want ..


Share this post


Link to post
Share on other sites

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