void WriteI4Encoder(char* p) { WriteSwizzler(p, GX_TF_I4); WRITE(p, " float3 texSample;\n"); WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); WriteSampleColor(p, "rgb", "texSample", 0); WriteColorToIntensity(p, "texSample", "color0.b"); WriteSampleColor(p, "rgb", "texSample", 1); WriteColorToIntensity(p, "texSample", "color1.b"); WriteSampleColor(p, "rgb", "texSample", 2); WriteColorToIntensity(p, "texSample", "color0.g"); WriteSampleColor(p, "rgb", "texSample", 3); WriteColorToIntensity(p, "texSample", "color1.g"); WriteSampleColor(p, "rgb", "texSample", 4); WriteColorToIntensity(p, "texSample", "color0.r"); WriteSampleColor(p, "rgb", "texSample", 5); WriteColorToIntensity(p, "texSample", "color1.r"); WriteSampleColor(p, "rgb", "texSample", 6); WriteColorToIntensity(p, "texSample", "color0.a"); WriteSampleColor(p, "rgb", "texSample", 7); WriteColorToIntensity(p, "texSample", "color1.a"); WRITE(p, " color0.rgba += IntensityConst.aaaa;\n"); WRITE(p, " color1.rgba += IntensityConst.aaaa;\n"); WriteToBitDepth(p, 4, "color0", "color0"); WriteToBitDepth(p, 4, "color1", "color1"); WRITE(p, " ocol0 = (color0 * 16.0f + color1) / 255.0f;\n"); WriteEncoderEnd(p); }
static void WriteI4Encoder(char*& p, API_TYPE ApiType) { WriteSwizzler(p, GX_TF_I4, ApiType); WRITE(p, " float3 texSample;\n"); WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); WriteSampleColor(p, "rgb", "texSample", 0, ApiType); WriteColorToIntensity(p, "texSample", "color0.b"); WriteSampleColor(p, "rgb", "texSample", 1, ApiType); WriteColorToIntensity(p, "texSample", "color1.b"); WriteSampleColor(p, "rgb", "texSample", 2, ApiType); WriteColorToIntensity(p, "texSample", "color0.g"); WriteSampleColor(p, "rgb", "texSample", 3, ApiType); WriteColorToIntensity(p, "texSample", "color1.g"); WriteSampleColor(p, "rgb", "texSample", 4, ApiType); WriteColorToIntensity(p, "texSample", "color0.r"); WriteSampleColor(p, "rgb", "texSample", 5, ApiType); WriteColorToIntensity(p, "texSample", "color1.r"); WriteSampleColor(p, "rgb", "texSample", 6, ApiType); WriteColorToIntensity(p, "texSample", "color0.a"); WriteSampleColor(p, "rgb", "texSample", 7, ApiType); WriteColorToIntensity(p, "texSample", "color1.a"); WRITE(p, " color0.rgba += IntensityConst.aaaa;\n"); WRITE(p, " color1.rgba += IntensityConst.aaaa;\n"); WriteToBitDepth(p, 4, "color0", "color0"); WriteToBitDepth(p, 4, "color1", "color1"); WRITE(p, " ocol0 = (color0 * 16.0 + color1) / 255.0;\n"); WriteEncoderEnd(p); }
static void WriteI4Encoder(char*& p, APIType ApiType, const EFBCopyParams& params) { WriteSwizzler(p, params, EFBCopyFormat::R4, ApiType); WRITE(p, " float3 texSample;\n"); WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); WriteSampleColor(p, "rgb", "texSample", 0, ApiType, params); WriteColorToIntensity(p, "texSample", "color0.b"); WriteSampleColor(p, "rgb", "texSample", 1, ApiType, params); WriteColorToIntensity(p, "texSample", "color1.b"); WriteSampleColor(p, "rgb", "texSample", 2, ApiType, params); WriteColorToIntensity(p, "texSample", "color0.g"); WriteSampleColor(p, "rgb", "texSample", 3, ApiType, params); WriteColorToIntensity(p, "texSample", "color1.g"); WriteSampleColor(p, "rgb", "texSample", 4, ApiType, params); WriteColorToIntensity(p, "texSample", "color0.r"); WriteSampleColor(p, "rgb", "texSample", 5, ApiType, params); WriteColorToIntensity(p, "texSample", "color1.r"); WriteSampleColor(p, "rgb", "texSample", 6, ApiType, params); WriteColorToIntensity(p, "texSample", "color0.a"); WriteSampleColor(p, "rgb", "texSample", 7, ApiType, params); WriteColorToIntensity(p, "texSample", "color1.a"); WRITE(p, " color0.rgba += IntensityConst.aaaa;\n"); WRITE(p, " color1.rgba += IntensityConst.aaaa;\n"); WriteToBitDepth(p, 4, "color0", "color0"); WriteToBitDepth(p, 4, "color1", "color1"); WRITE(p, " ocol0 = (color0 * 16.0 + color1) / 255.0;\n"); WriteEncoderEnd(p); }
static void WriteZ24Encoder(char*& p, APIType ApiType, const EFBCopyParams& params) { WriteSwizzler(p, EFBCopyFormat::RGBA8, ApiType); WRITE(p, " float depth0;\n"); WRITE(p, " float depth1;\n"); WRITE(p, " float3 expanded0;\n"); WRITE(p, " float3 expanded1;\n"); WriteSampleColor(p, "r", "depth0", 0, ApiType, params); WriteSampleColor(p, "r", "depth1", 1, ApiType, params); for (int i = 0; i < 2; i++) { WRITE(p, " depth%i *= 16777216.0;\n", i); WRITE(p, " expanded%i.r = floor(depth%i / (256.0 * 256.0));\n", i, i); WRITE(p, " depth%i -= expanded%i.r * 256.0 * 256.0;\n", i, i); WRITE(p, " expanded%i.g = floor(depth%i / 256.0);\n", i, i); WRITE(p, " depth%i -= expanded%i.g * 256.0;\n", i, i); WRITE(p, " expanded%i.b = depth%i;\n", i, i); } WRITE(p, " if (!first) {\n"); // upper 16 WRITE(p, " ocol0.b = expanded0.g / 255.0;\n"); WRITE(p, " ocol0.g = expanded0.b / 255.0;\n"); WRITE(p, " ocol0.r = expanded1.g / 255.0;\n"); WRITE(p, " ocol0.a = expanded1.b / 255.0;\n"); WRITE(p, " } else {\n"); // lower 8 WRITE(p, " ocol0.b = 1.0;\n"); WRITE(p, " ocol0.g = expanded0.r / 255.0;\n"); WRITE(p, " ocol0.r = 1.0;\n"); WRITE(p, " ocol0.a = expanded1.r / 255.0;\n"); WRITE(p, " }\n"); WriteEncoderEnd(p); }
static void WriteZ24Encoder(char*& p, API_TYPE ApiType) { WriteSwizzler(p, GX_TF_Z24X8, ApiType); WRITE(p, " float depth0;\n"); WRITE(p, " float depth1;\n"); WRITE(p, " float3 expanded0;\n"); WRITE(p, " float3 expanded1;\n"); WriteSampleColor(p, "b", "depth0", 0, ApiType); WriteSampleColor(p, "b", "depth1", 1, ApiType); for (int i = 0; i < 2; i++) { WRITE(p, " depth%i *= 16777215.0;\n", i); WRITE(p, " expanded%i.r = floor(depth%i / (256.0 * 256.0));\n", i, i); WRITE(p, " depth%i -= expanded%i.r * 256.0 * 256.0;\n", i, i); WRITE(p, " expanded%i.g = floor(depth%i / 256.0);\n", i, i); WRITE(p, " depth%i -= expanded%i.g * 256.0;\n", i, i); WRITE(p, " expanded%i.b = depth%i;\n", i, i); } WRITE(p, " if (!first) {\n"); // upper 16 WRITE(p, " ocol0.b = expanded0.g / 255.0;\n"); WRITE(p, " ocol0.g = expanded0.b / 255.0;\n"); WRITE(p, " ocol0.r = expanded1.g / 255.0;\n"); WRITE(p, " ocol0.a = expanded1.b / 255.0;\n"); WRITE(p, " } else {\n"); // lower 8 WRITE(p, " ocol0.b = 1.0;\n"); WRITE(p, " ocol0.g = expanded0.r / 255.0;\n"); WRITE(p, " ocol0.r = 1.0;\n"); WRITE(p, " ocol0.a = expanded1.r / 255.0;\n"); WRITE(p, " }\n"); WriteEncoderEnd(p, ApiType); }
static void WriteRGB565Encoder(char*& p,API_TYPE ApiType) { WriteSwizzler(p, GX_TF_RGB565, ApiType); WriteSampleColor(p, "rgb", "float3 texSample0", 0, ApiType); WriteSampleColor(p, "rgb", "float3 texSample1", 1, ApiType); WRITE(p, " float2 texRs = float2(texSample0.r, texSample1.r);\n"); WRITE(p, " float2 texGs = float2(texSample0.g, texSample1.g);\n"); WRITE(p, " float2 texBs = float2(texSample0.b, texSample1.b);\n"); WriteToBitDepth(p, 6, "texGs", "float2 gInt"); WRITE(p, " float2 gUpper = floor(gInt / 8.0);\n"); WRITE(p, " float2 gLower = gInt - gUpper * 8.0;\n"); WriteToBitDepth(p, 5, "texRs", "ocol0.br"); WRITE(p, " ocol0.br = ocol0.br * 8.0 + gUpper;\n"); WriteToBitDepth(p, 5, "texBs", "ocol0.ga"); WRITE(p, " ocol0.ga = ocol0.ga + gLower * 32.0;\n"); WRITE(p, " ocol0 = ocol0 / 255.0;\n"); WriteEncoderEnd(p, ApiType); }
void WriteRGBA4443Encoder(char* p,API_TYPE ApiType) { WriteSwizzler(p, GX_TF_RGB5A3, ApiType); WRITE(p, " float4 texSample;\n"); WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); WriteSampleColor(p, "rgba", "texSample", 0, ApiType); WriteToBitDepth(p, 3, "texSample.a", "color0.b"); WriteToBitDepth(p, 4, "texSample.r", "color1.b"); WriteToBitDepth(p, 4, "texSample.g", "color0.g"); WriteToBitDepth(p, 4, "texSample.b", "color1.g"); WriteSampleColor(p, "rgba", "texSample", 1, ApiType); WriteToBitDepth(p, 3, "texSample.a", "color0.r"); WriteToBitDepth(p, 4, "texSample.r", "color1.r"); WriteToBitDepth(p, 4, "texSample.g", "color0.a"); WriteToBitDepth(p, 4, "texSample.b", "color1.a"); WRITE(p, " ocol0 = (color0 * 16.0 + color1) / 255.0;\n"); WriteEncoderEnd(p, ApiType); }
void WriteZ8Encoder(char* p, const char* multiplier,API_TYPE ApiType) { WriteSwizzler(p, GX_CTF_Z8M,ApiType); WRITE(p, " float depth;\n"); WriteSampleColor(p, "b", "depth",ApiType); WRITE(p, "ocol0.b = frac(depth * %s);\n", multiplier); WriteIncrementSampleX(p,ApiType); WriteSampleColor(p, "b", "depth",ApiType); WRITE(p, "ocol0.g = frac(depth * %s);\n", multiplier); WriteIncrementSampleX(p,ApiType); WriteSampleColor(p, "b", "depth",ApiType); WRITE(p, "ocol0.r = frac(depth * %s);\n", multiplier); WriteIncrementSampleX(p,ApiType); WriteSampleColor(p, "b", "depth",ApiType); WRITE(p, "ocol0.a = frac(depth * %s);\n", multiplier); WriteEncoderEnd(p); }
static void WriteZ16LEncoder(char*& p,API_TYPE ApiType) { WriteSwizzler(p, GX_CTF_Z16L, ApiType); WRITE(p, " float depth;\n"); WRITE(p, " float3 expanded;\n"); // byte order is reversed WriteSampleColor(p, "r", "depth", 0, ApiType); if (ApiType == API_D3D) WRITE(p, "depth = 1.0f - depth;\n"); WRITE(p, " depth *= 16777216.0;\n"); WRITE(p, " expanded.r = floor(depth / (256.0 * 256.0));\n"); WRITE(p, " depth -= expanded.r * 256.0 * 256.0;\n"); WRITE(p, " expanded.g = floor(depth / 256.0);\n"); WRITE(p, " depth -= expanded.g * 256.0;\n"); WRITE(p, " expanded.b = depth;\n"); WRITE(p, " ocol0.b = expanded.b / 255.0;\n"); WRITE(p, " ocol0.g = expanded.g / 255.0;\n"); WriteSampleColor(p, "r", "depth", 1, ApiType); if (ApiType == API_D3D) WRITE(p, "depth = 1.0f - depth;\n"); WRITE(p, " depth *= 16777216.0;\n"); WRITE(p, " expanded.r = floor(depth / (256.0 * 256.0));\n"); WRITE(p, " depth -= expanded.r * 256.0 * 256.0;\n"); WRITE(p, " expanded.g = floor(depth / 256.0);\n"); WRITE(p, " depth -= expanded.g * 256.0;\n"); WRITE(p, " expanded.b = depth;\n"); WRITE(p, " ocol0.r = expanded.b / 255.0;\n"); WRITE(p, " ocol0.a = expanded.g / 255.0;\n"); WriteEncoderEnd(p); }
void WriteZ16LEncoder(char* p,API_TYPE ApiType) { WriteSwizzler(p, GX_CTF_Z16L,ApiType); WRITE(p, " float depth;\n"); WRITE(p, " float3 expanded;\n"); // byte order is reversed WriteSampleColor(p, "b", "depth",ApiType); WRITE(p, " depth *= 16777215.0f;\n"); WRITE(p, " expanded.r = floor(depth / (256 * 256));\n"); WRITE(p, " depth -= expanded.r * 256 * 256;\n"); WRITE(p, " expanded.g = floor(depth / 256);\n"); WRITE(p, " depth -= expanded.g * 256;\n"); WRITE(p, " expanded.b = depth;\n"); WRITE(p, " ocol0.b = expanded.b / 255;\n"); WRITE(p, " ocol0.g = expanded.g / 255;\n"); WriteIncrementSampleX(p,ApiType); WriteSampleColor(p, "b", "depth",ApiType); WRITE(p, " depth *= 16777215.0f;\n"); WRITE(p, " expanded.r = floor(depth / (256 * 256));\n"); WRITE(p, " depth -= expanded.r * 256 * 256;\n"); WRITE(p, " expanded.g = floor(depth / 256);\n"); WRITE(p, " depth -= expanded.g * 256;\n"); WRITE(p, " expanded.b = depth;\n"); WRITE(p, " ocol0.r = expanded.b;\n"); WRITE(p, " ocol0.a = expanded.g;\n"); WriteEncoderEnd(p); }
static void WriteRGBA8Encoder(char*& p,API_TYPE ApiType) { WriteSwizzler(p, GX_TF_RGBA8, ApiType); WRITE(p, " float4 texSample;\n"); WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); WriteSampleColor(p, "rgba", "texSample", 0, ApiType); WRITE(p, " color0.b = texSample.a;\n"); WRITE(p, " color0.g = texSample.r;\n"); WRITE(p, " color1.b = texSample.g;\n"); WRITE(p, " color1.g = texSample.b;\n"); WriteSampleColor(p, "rgba", "texSample", 1, ApiType); WRITE(p, " color0.r = texSample.a;\n"); WRITE(p, " color0.a = texSample.r;\n"); WRITE(p, " color1.r = texSample.g;\n"); WRITE(p, " color1.a = texSample.b;\n"); WRITE(p, " ocol0 = first ? color0 : color1;\n"); WriteEncoderEnd(p, ApiType); }
void WriteI8Encoder(char* p, API_TYPE ApiType) { WriteSwizzler(p, GX_TF_I8,ApiType); WRITE(p, " float3 texSample;\n"); WriteSampleColor(p, "rgb", "texSample",ApiType); WriteColorToIntensity(p, "texSample", "ocol0.b"); WriteIncrementSampleX(p,ApiType); WriteSampleColor(p, "rgb", "texSample",ApiType); WriteColorToIntensity(p, "texSample", "ocol0.g"); WriteIncrementSampleX(p,ApiType); WriteSampleColor(p, "rgb", "texSample",ApiType); WriteColorToIntensity(p, "texSample", "ocol0.r"); WriteIncrementSampleX(p,ApiType); WriteSampleColor(p, "rgb", "texSample",ApiType); WriteColorToIntensity(p, "texSample", "ocol0.a"); WRITE(p, " ocol0.rgba += IntensityConst.aaaa;\n"); // see WriteColorToIntensity WriteEncoderEnd(p); }
void WriteRGB565Encoder(char* p,API_TYPE ApiType) { WriteSwizzler(p, GX_TF_RGB565,ApiType); WriteSampleColor(p, "rgb", "float3 texSample0",ApiType); WriteIncrementSampleX(p,ApiType); WriteSampleColor(p, "rgb", "float3 texSample1",ApiType); WRITE(p, " float2 texRs = {texSample0.r, texSample1.r};\n"); WRITE(p, " float2 texGs = {texSample0.g, texSample1.g};\n"); WRITE(p, " float2 texBs = {texSample0.b, texSample1.b};\n"); WriteToBitDepth(p, 6, "texGs", "float2 gInt"); WRITE(p, " float2 gUpper = floor(gInt / 8.0f);\n"); WRITE(p, " float2 gLower = gInt - gUpper * 8.0f;\n"); WriteToBitDepth(p, 5, "texRs", "ocol0.br"); WRITE(p, " ocol0.br = ocol0.br * 8.0f + gUpper;\n"); WriteToBitDepth(p, 5, "texBs", "ocol0.ga"); WRITE(p, " ocol0.ga = ocol0.ga + gLower * 32.0f;\n"); WRITE(p, " ocol0 = ocol0 / 255.0f;\n"); WriteEncoderEnd(p); }
static void WriteRGB565Encoder(char*& p, APIType ApiType, const EFBCopyParams& params) { WriteSwizzler(p, params, EFBCopyFormat::RGB565, ApiType); WRITE(p, " float3 texSample0;\n"); WRITE(p, " float3 texSample1;\n"); WriteSampleColor(p, "rgb", "texSample0", 0, ApiType, params); WriteSampleColor(p, "rgb", "texSample1", 1, ApiType, params); WRITE(p, " float2 texRs = float2(texSample0.r, texSample1.r);\n"); WRITE(p, " float2 texGs = float2(texSample0.g, texSample1.g);\n"); WRITE(p, " float2 texBs = float2(texSample0.b, texSample1.b);\n"); WriteToBitDepth(p, 6, "texGs", "float2 gInt"); WRITE(p, " float2 gUpper = floor(gInt / 8.0);\n"); WRITE(p, " float2 gLower = gInt - gUpper * 8.0;\n"); WriteToBitDepth(p, 5, "texRs", "ocol0.br"); WRITE(p, " ocol0.br = ocol0.br * 8.0 + gUpper;\n"); WriteToBitDepth(p, 5, "texBs", "ocol0.ga"); WRITE(p, " ocol0.ga = ocol0.ga + gLower * 32.0;\n"); WRITE(p, " ocol0 = ocol0 / 255.0;\n"); WriteEncoderEnd(p); }
static void WriteZ8Encoder(char*& p, const char* multiplier,API_TYPE ApiType) { WriteSwizzler(p, GX_CTF_Z8M, ApiType); WRITE(p, " float depth;\n"); WriteSampleColor(p, "r", "depth", 0, ApiType); if (ApiType == API_D3D) WRITE(p, "depth = 1.0f - depth;\n"); WRITE(p, "ocol0.b = frac(depth * %s);\n", multiplier); WriteSampleColor(p, "r", "depth", 1, ApiType); if (ApiType == API_D3D) WRITE(p, "depth = 1.0f - depth;\n"); WRITE(p, "ocol0.g = frac(depth * %s);\n", multiplier); WriteSampleColor(p, "r", "depth", 2, ApiType); if (ApiType == API_D3D) WRITE(p, "depth = 1.0f - depth;\n"); WRITE(p, "ocol0.r = frac(depth * %s);\n", multiplier); WriteSampleColor(p, "r", "depth", 3, ApiType); if (ApiType == API_D3D) WRITE(p, "depth = 1.0f - depth;\n"); WRITE(p, "ocol0.a = frac(depth * %s);\n", multiplier); WriteEncoderEnd(p); }
static void WriteXFBEncoder(char*& p, APIType ApiType, const EFBCopyParams& params) { WriteSwizzler(p, params, EFBCopyFormat::XFB, ApiType); WRITE(p, "float3 color0, color1;\n"); WriteSampleColor(p, "rgb", "color0", 0, ApiType, params); WriteSampleColor(p, "rgb", "color1", 1, ApiType, params); // Gamma is only applied to XFB copies. WRITE(p, " color0 = pow(color0, float3(gamma_rcp, gamma_rcp, gamma_rcp));\n"); WRITE(p, " color1 = pow(color1, float3(gamma_rcp, gamma_rcp, gamma_rcp));\n"); // Convert to YUV. WRITE(p, " const float3 y_const = float3(0.257, 0.504, 0.098);\n"); WRITE(p, " const float3 u_const = float3(-0.148, -0.291, 0.439);\n"); WRITE(p, " const float3 v_const = float3(0.439, -0.368, -0.071);\n"); WRITE(p, " float3 average = (color0 + color1) * 0.5;\n"); WRITE(p, " ocol0.b = dot(color0, y_const) + 0.0625;\n"); WRITE(p, " ocol0.g = dot(average, u_const) + 0.5;\n"); WRITE(p, " ocol0.r = dot(color1, y_const) + 0.0625;\n"); WRITE(p, " ocol0.a = dot(average, v_const) + 0.5;\n"); WriteEncoderEnd(p); }
void WriteZ8Encoder(char* p, const char* multiplier) { WriteSwizzler(p, GX_CTF_Z8M); WRITE(p, " float depth;\n"); WriteSampleColor(p, "b", "depth", 0); WRITE(p, " depth = 1.0f - depth;\n"); WRITE(p, "ocol0.b = frac(depth * %s);\n", multiplier); WriteSampleColor(p, "b", "depth", 1); WRITE(p, " depth = 1.0f - depth;\n"); WRITE(p, "ocol0.g = frac(depth * %s);\n", multiplier); WriteSampleColor(p, "b", "depth", 2); WRITE(p, " depth = 1.0f - depth;\n"); WRITE(p, "ocol0.r = frac(depth * %s);\n", multiplier); WriteSampleColor(p, "b", "depth", 3); WRITE(p, " depth = 1.0f - depth;\n"); WRITE(p, "ocol0.a = frac(depth * %s);\n", multiplier); WriteEncoderEnd(p); }
static void WriteRGBA8Encoder(char*& p, APIType ApiType, const EFBCopyParams& params) { WriteSwizzler(p, EFBCopyFormat::RGBA8, ApiType); WRITE(p, " float4 texSample;\n"); WRITE(p, " float4 color0;\n"); WRITE(p, " float4 color1;\n"); WriteSampleColor(p, "rgba", "texSample", 0, ApiType, params); WRITE(p, " color0.b = texSample.a;\n"); WRITE(p, " color0.g = texSample.r;\n"); WRITE(p, " color1.b = texSample.g;\n"); WRITE(p, " color1.g = texSample.b;\n"); WriteSampleColor(p, "rgba", "texSample", 1, ApiType, params); WRITE(p, " color0.r = texSample.a;\n"); WRITE(p, " color0.a = texSample.r;\n"); WRITE(p, " color1.r = texSample.g;\n"); WRITE(p, " color1.a = texSample.b;\n"); WRITE(p, " ocol0 = first ? color0 : color1;\n"); WriteEncoderEnd(p); }
static void WriteRGB5A3Encoder(char*& p,API_TYPE ApiType) { WriteSwizzler(p, GX_TF_RGB5A3, ApiType); WRITE(p, " float4 texSample;\n"); WRITE(p, " float color0;\n"); WRITE(p, " float gUpper;\n"); WRITE(p, " float gLower;\n"); WriteSampleColor(p, "rgba", "texSample", 0, ApiType); // 0.8784 = 224 / 255 which is the maximum alpha value that can be represented in 3 bits WRITE(p, "if(texSample.a > 0.878f) {\n"); WriteToBitDepth(p, 5, "texSample.g", "color0"); WRITE(p, " gUpper = floor(color0 / 8.0);\n"); WRITE(p, " gLower = color0 - gUpper * 8.0;\n"); WriteToBitDepth(p, 5, "texSample.r", "ocol0.b"); WRITE(p, " ocol0.b = ocol0.b * 4.0 + gUpper + 128.0;\n"); WriteToBitDepth(p, 5, "texSample.b", "ocol0.g"); WRITE(p, " ocol0.g = ocol0.g + gLower * 32.0;\n"); WRITE(p, "} else {\n"); WriteToBitDepth(p, 4, "texSample.r", "ocol0.b"); WriteToBitDepth(p, 4, "texSample.b", "ocol0.g"); WriteToBitDepth(p, 3, "texSample.a", "color0"); WRITE(p, "ocol0.b = ocol0.b + color0 * 16.0;\n"); WriteToBitDepth(p, 4, "texSample.g", "color0"); WRITE(p, "ocol0.g = ocol0.g + color0 * 16.0;\n"); WRITE(p, "}\n"); WriteSampleColor(p, "rgba", "texSample", 1, ApiType); WRITE(p, "if(texSample.a > 0.878f) {\n"); WriteToBitDepth(p, 5, "texSample.g", "color0"); WRITE(p, " gUpper = floor(color0 / 8.0);\n"); WRITE(p, " gLower = color0 - gUpper * 8.0;\n"); WriteToBitDepth(p, 5, "texSample.r", "ocol0.r"); WRITE(p, " ocol0.r = ocol0.r * 4.0 + gUpper + 128.0;\n"); WriteToBitDepth(p, 5, "texSample.b", "ocol0.a"); WRITE(p, " ocol0.a = ocol0.a + gLower * 32.0;\n"); WRITE(p, "} else {\n"); WriteToBitDepth(p, 4, "texSample.r", "ocol0.r"); WriteToBitDepth(p, 4, "texSample.b", "ocol0.a"); WriteToBitDepth(p, 3, "texSample.a", "color0"); WRITE(p, "ocol0.r = ocol0.r + color0 * 16.0;\n"); WriteToBitDepth(p, 4, "texSample.g", "color0"); WRITE(p, "ocol0.a = ocol0.a + color0 * 16.0;\n"); WRITE(p, "}\n"); WRITE(p, " ocol0 = ocol0 / 255.0;\n"); WriteEncoderEnd(p, ApiType); }