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 hendefer · Oct 06, 2017 at 01:53 PM · shaderskyboxfadealpha-channelcutout

help with fade/cutout skybox shader

Hi guys I'm trying to give a fade/cutout to this shader, this is not my shader and I found that on the unity forum. I have tried but with no luck, the "best" result is this with the clip() function.. but sadly in the reverse like this and the hard edge of the cut out: alt text

my ideal result of the shader is this, with a cubemap and an Alpha channel with fade: alt text

here the original code:

 Shader "Skybox/CubemapTransparent" {
 Properties {
     _Tint ("Tint Color", Color) = (.5, .5, .5, .5)
     [Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0
     _Rotation ("Rotation", Range(0, 360)) = 0
     [NoScaleOffset] _Tex ("Cubemap   (HDR)", Cube) = "grey" {}
 }
  
 SubShader {
     Tags { "Queue"="Background" "RenderType"="Background" "PreviewType"="Skybox" }
     Cull Off ZWrite Off
     Blend SrcAlpha OneMinusSrcAlpha
  
     Pass {
      
         CGPROGRAM
         #pragma vertex vert
         #pragma fragment frag
  
         #include "UnityCG.cginc"
  
         samplerCUBE _Tex;
         half4 _Tex_HDR;
         half4 _Tint;
         half _Exposure;
         float _Rotation;
  
         float4 RotateAroundYInDegrees (float4 vertex, float degrees)
         {
             float alpha = degrees * UNITY_PI / 180.0;
             float sina, cosa;
             sincos(alpha, sina, cosa);
             float2x2 m = float2x2(cosa, -sina, sina, cosa);
             return float4(mul(m, vertex.xz), vertex.yw).xzyw;
         }
      
         struct appdata_t {
             float4 vertex : POSITION;
         };
  
         struct v2f {
             float4 vertex : SV_POSITION;
             float3 texcoord : TEXCOORD0;
         };
  
         v2f vert (appdata_t v)
         {
             v2f o;
             o.vertex = mul(UNITY_MATRIX_MVP, RotateAroundYInDegrees(v.vertex, _Rotation));
             o.texcoord = v.vertex;
             return o;
         }
  
         fixed4 frag (v2f i) : SV_Target
         {
             half4 tex = texCUBE (_Tex, i.texcoord);
             half3 c = DecodeHDR (tex, _Tex_HDR);
             c = c * _Tint.rgb * unity_ColorSpaceDouble;
             c *= _Exposure;
             return half4(c, 0.15);
         }
         ENDCG
     }
 }  
 } 

someone can help me? thanks

p.s. here the clip() code:

 Shader "Skybox/CubemapTransparent2" {
 Properties {
     _Tint ("Tint Color", Color) = (.5, .5, .5, .5)
     [Gamma] _Exposure ("Exposure", Range(0, 8)) = 1.0
     _Rotation ("Rotation", Range(0, 360)) = 0
     [NoScaleOffset] _Tex ("Cubemap   (HDR)", Cube) = "grey" {}
     _alpetto ("alpetto", Range(0, 1)) = 0
 
     _CutoutThresh("Cutout Threshold", Range(0.0,1.0)) = 0.2
 }
  
 SubShader {
     Tags { "Queue"="Background" "Queue"="Transparent"  "RenderType"="Background" "PreviewType"="Skybox" }
     Cull Off ZWrite Off
     Blend SrcAlpha OneMinusSrcAlpha
  
     Pass {
      
         CGPROGRAM
         #pragma vertex vert
         #pragma fragment frag surf alpha
  
         #include "UnityCG.cginc"
          float _CutoutThresh;
         samplerCUBE _Tex;
         half4 _Tex_HDR;
         half4 _Tint;
         half _Exposure;
         float _Rotation;
         float _alpetto;
 
  
         float4 RotateAroundYInDegrees (float4 vertex, float degrees)
         {
             float alpha = degrees * UNITY_PI / 180.0;
             float sina, cosa;
             sincos(alpha, sina, cosa);
             float2x2 m = float2x2(cosa, -sina, sina, cosa);
             return float4(mul(m, vertex.xz), vertex.yw).xzyw;
         }
      
         struct appdata_t {
             float4 vertex : POSITION;
         };
  
         struct v2f {
             float4 vertex : SV_POSITION;
             float3 texcoord : TEXCOORD0;
            // float4 uv_Tex;
         };
 
          struct Input {
          float2 uv_Tex;
      };
  
         v2f vert (appdata_t v)
         {
             v2f o;
             o.vertex = mul(UNITY_MATRIX_MVP, RotateAroundYInDegrees(v.vertex, _Rotation));
             o.texcoord = v.vertex;
 
             return o;
         }
  
         fixed4 frag (v2f i) : SV_Target
         {
             half4 tex = texCUBE (_Tex, i.texcoord);
          
            half3 c = DecodeHDR (tex, _Tex_HDR);
          
             c = c * _Tint.rgb * unity_ColorSpaceDouble;
             c *= _Exposure;
             clip(c - _CutoutThresh);
 
            
             return half4(c, _alpetto);
           
 
         }
 
              
          
 
         ENDCG
     }
 }  
 } 


image3.jpg (77.6 kB)
imagecom.jpg (115.3 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.

Follow this Question

Answers Answers and Comments

112 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

Related Questions

please how can i add cutout or fade to this shader 0 Answers

Fade SkyBox to Black 3 Answers

How to make Pixelstudio's skydome works on Mobile(iOS & Android)? 1 Answer

How to change the reflection according to skybox-material? 2 Answers

Help with Skybox Fading 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