Method and system for switching baking data in real time based on illumination environment

文档序号:1880858 发布日期:2021-11-26 浏览:19次 中文

阅读说明:本技术 一种基于光照环境实时切换烘焙数据的方法及其系统 (Method and system for switching baking data in real time based on illumination environment ) 是由 刘德建 董志翔 涂智业 陈宏展 于 2020-05-20 设计创作,主要内容包括:本发明提供了一种基于光照环境实时切换烘焙数据的方法,该方法为:步骤S1、需要烘焙光照环境时,将场景中需要烘焙的物件信息与光源信息输入离线烘焙程序中;步骤S2、离线烘焙程序通过最终聚集算法将物件对应像素的光照信息写入光照贴图中,将采样点处的球谐函数系数写入光照探针中;步骤S3、等待烘焙线程完成后,读取烘焙结果生成光照贴图与光照探针,并存储生产该光照环境对应的烘焙文件;步骤S4、修改光照环境,重复执行步骤S1至步骤S3生成修改后的光照环境对应的烘焙文件,指向修改后的光照环境;步骤S5、通过更改索引的烘焙文件,在不同的光照环境下进行实时切换烘焙文件来达到烘焙效果,能实时切换烘焙数据,实现了展示不同的光照环境。(The invention provides a method for switching baking data in real time based on an illumination environment, which comprises the following steps: step S1, when the lighting environment needs to be baked, inputting the information of the object needing to be baked and the information of the light source in the scene into an off-line baking program; step S2, the off-line baking program writes the illumination information of the corresponding pixel of the object into an illumination map through a final aggregation algorithm, and writes the spherical harmonic coefficient at the sampling point into an illumination probe; step S3, after the baking thread is finished, reading the baking result to generate an illumination map and an illumination probe, and storing and producing a baking file corresponding to the illumination environment; step S4, modifying the illumination environment, and repeatedly executing the step S1 to the step S3 to generate a baking file corresponding to the modified illumination environment and point to the modified illumination environment; and step S5, the baking files are switched in real time under different illumination environments to achieve the baking effect by changing the indexed baking files, the baking data can be switched in real time, and different illumination environments are displayed.)

1. A method for switching baking data in real time based on an illumination environment is characterized in that: the method comprises the following steps:

step S1, when the lighting environment needs to be baked, inputting the information of the object needing to be baked and the information of the light source in the scene into an off-line baking program;

step S2, the off-line baking program writes the illumination information of the corresponding pixel of the object into an illumination map through a final aggregation algorithm, and writes the spherical harmonic coefficient at the sampling point into an illumination probe;

step S3, after the baking thread is finished, reading the baking result to generate an illumination map and an illumination probe, and storing and producing a baking file corresponding to the illumination environment;

step S4, modifying the illumination environment, and repeatedly executing the step S1 to the step S3 to generate a baking file corresponding to the modified illumination environment and point to the modified illumination environment;

and step S5, changing the indexed baking files, and switching the baking files in real time under different illumination environments to achieve the baking effect.

2. The method of claim 1, wherein the method comprises the steps of: the item information includes, but is not limited to: vertex cache, index cache, vertex normal, material diffuse reflection texture, and texture coordinates; the light source information includes but is not limited to: light source type, light source intensity, light source color, and degree of attenuation; the offline baking process can produce a lighting map based on the object information and the light source information.

3. The method of claim 1, wherein the method comprises the steps of: the step S2 further includes: configuring a bake option for a scene, the bake option comprising: a global baking configuration, a single item baking configuration, a light source configuration, and an illumination probe editing; the global baking configuration comprises a baking type, whether a terrain is baked, whether an environment shield is generated, environment shield intensity, indirect light bounce times and an offline baking algorithm;

the single item bake configuration includes setting a bake group, a bake resolution, whether to receive a shadow, whether to generate a shadow, whether to receive an environmental occlusion, whether to generate an environmental occlusion; the light source configuration comprises adding light sources, deleting light sources, moving light sources, and modifying illumination types, illumination intensities, illumination directions and illumination colors; and writing the illumination information of the corresponding pixel of the object into an illumination map by an offline baking program through a final aggregation algorithm according to the baking options of the scene, and writing the spherical harmonic coefficient at the sampling point into an illumination probe.

4. The method of claim 3, wherein the method comprises the steps of: the baking types include, but are not limited to: full bake, indirect light bake, and shadow bake.

