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 /
  • Help Room /
avatar image
0
Question by vyruz18 · Feb 05, 2016 at 07:32 PM · transparency

object transparency slider script

I'm working on an anatomical application of a human hand. Surrounding all the muscles/bones etc we've included a model of the skin, linked to a slider to change the transparency.

Short impression: link text

the transparency/opacity changes when you drag town the slider, however between 90%-100% there is a big "gap"

The script for the slider:

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 public class SliderFunctionatlity : MonoBehaviour {
 
     public Transform target;
 //    GameObject VolumeSliderGet;
     public Slider slider;
     public float VolumeSliderGet;
     // Use this for initialization
 
     void Start () {
        }
     
     // Update is called once per frame
     void Update () {
     
 //        setAlpha();
         VolumeSliderGet = GameObject.Find ("Main Menu/Panel/Slider").GetComponent<Slider>().value;
     }
 
     public void setAlpha()
     {
         MeshRenderer elemRenderer,elemRenderer2;
         Shader shader = Shader.Find("Marmoset/Beta/HairSKIN IBL");
         Shader shader1 = Shader.Find ("Marmoset/Bumped Specular IBL");
         Color mycolor = new Color();
         ColorUtility.TryParseHtmlString ("#c0c0c0", out mycolor);
 
         if(VolumeSliderGet != 1)
         {
             elemRenderer = target.GetComponentInChildren<MeshRenderer>();
             Color originalColor = elemRenderer.material.color;
             elemRenderer.material.shader = shader;
             elemRenderer.material.color = new Color(originalColor.r, originalColor.g, originalColor.b, VolumeSliderGet);
 
             if(VolumeSliderGet > 0.95){
 //            Debug.Log ("Using shader without transparency");
                 elemRenderer = target.GetComponentInChildren<MeshRenderer>();
                 elemRenderer.material.shader = shader1;
                 elemRenderer.material.color = mycolor;
             }
 
 //            Camera.main.GetComponent<camerahandling>().enabled = false;
             }
         }
 }
 

I'm too unexperienced to start adjusting the 2 shaders linked in this script (both from the Marmoset), but I figured out that the "HairSKIN IBL" shader still remains at about 90% and basically never hit 100%, the other shader ("Bumped Specular IBL") doesnt have an alpha channel I think, so not sure how to change that.

Does anybody know a possible solution for this? Basically I'm looking for a diffuse bumped specular shader with the possiblity to change the alpha/opacity or another solution to change the alpha/opacity from the skin. Thanks in advance!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by vyruz18 · Feb 05, 2016 at 11:14 PM

