private void StartLayer(GenericLayer layer) { currentGenericLayer = layer; currentPainterLayer = layer.painterLayer; // TODO: check if currentLayerTempRenderTextures is empty }
public void ResetChannelsToDefaults(IEnumerable <GenericChannel> channels) { DiscardAllChannels(); // hack to work around issue with WriteChannel(); currentPainterLayer = null; currentGenericLayer = null; foreach (GenericChannel channel in channels) { // initialize a render target for each channel RenderTextureDescriptor descriptor = new RenderTextureDescriptor(channel.format.width, channel.format.height, channel.format.format); RenderTexture channelTarget = CreateRenderTexture(descriptor); RenderTexture oldRT = UnityEngine.RenderTexture.active; if (channel.defaultTexture != null) { // initialize to default texture Graphics.Blit(channel.defaultTexture, channelTarget); } else { // initialize to default color UnityEngine.RenderTexture.active = channelTarget; GL.Clear(true, true, channel.defaultColor); } UnityEngine.RenderTexture.active = oldRT; // setup painter channel WriteChannel(channel.name, channelTarget); } }
private void EndLayer() { // any remaining temp render textures are discarded (for re-use) foreach (RenderTexture rt in currentLayerTempRenderTextures) { discardedRenderTextures.Add(rt.descriptor, rt); } currentLayerTempRenderTextures.Clear(); currentGenericLayer = null; currentPainterLayer = null; }