Explaining emissive mapping and TEVs

Started by DarkPikachu, March 19, 2019, 03:12:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

March 19, 2019, 03:12:57 PM Last Edit: August 26, 2020, 06:27:46 PM by DarkPikachu
Decided to come out of my hole on Smashboards and make a quick guide towards dealing with emissive maps.

Now note, I'm by no means an expert on TEVs (I refuse to call them shaders, because that's not what they are)
in fact, I'm really only just learning about them...
Really all I'm doing here is just basic mapping which is very easy.
Harder stuff like bloom, while possible, I'm not sure how to do.

Just recently I released a new version of my signature hack Dark Pikachu version 4.6 which makes use of a fake (constant color Intensity) emissive map to achieve this without a memory overflow:


basically how this fake map works exactly is you have the emissive map:

and the color you want it to show in the material's Constant Color 2 (basically the image functions as an alpha channel for this color)

note that Constant Color 2 is delegated by the TEV stage applying the emissive map (stage1 in this case)
in order: stage0 | stage1 | stage2 | stage3

note that stage1 was added and is completely custom

it takes the output from stage0, adds Constant Color 2 * TextureColor, and clamps the result
stage0 just applies shading to the diffuse map (untouched from the original TEV)
stages 2 and 3 are for finalization (also untouched) (not too sure how they work)

now if you want to use a REAL emissive map like this:

all you need to do is change B and C of stage1 to multiply the TextureColor by the TextureAlpha: (rather than the Constant Color by the TextureColor like the fake one does)


I couldn't use a real emissive map at original quality because it would cause a memory overflow causing the Wii to freeze,
but I WAS able to get it working by downscaling the emissive maps by 50%
but here I thought the scaling would automatically apply the size difference and upscale...
I ended up being wrong, and as such, the emissive map is repeated here:

at least it works like it's supposed to :P

now note the entire image is green (including the transparent parts), so it looks no different from the fake version
but that's where the similarities stop as the fake version can't mix colors.

if you still need a little extra info as to how TEVs actually work, basically they just iterate over each stage in order and apply the equation noted in the Output Function.

here's a rough mock-up I did to help me understand Pikachu's TEV0:

note that the values supplied below the stage() function are just best guess values for testing
there's other stuff that could be done to it, such as comparison operations, but I never really needed that

so note that OutputColor is treated as a register with a default value of 0.0
Python doesn't inherently support vectors, let alone vector maths, so this was really all I could do without writing a complex vector class.
but the operations are still the same as what I have above:
(0,1,2) + (3,4,5) = (3,5,7)
(0,1,2) * 2 = (0,2,4)

for even more detailed information, you can follow BlackJax96's old notes here:
https://forums.kc-mm.com/index.php?topic=39649.msg801235#msg801235

hopefully this helps shed some detail on a topic that's not so well covered :)

EDIT: Update!
HOOOOO BOY this one took some real effort to get working:



so for the main texture, in order to optimize it AND make it look good, I had to separate the RGB and A channels
how I did that was a CMPR image for the RGB, and an IA4 image for the alpha:
RGB + A =
and then of course overlay the RGB5A3 emissive texture to achieve the glow

the reason I used CMPR+IA4 instead of RGB5A3 is because of the bit difference on alpha
RGB4A3 only has 8 shades of alpha
IA4 has 16 shades of alpha
and of course
CMPR only has 2 shades of alpha (GIF quality alpha)

so with CMPR I actually get ~RGB565 quality with a smaller data print
add 16 shades of alpha to that and the reduced quality is almost unnoticable

as a result of this, I had to write a separate TEV to merge the channels AND overlay the emission:

TEV0 is the original emissive TEV from the full RGBA8 version
TEV3 is the new version that references the alpha map in stage0, and applies it to the RGB map in stage1 before adding the emissive map in stage2 with the finalizations in stages 3 and 4

the material layout also adds the alpha map as a texture slot:

so yeah stage0 references TexMap2, stage1 -> TexMap0, stage2 -> TexMap1
(I wanted to keep compatibility so I wouldn't have to touch the emissive stage)

so yeah, REAL emissive map fully working in Brawl
here's the hack btw if anyone wants to play with it:
https://mega.nz/#!M0ASkSAa!Vj5T4I3A92uG5XGFTj3yoQ3TKEw3L7rX7eP7JLyQwQo
as well as the full quality version:
https://mega.nz/#!l4ZnzAQA!cHOYoJ2f-dUDa9fEkeiqY-k2jlL8f4ON7YXp-Zb1yPM
and the fake version:
https://mega.nz/#!Y9gjzKab!rVwEL5KIXDFUrUEwEIZCx9rLZotL81A67Ce_sMtHmJs
hopefully these serve as some good examples to help you guys get a feel for TEVs ;)

[spoiler]Quote: Friedslick6
you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
But the coolest part was that you didn't stop working on it despite that.

Quote: Internet Explorer
you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

quote: Greg
You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

As always, you continue to impress! :D

March 20, 2019, 01:27:52 AM #2 Last Edit: August 26, 2020, 06:02:40 PM by DarkPikachu
just wanted to give a spoiler
I'm working on another revision for a real emissive map that actually works on the wii
will update the OP with the results once they work. ;)

specs and current results:
Sorry but you are not allowed to view spoiler contents.

I don't blame you if you don't want to see ;D

[spoiler]Quote: Friedslick6
you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
But the coolest part was that you didn't stop working on it despite that.

Quote: Internet Explorer
you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

quote: Greg
You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.

This is going to be extremely useful to people who have UV maps that have emissive sections. I'm putting this in my tutorial folder in my book marks in case if i forget. Though i hope one day you will get the bloom to work.

June 21, 2019, 11:40:19 AM #4 Last Edit: June 21, 2019, 11:43:00 AM by DarkPikachu
So apparently there was an issue where the word "l o s s" in my previous post was replaced by this comic:


While funny, I was left confused when my friend informed me because the comic didn't appear for me...
I had to log out or use Opera's private window to be able to see it.

The issue should be fixed now as I modified the previous post to state "reduced quality" instead of "quality l o s s".

EDIT: wow not even surrounding the word with text fixes the issue.

[spoiler]Quote: Friedslick6
you have been through a lot of hassle. I've watched every topic you posted on this, and most of them seemed to disintegrate gradually.
But the coolest part was that you didn't stop working on it despite that.

Quote: Internet Explorer
you're doing more with your life right now than probably most other people around you. You're a valuable asset to the Smash community. So yeah, you should be proud.

quote: Greg
You do have a gift which I've seen many developers use to their advantage. You can become a great coder, and with all of those ideas I think you can really build something great.