Ir para o conteúdo
Node packVerificadoExterno
Fonte aberta

comfyUI_TJ_NormalLighting

Custom Node for comfyUI for virtual lighting based on normal map

Mantenedor@TJ16thUnratednota

Perfil do pacote

Status
Verificado
Publicador
@TJ16th
Fonte
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.

https://github.com/TJ16th/comfyUI_TJ_NormalLighting/assets/30209833/4b61cdf7-6e4e-4a69-91b7-10e8c692c76a

https://github.com/TJ16th/comfyUI_TJ_NormalLighting/assets/30209833/581fb547-6899-4421-afa9-c33c8919f049

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:

Nós neste pacote

Nó 1
  • EulerLightingNode

Fontes

3 fontes
GitHubFonteVersão f02c6094d92f974a2dbcaacc4019a71906d2b917
github.com/TJ16th/comfyUI_TJ_NormalLighting

Verificado 25 de out.

GitHubFonte
github.com/TJ16th/comfyUI_TJ_NormalLighting

Verificado 30 de out.

Trechos de fonte

1 trecho

Source context: Repo TJ16th/comfyUI_TJ_NormalLighting