Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LabPBR Resource Pack Support/Improvement #431

Closed
1 task done
TheoBearDB opened this issue Jun 17, 2023 · 7 comments · May be fixed by #600
Closed
1 task done

LabPBR Resource Pack Support/Improvement #431

TheoBearDB opened this issue Jun 17, 2023 · 7 comments · May be fixed by #600
Labels
enhancement Feature requests or new functionality suggestions

Comments

@TheoBearDB
Copy link

Check against existing requests

  • I have checked existing feature requests, and my idea is different

Describe the context

Overview

I've done quite a bit of research into LabPBR's material standard, and how to implement that properly into Blender for LabPBR resource packs. I've been able to implement a lot of these materials properly, but some are still a bit of a mystery to me and it would be great to have this option included with Specular and SEUS.

Also, this is similar to #78, but I don't think that the extra options for LabPBR have been implemented correctly.

LabPBR packs support the following features:

  • Porosity (Wetness)
  • Subsurface Scattering
  • Emission
  • Ambient Occlusion
  • Parallax Occlusion Mapping
  • Hardcoded Metals

LabPBR uses packed color/alpha channels on both the Specular and Normal textures to achieve all of these different effects. Most of the values are stored linearly from 0-255, which can create an issue when trying to translate them to a Principled BSDF shader. In my own time, I believe I've found the appropriate way to implement them, but there are a few that I'm a bit unsure of and could use some assistance in assuring they're correctly done.

For ease, I'll describe how LabPBR does this on each texture, and what channels/values represent what!

Textures

For most of these, the values are stored linearly from 0-255. We don't want those values to be translated directly in Blender, as that could leave us open to some issues, so we'll need to create a Map Range node for each value range and their corresponding input on the Principled BSDF shader.

Specular Texture

Red Channel

ShaderLABS describes the Red channel as being "perceptual" smoothness, and stores the values of 0 being fully rough, and 255 being fully smooth. This can easily translate to the Roughness input.

Green Channel

  • Values 0-228 represent "F0" or "Reflectance". This could go to either the Specular input, or in my opinion, the Clearcoat input.
  • Values 229-255 are reserved for the different types of metal in Minecraft. This cannot translate to the "Metallic" input in Blender, as the different values here are set in the resource pack to other values that the pack can reference for the specific metal that it's assigned to. The table they use is listed here: https://wiki.shaderlabs.org/wiki/LabPBR_Material_Standard#How_metals_work
  • I'm a bit unsure of how exactly to translate these to Blender.

Blue Channel

  • 0-64 is set for "Porosity". As far as I can tell, this is simply how wet an object looks.
  • 65-255 is for Subsurface Scattering. This can be plugged directly into the Subsurface amount input.

Alpha Channel

  • Alpha is used for Emission. It uses values 0-254 with 0 being not emissive at all, and 254 being fully emissive. This can go directly into the Emission Strength input.

Normal Texture

The normal texture is a bit different, as it uses the Red and Green channel for X and Y values for the normal calculation. These can be combined into the Normal input, but we still have the Blue and Alpha channels.

Blue Channel

  • This is used for Ambient Occlusion, and is stored linearly through values 0-255, with 0 using 100% AO and 255 being 0% AO. This can be combined into a Hue/Saturation node along with the diffuse texture to fake AO on the material.

Alpha Channel

  • This is used as a Height Map in Minecraft, specifically for Parallax Occlusion Mapping. While POM can be done in Blender, since this is in essence a black and white map, it can be used for bump mapping, or even displacement. It can be plugged directly into the Height input of either a Bump node or a Displacement node.
  • Uses values 0-255, with 0 being 25% depth.

How do you imagine your feature works?

If an option is given for LabPBR when prepping materials, it'd have the option for the different channels and to implement them properly in the shader nodes for each different block using the specified values. This will require quite a bit of testing to ensure they are represented properly from how the resource pack created them.

What existing workaround (or closest thing to a workaround) do you have today (within Blender, MCprep, or any software)? If there is no workaround, explain why you feel this way.

Blender Implementation

For implementing these textures in Blender, and assuring their values are assigned correctly, I've created the following using the Hardtop VanillaAccurate 32x Resourcepack as an example. It utilizes all of the features of LabPBR 1.2+ packs:

image

The following is a rough and quick render I did of the block that uses this setup:

image

However, I'm not sure if these are done correctly, or if there is a better way of doing so. I like to maintain as much creative control as possible with my projects, so I believe I've set this up in the proper way while still allowing control, but some things feel off.

I did create this other shader node setup as well that I personally think looks much better, but it doesn't quite use all of the available information that comes with the textures, and I let Cycles handle a lot of the legwork. Though, this is specific to the style I want to go for in my renders/animations, so take it with a grain of salt. I put it into a group to make it easier to plug into new materials:

image

And a render of what it looks like:

image

This is most likely not accurate to how the resource pack looks in Minecraft with shaders, but it's about the best I've been able to do so far and achieve the look that I want. Hopefully this can help in implementing this, and give a good idea on how to approach this.

@TheoBearDB TheoBearDB added the enhancement Feature requests or new functionality suggestions label Jun 17, 2023
@StandingPadAnimations StandingPadAnimations added the first good contribution This issue makes a good first submission for someone looking to contribute to MCprep label Jun 17, 2023
@StandingPadAnimations
Copy link
Collaborator

StandingPadAnimations commented Jun 17, 2023

I think MCprep would benefit from better LabPBR support. Right now however, we're spread pretty thin, so I've added this as a First Good Contribution for any developers who want to take the challenge

@TheoBearDB
Copy link
Author

I'll continue looking into this myself as well! :)

@StandingPadAnimations
Copy link
Collaborator

Looking into this further, this should be possible with #274, with some extensions

@StandingPadAnimations StandingPadAnimations removed the first good contribution This issue makes a good first submission for someone looking to contribute to MCprep label Jun 25, 2023
@StandingPadAnimations
Copy link
Collaborator

StandingPadAnimations commented Oct 28, 2023

So I've tried to port your setup to Blender 4.0 and... let's just say things look weird (tested with VanillaPBR):
image
image

Everything basically becomes glossy, and I'm not sure why. This is with a partial port based on the options I have in the new Principled V2 shader:
image

@StandingPadAnimations
Copy link
Collaborator

Turns out I was missing a map (I'm using the fork I mentioned in #274 (comment)), using a different resource pack works

@StandingPadAnimations
Copy link
Collaborator

One thing I did notice on the LabPBR spec is that the red channel for the specular map doesn't represent linear roughness, it represents “perceptual smoothness”. Thus, conversion is needed, which according to the documentation can be done with the following expression (they use a some function syntax, but I prefer actual math syntax):
$$(1 - p)^2$$

@StandingPadAnimations
Copy link
Collaborator

Closing as superseded by #600, which implements a template based material system (and thus covers this as well). Note that this new system however is planned for MCprep 4.0 (which is a ways away)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests or new functionality suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants