Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by lunarpaddle · Oct 11, 2021 at 09:15 PM · compute shaderrender texture

Render Texture seems to go blank when sent to Compute Shader?

I have a render texture (that's being blitted to from a webcamtexture, if thats helpful), that works fine when I blit it in turn onto the screen - but when I send it to the compute shader, write whats on it onto a different texture, and blit that new texture to the screen it's entirely black.

Relevant CPU code :

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 [RequireComponent(typeof(Camera_Handler))]
 public class Gol_Handler_Camera : MonoBehaviour
 {
     public ComputeShader compute;
     public int _width;
     public int _height;
 
     int width_groups;
     int height_groups;
 
     RenderTexture _Input;
     RenderTexture _Output;
     RenderTexture _Screen;
     RenderTexture _Video;
     RenderTexture _Video_Save;
 
     void OnRenderImage(RenderTexture src, RenderTexture dest) {
       Graphics.Blit(_Screen, dest);
     }
 
     void Start() {
       _Video = GetComponent<Camera_Handler>().Camera_Render();
       _Video_Save = GetComponent<Camera_Handler>().Camera_Render();
       _width = _Video.width;
       _height = _Video.height;
 
       _Screen = new RenderTexture(_width, _height, 0);
       _Screen.enableRandomWrite = true;
       _Screen.filterMode = FilterMode.Point;
       _Screen.wrapMode = TextureWrapMode.Clamp;
       _Screen.Create();
 
       compute.SetInt(width_id, _width);
       compute.SetInt(height_id, _height);
       compute.SetInt(buffer_length_id, _buffer_length);
   
       compute.SetTexture(4, input_id, _Input);
       compute.SetTexture(4, output_id, _Output);
       compute.SetTexture(4, screen_id, _Screen);
       compute.SetTexture(4, video_id, _Video);
       compute.SetTexture(4, video_save_id, _Video_Save);
       compute.SetBuffer(4, buffer_id, _Buffer);
 
       width_groups = Mathf.CeilToInt((float)_width/8f);
       height_groups = Mathf.CeilToInt((float)_height/8f);
     }
 
     void Update() {
       compute.SetTexture(4, video_id, _Video);
       compute.Dispatch(4, width_groups, height_groups, 1);
     }
 }

Relevant GPU code:

 #pragma kernel Initialise
 
 uint _width;
 uint _height;
 
 RWTexture2D<float4> _Video;
 RWTexture2D<float4> _Video_Save;
 RWTexture2D<float4> _Input;
 RWTexture2D<float4> _Output;
 RWTexture2D<float4> _Screen;
 
 StructuredBuffer<uint2> _Buffer;
 uint _buffer_length;
 
 ...
 
 #pragma kernel GOL
 
 ...

 #pragma kernel Display

 ...
 
 #pragma kernel Reset
 
 ...
 
 #pragma kernel Video_Input
 
 [numthreads(8,8,1)]
 void Video_Input (uint3 id : SV_DispatchThreadID)
 {
   _Screen[id.xy] = _Video[id.xy];
 }

If I change the OnRenderImage blit from blitting _Screen to blitting _Video it works fine, so clearly the _Video render texture contains data prior to being sent over to the shader - but once it's there it seems to behave like it's completely blank. I ideally want to be able to alter and use the data from the _Video texture once its in the compute shader, not just send it back to the screen, but I can't even seem to do that at the moment.

Any help would be really appreciated.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

167 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is there a way to fetch albedo/spec/roughness/AO and normals (RTs) in a deferred frag. shader? 0 Answers

Terrain texture layers not working after universal render pipeline install,Textures on terrain not showing after removing universal render pipeline 0 Answers

How to add a Vector3 to a ComputeBuffer 1 Answer

camera viewport from rect to triangle 0 Answers

DrawProcedural draws nothing although buffers are assigned properly 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges