콘텐츠로 건너뛰기

A description of the restoration of the glossy effect of indoor scene PBR.

A description of the restoration of the glossy effect of indoor scene PBR.

a fundamental cause

For the Unity or Unreal engines they are currently using, the following structures are taken.

There is a technique called Indirect GI in unity and a lighting bake in unreal engines that states Stationary.

In general, both of these techniques are designed to be used in the development of PC or Console games.

When the engine developer designs the software, it is important to understand that it has already been developed for both platforms.

Game rendering uses simplified computation because it does not use true raytracing.

Typically, assuming that an object is present in the shadow (concentration 1, the value of the complete shadow shielding), the object has a specular value of zero. (Not in the real world.)

This is because logically (programmatically…) it completely returns the shadow density 1 value when complete light shielding is achieved.

For clarity, it is assumed that the object placed inside the room is opaque.

Image result for directional lighting

Computer-programmed direct light has a light source that travels only in a straight forward, which means that if an object is placed and shields the light, it produces a complete shadow density of 1 on the opposite side of the line.

Engine developers do not think that the Lighting Artist will construct a scene using only one light.

In fact, if there is complete shielding, the room without windows will be completely dark.

Image result for directional lighting

However, it is a phenomenon of the real world that the human eye adapts to the dark and some objects can be seen but the specular is hardly felt.

When creating indoor scenes in game scenes, a lot of auxiliary light sources are used besides sunlight.

Naturally, this is an example of an environment that makes PC games or console games.

However, in our game or other mobile games, we do not recommend using point light for performance reasons, and our engine currently removes the operation of pixel lighting internally from the Additional Light method.

Understand the above situation and figured out how to restore the effects of Specular and Environment reflection in the dark (inside the shadow) using two shortcuts.

室内场景PBR光泽效果复原阐述.

根本原因

现在我们使用的Unity以及虚幻引擎使用的构造如下:

Unity里面的Indirect GI以及虚幻引擎里明示的Stationary的照明烘焙手段。

上面两个方式都是为了应用在PC端游以及主机游戏研发而设计的功能。

我们需要理解引擎开发公司在设计软件的时候,已经将以上两个平台作为目标进行研发的事实。

游戏渲染因为没有使用真实的Raytracing,因此使用的是简略的计算。

假定某个物体在阴影(浓度1的值:完全被阴影遮蔽的值)中,这个物体的Specular值就变成了0.(现实世界并非如此)

原因是逻辑上(程序逻辑上)完全被光遮蔽的情况下,阴影浓度1的值会返还回去。

为了进一步说明,我们假定室内里面放的物体是不透明的。

电脑编程做出的直线光是以直线的光源打出去的,这个时候不管放的是什么物体,只要直线光被遮蔽,这个直线光打出的反方向会形成一个完整的阴影浓度1。

引擎研发人员不会认为照明美术只用一个照明去做场景。

实际上如果形成了完整的遮蔽,在没有窗户的室内就是漆黑的。

但是人的眼睛如果适应了黑暗,也能看到一部分物体,但是实际情况下也是几乎感受不到Specular的。

游戏场景制作室内场景的时候,除了太阳光之外,也会使用很多补光源。

当然这种情况基本上是在PC端游以及主机游戏内存在。

但是我们游戏或其他手游会因为性能的原因不选择使用点光源,现在我们引擎内部也是去掉了对Additional Light method Pixel lighting的计算部分。

以上情况理解之后,目前想到了两种方法来解决阴影内Specular和Environment reflection效果

first.

Shadows are part of the result of light occlusion.

Let’s understand that the shadow density returns 1.

Now what if you apply the shadow density (1 value) to a specific object by reducing it?

This means that the reduced value is [complete shielding – reduced value = shadow final concentration reflected in the room]

You can understand it as above.

Let’s look at the code.

I will modify the Shadows.hlsl section.

第一个.

阴影就是光的遮蔽

我们就理解为这个时候阴影浓度返还了1

这时如果我们在特定物件上将反方向阴影浓度(1值)减小应用一下呢?

意思就是减少的值[完整的遮蔽– 减少的值= 室内反映的阴影最终浓度]

可以这样理解

看下代码

Shadows.hlsl这部分要进行修改

half4 _MainLightShadowParams;  // (x: shadowStrength, y: 1.0 if soft shadows, 0.0 otherwise)

The above code explains _MainLightShadowParams.

_MainLightShadowParams.x-The value to decrease (or weight) = the final shadow density.

以上代码是对_MainLightShadowParams的注解处理

_MainLightShadowParams.x – 减少的值(或加权值) = 最终阴影浓度

