The VG Resource
Would like additional insight on BRRES shaders - Printable Version

+- The VG Resource (https://www.vg-resource.com)
+-- Forum: The Resources (https://www.vg-resource.com/forum-109.html)
+--- Forum: The Models Resource (https://www.vg-resource.com/forum-111.html)
+---- Forum: Ripping Help (https://www.vg-resource.com/forum-115.html)
+---- Thread: Would like additional insight on BRRES shaders (/thread-36187.html)



Would like additional insight on BRRES shaders - Sir Teatei Moonlight - 10-09-2019

I'm using this page as a source for how BRRES shaders work, and I think I have the major parts down, but I'm running into some things that don't make sense and would basically like a second opinion.

   

This is a standard shader that I can translate into Blender as "simple material with single texture (maybe with an alpha texture)". It interpolates from zero (black) to the texture colour based on the lighting ("raster") colour. But if that's correct, I can't understand how this could be:

   

This is a three-part shader: part one is a base colour, part two is a scrolling glow, and part three layers the two based on a mask. There are several things I don't get:
  • Part 1 interpolates from zero (black) to...the lighting colour based on the texture colour? Isn't that backwards? This part is known to have the same appearance as the first shader in-game so this doesn't make sense.
  • What's the deal with the two constants in the top? I get where the KSel_* ones are coming from (the material calling the shader), but what's Constant3_8? (I don't get why the _Green and _Blue constants specifically are being used here, but that's not all that important.)
  • What is the alpha segment doing in parts 2 and 3? Part is looks like a simple "use texture alpha straight", but then the other parts both look like "raise alpha by 85 (on the 255 scale)" (both constants are 85 here). This doesn't seem right because it would make the material a lot more opaque than it should be on the transparent bits.

I have further confusions but will wait to see if they happen to get solved by an answer first.


RE: Would like additional insight on BRRES shaders - Sir Teatei Moonlight - 10-10-2019

After going through other shaders and doing some experiments in Blender I think I have some partial answers:
  • Interpolating from black to texture based on lighting is actually the same thing as interpolating from black to lighting based on texture. You shine a white light on a red thing and get red; you shine a red light on a white thing and get red. I don't understand the math behind it but the logic checks out. So basically, the b and c terms can be reversed to whatever makes more sense.
  • Constant3_8 is probably "constant 3/8", or 0.375. There are other constants in the order Constant1_8, Constant1_4, Constant3_8, Constant1_2... it looks suspiciously like eighth fractions, and it goes up to Constant1_1.