| 1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
| 2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
| 3 | #include "2D/BsSpriteMaterials.h" |
| 4 | #include "Resources/BsBuiltinResources.h" |
| 5 | #include "RenderAPI/BsGpuBuffer.h" |
| 6 | #include "Material/BsMaterial.h" |
| 7 | |
| 8 | namespace bs |
| 9 | { |
| 10 | UINT32 getMaterialId(bool transparent, bool animated) |
| 11 | { |
| 12 | if(!animated) |
| 13 | return transparent ? 0 : 1; |
| 14 | |
| 15 | return transparent ? 2 : 3; |
| 16 | } |
| 17 | |
| 18 | ShaderVariation getMaterialVariation(bool transparent, bool animated) |
| 19 | { |
| 20 | return ShaderVariation(SmallVector<ShaderVariation::Param, 4>({ |
| 21 | ShaderVariation::Param("TRANSPARENT" , transparent), |
| 22 | ShaderVariation::Param("ANIMATED" , animated) |
| 23 | })); |
| 24 | } |
| 25 | |
| 26 | SpriteImageMaterial::SpriteImageMaterial(bool transparent, bool animated) |
| 27 | :SpriteMaterial( |
| 28 | getMaterialId(transparent, animated), |
| 29 | BuiltinResources::instance().createSpriteImageMaterial(), |
| 30 | getMaterialVariation(transparent, animated), |
| 31 | !animated) |
| 32 | { |
| 33 | |
| 34 | } |
| 35 | |
| 36 | SpriteTextMaterial::SpriteTextMaterial() |
| 37 | : SpriteMaterial(4, BuiltinResources::instance().createSpriteTextMaterial()) |
| 38 | { } |
| 39 | |
| 40 | SpriteLineMaterial::SpriteLineMaterial() |
| 41 | : SpriteMaterial(5, BuiltinResources::instance().createSpriteLineMaterial()) |
| 42 | { } |
| 43 | } |