half4 GetMainLightShadowParams()
{
    return _MainLightShadowParams;
}

This function returns the shadow intensity to the scene.

以上函数是将阴影返还至场景的函数

half4 GetMainLightShadowParams()
{
    #ifdef INDOOR_SHADOW
        half4 tmpShadowParams = half4(0.25,0,0,0);
        return max(0,_MainLightShadowParams - tmpShadowParams);
    #else
        return _MainLightShadowParams;
    #endif
}

I’ve Defined as INDOOR_SHADOW in the shader applied to the object.

This results in brighter shadows because the interior walls do not completely shield sunlight, even in interior spaces.

Since the interior wall is not completely shielded, it is logical to think that the light shines on an object placed inside the room. This is a logical approach, so it is not necessary to understand the light and shadow that enters the window opening on the interior wall. .

We simply understood the engine structure and modified it to the above concept.

See the output below.

应用至物件的shader内定义为 INDOOR_SHADOW

这样的话,就能做出室内外墙不完全遮蔽太阳光,从而让阴影部分变亮的结果

室内外墙不完全遮蔽的话,逻辑上室内放的物件也能反射光,但因为这个是逻辑上的构想,因此不需要理解室内外墙通过窗户缝进来的光和阴影的方式

这是单纯理解引擎结构之后,根据以上概念进行的修改。

结果如下:

Before modifying code. There is no gloss effect because it is logically completely shielded from sunlight.

However, due to the GI effect, it affects the brightness of Diffuse, and the minute indirect specular can be seen.

However, this expression does not mimic the phenomenon of lighting in the interior space.

代码修改前,逻辑上对太阳光形成了完全的遮蔽,因此没有光泽效果。

但是由于GI效果,对Diffuse产生了影响,也能看到一些细小的indirect Specular.

但是这样的方式室内空间照明无法模仿.

After modifying the code. The logical solar shielding ratio was calculated to a value of 0.75.

This means that it is conceptually equivalent to the fact that sunlight is 0.25 in direct sunlight.

The advantage of this modification is that there is almost no incremental operation instruction.

ALU increased by 1-2.

Since it is written in global code, it is easy to control the shielding reduction weight of the whole room and it is possible to define the weight of day and night.

Second way.

This is done by adding virtual lights inside the shader.

The effect is almost identical visually, but the instruction count increases more than the first method.

It is not reasonable to restore the virtual lighting model back to Specular NDF, Fresnel and Env_Reflection.

At first, I tried to solve it by adding virtual lighting.

Although not recommended, if you choose to add virtual lighting operations, you can use the blinn-Phong specular model, which has a small number of instructions.

代码修改后,逻辑上太阳光遮蔽比例计算为0.75.

这意味着太阳光作为直接光进来了0.25,与我们上面讲的概念相同。

这样改的优点是几乎不会增加计算命令句.

ALU增加了1 ~ 2.

因为是全域代码,室内整体遮蔽减少权重值便于控制,可以将昼夜的权重值定义使用.

第二种方式.

在shader内部增加一个假想照明,进行计算.

效果在视觉上几乎是一样的,但与第一个方式相比,会增加较多的命令句

假想照明模型需要恢复Specular NDF 和 Fresnel,以及Env_Reflection,但是判断并不是一个合理的方法

起初想通过增加假想照明的方式来解决.

虽然不是推荐方法,但是如果一定要选择增加假想照明计算的方式,可以使用命令句数量较少的blinn-Phong specular model,此时可以增加应用对于能量保存的计算

You can also add virtual lighting this way.

If you don’t conserve energy, it’s a simpler command.

However, the gloss effect is not as good as the original PBR effect, and this is a way of increasing the instruction count since other functions already do direct Brdf calculations.

Below is the result of adding the simplest blinn-Phong specular model.

可以照这样增加假想照明

如果不需要保存能量,就可以让命令句简洁一点.

但是光泽效果比原来的PBR效果要差,同时因为已经在别的函数计算了direct Brdf, 因此这个方式会导致命令句增多

以下是增加了最单纯的blinn-Phong specular model的结果

conclusion.
If batch processing indoor scenes is not a problem, a simple modification in the first way is also efficient in terms of performance.
This document describes two methods, but I welcome any inspiration while reading the document.

结论.

室内场景如果在统一处理上没有问题,在性能层面上也是按照第一种方式简单修改,会更有效率.

虽然本文介绍了两种方式,但是如果大家在阅读的过程中得到灵感得出更好的方案,那也是极好的,欢迎讨论。

댓글 남기기

%d