Author Topic: Updated 9/16/16 Material Coding for Beginners! Glow, metal, transparent, more!  (Read 99119 times)

Offline Ruby1234

  • Mean Tutorial Queen
  • Hero Member
  • *****
  • Posts: 2,751
  • Country: us
  • Floof-O-Meter: 297
  • Je te vois.
    • View Profile
The lion preset
used in this tutorial
came with FH and
does not belong to me,
nor do I claim it as mine.

Yay, time for fun. Well I find this fun anyways, no guarantee you will.
Anyhow, I'm going to be showin' ya a few things about material codes. You know, those things that are found in the presets folders? If you dun know what materials are, you probably shouldn't be here. :3

Kayso, if I dun do a code that you want, you can request one as a comment or PM.
So let's get right to it~

The codes for Preset Mane Fix and Scrolling are located here in the first post. All other codes will be linked below:
How to: Add Wings to Your Preset (Works with all presets, not just 11 & 12)
Ghost Code
Glow & Shading (Emissive & Ambient - Does not cover glowing markings.)
Metallic Markings
Transparent & Semi-Transparent
Glowing Markings

Preset Mane Fix
-The first thing I'm going to start off with is the mane fix for presets, since this seems difficult for people to find. You only need this code if you're using anything but the fluffy mane.

Go to your preset's material file, open it in notepad.
Scroll down to the mane code (should be the very bottom, and should read something like this:)

Code: [Select]
material preset_#_maneMat
{
technique
{
pass
{
lighting off
cull_hardware none
cull_software none
scene_blend alpha_blend
depth_write off
texture_unit
{
texture preset_#mane.png
}
}
}
}

Now all you do is select that section, copy this:

Code: [Select]
material preset_#_maneMat
{
        technique
        {
                pass
                {
                        cull_hardware none
                        cull_software none
                        alpha_rejection greater_equal 128
                        texture_unit
                        {
                                texture preset_#mane.png
                        }
                }
        }
}

and paste this over the previous selection. Then look for the # signs in the code, and replace it with the preset's number, which is found in the name of that preset's files. If done correctly, you would be going from this:


to this:



_______________________________________

Scrolling
-This works for meshes and presets, and this just makes the texture flow across the entire thing, or, if you wanted, you could restrict the flow to a certain spot, and have it be a certain color. For this example, and all examples to follow, I will be using presets. Let's get started.

Go to your material file, and open it in notepad.
You'll have the basic codes, which look something like this:

Code: [Select]
material preset_#_bodyMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#body.png
}
}
}
}
material preset_#_bodyMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#body.png
}
}
}
}
material preset_#_headMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#head.png
}
}
}
}
material preset_#_headMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#head.png
}
}
}
}
material preset_#_eyeMatL
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.png
}
}
}
}
material preset_#_eyeMatR
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.png
}
}
}
}
material preset_#_tailMat
{
technique
{
pass
{
texture_unit
{
texture preset_#tail.png
}
}
}
}
material preset_#_maneMat
{
technique
{
pass
{
cull_hardware none
cull_software none
alpha_rejection greater_equal 128
texture_unit
{
texture preset_#mane.png
}
}
}
}

I recommend that, like this code above, you change all your image formats to .png. It's just easier to work with materials that way.
Now, to get your textures to scroll, all you need to do is add the line:
scroll_anim 1.0 1.0
underneath the texture names, like so:

Code: [Select]
material preset_#_bodyMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#body.png
scroll_anim 1.0 1.0
}
}
}
}
material preset_#_bodyMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#body.png
scroll_anim 1.0 1.0
}
}
}
}
material preset_#_headMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#head.png
scroll_anim 1.0 1.0
}
}
}
}
material preset_#_headMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#head.png
scroll_anim 1.0 1.0
}
}
}
}
material preset_#_eyeMatL
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.png
scroll_anim 1.0 1.0
}
}
}
}
material preset_#_eyeMatR
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.png
scroll_anim 1.0 1.0
}
}
}
}
material preset_#_tailMat
{
technique
{
pass
{
texture_unit
{
texture preset_#tail.png
scroll_anim 1.0 1.0
}
}
}
}
material preset_#_maneMat
{
technique
{
pass
{
cull_hardware none
cull_software none
alpha_rejection greater_equal 128
texture_unit
{
texture preset_#mane.png
scroll_anim 1.0 1.0
}
}
}
}