5. The method of claim 1, wherein the method comprises the steps of: the step S5 further includes: and when the images are in different illumination environments, the indexed baking file is changed, the changed baking file is read, all objects in the main scene are traversed, the illumination map is updated according to the ID of the baking file, all illumination probes in the main scene are emptied, and the data of the illumination probes are loaded, so that the baking effect is achieved.

6. The utility model provides a system for switching in real time and bake data based on illumination environment which characterized in that: the system comprises: the device comprises an input module, a baking module, a storage module, an execution module and a switching module;

the input module is used for inputting the information of the object to be baked and the information of the light source in the scene into an offline baking program when the illumination environment needs to be baked;

the baking module is used for writing illumination information of pixels corresponding to the object into an illumination map through a final aggregation algorithm by an offline baking program, and writing spherical harmonic coefficients at sampling points into an illumination probe;

the storage module is used for reading the baking result to generate an illumination map and an illumination probe after the baking thread is finished, and storing a baking file corresponding to the illumination environment;

the execution module is used for modifying the illumination environment, repeatedly executing the input module, the baking module and the storage module to generate a baking file corresponding to the modified illumination environment, and pointing to the modified illumination environment;

the switching module is used for switching the baking files in real time under different illumination environments to achieve the baking effect by changing the indexed baking files.

7. The system for switching baking data in real time based on lighting environment according to claim 6, wherein: the item information includes, but is not limited to: vertex cache, index cache, vertex normal, material diffuse reflection texture, and texture coordinates; the light source information includes but is not limited to: light source type, light source intensity, light source color, and degree of attenuation; the offline baking process can produce a lighting map based on the object information and the light source information.

8. The system for switching baking data in real time based on lighting environment according to claim 6, wherein: the baking module is further specifically: configuring a bake option for a scene, the bake option comprising: a global baking configuration, a single item baking configuration, a light source configuration, and an illumination probe editing; the global baking configuration comprises a baking type, whether a terrain is baked, whether an environment shield is generated, environment shield intensity, indirect light bounce times and an offline baking algorithm;

the single item bake configuration includes setting a bake group, a bake resolution, whether to receive a shadow, whether to generate a shadow, whether to receive an environmental occlusion, whether to generate an environmental occlusion; the light source configuration comprises adding light sources, deleting light sources, moving light sources, and modifying illumination types, illumination intensities, illumination directions and illumination colors; and writing the illumination information of the corresponding pixel of the object into an illumination map by an offline baking program through a final aggregation algorithm according to the baking options of the scene, and writing the spherical harmonic coefficient at the sampling point into an illumination probe.

9. A system for switching baking data in real time based on lighting environment as claimed in claim 8, wherein: the baking types include, but are not limited to: full bake, indirect light bake, and shadow bake.

10. The system for switching baking data in real time based on lighting environment according to claim 6, wherein: the switching module further specifically comprises: and when the images are in different illumination environments, the indexed baking file is changed, the changed baking file is read, all objects in the main scene are traversed, the illumination map is updated according to the ID of the baking file, all illumination probes in the main scene are emptied, and the data of the illumination probes are loaded, so that the baking effect is achieved.

Technical Field

The invention relates to the technical field of computer graphics, in particular to a method and a system for switching baking data in real time based on an illumination environment.

Background

Baking is to generate an illumination map in a memory, and then the illumination map can be used to emit light normally even if light is disabled.

The pre-baking technology can effectively help developers to monitor the ambient lighting effect in real time. It can be baked in real time in the scene without saving data. But is more power consuming, so it is disabled when the scene bake is not done.

In a conventional game rendering scheme, due to performance limitation, a part of real-time rendering calculation generally includes only Local illumination (Local illumination), and the Local illumination information expresses a direct illumination effect between a light source and an object; the Global illumination (Global illumination) includes not only a direct illumination effect, but also an indirect illumination effect after light bounces, and an optical phenomenon existing in a series of real environments such as environmental Occlusion (Ambient illumination) between models. In some schemes, the global illumination effect is simulated by adding point light sources in a scene and supplementing light. Doing so can make the lighting environment in the scene more complex, increasing the meaningless performance consumption; and the scene loses obvious brightness change, and the scene is stiff because of unobtrusive illumination.

Disclosure of Invention

In order to overcome the above problems, an object of the present invention is to provide a method for switching baking data in real time based on an illumination environment, which switches baking data in real time, realizes displaying different illumination environments, and has low hardware performance consumption.

The invention is realized by adopting the following scheme: a method for switching baking data in real time based on an illumination environment comprises the following steps:

step S1, when the lighting environment needs to be baked, inputting the information of the object needing to be baked and the information of the light source in the scene into an off-line baking program;