I fixed the difference between the 2 different shaders, the transition is very smooth now (the alpha channel wasnt having the (255,255.255.255) color as default...

howevery, the transparency shaders gives me quite some "artifacts now when the alpha is somewhere between 0.8 and 1.0. I'm using the Marmoset/Beta/Hair IBL for the purpose: link text

 // Marmoset Skyshop
 // Copyright 2013 Marmoset LLC
 // http://marmoset.co
 
 Shader "Marmoset/Beta/Hair IBL" {
     Properties {
         _Color   ("Diffuse Color", Color) = (1,1,1,1)
         _SpecColor ("Specular Color", Color) = (1,1,1,1)
         _SpecInt ("Specular Intensity", Float) = 1.0
         _Shininess ("Specular Sharpness", Range(2.0,8.0)) = 4.0
         _Fresnel ("Specular Fresnel", Range(0.0,1.0)) = 0.0        
         _MainTex ("Diffuse(RGB) Alpha(A)", 2D) = "white" {}
         _SpecTex ("Specular(RGB) Gloss(A)", 2D) = "white" {}
         _BumpMap ("Normalmap", 2D)     = "bump" {}
         
         _SubdermisColor ("Subdermis Color", Color) = (1,1,1,1)
         _Subdermis ("Subdermis", Range(0.0,1.0)) = 1.0
         _SubdermisTex("Subdermis(RGB) Skin Mask(A)", 2D) = "white" {}
 
         _TranslucencyColor ("Translucency Color", Color) = (1,0.5,0.4,1)
         _Translucency ("Translucency", Range(0.0,1.0)) = 0.0
         _TranslucencySky ("Sky Translucency", Range(0.0,1.0)) = 0.0
         _TranslucencyMap ("Translucency Map", 2D) = "white" {}
 
         _FuzzColor    ("Fuzz Color", Color) = (1,1,1,1)
         _Fuzz        ("Fuzz", Range(0.0,1.0)) = 0.0
         _FuzzScatter ("Fuzz Scatter", Range(0.0,1.0)) = 1.0
         _FuzzOcc     ("Fuzz Occlusion", Range(0.5,1.0)) = 0.5
         
         _Aniso        ("Anisotropy", Range(0.0,1.0)) = 0.0
         _AnisoDir    ("Anisotropy Direction", Range(0.0,180.0)) = 0.0
         
         _Cutoff        ("Shadow Cutoff", Range(0.0,1.0)) = 0.3
         
         //slots for custom lighting cubemaps
         
     }
     
     SubShader {
         
         Ztest Less
             Blend SrcAlpha OneMinusSrcAlpha
         Tags {
             "Queue"="Transparent"
             "RenderType"="Transparent"
             "IgnoreProjector"="True"
         }
         LOD 400
         //diffuse LOD 200
         //diffuse-spec LOD 250
         //bumped-diffuse, spec 350
         //bumped-spec 400
         
         //mac stuff
         CGPROGRAM
         #ifdef SHADER_API_OPENGL
             #pragma glsl
         #endif
                 
         #pragma target 3.0
         #pragma exclude_renderers flash
         #pragma surface MarmosetSkinSurf MarmosetSkinDirect vertex:MarmosetSkinVert noambient alpha:fade
                 
         #pragma multi_compile MARMO_BOX_PROJECTION_OFF MARMO_BOX_PROJECTION_ON
         #if MARMO_BOX_PROJECTION_ON    
             #define MARMO_BOX_PROJECTION
         #endif
         
         #pragma multi_compile MARMO_SKY_BLEND_OFF MARMO_SKY_BLEND_ON
         
         #if MARMO_SKY_BLEND_ON
             #define MARMO_SKY_BLEND
         #endif
         
         #define MARMO_HQ
         #define MARMO_SKY_ROTATION
         #define MARMO_DIFFUSE_IBL
         #define MARMO_SPECULAR_IBL
         #define MARMO_DIFFUSE_DIRECT
         #define MARMO_SPECULAR_DIRECT        
         #define MARMO_NORMALMAP
         #define MARMO_MIP_GLOSS
         
         #define MARMO_SUBDERMIS_MAP
         #define MARMO_TRANSLUCENCY_MAP
         #define MARMO_SPECULAR_ANISO
         #define MARMO_TRANSLUCENCY_DIRECT
         #define MARMO_TRANSLUCENCY_IBL
         
         #define MARMO_SKIN_IBL
         #define MARMO_SKIN_DIRECT
         //#define MARMO_SPECULAR_FILTER
         //#define MARMO_DIFFUSE_SPECULAR_COMBINED
                 
         #define MARMO_ALPHA
         //#define MARMO_GLOW
         //#define MARMO_PREMULT_ALPHA
         //#define MARMO_OCCLUSION
         //#define MARMO_VERTEX_OCCLUSION
         //#define MARMO_VERTEX_COLOR        
                         
         #include "../../MarmosetCore.cginc"
         #include "MarmosetSkinInput.cginc"
         #include "MarmosetSkin.cginc"
 
         ENDCG
     }
     
     SubShader {
         Blend SrcAlpha OneMinusSrcAlpha
         Tags {
             "Queue"="Transparent"
             "RenderType"="Transparent"
             "IgnoreProjector"="True"
         }
         LOD 400
         //diffuse LOD 200
         //diffuse-spec LOD 250
         //bumped-diffuse, spec 350
         //bumped-spec 400
         
         //mac stuff
         CGPROGRAM
         #ifdef SHADER_API_OPENGL
             #pragma glsl
         #endif
                 
         #pragma target 3.0
         #pragma only_renderers gles gles3 metal d3d11_9x
         #pragma surface MarmosetSkinSurf MarmosetSkinDirect vertex:MarmosetSkinVert noambient alpha:fade
                 
         #pragma multi_compile MARMO_BOX_PROJECTION_OFF MARMO_BOX_PROJECTION_ON
         #if MARMO_BOX_PROJECTION_ON    
             #define MARMO_BOX_PROJECTION
         #endif
         
         #pragma multi_compile MARMO_SKY_BLEND_OFF MARMO_SKY_BLEND_ON
         
         #if MARMO_SKY_BLEND_ON
             #define MARMO_SKY_BLEND
         #endif
         
         #define MARMO_HQ
         #define MARMO_SKY_ROTATION
         #define MARMO_DIFFUSE_IBL
         #define MARMO_SPECULAR_IBL
         #define MARMO_DIFFUSE_DIRECT
         #define MARMO_SPECULAR_DIRECT        
         #define MARMO_NORMALMAP
         //#define MARMO_MIP_GLOSS
         
         #define MARMO_SUBDERMIS_MAP
         #define MARMO_TRANSLUCENCY_MAP
         #define MARMO_SPECULAR_ANISO
         #define MARMO_TRANSLUCENCY_DIRECT
         #define MARMO_TRANSLUCENCY_IBL
         
         #define MARMO_SKIN_IBL
         #define MARMO_SKIN_DIRECT
         //#define MARMO_SPECULAR_FILTER
         //#define MARMO_DIFFUSE_SPECULAR_COMBINED
                 
         #define MARMO_ALPHA
         //#define MARMO_GLOW
         //#define MARMO_PREMULT_ALPHA
         //#define MARMO_OCCLUSION
         //#define MARMO_VERTEX_OCCLUSION
         //#define MARMO_VERTEX_COLOR        
                         
         #include "../../MarmosetCore.cginc"
         #include "MarmosetSkinInput.cginc"
         #include "MarmosetSkin.cginc"
 
         ENDCG
     }
     
     FallBack "Transparent/Cutout/Bumped Specular"
 }
 

I checked some other objects (the skin is a high-polygon model compared to some smaller bones), but they all give the same strange "artifacts". Is this issue due to bad structures/textures or something I can change in the script?

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

39 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

Related Questions

Changing sprite alpha on all prefab clones 0 Answers

Unity 5 standard shader transparency not working on mobile 0 Answers

(using shader blending to) remove white background from an image at runtime 3 Answers

Imported material with texture transparency 0 Answers

Two transperent object overlapping problem! 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