Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Kantharr · Feb 14, 2013 at 11:46 PM · androidshaderngui

Shader problem with Droid X2 and soft clipping

Hey,

Recently while working on our project we had our game working on the Droid X2 with 1 panel and with no clipping (we are using NGUI). But when we added a second panel that has soft clipping (for dragging objects on the screen). The game will only flicker the first screen that comes up when we start the game up. I believe it is a shader issue because it stopped flickering the first screen when I changed the graphics level from OpenGL ES 2.0 to 1.x but if we do that then the soft clipping will not work properly. Here is the soft clipping shader script that came with NGUI (we have not modified it):

 Shader "Unlit/Transparent Colored (SoftClip)"
 {
     Properties
     {
         _MainTex ("Base (RGB), Alpha (A)", 2D) = "white" {}
     }
 
     SubShader
     {
         LOD 200
 
         Tags
         {
             "Queue" = "Transparent"
             "IgnoreProjector" = "True"
             "RenderType" = "Transparent"
         }
         
         Pass
         {
             Cull Off
             Lighting Off
             ZWrite Off
             Offset -1, -1
             Fog { Mode Off }
             ColorMask RGB
             Blend SrcAlpha OneMinusSrcAlpha
 
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #pragma fragmentoption ARB_precision_hint_fastest
 
             #include "UnityCG.cginc"
 
             sampler2D _MainTex;
             float4 _MainTex_ST;
             float2 _ClipSharpness = float2(20.0, 20.0);
 
             struct appdata_t
             {
                 float4 vertex : POSITION;
                 fixed4 color : COLOR;
                 float2 texcoord : TEXCOORD0;
             };
 
             struct v2f
             {
                 float4 vertex : POSITION;
                 fixed4 color : COLOR;
                 float2 texcoord : TEXCOORD0;
                 float2 worldPos : TEXCOORD1;
             };
 
             v2f vert (appdata_t v)
             {
                 v2f o;
                 o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                 o.color = v.color;
                 o.texcoord = v.texcoord;
                 o.worldPos = TRANSFORM_TEX(v.vertex.xy, _MainTex);
                 return o;
             }
 
             fixed4 frag (v2f IN) : COLOR
             {
                 // Softness factor
                 float2 factor = (float2(1.0, 1.0) - abs(IN.worldPos)) * _ClipSharpness;
             
                 // Sample the texture
                 fixed4 col = tex2D(_MainTex, IN.texcoord) * IN.color;
                 col.a *= clamp( min(factor.x, factor.y), 0.0, 1.0);
                 return col;
             }
             ENDCG
         }
     }
     
     SubShader
     {
         Tags
         {
             "Queue" = "Transparent"
             "IgnoreProjector" = "True"
             "RenderType" = "Transparent"
         }
         
         LOD 100
         Cull Off
         Lighting Off
         ZWrite Off
         Fog { Mode Off }
         ColorMask RGB
         AlphaTest Greater .01
         Blend SrcAlpha OneMinusSrcAlpha
         
         Pass
         {
             ColorMaterial AmbientAndDiffuse
             
             SetTexture [_MainTex]
             {
                 Combine Texture * Primary
             }
         }
     }
 }

Any help will be greatly appreciated.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Kantharr · Feb 15, 2013 at 09:17 PM

Never mind, the problem was solved. You guys can close this post now.

Comment
Add comment · Share
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
0

Answer by renderhjs · Feb 25, 2013 at 12:24 AM

How about sharing for people like me that bumped into this after a google search?

Comment
Add comment · Share
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

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

10 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

Related Questions

A node in a childnode? 1 Answer

Control basics - NGUI 1 Answer

android shader issue 1 Answer

How to make Custom Clipping in NGUI 1 Answer

Android repeated texture problem 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