• 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 TerminalPlantain · Dec 31, 2019 at 03:22 AM · shaderspost-processing

Blocky output from shader using tex3D sample

I'm experimenting with a simple color lookup table using a 3D texture, but I'm getting unexpected output from the shader. I'm applying it via a simple blit with material in OnRenderImage, and its implementation looks like this:

 Shader "Custom/Lookup"
 {
     Properties
     {
         _MainTex("Base (RGB)", 2D) = "white" {}
         _LUT("Lookup table", 3D) = "white" {}
     }
 
     SubShader
     {
         Cull Off ZWrite Off ZTest Always
 
         Pass
         {
             CGPROGRAM
 
                 #pragma vertex vert_img
                 #pragma fragment frag
 
                 #include "UnityCG.cginc"
 
                 uniform sampler2D _MainTex;
                 uniform sampler3D _LUT;
 
                 float4 frag(v2f_img i) : COLOR
                 {
                     float4 color = tex2D(_MainTex, i.uv);
                     float4 converted = tex3D(_LUT, color.rgb);
                     converted.a = color.a;
 
                     return converted;
                 }
 
             ENDCG
         }
     }
 }


Without the shader applied, I get this output (with the editor's render scale set to 3x):

alt text

With the shader, I get this. Note that there are blocky, discolored pixels at intersections between colors:

alt text

My 3D texture is a neutral LUT with 32 pixels in each dimension. I've even tried this with a size 256 LUT just to rule out that problem, and although the colors are more accurate (as I would expect), the blocky pixels still show up.

Anti-aliasing is entirely disabled in the project, but that's the only thing I can think of that would cause this problem. Has anybody else encountered this?

withoutshader.png (77.2 kB)
withshader.png (50.6 kB)
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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

127 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

Related Questions

Possible to have certain objects in the scene cast shadows that have a different colour? 0 Answers

Where can I find any tutorial on Post Processing shader manually (ie. not using Post Processing Stack)? 0 Answers

What is the meaning of a vertex shader for a post-processing shader? 1 Answer

How do you use a shader file once written? 1 Answer

Mask particles inside an object with a transparent shader 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