diff options
author | Chris Craik <ccraik@google.com> | 2016-04-28 16:59:42 -0700 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2016-05-03 14:36:29 -0700 |
commit | 138c21fbec12bead3c7ca1f181c3fd35542ccb00 (patch) | |
tree | 44e5b182b83c2532dd02f1ccb6d9c9186a48c4cf /libs/hwui/ProgramCache.cpp | |
parent | 08ca2e3a7593ced4967c56709a1fe675408d42dc (diff) |
Use LUT for computing final shadow alpha
bug:27415250
Significantly reduces shadow fragment shader computation.
Change-Id: Ie9b3c712700754b3734d0ae9cda8751c298fc59e
Diffstat (limited to 'libs/hwui/ProgramCache.cpp')
-rw-r--r-- | libs/hwui/ProgramCache.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp index 05be48822fb2..59225e108ac7 100644 --- a/libs/hwui/ProgramCache.cpp +++ b/libs/hwui/ProgramCache.cpp @@ -231,9 +231,8 @@ const char* gFS_Main_ModulateColor = const char* gFS_Main_ApplyVertexAlphaLinearInterp = " fragColor *= alpha;\n"; const char* gFS_Main_ApplyVertexAlphaShadowInterp = - // Use a gaussian function for the shadow fall off. Note that alpha here - // is actually (1.0 - alpha) for saving computation. - " fragColor *= exp(- alpha * alpha * 4.0) - 0.018;\n"; + // map alpha through shadow alpha sampler + " fragColor *= texture2D(baseSampler, vec2(alpha, 0.5)).a;\n"; const char* gFS_Main_FetchTexture[2] = { // Don't modulate " fragColor = texture2D(baseSampler, outTexCoords);\n", @@ -565,7 +564,7 @@ String8 ProgramCache::generateFragmentShader(const ProgramDescription& descripti shader.append(gFS_Uniforms_Color); if (!singleColor) modulateOp = MODULATE_OP_MODULATE; } - if (description.hasTexture) { + if (description.hasTexture || description.useShadowAlphaInterp) { shader.append(gFS_Uniforms_TextureSampler); } else if (description.hasExternalTexture) { shader.append(gFS_Uniforms_ExternalTextureSampler); |