Create a scrolling material effect


#1

Hey everybody!

Just a quick trick… if you’re coming from Unity and wish you had something like the Scrolling UV Shader, here’s how you can do it…

A lot of folks have asked about ways to create materials which scroll and move around… if you would like something like a moving river or magical scrolling pants on your avatar, you just need to create a material with a script to move its UVs and UV scale… and then you make the material a child of the mesh… Personally I feel it is easiest to parent a material to a mesh by just copying the ID of the target mesh, and pasting it in the parent ID box of the material… that’ll assign the material to the target mesh.

Here’s an example I made with a simple moving water effect… to get the river-like effect where it follows the contours of the river, I’ve just extruded the faces of a box, and it will make the UVs connect… then by rotating the edges I’ve made a simple little river model which follows a path

http://hifi-content.s3.amazonaws.com/caitlyn/dev/river_animated.json

Take a look at the material file which is a child of the mesh and the entity server script… you can look at how it works in there, and be sure to check out the userdata where you can specify the texture and the scroll rate… To make it work on your avatar, instead of standard entity model, you can use this script, which will apply it to an avatar submesh. You’ll need to put in the URL to your material in the script on line 2:

http://hifi-content.s3.amazonaws.com/caitlyn/dev/animatedAvatarMaterial.js


Avatar Textures
#2

This is good, thanks for sharing. I need this for my ‘Angel Of Doom’ / ‘Pizza with bacon wings’ avatar but i do seem to be a few n00b level steps away from making this work.

The part I want to animate (on avatar) needs to be a separate submesh? Where in the script is it decided which one to apply the material to?

I need an material entity (JSON) How do i go about brewing up one of these, The docs doesn’t seem to cover this at all and i only found examples without any texture maps.

Yes I know, I am mostly flapping my arms wildly hoping to take flight, but i can see others soar, I just need a copy of ‘flying for dummies’.


#3

Hi!

Hope that helps! Let me know if you have any questions!


#4

Thank you very much, think I get it now :grinning:

the target material is set by parentMaterialName: "mat::name of FBX material here".
I was just confused as I thought the new material would apply to the whole submesh. Terminology confusion, the downfall of humanity (perhaps staring Jeff Goldblum, would watch).

I somehow missed the API reference for materials so :+1: but I have to say that the workflow of programmaticlly defining a material is not going to sit well with me, I usually push all the buttons and end up with something I never knew I wanted but now that I have seen it, it’s perfect.

I guess what I want now is a material creator app to mess around with all the values and maps and then export the material data, It would actually be much better than messing about in blender and finding it looks nothing like that in hifi.


#5

Sorry for the confusion! One material entity was originally meant to replace one material in your model. We’re actually going to add support for replacing every material at once sometime soon, hopefully.

Re: a more visual editor, you can use Create and define the maps in the materialData JSON editor, which is close to what you’re asking for, but yes, we’re also working on a material editor that’s even easier to use!