Fresnel effect to the model

@Proverse, what you are running into is that you need to create a new shader that can use the PBR textures that come with your glTF asset. The reason you don’t see any of the original textures is that you are replacing the materials with a shader that uses grey as the diffuse color. The fresnel shader you have attached is also a blinn-phong lighting model, not a PBR lighting model. We need to rework the shader a bit to accept PBR textures.

As you can see we left the vertex blocks and the fragment blocks as they were in the original shader, but replaced the Light blocks - which is blinn phong - with PBR blocks so that we match the texture format in the asset.

From there we just need to load the shader (which I did from the snippet server for ease) and clone for each mesh that needs a fresnel material. In this case you have five meshes that make up the character, so you will clone the original node material five times. Each of the new materials must have the base color, orm, and normal textures from the original materials assigned. You will see that in lines 41-61 in the playground, but an example would be:

            materials.look_0.getBlockByName("baseColorTex").texture = meshes.look_0.material.albedoTexture;
            materials.look_0.getBlockByName("ormTex").texture = meshes.look_0.material.metallicTexture;
            materials.look_0.getBlockByName("normalTex").texture = meshes.look_0.material.bumpTexture;

We are getting the texture block in the node material by name and then assigning the same texure from the original material as matches the current texture channel. One thing to note is that you have some meshes that don’t have all of the needed PBR textures to render correctly. The body mesh is missing a normal texture and both hair meshes are missing the ORM (Ambient Occlusion, Roughness, Metallic channel-packed texture). If you want these to render correctly, you will either need to add these missing textures or create alternate fresnel node materials that either skip the perturb normal blocks (in the case of a missing normal texture) or use float number factors for AO, Roughness, and Metal (in the case of a missing ORM). The missing normal will just waste calculations that don’t need to be there, but a missing ORM will look wrong as you need to assign the AO, Roughness, and Metallic values as they need to render correctly. Using a missing texture block will pass incorrect values for these parameters which will render wrong.

For ease in explaining the process, I did not create any additional node materials to handle the cases of missing textures. But you should be aware that those alterations need to be made to render as physically accurate.

Your updated playground should have everything you need to follow along with the process. But please feel free to ping back with more questions.

6 Likes