Now, this will probably create a very weird looking preset, but might be okay on a mesh.
However, you can choose to restrict the flow, and have it be any texture you want. How you ask? Well, by layering it of course! Now, if you've ever tried to make layers on an image and use it in FH, it probably didn't work all that well. However, it is possible to layer images onto presets/meshes, using the material coding:



Let's get started.

Open your material and start with the basic coding again, but with .png formats again also.

Code: [Select]
material preset_#_bodyMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#body.png
}
}
}
}
material preset_#_bodyMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#body.png
}
}
}
}
material preset_#_headMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#head.png
}
}
}
}
material preset_#_headMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#head.png
}
}
}
}
material preset_#_eyeMatL
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.png
}
}
}
}
material preset_#_eyeMatR
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.png
}
}
}
}
material preset_#_tailMat
{
technique
{
pass
{
texture_unit
{
texture preset_#tail.png
}
}
}
}
material preset_#_maneMat
{
technique
{
pass
{
cull_hardware none
cull_software none
alpha_rejection greater_equal 128
texture_unit
{
texture preset_#mane.png
}
}
}
}

Now, we'll need two textures here.
1, your preset's actual texture:



and 2, the texture that will be scrolling. Normally, one picks a gradient to be scrolling, like my preset above:



Get your two textures and then come back.




Back? Okie.
Well, I'mma have to send you away again real quick. What you need to do now, is get your preset's actual texture, and take your /eraser/ tool, to make the markings, the place where you want the scrollyness to go. :3



So go do that if you dun have it done.




Back again? Okay.
Now it's time to layer it in with the coding.
Go to your code, and replace it with this one:

Code: [Select]
material preset_#_bodyMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#scroll.png
scroll_anim 1.0 1.0
}
}
pass
{
scene_blend alpha_blend
texture_unit
{
texture preset_#body.png
}
}
}
}
material preset_#_bodyMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#scroll.png
scroll_anim 1.0 1.0
}
}
pass
{
scene_blend alpha_blend
texture_unit
{
texture preset_#body.png
}
}
}
}
material preset_#_headMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#scroll.png
scroll_anim 1.0 1.0
}
}
pass
{
scene_blend alpha_blend
texture_unit
{
texture preset_#head.png
}
}
}
}
material preset_#_headMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#scroll.png
scroll_anim 1.0 1.0
}
}
pass
{
scene_blend alpha_blend
texture_unit
{
texture preset_#head.png
}
}
}
}
material preset_#_eyeMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#scroll.png
scroll_anim 1.0 1.0
}
}
pass
{
scene_blend alpha_blend
texture_unit
{
texture preset_#eye.png
}
}
}
}
material preset_#_eyeMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#scroll.png
scroll_anim 1.0 1.0
}
}
pass
{
scene_blend alpha_blend
texture_unit
{
texture preset_#eye.png
}
}
}
}
material preset_#_tailMat
{
technique
{
pass
{
texture_unit
{
texture preset_#scroll.png
scroll_anim 1.0 1.0
}
}
pass
{
scene_blend alpha_blend
texture_unit
{
texture preset_#tail.png
}
}
}
}
material preset_#_maneMat
{
technique
{
pass
{
cull_hardware none
cull_software none
alpha_rejection greater_equal 128
texture_unit
{
texture preset_#mane.png
scroll_anim 1.0 1.0
}
}
}
}

