• 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 /
avatar image
0
Question by Jovssen · Oct 05, 2017 at 11:36 AM · camerarenderingshadersrendertexturemultiple textures

How to make a custom GrabPass-like sampler2D in MRT shader?

I only know the basics of writing shaders, so I don't have a clue how I can make something similar to Unity's Grabpass in that a RenderTexture that is currently write only, can be changed to readonly and used in a sampler2D in a shader.

I set two render targets to my camera, and in one shader write to both targets, but in another shader I write to only one but need to read from the other one. I tried setting the rendertexture I need to read from to a material property, but even though the second shader doesn't currently touch the rendertexture, I believe the rendertexture is still write only because reading from it returns nothing.

I originally used GrabPass, but it doesn't work nicely with different camera viewport rects, as well as although it did work, it didn't make much sense to me because not only was I writing to rendertextures not the "screen" (GrabPass is supposed to makes a sampler of the screen area about to be drawn into, even though I wasn't writing to the screen directly currently), but I was using 2 rendertextures as targets but it only can grab from one, the first, so I had to change the order of the rendertextures so that the GrabPass sampler grabs from the correct first rendertexture. Also if at all possible I would like to avoid the supposed cost of GrabPass because I don't think I would need to make a new texture, just temporarily make one of the rendertextures read only and use it in a sampler2d, but again I know next to nothing about this.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

118 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

Related Questions

Using custom RenderTexture in ImageEffects. 1 Answer

Disabling AA Changes how SS Effects Work 1 Answer

Graphics.DrawTexture with multiple camera on mobile device not working 0 Answers

Render object ID to texture 2 Answers

How to read self when CustomRenderTexture dimension is Tex2DArray 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges