Jump to content

help shaders plis :(


Recommended Posts

as it could change the alpha of a shader

so that does not leave very dark image ? :(

/* 
    Author: 50p 
    Version: v1.0 
    Description: 
     This shader allows you to mask a texture with a mask texture (black and white). 
*/ 
  
  
texture ScreenTexture; 
sampler implicitInputTexture = sampler_state 
{ 
    Texture = ; 
}; 
  
texture MaskTexture; 
sampler implicitMaskTexture = sampler_state 
{ 
    Texture = ; 
}; 
  
  
float4 MaskTextureMain( float2 uv : TEXCOORD0 ) : COLOR0 
{ 
    
    float4 sampledTexture = tex2D( implicitInputTexture, uv ); 
    float4 maskSampled = tex2D( implicitMaskTexture, uv ); 
    sampledTexture.a = (maskSampled.r + maskSampled.g + maskSampled.b) / 3.0f; 
    return sampledTexture; 
} 
  
technique Technique1 
{ 
    pass Pass1 
    { 
        AlphaBlendEnable = true; 
        SrcBlend = SrcAlpha; 
        DestBlend = InvSrcAlpha; 
        PixelShader = compile ps_2_0 MaskTextureMain(); 
    } 
} 

Link to comment

If i understood correctly - you want to change the alpha of the ScreenTexture. You might edit the MaskTexture, or you can setShaderValue( myShader, "gAlphaMult", alphaValue) -- ( 0 - 1). Are you using 50p's mask class ? Or just this shader ?

/* 
    Author: 50p 
    Version: v1.0 
    Description: 
     This shader allows you to mask a texture with a mask texture (black and white). 
*/ 
  
float gAlphaMult = 1; 
  
texture ScreenTexture; 
sampler implicitInputTexture = sampler_state 
{ 
    Texture = ; 
}; 
  
texture MaskTexture; 
sampler implicitMaskTexture = sampler_state 
{ 
    Texture = ; 
}; 
  
  
float4 MaskTextureMain( float2 uv : TEXCOORD0 ) : COLOR0 
{ 
    
    float4 sampledTexture = tex2D( implicitInputTexture, uv ); 
    float4 maskSampled = tex2D( implicitMaskTexture, uv ); 
    sampledTexture.a = (maskSampled.r + maskSampled.g + maskSampled.b) / 3.0f; 
    sampledTexture.a *= gAlphaMult; 
    return sampledTexture; 
} 
  
technique Technique1 
{ 
    pass Pass1 
    { 
        AlphaBlendEnable = true; 
        SrcBlend = SrcAlpha; 
        DestBlend = InvSrcAlpha; 
        PixelShader = compile ps_2_0 MaskTextureMain(); 
    } 
} 

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...