comfyUI_TJ_NormalLighting
Custom Node for comfyUI for virtual lighting based on normal map
Paketprofil
- Status
- Überprüft
- Verleger
- @TJ16th
- Quelle
- GitHub
README
※ 日本語は英文の後ろにあります
comfyUI_TJ_NormalLighting
Custom Node for comfyUI for virtual lighting based on normal map
What is this?
You can use normal maps to add virtual lighting effects to your images.
Please read first
I love technology such as XR and AI, but I'm not a programming expert. Also, this is my first time publishing my code on Github. I don't know much about Github. So if I make a mistake, please smile and forgive me.
Lighting model
This program calculates diffuse reflection based on the Lambert Reflection Model.
The Lambertian reflection model is one of the most basic models of diffuse reflection and has the following characteristics:
Assume that the surface is completely diffusive and the incident light is isotropically scattered. The intensity of the reflected light is proportional to the dot product of the intensity of the incident light, the surface normal vector, and the direction vector of the light. The intensity of reflected light does not depend on the position of the viewpoint.
In addition to diffuse reflection, we also use Phong's specular reflection model to calculate specular reflection. The inner product of the half vector (intermediate vector between the direction of the light and the direction of the camera) and the normal vector is calculated and combined with the value of the specular map to find the intensity of specular reflection.
How to use
sample01_basic.json
sample02_2lamplighting.json
sample03_Animation.json
input
Please enter 3 images. Please keep the image sizes the same.
diffuse_map: normal RGB image
normal_map: Normal image. RGB images compatible with XYZ axes
specular_map: Specular map. It's RGB. Reflected light can be colored
Parameters
Light source direction
light_yaw, light_pitch: Euler angle indicating the direction of the light source. The unit is Deg.
Strength of specular reflection
specular_power: A parameter that controls the strength of specular reflection. Physically, it expresses the smoothness and gloss of a surface.
The larger the value of specular_power, the stronger the specular reflection. Specifically, it has the following effects.
The larger the specular_power, the sharper the specular highlights. In other words, the range of highlights is narrower and you get a stronger shine. The smaller the specular_power, the more spread out the specular highlights will be. This means you get a wider range of highlights and a softer glow.
If specular_power = 1, specular reflection is the same as Lambertian reflection (fully diffuse reflection). If specular_power = 10 or so, you'll get relatively spread out highlights that look like plastic. If specular_power = 100 or so, you will get sharp highlights like metal.
The value of specular_power varies depending on the material. Commonly used values include:
Plastic: 10100
Metal: 1001000
Shiny surface: 10~1000
Matte surface: 1-10
However, these are typical values and actual values will vary depending on the material and purpose.
Output balance
ambient_light: Does not depend on the direction of the light source. If set to 1, the input diffuse_map will be output as is.
NormalDiffuseStrength:
Knoten in diesem Paket
1 Knoten
Knoten in diesem Paket
1 Knoten- EulerLightingNode
Quellen
3 Quellen
Quellen
3 QuellenVerifiziert 25. Okt.
Verifiziert 25. Okt.
Quellenauszüge
1 Auszug
Quellenauszüge
1 AuszugSource context: Repo TJ16th/comfyUI_TJ_NormalLighting