Now in notepad press Ctrl+H and it'll come up with replace (or just do Edit>Replace..)
and type in
_#
in the first box, then in the second type
_
and then after the underscore, put the number of your preset.
Then click replace all.
Now you may need to do some manual editing with the image names, because you might not have selected the same names as me.
But once you have everything pieced together, you should end up with a pretty nice result. :3


(Sorry, it came out low quality for some reason, I'll redo it later. xD)

Now, the line
scroll_anim 1.0 1.0
can be edited.
The numbers can be changed to even negative integers.
Just to create some other effects. :3
« Last Edit: July 29, 2017, 08:35:23 pm by Ruby1234 »

Offline animals_rock

  • Experienced Member
  • **
  • Posts: 160
  • Floof-O-Meter: 19
  • Lilly teh Lioness
    • View Profile
Re: Material Codes for You! (Makes effects on your Preset and/or Meshes!)
« Reply #1 on: August 25, 2012, 03:04:24 pm »
Thanks for posting this. This will be very helpful c:
Call me Lilly or Animal or Animals or Lillyfloof...I dun really care o3o Call me whatever you want... .3.

dA: Lacey186
Youtube: Lacey186
Skype: Lacey186
oovoo: Lacey186
Siggy made by the wonderful Nair~

Offline Ruby1234

  • Mean Tutorial Queen
  • Hero Member
  • *****
  • Posts: 2,751
  • Country: us
  • Floof-O-Meter: 297
  • Je te vois.
    • View Profile
Re: Material Codes for You! (Makes effects on your Preset and/or Meshes!)
« Reply #2 on: August 25, 2012, 03:06:25 pm »
Thanks for posting this. This will be very helpful c:

You're welcome and thanks! :3

Offline greystar

  • Experienced Member
  • **
  • Posts: 238
  • Country: 00
  • Floof-O-Meter: 24
  • hhhahahahahhhh...
    • Greystar2000
    • Quinnbee-s
    • View Profile
Re: Material Codes for You! (Makes effects on your Preset and/or Meshes!)
« Reply #3 on: August 26, 2012, 01:38:26 am »
AWESOMESAUCE
      Thy SO much i was wondering how 2. Now all i need to know is how to put pics in my FH acc >_>....
Happy Pride Month!

Offline greystar

  • Experienced Member
  • **
  • Posts: 238
  • Country: 00
  • Floof-O-Meter: 24
  • hhhahahahahhhh...
    • Greystar2000
    • Quinnbee-s
    • View Profile
Re: Material Codes for You! (Makes effects on your Preset and/or Meshes!)
« Reply #4 on: August 29, 2012, 12:08:29 am »
Ok got it to work... how i make things INVISABLE? >:3
Happy Pride Month!

Offline hugrf2

  • Purple Derple
  • Elite Member
  • ****
  • Posts: 2,390
  • Country: us
  • Floof-O-Meter: 117
  • It's not a phase, son. �
    • hugrf
    • channel/UChLphw5s3-hS8EFAgnNv6FQ
    • hugrf
    • hugrf
    • Ain't nobody got time fo' dat
    • View Profile
Re: Material Codes for You! (Makes effects on your Preset and/or Meshes!)
« Reply #5 on: August 29, 2012, 08:01:06 am »
Thank you, now i can make randomized and beautiful presets, YOU ARE THANKED!  ;) Floor-O-Meter for you!  XD

Signature made by Afrus. Avatar made by Reccewolf.

Offline hugrf2

  • Purple Derple
  • Elite Member
  • ****
  • Posts: 2,390
  • Country: us
  • Floof-O-Meter: 117
  • It's not a phase, son. �
    • hugrf
    • channel/UChLphw5s3-hS8EFAgnNv6FQ
    • hugrf
    • hugrf
    • Ain't nobody got time fo' dat
    • View Profile
Re: Material Codes for You! (Makes effects on your Preset and/or Meshes!)
« Reply #6 on: August 29, 2012, 01:07:31 pm »
*Looks at preset* when i made the preset it didn't show up in-game and i followed everything and NON of the preset showed up in-game and i just edited the head to be moving or whatever!

