void Update() { if (materialShader) { Shader.SetGlobalTexture(uniformName, frameBuffer.Apply(materialShader)); } }
void Update() { if (materialShader && firedAt + 1f / frameRate < Time.time) { firedAt = Time.time; Shader.SetGlobalTexture(uniformName, frameBuffer.Apply(materialShader)); } }
void Update() { if (timeElapsed >= (animDuration - 0.00001)) { record = false; } if (materialShader) { if (!record) { Shader.SetGlobalTexture(uniformName, frameBuffer.Apply(materialShader)); Shader.SetGlobalFloat("_TimeElapsed", Time.time); index = 0; wasRecording = false; } else { if (wasRecording == false) { wasRecording = true; timeStarted = Time.time; filePath = System.IO.Path.Combine(path, "Renders") + "/" + DateTime.Now.ToString("yyyyMMddHHmmssffff"); } Shader.SetGlobalFloat("_TimeElapsed", timeElapsed); Shader.SetGlobalTexture(uniformName, frameBuffer.Apply(materialShader)); if (File.Exists(filePath) == false) { Directory.CreateDirectory(filePath); } // UnityEngine.Debug.Log(timeElapsed); RenderTexture.active = frameBuffer.Get(); texture2D.ReadPixels(new Rect(0, 0, frameBuffer.Get().width, frameBuffer.Get().height), 0, 0); texture2D.Apply(); File.WriteAllBytes(filePath + "/" + index.ToString().PadLeft(3, '0') + ".jpg", texture2D.EncodeToJPG()); ++index; timeElapsed += 1f / frameRate; } } }
public void Clear(ClearMask mask, Color?clearColor = null, float depth = float.PositiveInfinity) { Color realClearColor = clearColor == null ? Color.clear : clearColor.Value; for (int i = 0; i < m_FrameBuffer.m_Width; i++) { for (int j = 0; j < m_FrameBuffer.m_Height; j++) { if ((mask & ClearMask.COLOR) > 0) { m_FrameBuffer.SetColor(i, j, realClearColor); } if ((mask & ClearMask.DEPTH) > 0) { m_FrameBuffer.SetDepth(i, j, depth); } } } m_FrameBuffer.Apply(); }
void Update() { if (Input.GetKeyDown(KeyCode.LeftArrow)) { ChangeLOD(lod - 1); } else if (Input.GetKeyDown(KeyCode.RightArrow)) { ChangeLOD(lod + 1); } if (Input.GetKeyDown(KeyCode.UpArrow)) { ChangeCount(count + 50); } else if (Input.GetKeyDown(KeyCode.DownArrow)) { ChangeCount(count - 50); } if (isReady) { materialSlicing.SetFloat("_LineSize", lineSize); if (lastFire + 1f / frameRate < Time.time) { lastFire = Time.time; for (int i = count - 1; i > 0; --i) { Graphics.Blit(textures[(i - 1) % count], textures[i % count]); materialSlicing.SetFloat("_LinePosition", i / (float)count); materialSlicing.SetTexture("_NewFrame", textures[(i - 1) % count]); frameBuffer.Apply(materialSlicing); } Graphics.Blit(webcam.texture, textures[0]); } Shader.SetGlobalTexture("_TimeTexture", frameBuffer.Get()); } }
public void Update() { result = buffer.Apply(material); }