From fded195eff9a001fb0d875ef0e7923429bf0dd3f Mon Sep 17 00:00:00 2001 From: turanszkij Date: Sun, 7 Feb 2016 11:48:02 +0100 Subject: [PATCH] update --- WickedEngine/cubeShadowPS.hlsl | 4 ++-- WickedEngine/decalPS.hlsl | 2 +- WickedEngine/effectPS.hlsl | 2 +- WickedEngine/effectPS_blackout.hlsl | 17 +++++------------ WickedEngine/effectPS_forwardSimple.hlsl | 2 +- WickedEngine/effectPS_textureonly.hlsl | 19 +++++-------------- WickedEngine/effectPS_transparent.hlsl | 14 ++------------ WickedEngine/envMapPS.hlsl | 2 +- WickedEngine/globals.hlsli | 2 ++ WickedEngine/qGrassPS.hlsl | 2 +- WickedEngine/shadowPS.hlsl | 4 ++-- 11 files changed, 23 insertions(+), 47 deletions(-) diff --git a/WickedEngine/cubeShadowPS.hlsl b/WickedEngine/cubeShadowPS.hlsl index 2d426212a..c3efd5e4e 100644 --- a/WickedEngine/cubeShadowPS.hlsl +++ b/WickedEngine/cubeShadowPS.hlsl @@ -12,7 +12,7 @@ struct VertextoPixel float main(VertextoPixel PSIn) : SV_DEPTH { - [branch]if(g_xMat_hasTex) - clip( xTextureTex.Sample(sampler_linear_wrap,PSIn.tex).a<0.1?-1:1 ); + [branch]if (g_xMat_hasTex) + ALPHATEST(xTextureTex.Sample(sampler_linear_wrap,PSIn.tex).a); return distance(PSIn.pos3D.xyz,lightPos.xyz)/lightEnerdis.y; } \ No newline at end of file diff --git a/WickedEngine/decalPS.hlsl b/WickedEngine/decalPS.hlsl index 0b284bc4a..7b39c71a9 100644 --- a/WickedEngine/decalPS.hlsl +++ b/WickedEngine/decalPS.hlsl @@ -66,7 +66,7 @@ PixelOutputType main(VertexToPixel PSIn) edgeBlend = abs(edgeBlend); Out.col.a *= 1 - pow(max(max(edgeBlend.x, edgeBlend.y), edgeBlend.z), 8); //Out.col.a *= pow(saturate(-dot(normal,front)), 4); - clip( Out.col.a<0.05?-1:1 ); + ALPHATEST(Out.col.a) if(hasTexNor & 0x0000010) Out.nor.a=Out.col.a; } diff --git a/WickedEngine/effectPS.hlsl b/WickedEngine/effectPS.hlsl index b225b00bf..87641cb16 100644 --- a/WickedEngine/effectPS.hlsl +++ b/WickedEngine/effectPS.hlsl @@ -29,7 +29,7 @@ PixelOutputType main(PixelInputType PSIn) } baseColor.rgb *= PSIn.instanceColor; - clip( baseColor.a - 0.1f ); + ALPHATEST(baseColor.a) if(depth){ diff --git a/WickedEngine/effectPS_blackout.hlsl b/WickedEngine/effectPS_blackout.hlsl index aeaf9f229..f9c3d7a48 100644 --- a/WickedEngine/effectPS_blackout.hlsl +++ b/WickedEngine/effectPS_blackout.hlsl @@ -6,19 +6,12 @@ float4 main(PixelInputType PSIn) : SV_TARGET { float4 baseColor = float4(0,0,0,0); - //uint mat = PSIn.mat; - //if(mat == matIndex){ - if(g_xMat_hasTex) { - baseColor = xTextureTex.Sample(sampler_aniso_wrap,PSIn.tex); - /*else if(mat==1) baseColor = xTextureTex1.Sample(texSampler,PSIn.tex); - else if(mat==2) baseColor = xTextureTex2.Sample(texSampler,PSIn.tex); - else if(mat==3) baseColor = xTextureTex3.Sample(texSampler,PSIn.tex);*/ - } + if(g_xMat_hasTex) { + baseColor = xTextureTex.Sample(sampler_aniso_wrap,PSIn.tex); + } - clip( baseColor.a < 0.1f ? -1:1 ); - //} - //else discard; + ALPHATEST(baseColor.a) - return float4(baseColor.rgb*0,1); + return float4(0, 0, 0, 1); } \ No newline at end of file diff --git a/WickedEngine/effectPS_forwardSimple.hlsl b/WickedEngine/effectPS_forwardSimple.hlsl index 257e3ef4c..da666b924 100644 --- a/WickedEngine/effectPS_forwardSimple.hlsl +++ b/WickedEngine/effectPS_forwardSimple.hlsl @@ -24,7 +24,7 @@ float4 main(PixelInputType PSIn) : SV_TARGET } baseColor.rgb *= PSIn.instanceColor; - clip(baseColor.a < 0.1f ? -1 : 1); + ALPHATEST(baseColor.a) if (!g_xMat_shadeless.x) { diff --git a/WickedEngine/effectPS_textureonly.hlsl b/WickedEngine/effectPS_textureonly.hlsl index 7295e2848..fc5040894 100644 --- a/WickedEngine/effectPS_textureonly.hlsl +++ b/WickedEngine/effectPS_textureonly.hlsl @@ -12,22 +12,13 @@ float4 main(PixelInputType PSIn) : SV_TARGET PSIn.tex *= g_xMat_texMulAdd.xy; PSIn.tex += g_xMat_texMulAdd.zw; - //if(PSIn.mat==matIndex){ - if(g_xMat_hasTex) { - baseColor *= xTextureTex.Sample(sampler_aniso_wrap,PSIn.tex); - } - baseColor.rgb *= PSIn.instanceColor; - //baseColor=pow(baseColor,GAMMA); + if(g_xMat_hasTex) { + baseColor *= xTextureTex.Sample(sampler_aniso_wrap,PSIn.tex); + } + baseColor.rgb *= PSIn.instanceColor; - clip( baseColor.a < 0.1f ? -1:1 ); + ALPHATEST(baseColor.a) - //float light = saturate( dot(xSun,normalize(PSIn.nor)) ); - //if(toonshaded) toon(light); - //light=clamp(light,xAmbient,1); - //if(!shadeless.x) baseColor.rgb*=light*xSunColor; - //baseColor=pow(baseColor,INV_GAMMA); - //} - //else discard; return baseColor*(1 + g_xMat_emissive); } diff --git a/WickedEngine/effectPS_transparent.hlsl b/WickedEngine/effectPS_transparent.hlsl index 471074858..a068a6a50 100644 --- a/WickedEngine/effectPS_transparent.hlsl +++ b/WickedEngine/effectPS_transparent.hlsl @@ -19,11 +19,10 @@ float4 main( PixelInputType PSIn) : SV_TARGET [branch]if(g_xMat_hasTex){ baseColor *= xTextureTex.Sample(sampler_aniso_wrap, PSIn.tex); - //baseColor*=baseColor.a; } baseColor.rgb *= PSIn.instanceColor; - //baseColor.a=1; - clip( baseColor.a < 0.1f ? -1:1 ); + + ALPHATEST(baseColor.a) float3 eyevector = normalize(g_xCamera_CamPos - PSIn.pos3D); float2 screenPos; @@ -75,10 +74,6 @@ float4 main( PixelInputType PSIn) : SV_TARGET if(g_xMat_hasSpe && !g_xMat_shadeless){ spec = xTextureSpe.Sample(sampler_aniso_wrap, PSIn.tex); } - /*float3 reflectionVector = reflect(xSun, normal); - float specR = dot(normalize(reflectionVector), eyevector); - specR = pow(saturate(-specR), specular_power)*spec.w; - baseColor.rgb += saturate(xSunColor.rgb * specR);*/ [branch]if(!g_xMat_shadeless.x){ baseColor.rgb*=clamp( saturate( abs(dot(g_xWorld_SunDir.xyz,PSIn.nor)) * g_xWorld_SunColor.rgb ), g_xWorld_Ambient.rgb,1 ); applySpecular(baseColor, g_xWorld_SunColor, normal, eyevector, g_xWorld_SunDir.xyz, 1, g_xMat_specular_power, spec.w, 0); @@ -87,11 +82,6 @@ float4 main( PixelInputType PSIn) : SV_TARGET baseColor.rgb = pow(abs(baseColor.rgb*(1 + g_xMat_emissive)), INV_GAMMA); baseColor.rgb = applyFog(baseColor.rgb,getFog(getLinearDepth(depth/PSIn.pos2D.w))); - - //Out.col = saturate(baseColor); - //Out.nor = float4((normal),1); - //Out.spe = saturate(spec); - //Out.vel = float4(PSIn.vel*float3(-1,1,1),1); return baseColor; } \ No newline at end of file diff --git a/WickedEngine/envMapPS.hlsl b/WickedEngine/envMapPS.hlsl index e6e2f4ea0..19c332a1b 100644 --- a/WickedEngine/envMapPS.hlsl +++ b/WickedEngine/envMapPS.hlsl @@ -21,7 +21,7 @@ float4 main(PSIn input) : SV_TARGET //lighting = saturate(dot(input.nor.xyz, g_xDirLight_direction.xyz)); //baseColor.rgb *= lighting; - clip(baseColor.a < 0.1f ? -1 : 1); + ALPHATEST(baseColor.a) return baseColor*(1 + g_xMat_emissive); } \ No newline at end of file diff --git a/WickedEngine/globals.hlsli b/WickedEngine/globals.hlsli index 37e56170e..2c7783e8b 100644 --- a/WickedEngine/globals.hlsli +++ b/WickedEngine/globals.hlsli @@ -93,4 +93,6 @@ CBUFFER(APICB, CBSLOT_API) }; +#define ALPHATEST(x) clip((x)-0.1); + #endif // _SHADERDEF_CONSTANTBUFFERS_ \ No newline at end of file diff --git a/WickedEngine/qGrassPS.hlsl b/WickedEngine/qGrassPS.hlsl index adc572eb1..8544c530d 100644 --- a/WickedEngine/qGrassPS.hlsl +++ b/WickedEngine/qGrassPS.hlsl @@ -15,7 +15,7 @@ PS_OUT main(QGS_OUT PSIn) PS_OUT Out = (PS_OUT)0; float4 col = xTexture.Sample(sampler_linear_clamp,PSIn.tex); - clip( col.a < 0.1 ? -1:1 ); + ALPHATEST(col.a) Out.col = float4(col.rgb,1); Out.nor = float4(PSIn.nor,0); Out.vel = float4(vel,0,0); diff --git a/WickedEngine/shadowPS.hlsl b/WickedEngine/shadowPS.hlsl index fd61a03d3..0623f76aa 100644 --- a/WickedEngine/shadowPS.hlsl +++ b/WickedEngine/shadowPS.hlsl @@ -10,6 +10,6 @@ struct VertextoPixel void main(VertextoPixel PSIn) { - [branch]if(g_xMat_hasTex) - clip( xTextureTex.Sample(sampler_linear_wrap,PSIn.tex).a<0.1?-1:1 ); + [branch]if (g_xMat_hasTex) + ALPHATEST(xTextureTex.Sample(sampler_linear_wrap, PSIn.tex).a); } \ No newline at end of file