예제 #1
0
        static public void MaskSprite(LightTile tile, LayerSetting layerSetting, Material material, LightTilemapCollider2D tilemap, float lightSizeSquared)
        {
            virtualSpriteRenderer.sprite = tile.GetOriginalSprite();

            if (virtualSpriteRenderer.sprite == null)
            {
                return;
            }

            LightTilemapCollider.Base tilemapBase = tilemap.GetCurrentTilemap();

            Vector2 tilePosition = tile.GetWorldPosition(tilemapBase) - ShadowEngine.light.transform2D.position;

            material.color = LayerSettingColor.Get(tilePosition, layerSetting, MaskEffect.Lit, 1);             // 1?

            material.mainTexture = virtualSpriteRenderer.sprite.texture;

            Vector2 scale = tile.worldScale * tile.scale;

            GLExtended.SetColor(Color.white);

            tilePosition += ShadowEngine.drawOffset;

            Universal.Sprite.FullRect.Simple.Draw(tile.spriteMeshObject, material, virtualSpriteRenderer, tilePosition, scale, tile.worldRotation);

            material.mainTexture = null;
        }
예제 #2
0
        static public void BumpedSprite(Light2D light, LightTilemapCollider2D id, Material material, LayerSetting layerSetting)
        {
            Texture bumpTexture = id.bumpMapMode.GetBumpTexture();

            if (bumpTexture == null)
            {
                return;
            }

            material.SetTexture("_Bump", bumpTexture);

            Vector2 lightPosition = -light.transform.position;

            LightTilemapCollider.Base tilemap = id.GetCurrentTilemap();
            Vector2 scale = tilemap.TileWorldScale();

            Texture2D currentTexture = null;

            GL.Begin(GL.QUADS);

            foreach (LightTile tile in tilemap.mapTiles)
            {
                if (tile.GetOriginalSprite() == null)
                {
                    return;
                }

                Vector2 tilePosition = tilemap.TileWorldPosition(tile);

                tilePosition += lightPosition;

                if (tile.NotInRange(tilePosition, light.size))
                {
                    continue;
                }

                virtualSpriteRenderer.sprite = tile.GetOriginalSprite();

                if (virtualSpriteRenderer.sprite.texture == null)
                {
                    continue;
                }

                if (currentTexture != virtualSpriteRenderer.sprite.texture)
                {
                    currentTexture       = virtualSpriteRenderer.sprite.texture;
                    material.mainTexture = currentTexture;

                    material.SetPass(0);
                }

                Color color = LayerSettingColor.Get(tilePosition, layerSetting, MaskEffect.Lit, 1); // 1

                GLExtended.SetColor(color);

                Universal.Sprite.FullRect.Simple.DrawPass(tile.spriteMeshObject, virtualSpriteRenderer, tilePosition, scale, tile.worldRotation);
            }

            GL.End();

            material.mainTexture = null;
        }