Author Topic: TransparentColored Shader Question/Optimization?  (Read 3300 times)

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
TransparentColored Shader Question/Optimization?
« on: January 31, 2013, 05:35:50 PM »
Hi,

I was just looking through the built-in shaders in NGUI and in the Transparent-Colored shaders there are two settings that I'm concerned about.

  1. ColorMask RGB
  2. AlphaTest Greater .01
  3.  

The AlphaTest is the concern. Why are we doing another alpha test here? I know that more modern GPUs are much faster and don't have the problems with Alpha testing that the early PowerVR hardware did. I'm not a shader master, but I'm wondering why the shader is doing a test here? Has anyone done any performance comparisons?

The ColorMask is more of a curiosity. Why is a transparent shader not writing into the Alpha? Isn't that required in order to do subsequent alpha blending?

Thanks for any help or clarification anyone could provide.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TransparentColored Shader Question/Optimization?
« Reply #1 on: February 01, 2013, 12:53:11 AM »
Writing to screen there is no alpha, so writing to alpha is pointless.

AlphaTest happens whether you like it or not when alpha blending is enabled. Greater than 0.01 simply means that everything under 0.01 alpha will be considered as invisible and will not be drawn. This actually improves performance, not reduces it.

When in doubt, wikipedia this stuff. If you have such beginner questions about shaders, you better leave it as is or do some more research first. ;)