Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Help! i have warning message "OnRenderImage() possibly didn't write anything to the destination texture"

$
0
0
[1]: /storage/temp/93205-sketch3.png using System.Collections; using System.Collections.Generic; using UnityEngine; [RequireComponent(typeof(Camera))] public class BlackHole : MonoBehaviour { //public settings public Shader shader; public Transform blackHole; public float ratio; //aspect ratio of the screen public float radius; //size of black hone in scene //private settings Camera cam; Material _material; //will be procedurally generated Material material { get { if (_material == null) { _material = new Material (shader); _material.hideFlags = HideFlags.HideAndDontSave; } return _material; } } void onenable(){ cam = GetComponent (); ratio = 1f / cam.aspect; } void ondisable(){ if (_material) { DestroyImmediate (_material); } } Vector3 wtsp; Vector2 pos; void OnRenderImage(RenderTexture source, RenderTexture destination){ //processing happens here if (shader && material && blackHole){ wtsp = cam.WorldToScreenPoint (blackHole.position); //is the Black Hole in front of the camera if (wtsp.z > 0) { pos = new Vector2 (wtsp.x / cam.pixelWidth, 1 - (wtsp.y / cam.pixelHeight)); //apply shader parametrs _material.SetVector ("_position", pos); _material.SetFloat ("_ratio", ratio); _material.SetFloat ("_rad", radius); _material.SetFloat ("_distance", Vector3.Distance (blackHole.position, transform.position)); //apply the shader to the image Graphics.Blit(source, destination, material); } } } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>