Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Michael 12 · Apr 26, 2011 at 02:17 PM · shadereffectdisappeardeath

dissolving shader help

OK I'm trying to create a cool death effect for my "Alien Zombie". I'm using the Dissolve shader from the Wiki:

// simple "dissolving" shader by genericuser (radware.wordpress.com)
// clips materials, using an image as guidance.
// use clouds or random noise as the slice guide for best results.
  Shader "Custom Shaders/Dissolving" {
    Properties {
      _MainTex ("Texture (RGB)", 2D) = "white" {}
      _SliceGuide ("Slice Guide (RGB)", 2D) = "white" {}
      _SliceAmount ("Slice Amount", Range(0.0, 1.0)) = 0.5
    }
    SubShader {
      Tags { "RenderType" = "Opaque" }
      Cull Off
      CGPROGRAM
      //if you're not planning on using shadows, remove "addshadow" for better performance
      #pragma surface surf Lambert addshadow
      struct Input {
          float2 uv_MainTex;
          float2 uv_SliceGuide;
          float _SliceAmount;
      };
      sampler2D _MainTex;
      sampler2D _SliceGuide;
      float _SliceAmount;
      void surf (Input IN, inout SurfaceOutput o) {
          clip(tex2D (_SliceGuide, IN.uv_SliceGuide).rgb - _SliceAmount);
          o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
      }
      ENDCG
    } 
    Fallback "Diffuse"
  }

I have it as a material on my "Alien Zombie" dead replacement... but it dissolves too quickly! Is there a way to slow the dissolve and delay it so it only dissolves a certain amount of time after the body has dropped to the ground?

And secondly how can I make it look sort of like the old TV series "The Invaders" when those alien died? And then destroy my dead alien body a short time after that?

I think on the destroy my dead alien I can just use a wait for seconds, but the rest I've got no clue how to do... has anyone done a cool effect like this and if so how did you do it?

EDIT here is where I keep trying to make my adjustment to slow the effect down but nothing happens?