Signature made by Afrus. Avatar made by Reccewolf.

Offline Ruby1234

  • Mean Tutorial Queen
  • Hero Member
  • *****
  • Posts: 2,751
  • Country: us
  • Floof-O-Meter: 297
  • Je te vois.
    • View Profile
Re: Material Codes for You! (Makes effects on your Preset and/or Meshes!)
« Reply #7 on: September 01, 2012, 12:43:25 pm »
PM me your material code and I'll look it over. c:

Offline Dafniforfree

  • Elder Member
  • ****
  • Posts: 1,431
  • Floof-O-Meter: 59
  • .:Let's be heros in our own destiny:.
    • View Profile
Re: Material Codes for You! (Makes effects on your Preset and/or Meshes!)
« Reply #8 on: September 01, 2012, 01:01:42 pm »
wow awesome all I needed :O

Offline Ruby1234

  • Mean Tutorial Queen
  • Hero Member
  • *****
  • Posts: 2,751
  • Country: us
  • Floof-O-Meter: 297
  • Je te vois.
    • View Profile
Re: Material Codes for You! (Preset Mane Fix / Scrolling +more soon
« Reply #9 on: September 01, 2012, 02:45:31 pm »
Ghost
-This will make your presets look semi-transparent, like a ghost!

We start with a preset.



(If you don't have a preset yet, you need one. I use preset 2 for the purpose of this tutorial, but you need your own. So go get one if you dun have one.)

Now, your preset's code probably looks something like this:
Code: [Select]
material preset_#_bodyMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#body.jpg
}
}
}
}
material preset_#_bodyMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#body.jpg
}
}
}
}
material preset_#_headMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#head.jpg
}
}
}
}
material preset_#_headMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#head.jpg
}
}
}
}
material preset_#_eyeMatL
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.jpg
}
}
}
}
material preset_#_eyeMatR
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.jpg
}
}
}
}
material preset_#_tailMat
{
technique
{
pass
{
texture_unit
{
texture preset_#tail.jpg
}
}
}
}
material preset_#_maneMat
{
technique
{
pass
{
cull_hardware none
cull_software none
alpha_rejection greater_equal 128
texture_unit
{
texture preset_#mane.png
}
}
}
}

Well, we are going to make some changes.
First thing you want to do is make a 512x512 square of any color you want. This is going to add the ghost tint to your character, so you can make it lighter or darker depending on how you want it.
This is my ghost layer:



Once you have the color you want,
name it
preset_#ghost.png
And of course change the # to your preset's actual number.

