public Sprite GetAtlasWhiteMaskSprite() { if (atlasWhiteMaskSprite == null) { atlasWhiteMaskSprite = SpriteAtlasManager.RequestSprite(GetWhiteMaskSprite(), SpriteRequest.Type.WhiteMask); } return(atlasWhiteMaskSprite); }
public Sprite GetAtlasPenumbraSprite() { if (atlasPenumbraSprite == null) { atlasPenumbraSprite = SpriteAtlasManager.RequestSprite(GetPenumbraSprite(), SpriteRequest.Type.BlackAlpha); } return(atlasPenumbraSprite); }
static public void MaskSpriteDepthWithAtlas(LightingBuffer2D buffer, LightingTile tile, LayerSetting layerSetting, LightingTilemapCollider2D id, Vector2D offset, float z) { if (id.maskType != LightingTilemapCollider2D.MaskType.Sprite) { return; } if (id.maskType == LightingTilemapCollider2D.MaskType.None) { return; } if (tile.GetOriginalSprite() == null) { return; } Sprite sprite = tile.GetAtlasSprite(); Vector2 scale = new Vector2(1, 1); if (sprite == null) { Sprite reqSprite = SpriteAtlasManager.RequestSprite(tile.GetOriginalSprite(), SpriteRequest.Type.WhiteMask); if (reqSprite == null) { PartiallyBatched_Tilemap batched = new PartiallyBatched_Tilemap(); batched.virtualSpriteRenderer = new VirtualSpriteRenderer(); batched.virtualSpriteRenderer.sprite = tile.GetOriginalSprite(); batched.polyOffset = offset.ToVector2(); batched.tileSize = scale; batched.tilemap = id; buffer.partiallyBatchedList_Tilemap.Add(batched); return; } else { tile.SetAtlasSprite(reqSprite); sprite = reqSprite; } } VirtualSpriteRenderer spriteRenderer = new VirtualSpriteRenderer(); spriteRenderer.sprite = sprite; Max2D.DrawSpriteBatched_Tris(spriteRenderer, layerSetting, id.maskMode, offset.ToVector2(), scale, id.transform.rotation.eulerAngles.z, z); LightingDebug.maskGenerations++; }
static public void DrawWithAtlas(Vector2D offset, float z) { material = manager.materials.GetAdditive(); material.SetColor("_TintColor", Color.white); material.mainTexture = SpriteAtlasManager.Get().atlasTexture.texture; material.SetPass(0); GL.Begin(GL.TRIANGLES); for (int i = 0; i < spriteRendererList.Count; i++) { id = spriteRendererList[i]; if (id.type != LightingSpriteRenderer2D.Type.Particle) { continue; } if (id.GetSprite() == null) { continue; } if (id.InCamera() == false) { continue; } position = id.transform.position; scale = id.transform.lossyScale; scale.x *= id.offsetScale.x; scale.y *= id.offsetScale.y; rot = id.offsetRotation; if (id.applyTransformRotation) { rot += id.transform.rotation.eulerAngles.z; } color = id.color; color.a = id.alpha; GL.Color(color); spriteRenderer.sprite = SpriteAtlasManager.RequestSprite(id.GetSprite(), SpriteRequest.Type.Normal); Max2D.DrawSpriteBatched_Tris_Day(spriteRenderer, offset.ToVector2() + position + id.offsetPosition, scale, rot, z); LightingDebug.SpriteRenderersDrawn++; } GL.End(); material = manager.materials.GetAtlasMaterial(); material.SetPass(0); GL.Begin(GL.TRIANGLES); for (int i = 0; i < spriteRendererList.Count; i++) { id = spriteRendererList[i]; if (id.type == LightingSpriteRenderer2D.Type.Particle) { continue; } if (id.GetSprite() == null) { continue; } if (id.InCamera() == false) { continue; } position = id.transform.position; scale = id.transform.lossyScale; scale.x *= id.offsetScale.x; scale.y *= id.offsetScale.y; rot = id.offsetRotation; if (id.applyTransformRotation) { rot += id.transform.rotation.eulerAngles.z; } switch (id.type) { case LightingSpriteRenderer2D.Type.WhiteMask: GL.Color(Color.white); spriteRenderer.sprite = SpriteAtlasManager.RequestSprite(id.GetSprite(), SpriteRequest.Type.WhiteMask); Max2D.DrawSpriteBatched_Tris_Day(spriteRenderer, offset.ToVector2() + position + id.offsetPosition, scale, rot, z); break; case LightingSpriteRenderer2D.Type.BlackMask: GL.Color(Color.black); spriteRenderer.sprite = SpriteAtlasManager.RequestSprite(id.GetSprite(), SpriteRequest.Type.WhiteMask); Max2D.DrawSpriteBatched_Tris_Day(spriteRenderer, offset.ToVector2() + position + id.offsetPosition, scale, rot, z); break; } LightingDebug.SpriteRenderersDrawn++; } GL.End(); }
static public void MaskSpriteWithAtlas(LightingBuffer2D buffer, LightingTilemapCollider2D id, Vector2D offset, float z) { if (id.maskType != LightingTilemapCollider2D.MaskType.Sprite) { return; } if (id.map == null) { return; } SetupLocation(buffer, id); Sprite reqSprite; PartiallyBatched_Tilemap batched; for (int x = newPositionInt.x - sizeInt; x < newPositionInt.x + sizeInt; x++) { for (int y = newPositionInt.y - sizeInt; y < newPositionInt.y + sizeInt; y++) { if (x < 0 || y < 0) { continue; } if (x >= id.area.size.x || y >= id.area.size.y) { continue; } tile = id.map[x, y]; if (tile == null) { continue; } if (tile.GetOriginalSprite() == null) { continue; } polyOffset.x = x + tilemapOffset.x; polyOffset.y = y + tilemapOffset.y; polyOffset.x *= scale.x; polyOffset.y *= scale.y; polyOffset2.x = (float)polyOffset.x; polyOffset2.y = (float)polyOffset.y; if (LightingManager2D.culling && Vector2.Distance(polyOffset2, buffer.lightSource.transform.position) > 2 + buffer.lightSource.lightSize) { LightingDebug.culled++; continue; } polyOffset.x += offset.x; polyOffset.y += offset.y; spriteRenderer.sprite = tile.GetAtlasSprite(); if (spriteRenderer.sprite == null) { reqSprite = SpriteAtlasManager.RequestSprite(tile.GetOriginalSprite(), SpriteRequest.Type.WhiteMask); if (reqSprite == null) { // Add Partialy Batched batched = new PartiallyBatched_Tilemap(); batched.virtualSpriteRenderer = new VirtualSpriteRenderer(); batched.virtualSpriteRenderer.sprite = tile.GetOriginalSprite(); batched.polyOffset = polyOffset.ToVector2(); batched.tileSize = tileSize; buffer.partiallyBatchedList_Tilemap.Add(batched); continue; } else { tile.SetAtlasSprite(reqSprite); spriteRenderer.sprite = reqSprite; } } polyOffset2.x = (float)polyOffset.x; polyOffset2.y = (float)polyOffset.y; Max2D.DrawSpriteBatched_Tris(spriteRenderer, buffer.lightSource.layerSetting[0], id.maskMode, polyOffset2, tileSize, 0, z); LightingDebug.maskGenerations++; } } }
public static void MaskWithAtlas(LightingBuffer2D buffer, LightingCollider2D id, Vector2D offset, float z) { if (id.shape.maskType == LightingCollider2D.MaskType.None) { return; } if (id.shape.maskType != LightingCollider2D.MaskType.Sprite) { return; } if (id.isVisibleForLight(buffer) == false) { return; } if (id.spriteRenderer == null) { return; } if (id.shape.GetOriginalSprite() == null) { return; } Sprite sprite = id.shape.GetAtlasSprite(); if (sprite == null) { Sprite reqSprite = SpriteAtlasManager.RequestSprite(id.shape.GetOriginalSprite(), SpriteRequest.Type.WhiteMask); if (reqSprite == null) { PartiallyBatched_Collider batched = new PartiallyBatched_Collider(); batched.collider2D = id; buffer.partiallyBatchedList_Collider.Add(batched); return; } else { id.shape.SetAtlasSprite(reqSprite); sprite = reqSprite; } } Vector2 p = id.transform.position; p.x += (float)offset.x; p.y += (float)offset.y; Vector2 scale = id.transform.lossyScale; spriteRenderer.sprite = sprite; Max2D.DrawSpriteBatched_Tris(spriteRenderer, buffer.lightSource.layerSetting[0], id.maskMode, p, scale, id.transform.rotation.eulerAngles.z, z); LightingDebug.maskGenerations++; }