step S2, the off-line baking program writes the illumination information of the corresponding pixel of the object into an illumination map through a final aggregation algorithm, and writes the spherical harmonic coefficient at the sampling point into an illumination probe;

step S3, after the baking thread is finished, reading the baking result to generate an illumination map and an illumination probe, and storing and producing a baking file corresponding to the illumination environment;

step S4, modifying the illumination environment, and repeatedly executing the step S1 to the step S3 to generate a baking file corresponding to the modified illumination environment and point to the modified illumination environment;

and step S5, changing the indexed baking files, and switching the baking files in real time under different illumination environments to achieve the baking effect.

Further, the object information includes, but is not limited to: vertex cache, index cache, vertex normal, material diffuse reflection texture, and texture coordinates; the light source information includes but is not limited to: light source type, light source intensity, light source color, and degree of attenuation; the offline baking process can produce a lighting map based on the object information and the light source information.

Further, the step S2 is further specifically: configuring a bake option for a scene, the bake option comprising: a global baking configuration, a single item baking configuration, a light source configuration, and an illumination probe editing; the global baking configuration comprises a baking type, whether a terrain is baked, whether an environment shield is generated, environment shield intensity, indirect light bounce times and an offline baking algorithm;

the single item bake configuration includes setting a bake group, a bake resolution, whether to receive a shadow, whether to generate a shadow, whether to receive an environmental occlusion, whether to generate an environmental occlusion; the light source configuration comprises adding light sources, deleting light sources, moving light sources, and modifying illumination types, illumination intensities, illumination directions and illumination colors; and writing the illumination information of the corresponding pixel of the object into an illumination map by an offline baking program through a final aggregation algorithm according to the baking options of the scene, and writing the spherical harmonic coefficient at the sampling point into an illumination probe.

Further, the baking types include, but are not limited to: full bake, indirect light bake, and shadow bake.

Further, the illumination information includes, but is not limited to: an illumination map and an illumination probe.

Further, the step S5 is further specifically: and when the images are in different illumination environments, the indexed baking file is changed, the changed baking file is read, all objects in the main scene are traversed, the illumination map is updated according to the ID of the baking file, all illumination probes in the main scene are emptied, and the data of the illumination probes are loaded, so that the baking effect is achieved.

The invention also provides a system for switching baking data in real time based on the illumination environment, which comprises: the device comprises an input module, a baking module, a storage module, an execution module and a switching module;

the input module is used for inputting the information of the object to be baked and the information of the light source in the scene into an offline baking program when the illumination environment needs to be baked;

the baking module is used for writing illumination information of pixels corresponding to the object into an illumination map through a final aggregation algorithm by an offline baking program, and writing spherical harmonic coefficients at sampling points into an illumination probe;

the storage module is used for reading the baking result to generate an illumination map and an illumination probe after the baking thread is finished, and storing a baking file corresponding to the illumination environment;

the execution module is used for modifying the illumination environment, repeatedly executing the input module, the baking module and the storage module to generate a baking file corresponding to the modified illumination environment, and pointing to the modified illumination environment;

the switching module is used for switching the baking files in real time under different illumination environments to achieve the baking effect by changing the indexed baking files.

Further, the object information includes, but is not limited to: vertex cache, index cache, vertex normal, material diffuse reflection texture, and texture coordinates; the light source information includes but is not limited to: light source type, light source intensity, light source color, and degree of attenuation; the offline baking process can produce a lighting map based on the object information and the light source information.

Further, the baking module is further specifically: configuring a bake option for a scene, the bake option comprising: a global baking configuration, a single item baking configuration, a light source configuration, and an illumination probe editing; the global baking configuration comprises a baking type, whether a terrain is baked, whether an environment shield is generated, environment shield intensity, indirect light bounce times and an offline baking algorithm;

the single item bake configuration includes setting a bake group, a bake resolution, whether to receive a shadow, whether to generate a shadow, whether to receive an environmental occlusion, whether to generate an environmental occlusion; the light source configuration comprises adding light sources, deleting light sources, moving light sources, and modifying illumination types, illumination intensities, illumination directions and illumination colors; and writing the illumination information of the corresponding pixel of the object into an illumination map by an offline baking program through a final aggregation algorithm according to the baking options of the scene, and writing the spherical harmonic coefficient at the sampling point into an illumination probe.

Further, the baking types include, but are not limited to: full bake, indirect light bake, and shadow bake.

Further, the illumination information includes, but is not limited to: an illumination map and an illumination probe.