Shader "Custom Shaders/Dissolving" {
    Properties {
      _MainTex ("Texture (RGB)", 2D) = "white" {}
      _SliceGuide ("Slice Guide (RGB)", 2D) = "white" {}
      _SliceAmount ("Slice Amount", Range(0.0, 1.0)) = 0.5
    }

There is clearly some part to this I'm missing... Is there not a DETAILED tutorial on this stuff anywhere??

EDIT 03

I see sort of where I'm going wrong. I added a new script to my "Dead Replacement Alien Zombie":

function Start () { // Use the Glossy shader on the material renderer.material.shader = Shader.Find(" ZombieAlienDissolveMaterial"); }

function Update () { // Dissolve renderer.material.SetFloat( "_SliceAmount", 0.5 + Mathf.Sin(Time.time)*12 ); yield WaitForSeconds(12); Destroy(gameObject);

}

But it STILL is doing Jack!?!

EDIT 04

Ok let's try again... I'm trying this and it's STILL NOT WORKING!!

function Start () { // Use the Glossy shader on the material renderer.material.shader = Shader.Find(" ZombieAlienDissolveMaterial"); }

function Update () { // Dissolve renderer.material.SetFloat( "_SliceAmount", 0.0 + Mathf.Sin(Time.time)*1 );

}

function KillSelf () { yield WaitForSeconds(12); Destroy(gameObject);

}

Like I say is there not a DETAILED tutorial on this anywhere, something step by step!

EDIT 05

I set up a new Zombie Alien Ragdoll prefab and gave it this script:

function Start () { // Use the Glossy shader on the material renderer.material.shader = Shader.Find("ZombieAlienDissolveMaterial"); }

function Update () { // Dissolve renderer.material.SetFloat( "_SliceAmount", 0.9 + Mathf.Sin(Time.time)*1 );

}

The Dissolve shader is attached to the "Body" of my Ragdoll (dead replacement) What hapens when I shoot my Alien Zombie is that his dead replacement shows up Bright Pink and the Dissolve material is NOT working.

I conducted a test where I just dragged into my scene a ragdoll with the Dissolve shader and the above attached script and when I play the game (test) in the inspector I can select my custom Dissolve Shader and it works, it dissolves in and out, I only want it to dissolve out but it also says it's a "Shader Instance??"

How do I fix this so that when I shoot my alien Zombies they're Dead Replacements/ragdolls Dissolve out?

Comment
Add comment · Show 13
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 flaviusxvii · Apr 26, 2011 at 06:55 PM 0
Share

I amended my answer with a link to what you need.

avatar image flaviusxvii · Apr 26, 2011 at 07:46 PM 0
Share
    • $$anonymous$$athf.Sin(Time.time)*12 <-- This will produce values in the range -11.5 to 12.5.. you want 0 to 1.

Also, you don't want to set the value once, wait 12 seconds, and then destroy the object. You won't see anything change that way. Why on Earth would you use 'yield' here?

avatar image flaviusxvii · Apr 26, 2011 at 07:49 PM 0
Share
  • From the docs "Note that you can't use yield from within Update"

http://unity3d.com/support/documentation/ScriptReference/index.Coroutines_26_Yield.html

avatar image Michael 12 · Apr 26, 2011 at 08:08 PM 0
Share

I'm trying to use Yield because after it's done desolving I naturally want to remove my dead alien zombie from the scene. So how do I do that with what I have here?

avatar image flaviusxvii · Apr 26, 2011 at 08:30 PM 0
Share

Shader.Find(" ZombieAlienDissolve$$anonymous$$aterial"); The leading space before "Zombie" might be an issue. If the compiler complaining? Are you getting any error messages? Have you chosen a good _SliceGuide?

Your yield+Destroy would make more sense it it was at the end of your Start function.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by flaviusxvii · Apr 26, 2011 at 02:25 PM

You control the rate of Di*ss*olve with the _SliceAmount parameter in the shader. Slow that down and you'll slow the effect.

http://unity3d.com/support/documentation/ScriptReference/Material.SetFloat.html

You've been setting a hard-coded value in your shader that gets compiled in and never changes.

You'll need to do something LIKE: renderer.material.SetFloat( "_SliceAmount", amount );

Comment
Add comment · Show 4 · 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 Michael 12 · Apr 26, 2011 at 03:58 PM 0
Share

I tried adjusting those numbers and it just starts the material off at whatever those setting are, there does NOT seem to be a nice slow disolve effect???

avatar image flaviusxvii · Apr 26, 2011 at 05:49 PM 0
Share

_SliceAmount must CHANGE OVER TI$$anonymous$$$$anonymous$$ Over the course of N seconds it should traverse a series of values to render the object increasingly more dissolved.

And since my hint was too subtle. Dissolve is spelled with two 's'sss. DisSolve.

avatar image Michael 12 · Apr 26, 2011 at 05:57 PM 0
Share

Thanks for the grammer lesson but I'm clearly missing something else because it's still not working no matter how much I adjust that slider or change the values in the shader intself!?!

avatar image flaviusxvii · Apr 26, 2011 at 06:03 PM 0
Share

Post the snipped of code where you adjust the _SliceAmount.

avatar image
0

Answer by Rispat-Momit · Dec 03, 2020 at 08:06 PM

Hi mate!

I got into the same trouble. The solution is even more simple. Here is an example code:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class DissolveMyMaterial: MonoBehaviour {
 
 
     public bool Disolve;
     public Renderer MyRend;
 
 
 void Start(){
 
 MyRend.material.shader = Shader.Find ("MyShader");
 
 
  
 }    
 
 void Update(){
 
  
 if (Disolve == true) {
 
     DisolveSpeed  += 1f*Time.deltaTime;
 
 MyRend.material.SetFloat("_Dis", DisolveSpeed);
 
         }
 
     }
 }
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

1 Person is following this question.

avatar image

Related Questions

Cooldown effect in GUI 0 Answers

Tracing in Unity3D 2 Answers

How to blend colors from two texture maps in VFX graph 1 Answer

How to achieve Assasins Creed fragmented shader effect? 0 Answers

A brush stroke 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