Sign in to follow this  
nef123

transparency artefacts (hlsl)

Recommended Posts

Hello, i think its something simple and pretty common but i cant figure out what to change to fix it. http://img19.imageshack.us/img19/1517/26268022.png As you can see on the left, its an image that when connected with others should make something like on the right. The problem is, i get a blue border (barely visible in single image, but quite annoying when joined together). Im pretty sure i know why. In graphics program its just 100% alpha, and green image in the middle. But hlsl smoothens some colors, and this little pixel on the border of transparent background and green image is also smoothed and becomes bluish (apparently the alpha color is actually 100% alpha and some of blue, which is not visilbe). Also i get an artifact on the top of this image. This one i dont understand as i have set AdressU and AdressV to clamp, but it apepars as its in wrap mode, and wraps a bit of green/blue part of the image from bottom to top. (to see this you need to look carefully on top of the left part of that image, and perhaps adjust contrast of your monitor - but its there) How can i get rid of this? Here are my hlsl codes (well, part of, as there are other parts, but not to make in too unclear, i hope this should be enough): technique Render2D { pass P0 { VertexShader = compile vs_2_0 VShade2D(); PixelShader = compile ps_2_0 PShadeFullBright(); ZEnable = True; ZwriteEnable = True; CullMode = CCW; AlphaTestEnable = false; FillMode = Solid; AlphaBlendEnable = true; SrcBlend = SrcAlpha; DestBlend = INVSRCALPHA; } } VS_OUTPUT VShade2D(VS_INPUT In) { VS_OUTPUT Out = (VS_OUTPUT) 0; Out.Pos.x=In.Pos.x/scr_width - 1.0f; Out.Pos.y=In.Pos.y/scr_height - 1.0f; Out.Pos.z=dist; Out.Pos.w=1; Out.Light=normalize(vecLightDir); Out.Norm = normalize(mul(In.Normal, matWorld)); float3 PosWorld = normalize(mul(In.Pos, matWorld)); Out.View = PosWorld; Out.Tex0.xy = In.Tex0.xy; return Out; } PS_OUTPUT PShadeFullBright(PS_INPUT In) { PS_OUTPUT Out = (PS_OUTPUT) 0; float4 texFragment = tex2D( Sampler1, In.Tex0); Out.Color = texFragment; return Out; } uniform sampler2D Sampler1 = sampler_state { Texture = <tDif>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = Clamp; AddressV = Clamp; }; thanks. EDIT: I tried changing MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; all to "None;" in hopes of not mixing colors. But as a result i had an ugly unsmothed picture, which still seems to have some artefacts, but less visible. Anyways, i would like to have smooth picture, but no bluish thingies. [Edited by - nef123 on March 14, 2009 5:52:03 AM]

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