Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 FChavez509 · Jul 11, 2018 at 10:42 PM · renderingshadersgraphicsprogrammingrendertexture

How to pass a RInt RenderTexture to a ComputeShader?

Hi,


I've been trying to pull Int32 data from fragment shaders for a bit of a while now, and the most successful solution I've had so far, is to pass the data to RenderTextures with ARGBFloat pixel formats, and then convert (caste) it in a compute shader. I've been trying to get the fragment shader to pass the data to a RenderTexture with a pixel format of RInt. I've only found one post where the person claims to have done this, but that post never actually went into how they got the data out of the RInt RenderTexture afterwards.


Now, I've written fragment shaders that will just pass 42 to every pixel of the RenderTexuture, only to get nothing but 0s when I try to read those pixels in a compute shader. I'm trying to use a compute shader because the Texture2D.ReadPixels method (as far as I can tell) doesn't work with Pixels of type RInt. Since all I ever get is zero values, I don't know if I'm failing to read the data from the RenderTexture, or if I'm failing to write the data into the RenderTexture.


Does anyone know how to actually pull data from a RenderTexture with RInt pixel format, and place said data into a readable format in system memory? While the ARGBFloat then caste to int works for some of my use cases; it's not ideal and like I said, it only works for some of my use cases. I have found references where people that came across this problem were simply told to write a native plugin for Unity, but after looking at a few tutorials on writing native plug-ins for Unity, I have concluded that those answers are of no use. There's a bit of a gap between what a tutorial will teach you, and what you need to know to access RenderTexuture data. Not to mention, it would be a bit of a shocker to go to all that work only to find out that the issue was with the fragment shader.

Comment
Add comment · Show 2
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
avatar image NoDumbQuestion · Jul 12, 2018 at 01:29 AM 0
Share

What are you trying to do? There might be more simple solution than whatever you trying to pull from ComputeShader

avatar image FChavez509 NoDumbQuestion · Jul 12, 2018 at 11:00 PM 0
Share

I'm trying to pull the int values from a fragment shader and read them on the CPU (or at least that is the end result). The ComputeShader is just an in-between step that I'm trying out. In my latest use case, we want the vert ids of the visible verts, but using a float that gets caste to an int isn't an option because the mesh has more than 2^16 verts in it. The reason I'm trying the RenderTexture is because the RenderTexture has RInt as one of the available pixel formats which is exactly what I need. The RenderTexture lets me send that info somewhere that isn't a computer monitor, but I still need to get it to the CPU.

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

177 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

HDRP Render ObjectIDs to Texture 0 Answers

Screen Not rendering 0 Answers

How do you use Blend Shapes when rendering a mesh via Graphics.DrawMesh()? 0 Answers

Best way to render hundreds of textures for flooring in an in-game editor? 0 Answers

Optimizing Shader Compiler for HDRP 0 Answers


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