Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
avatar image
0
Question by at1012 · Feb 27, 2017 at 09:08 PM · shadershaderlabvoxelblendingdirectx

Logical BlendOp not working

I am attempting to voxelize the scene through a logical blending operation using the dx 11.1 blend ops referenced here. However, this appears to have no effect in viewing the rendered result.

I am using the dx 11 option in the player settings, and other blend modes, such as Min, Max, etc. seem to work fine. Any ideas or suggestions on what might be causing the problem are greatly appreciated.

Thank you!

Shader Code:

 Shader "Hidden/T_Voxelize"
 {
     Properties
     {
         _MainTex("Base (RGB)", 2D) = "black" {}
     }
     
     CGINCLUDE
     
     #include "UnityCG.cginc"
     
     struct appdata_t
     {
         float4 vertex : POSITION;
     };
     
     struct v2f
     {
         float4 vertex : SV_POSITION;
         float vdist : TEXCOORD0;
     };
     
     uniform sampler2D _MainTex;
     
     v2f vert (appdata_t v)
     {
         v2f o;
         o.vertex = mul(UNITY_MATRIX_MV, v.vertex);
         o.vdist = -o.vertex.z;
         o.vertex = mul(UNITY_MATRIX_P, o.vertex);
         
         return o;
     }
 
     float4 frag (v2f i) : SV_Target
     {
         int shift = floor(i.vdist / _ProjectionParams.z * 127 + 0.5);
         
         float rshift = shift > 31 ? 0 : 1 << shift;
         float gshift = shift > 63 || shift < 32 ? 0 : 1 << (shift - 32);
         float bshift = shift > 95 || shift < 64 ? 0 : 1 << (shift - 64);
         float ashift = shift < 96 ? 0 : 1 << (shift - 96);
         
         return float4(rshift, gshift, bshift, ashift);
     }
     
     ENDCG
     
     SubShader
     {
         Pass
         {
             Fog { Mode Off }
             ZTest Always Cull Off ZWrite Off
             Blend One One
             BlendOp LogicalOr
             
             CGPROGRAM
             
             #pragma target 5.0
             #pragma vertex vert
             #pragma fragment frag
             
             ENDCG
         }
     }
     Fallback off
 }
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 tanoshimi · Feb 27, 2017 at 10:44 PM 0
Share

And you're using Gamma colourspace?

avatar image at1012 tanoshimi · Feb 28, 2017 at 01:36 AM 0
Share

Correct, although it does not work in linear either.

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

91 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

Related Questions

BlendOps on mobile not supported? 1 Answer

How do I use advanced OpenGL blend mode ? 0 Answers

Additive Surface Shader in Unity 5 1 Answer

Does AlphaToMask works in unity ? 0 Answers

How can I write a custom cutout diffuse shader that supports custom vertex colors? 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