Further, the switching module further specifically includes: and when the images are in different illumination environments, the indexed baking file is changed, the changed baking file is read, all objects in the main scene are traversed, the illumination map is updated according to the ID of the baking file, all illumination probes in the main scene are emptied, and the data of the illumination probes are loaded, so that the baking effect is achieved.

The invention has the beneficial effects that: 1. the global illumination environment of the static object is restored by adopting the illumination map, and the performance consumption is low; the application of the illumination probe enriches the effect of dynamic objects, and makes the dynamic objects perfectly fit with a scene light source. 2. The function of switching illumination information in real time can meet the requirements of different illumination environments (particularly day and night), so that the scene is changed more truly day and night.

Drawings

FIG. 1 is a schematic flow diagram of the process of the present invention.

Fig. 2 is a flow chart of the illumination information switching according to the present invention.

FIG. 3 is a flow chart of an embodiment of the present invention.

Fig. 4 is a schematic block diagram of the system of the present invention.

Detailed Description

The invention is further described below with reference to the accompanying drawings.

Referring to fig. 1, a method for switching baking data in real time based on an illumination environment according to the present invention includes the following steps:

step S1, when the lighting environment needs to be baked, in order to not affect other operations, the editor opens up a new thread, converts the information of the object to be baked and the information of the light source in the scene into a format supported by offline baking and then inputs the information into an offline baking program; the item information includes, but is not limited to: vertex cache, index cache, vertex normal, material diffuse reflection texture, and texture coordinates; the light source information includes but is not limited to: light source type, light source intensity, light source color, and degree of attenuation; the offline baking process can produce a lighting map based on the object information and the light source information.

Step S2, the off-line baking program writes the illumination information of the corresponding pixel of the object into an illumination map through a final aggregation algorithm, and writes the spherical harmonic coefficient at the sampling point into an illumination probe;

step S3, after the baking thread is finished, reading the baking result to generate an illumination map and an illumination probe, and storing a baking file corresponding to the illumination environment, for example, storing the baking file in a disk;

step S4, modifying the illumination environment, and repeatedly executing the step S1 to the step S3 to generate a baking file corresponding to the modified illumination environment and point to the modified illumination environment;

step S5, the baking files in the index are changed, and the baking files are switched in real time under different lighting environments to achieve the baking effect (that is, after the whole offline baking is completed, a file is correspondingly generated to point to the baking result, and after the scene is baked for multiple times to generate multiple baking results, the file index is switched to complete the switching of the baking scheme).

The step S2 further includes: configuring a bake option for a scene, the bake option comprising: a global baking configuration, a single item baking configuration, a light source configuration, and an illumination probe editing; the global baking configuration comprises a baking type, whether a terrain is baked, whether an environment shield is generated, environment shield intensity, indirect light bounce times and an offline baking algorithm;

the single item bake configuration includes setting a bake group, a bake resolution, whether to receive a shadow, whether to generate a shadow, whether to receive an environmental occlusion, whether to generate an environmental occlusion; the light source configuration comprises adding light sources, deleting light sources, moving light sources, and modifying illumination types, illumination intensities, illumination directions and illumination colors; and writing the illumination information of the corresponding pixel of the object into an illumination map by an offline baking program through a final aggregation algorithm according to the baking options of the scene, and writing the spherical harmonic coefficient at the sampling point into an illumination probe. Wherein the baking types include, but are not limited to: full bake, indirect light bake, and shadow bake. The lighting information includes but is not limited to: an illumination map and an illumination probe.

As shown in fig. 2, the step S5 further specifically includes: and when the images are in different illumination environments, the indexed baking file is changed, the changed baking file is read, all objects in the main scene are traversed, the illumination map is updated according to the ID of the baking file, all illumination probes in the main scene are emptied, and the data of the illumination probes are loaded, so that the baking effect is achieved.

The invention is further illustrated below with reference to a specific embodiment:

referring to fig. 3, a certain game scene editing is taken as an example. For example, currently, a terrain editor needs to bake a lighting map and a lighting probe in two different lighting environments, namely day and night, in the same scene, and first needs to configure a baking option in the day, which includes:

1. global bake settings including bake type (full bake, indirect light bake, shadow bake, etc.), whether to bake terrain, whether to generate ambient occlusion, ambient occlusion intensity, indirect light bounce times, offline bake algorithms, etc.

2. Individual item bake configuration, including setting bake group, bake resolution, whether to receive shadow, whether to generate shadow, whether to receive ambient occlusion, whether to generate ambient occlusion, etc.

