Custom Material Shader shading model for lighting calculation adjustment

I’m looking for information on creating custom lighting modulation on a material.

My goal is to create partially non-pbr material shader that affects how the lighting is rendered on that material. In short, I want the lighting to ignore surface normal direction when determining rendered brightness. I then want to make it an option inside the material editor’s Shading model list.


Here’s the problem I’m looking to solve in more detail. I will note I’m using some terms that are more offline renderer oriented so they may not be accurate in unreal, but I think they get the general idea:

Raw Lighting
First let me describe the part of the rendering I’m trying to modify. On a material level there is the diffuse lighting step. As I understand it, there is raw direct lighting and raw global illumination that hold the diffuse lighting without material information. These two are added together into a element called “Raw Total Lighting.” This is then multiplied by the diffuse channel on the material. This combined pass would be referred to as the total lighting element. This is then added to the rest of the rendering elements to create the final image.

I want to focus on modifying how the lighting works before it’s multiplied by the diffuse information.

This is essentially the “lighting only” view mode in the viewport.

Shading model and Normals
For direct lighting, The default lit shading model uses the polygon’s normal relative to the light source to determine how bright a pixel appears in the raw lighting. I want to stop this behavior. I instead want the light’s brightness unmodulated by the normal direction. I still want all the light information, such as color, falloff, soft cone edges shadows, all that can still work as intended.

While I do not want the shading model to modulate brightness by angle, I do still want the normal to influence the lighting in two ways.

  1. Use vertex or normal maps to determine if a pixel is facing “away” from the light source.
  2. Use the normal relative to the light to create stylized colorization at oblique angles. (Fresnel from light source direction, not the camera)

GI
I feel like the solution I have in mind should would also carry over to how indirect lighting is applied. If it doesn’t I’d like to find information on how to access the volumetric light map, or at least change how it applies to the material so that it doesn’t take normal direction on the surface into account. Ideally it would blend linearly between those voxels. Just not sure how to access this information.


I’ve looked around to see if anything relevant has been requested, but I’ve not yet found anything that would help. This thread appears to mostly be talking about other types of functions unrelated to lighting or GI. There are a number of post-process materials that don’t really fit the requirements.

Any ideas where to look for information? Or thoughts on how reasonable this is to implement? I assume I’ll need to make a custom fork of unreal, not really sure how that process works yet.

2 Likes

You ever get anywhere with this? I’ve been having troubles with Unreal’s rigid rendering pipeline as well. I got to a point where I was creating my own system entirely via unlit materials, functions, and my own actors. Things would be much easier if we had an accessible scriptable rendering pipeline like unity does.