/* SHADER_DECL texture Tex0; texture Tex1 template; SHADER_DECL_END */ #define PRECISE_sRGB #include "Defs.fxh" sampler2D Tex0 : register(s0); sampler2D Tex1 : register(s1); sampler2D TexScreenCopy; // takie mieszanie flagami żeby nie robić znów shaderów *2 dla jednego przypadku #if defined(_ZTEST_HW) && !defined(_ZTEST) #undef _ZTEST_HW #define _ZTEST #define _ZTEST_PRECOMPUTED #endif #ifdef _ZTEST #include "Utils/FlareVisibility.fx" float4 ztest_point; #if !defined(_PS3) || defined(_ZTEST_PRECOMPUTED) #define ZTEST_IN_VS #endif #endif struct VSInput { float4 vPos : POSITION; float2 vTex0 : TEXCOORD0; float2 vTex1 : TEXCOORD1; float4 vColor : COLOR; }; struct VSOutput { float4 vHPos : POSITION; float2 vTex0 : TEXCOORD0; float2 vTex1 : TEXCOORD1; float4 vColor : COLOR; float2 vTexScreen : TEXCOORD2; }; VSOutput VShader(in VSInput IN) { VSOutput OUT; OUT.vHPos.x = 2 * (IN.vPos.x - 0.5); OUT.vHPos.y = -2 * (IN.vPos.y - 0.5); OUT.vHPos.z = 0; OUT.vHPos.w = 1; OUT.vTex0 = IN.vTex0; OUT.vTex1 = IN.vTex1; OUT.vColor = SwizzleColor(IN.vColor); OUT.vTexScreen = 0; #if defined(_ZTEST) #if defined(ZTEST_IN_VS) float occlusion = ComputeOcclusion(ztest_point.xy, ztest_point.z - 0.1); if(occlusion == 0) OUT.vHPos = -5; OUT.vColor.a *= occlusion; #endif #endif return OUT; } float4 linear_to_target_colorspace(float4 v) { #ifndef _FINAL_LINEAR return real_encode_sRGB(v); #else return v; #endif } float4 PShader(in VSOutput IN) : COLOR0 { #if defined(_ZTEST) && !defined(ZTEST_IN_VS) float occlusion = ComputeOcclusion(ztest_point.xy, ztest_point.z - 0.1); clip(occlusion); IN.vColor.a *= occlusion; #endif // tu jest linear // kolor będzie w sRGB // dla zgodności z *badziewnymi* platformami wszystko powinniśmy policzyć w sRGB // ale względem potęgowania mnożenie jest rozdzielne (tak to się mówi?) więc // możnaby tę transformację zrobić na wyniku // o ile kolor też dostarczą linear! #if !defined(_HW_SRGB) && !defined(_FINAL_LINEAR) // optymalizacja dla x360: wszystko liczymy w gamma-space float4 result = tex2D(Tex0, IN.vTex0); #ifdef _Tex1 result *= tex2D(Tex1, IN.vTex1); #endif #else float4 result = decode_sRGB(tex2D(Tex0, IN.vTex0)); #ifdef _Tex1 result *= decode_sRGB(tex2D(Tex1, IN.vTex1)); #endif result = linear_to_target_colorspace(result); #endif result *= IN.vColor; // vColor dostarczony jest w sRGB return result; } DEVTEST_TECH(__t0, VShader, PShader)