3. Light source configurations including adding light sources, deleting light sources, moving light sources, and modifying illumination types, illumination intensities, illumination directions, illumination colors, and the like.

4. And (4) light probe editing, including adding, deleting, copying and moving of the light probe.

After the baking preview is finished, the baking effect can be previewed in real time, after the real-time effect is continuously adjusted to meet the requirement, a baking starting button is clicked, an off-line baking program starts to operate, a plurality of baking tasks are executed in the system, baking information is finally generated, and corresponding pixel information is stored into a lighting map; and writing the spherical harmonic function coefficients at the sampling points into an illumination probe, applying the illumination data by default, storing the scene, and generating a corresponding baking file named as morning.

And modifying the night illumination environment in the same scene, similarly, after confirming the effect in the baking preview, starting the baking thread again, selecting another storage path, storing the illumination map and the illumination probe data in the night environment, and generating a new baking file named as night.

All the baking schemes of the scene can be listed in an editor UI, and a double click-and-click Morning scheme is that illumination information in a daytime illumination environment is applied; otherwise, the double click night selection scheme is to apply the illumination information in the night illumination environment. If no baking plan is selected, the latest baking effect is applied by default. In the game, the lighting environment of day and night is switched by program codes.

Referring to fig. 4, the present invention further provides a system for switching baking data in real time based on an illumination environment, the system comprising: the device comprises an input module, a baking module, a storage module, an execution module and a switching module;

the input module is used for inputting the information of the object to be baked and the information of the light source in the scene into an offline baking program when the illumination environment needs to be baked;

the baking module is used for writing illumination information of pixels corresponding to the object into an illumination map through a final aggregation algorithm by an offline baking program, and writing spherical harmonic coefficients at sampling points into an illumination probe;

the storage module is used for reading the baking result to generate an illumination map and an illumination probe after the baking thread is finished, and storing a baking file corresponding to the illumination environment;

the execution module is used for modifying the illumination environment, repeatedly executing the input module, the baking module and the storage module to generate a baking file corresponding to the modified illumination environment, and pointing to the modified illumination environment;

the switching module is used for switching the baking files in real time under different illumination environments to achieve the baking effect by changing the indexed baking files.

Wherein the item information includes, but is not limited to: vertex cache, index cache, vertex normal, material diffuse reflection texture, and texture coordinates; the light source information includes but is not limited to: light source type, light source intensity, light source color, and degree of attenuation; the offline baking process can produce a lighting map based on the object information and the light source information.

Further, the baking module is further specifically: configuring a bake option for a scene, the bake option comprising: a global baking configuration, a single item baking configuration, a light source configuration, and an illumination probe editing; the global baking configuration comprises a baking type, whether a terrain is baked, whether an environment shield is generated, environment shield intensity, indirect light bounce times and an offline baking algorithm;

the single item bake configuration includes setting a bake group, a bake resolution, whether to receive a shadow, whether to generate a shadow, whether to receive an environmental occlusion, whether to generate an environmental occlusion; the light source configuration comprises adding light sources, deleting light sources, moving light sources, and modifying illumination types, illumination intensities, illumination directions and illumination colors; and writing the illumination information of the corresponding pixel of the object into an illumination map by an offline baking program through a final aggregation algorithm according to the baking options of the scene, and writing the spherical harmonic coefficient at the sampling point into an illumination probe. The baking types include, but are not limited to: full bake, indirect light bake, and shadow bake. The lighting information includes but is not limited to: an illumination map and an illumination probe.

In addition, the switching module further specifically includes: and when the images are in different illumination environments, the indexed baking file is changed, the changed baking file is read, all objects in the main scene are traversed, the illumination map is updated according to the ID of the baking file, all illumination probes in the main scene are emptied, and the data of the illumination probes are loaded, so that the baking effect is achieved.

In a word, the invention pre-cures the illumination information into an illumination Map (Light Map) or an illumination Probe (Light Probe) through an off-line rendering process, and then samples the data of the illumination Map (Light Map) and the illumination Probe (Light Probe) in the game to restore the real illumination environment; the existing off-line rendering technology is not only used for prebaking game scenes, but also widely applied to movie special effect production and animation production; simultaneously, in order to deal with the demands of different illumination environments of the same scene at different moments, the scheme realizes the display of different illumination environments by switching the baking data in real time.

The above description is only a preferred embodiment of the present invention, and all equivalent changes and modifications made in accordance with the claims of the present invention should be covered by the present invention.

10页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:信息显示控制方法、装置和电子设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类