Next, we need to change the coding.
Open your preset's material file in notepad.
Select everything, and delete it.
Copy and paste this into it:
Code: [Select]
material preset_#_bodyMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#body.jpg
}
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_bodyMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#body.jpg
}
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_headMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#head.jpg
}
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_headMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#head.jpg
}
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_eyeMatL
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.jpg
}
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_eyeMatR
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.jpg
}
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_tailMat
{
technique
{
pass
{
texture_unit
{
texture preset_#tail.jpg
}
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_maneMat
{
technique
{
pass
{
cull_hardware none
cull_software none
alpha_rejection greater_equal 128
texture_unit
{
texture preset_#mane.png
}
texture_unit
{
texture preset_#ghost.png
}
}
}
}

Now press Ctrl+H, or go to Edit->Replace...
And type _# in the "Find what:" section.
Then in the "Replace with:" section, put an underscore:
_
and then put your preset's actual number after that. Then click Replace all.

Save and close that.

Open FH and look at your preset. It will have layered the color over it.



Now is the time to change the ghost.png if you don't like how the color turned out.

Once you have it the way you want it, we're doing some code replacing again! (Yay.)

Now there are two ways to do this. The first way makes it really bright, the second way makes it a little dimmer. So skip down to the one that you want, and we'll continue.

First way:



Open your preset's code in notepad and once again, erase it all,
and replace it with this:
Code: [Select]
material preset_#_bodyMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#body.jpg
}
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_bodyMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#body.jpg
}
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_headMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#head.jpg
}
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_headMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#head.jpg
}
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_eyeMatL
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.jpg
}
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_eyeMatR
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.jpg
}
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_tailMat
{
technique
{
pass
{
texture_unit
{
texture preset_#tail.jpg
}
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_maneMat
{
technique
{
pass
{
cull_hardware none
cull_software none
alpha_rejection greater_equal 128
texture_unit
{
texture preset_#mane.png
}
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}

Now repeat the replacing process:
Quote from: Me
Now press Ctrl+H, or go to Edit->Replace...
And type _# in the "Find what:" section.
Then in the "Replace with:" section, put an underscore:
_
and then put your preset's actual number after that. Then click Replace all.

Save and close and take a look ingame!


Second way:



Open your preset's code in notepad and once again, erase it all,
and replace it with this:
Code: [Select]
material preset_#_bodyMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#body.jpg
}
ambient 0.2 0.2 0.2 1
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_bodyMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#body.jpg
}
ambient 0.2 0.2 0.2 1
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_headMatL
{
technique
{
pass
{
texture_unit
{
texture preset_#head.jpg
}
ambient 0.2 0.2 0.2 1
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_headMatR
{
technique
{
pass
{
texture_unit
{
texture preset_#head.jpg
}
ambient 0.2 0.2 0.2 1
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_eyeMatL
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.jpg
}
ambient 0.2 0.2 0.2 1
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_eyeMatR
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.jpg
}
ambient 0.2 0.2 0.2 1
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_tailMat
{
technique
{
pass
{
texture_unit
{
texture preset_#tail.jpg
}
ambient 0.2 0.2 0.2 1
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_maneMat
{
technique
{
pass
{
cull_hardware none
cull_software none
alpha_rejection greater_equal 128
texture_unit
{
texture preset_#mane.png
}
ambient 0.2 0.2 0.2 1
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}

Now repeat the replacing process:
Quote from: Me
Now press Ctrl+H, or go to Edit->Replace...
And type _# in the "Find what:" section.
Then in the "Replace with:" section, put an underscore:
_
and then put your preset's actual number after that. Then click Replace all.

Save and close and take a look ingame!

One last thing,
if you don't like the teeth and eyes showing through,
we can fix that.
Replace your preset's eye texture with a 512x512 transparent square.

Then open the material file in notepad and look for the eye codes, which look like this:
Code: [Select]
material preset_#_eyeMatL
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.jpg
}
ambient 0.2 0.2 0.2 1
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}
material preset_#_eyeMatR
{
technique
{
pass
{
cull_hardware none
cull_software none
texture_unit
{
texture preset_#eye.jpg
}
ambient 0.2 0.2 0.2 1
scene_blend add
texture_unit
{
texture preset_#ghost.png
}
}
}
}

We're going to highlight those sections of the code in notepad, and replace it with this code:
Code: [Select]
material preset_#_eyeMatL
{
technique
{
pass
{
cull_hardware none
cull_software none
alpha_rejection greater_equal 128
texture_unit
{
texture preset_#eye.png
}
}
}
}material preset_#_eyeMatR
{
technique
{
pass
{
cull_hardware none
cull_software none
alpha_rejection greater_equal 128
texture_unit
{
texture preset_#eye.png
}
}
}
}
Once again, repeat the replacing process:
Quote from: Me
Now press Ctrl+H, or go to Edit->Replace...
And type _# in the "Find what:" section.
Then in the "Replace with:" section, put an underscore:
_
and then put your preset's actual number after that. Then click Replace all.

And now you should be all set.
The eyes and teeth will no longer show through. :3



And if you want, you can even draw on some eyes onto the head texture.
Lolz.
« Last Edit: July 29, 2017, 08:42:07 pm by Ruby1234 »