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 ChrisVranos · Sep 05, 2016 at 09:27 AM · shaders

Is it possible to pair an animated normal map image sequence to a diffuse sprite sequence?

alt text

I have about a dozen separate animations for this character, baked out to several image sequences. The animation is a dirty mix of 3D and 2D, so importing a 3D model and lighting it is not an option. To light him dynamically, I have to use normal maps on 2D sequences.

The problem is, I can't figure out how to get my normal map sequence to animate along with my main sequence. I can't use a sprite sheet, there are too many hundreds of frames, and too many animations.

You can see below how the shader is setup, the sprite sequence works as expected, playing through the animation, and changing as controls are input, but the normal map is only accepting a single image of a single animation. I've managed to create a string that gives the name I need: for example "WalkAnimation_NormalMap_0057.png" under "void Update". So I have the name of the normal map I need at any given time as a string. But I can't figure out how to use that string to load in the correct normal map on that frame.

10 years After Effects 5 years Cinema 4D 6 weeks Unity

Sorry if I appear clueless, because I am. Thanks for your feedback.

alt text

1.png (41.5 kB)
inunity.png (318.1 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ChrisVranos · Sep 06, 2016 at 06:19 AM

One step closer. I figured out how to load the images of a single sequence, just the character's idle animation. The problem is I'm calling the map by the integer of the array containing the idle normal maps inside my resources folder. I need to figure out how to load the correct animations too, as well as the correct index.

Kinda a cool effect though, right?

https://www.dropbox.com/sh/960s47okaif6pau/AACvG_2CkU92XH0NqXIJ7AyEa?dl=0⪯view=ScreenCaptureProject1.mp4

 using UnityEngine;
 using System.Collections;
 using System.IO;
 
 public class HopperShaderConnections : MonoBehaviour {
 
 
     private Texture imageofsprite;
     private Texture MainTex;
     Material mat;
     string animationName;
     string frameNumber;
     string NormalsName;
     Texture currentNormalMap;
     Texture2D[] _typedTextures;
     int _displayed = 0;
     public string _idle_normal_path;
     int index_of_idle_normal_seq;
 
 
         void Start () {
             Object[] textures = Resources.LoadAll(_idle_normal_path, typeof(Texture2D));
             _typedTextures = new Texture2D[textures.Length];
             for (int i = 0; i < textures.Length; i++){
                 _typedTextures[i] = (Texture2D)textures[i];
             }
         Debug.Log("Textures Loaded: " + _typedTextures.Length);
 
         }
     
     void Update () {
         imageofsprite = gameObject.GetComponent<SpriteRenderer> ().sprite.texture;
         frameNumber = imageofsprite.name.Substring (imageofsprite.name.Length - 4, 4);
         animationName = imageofsprite.name.Substring (0, imageofsprite.name.Length - 4);
         NormalsName = animationName + "Normal_" + frameNumber;
         index_of_idle_normal_seq = int.Parse (frameNumber);
         Debug.Log (NormalsName);
         GetComponent<Renderer>().material.SetTexture ("_BumpMap", _typedTextures[index_of_idle_normal_seq]);
 
     }
 
 
 
 
 
 
     }
 
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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Don't render an Area behind a plane 0 Answers

Mass assign shaders? 1 Answer

Combining BlinnPhong with WrapDiffuse 0 Answers

About Cg shaders and parameters 3 Answers

Android Shader Problem After Unity 3.5.1 Upgrade 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