CN115761105A - Illumination rendering method, device, electronic device and storage medium - Google Patents
Illumination rendering method, device, electronic device and storage medium Download PDFInfo
- Publication number
- CN115761105A CN115761105A CN202211510885.0A CN202211510885A CN115761105A CN 115761105 A CN115761105 A CN 115761105A CN 202211510885 A CN202211510885 A CN 202211510885A CN 115761105 A CN115761105 A CN 115761105A
- Authority
- CN
- China
- Prior art keywords
- illumination
- data
- target
- lighting
- model
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Landscapes
- Image Generation (AREA)
Abstract
本公开提供了一种光照渲染方法、装置、电子设备及存储介质,该光照渲染方法包括:获取与目标对象模型对应的模型初始光照数据,所述模型初始光照数据由用户预先配置生成;获取所述目标对象模型在目标场景内的当前位置信息以及虚拟相机的当前镜头信息,并基于所述当前位置信息以及所述当前镜头信息对所述模型初始光照数据进行处理,得到模型目标光照数据;基于所述模型目标光照数据以及所述模型初始光照数据,生成所述目标对象模型对应的第一光照信息;获取所述目标场景的场景光源的第二光照信息,基于所述第一光照信息和所述第二光照信息对所述目标对象模型进行光照渲染。本申请实施例,可以在保证渲染画面的流畅度的同时提升渲染效果。
The present disclosure provides a lighting rendering method, device, electronic equipment, and storage medium. The lighting rendering method includes: acquiring model initial lighting data corresponding to a target object model, the model initial lighting data being generated by pre-configuration by the user; acquiring the The current position information of the target object model in the target scene and the current lens information of the virtual camera, and based on the current position information and the current lens information, process the initial lighting data of the model to obtain the model target lighting data; The model target lighting data and the model initial lighting data generate first lighting information corresponding to the target object model; acquire second lighting information of the scene light source of the target scene, based on the first lighting information and the obtained Perform lighting rendering on the target object model based on the second lighting information. In the embodiment of the present application, the rendering effect can be improved while ensuring the smoothness of the rendering image.
Description
技术领域technical field
本公开涉及渲染技术领域,具体而言,涉及一种光照渲染方法、装置、电子设备和存储介质。The present disclosure relates to the technical field of rendering, and in particular, to a lighting rendering method, device, electronic equipment, and storage medium.
背景技术Background technique
随着计算机技术的不断发展,3D游戏已经成为市场的主流,人们在体验游戏的同时,对游戏的视觉效果也提出了更高的要求。相关技术中,为了提升游戏中每个角色的视觉效果,在渲染过程中,除了采用场景光源外,还为每个角色的模型单独设置一个光源。With the continuous development of computer technology, 3D games have become the mainstream of the market. While people experience games, they also put forward higher requirements for the visual effects of games. In related technologies, in order to improve the visual effect of each character in the game, in the rendering process, in addition to using the scene light source, a separate light source is also set for the model of each character.
然而,该方法虽然能够提升每个角色模型渲染后的展示效果,但由于每个角色模型对应一个单独的灯光,在不同角色模型之间靠的较近时,角色模型之间的灯光会相互影响,进而影响整体的视觉展示效果。此外,由于灯光数量增多,在渲染过程中会增加渲染管线的计算压力,进而影响游戏的流畅度。However, although this method can improve the rendering effect of each character model, since each character model corresponds to a separate light, when different character models are close together, the lights between the character models will affect each other , thereby affecting the overall visual display effect. In addition, due to the increase in the number of lights, the calculation pressure of the rendering pipeline will be increased during the rendering process, which will affect the fluency of the game.
发明内容Contents of the invention
本公开实施例至少提供一种光照渲染方法、装置、电子设备及存储介质,可以提升卡通风格渲染的渲染效果。Embodiments of the present disclosure at least provide a lighting rendering method, device, electronic device, and storage medium, which can improve the rendering effect of cartoon style rendering.
本公开实施例提供了一种光照渲染方法,包括:An embodiment of the present disclosure provides a lighting rendering method, including:
获取与目标对象模型对应的模型初始光照数据,所述模型初始光照数据由用户预先配置生成;Obtain model initial lighting data corresponding to the target object model, where the model initial lighting data is generated by user pre-configuration;
获取所述目标对象模型在目标场景内的当前位置信息以及虚拟相机的当前镜头信息,并基于所述当前位置信息以及所述当前镜头信息对所述模型初始光照数据进行处理,得到模型目标光照数据;Obtain the current position information of the target object model in the target scene and the current lens information of the virtual camera, and process the initial lighting data of the model based on the current position information and the current lens information to obtain model target lighting data ;
基于所述模型目标光照数据以及所述模型初始光照数据,生成所述目标对象模型对应的第一光照信息;generating first lighting information corresponding to the target object model based on the model target lighting data and the model initial lighting data;
获取所述目标场景的场景光源的第二光照信息,基于所述第一光照信息和所述第二光照信息对所述目标对象模型进行光照渲染。Acquiring second lighting information of a scene light source of the target scene, and performing lighting rendering on the target object model based on the first lighting information and the second lighting information.
本公开实施例中,由于目标对象模型对应的第一光照信息为通过用户预先配置的模型初始光照数据生成,因此无需为目标对象模型设置单独的光源,即可实现对目标对象模型的单独光照效果,进而在不同的模型靠近时不会相互影响,从而可以提升模型渲染效果。此外,由于各个模型之间可以共用模型初始光照数据,因此,在生成各个模型的第一光照信息的过程中,部分数据只需要计算一次即可,进而可以降低渲染管线的计算压力,也即,可以在保证渲染画面的流畅度的同时提升渲染效果。In the embodiment of the present disclosure, since the first lighting information corresponding to the target object model is generated by the initial lighting data of the model pre-configured by the user, it is not necessary to set a separate light source for the target object model to achieve a separate lighting effect on the target object model , and then different models will not affect each other when they are close together, so that the rendering effect of the model can be improved. In addition, since the initial lighting data of each model can be shared among the models, in the process of generating the first lighting information of each model, part of the data only needs to be calculated once, which can reduce the calculation pressure of the rendering pipeline, that is, It can improve the rendering effect while ensuring the smoothness of the rendered image.
在一种可能的实施方式中,所述模型初始光照数据包括初始光照方向数据以及初始光照位置数据;所述基于所述当前位置信息以及所述当前镜头信息对所述模型初始光照数据进行处理,得到模型目标光照数据,包括:In a possible implementation manner, the initial illumination data of the model includes initial illumination direction data and initial illumination position data; the processing of the initial illumination data of the model based on the current position information and the current lens information, Get model target lighting data, including:
基于所述虚拟相机的当前镜头朝向信息,对所述初始光照方向数据进行处理,得到目标光照方向数据;Based on the current lens orientation information of the virtual camera, the initial illumination direction data is processed to obtain target illumination direction data;
根据所述目标光照方向数据、所述目标对象模型的当前位置信息以及所述初始光照位置数据,确定目标光照位置数据;Determine target lighting position data according to the target lighting direction data, current position information of the target object model, and the initial lighting position data;
基于所述目标光照方向数据以及所述目标光照位置数据,得到所述模型目标光照数据。Obtain the model target illumination data based on the target illumination direction data and the target illumination position data.
本公开实施例中,通过虚拟相机的当前镜头朝向信息对所述初始光照方向数据进行处理,以及通过目标对象模型的当前位置信息对初始光照位置数据进行调整,使得调整后的光照方向是相对于虚拟相机的且调整后的光照位置是相对于目标对象模型的,而不是相对于场景的,且由于每个模型的渲染着色器仅接收模型本身对应的模型初始光照数据以及模型目标光照数据,进而生成与模型本身对应的第一光照信息,而不会涉及到其他模型,因此,可保证在不同模型相互靠近时模型之间的光照不会相互影响。In the embodiment of the present disclosure, the initial illumination direction data is processed through the current lens orientation information of the virtual camera, and the initial illumination position data is adjusted through the current position information of the target object model, so that the adjusted illumination direction is relative to The adjusted lighting position of the virtual camera is relative to the target object model, not relative to the scene, and since the rendering shader of each model only receives the model's initial lighting data and model target lighting data corresponding to the model itself, and then The first lighting information corresponding to the model itself is generated without involving other models, so it can be ensured that the lighting between the models will not affect each other when different models are close to each other.
在一种可能的实施方式中,所述初始光照方向数据以相对于所述虚拟相机的单位矢量方向表示,所述基于所述虚拟相机的当前镜头朝向信息,对所述初始光照方向数据进行处理,得到目标光照方向数据,包括:In a possible implementation manner, the initial illumination direction data is represented by a unit vector direction relative to the virtual camera, and the initial illumination direction data is processed based on the current lens orientation information of the virtual camera , to get the target light direction data, including:
基于所述虚拟相机的当前镜头朝向信息,确定所述单位矢量方向在相机空间的当前方向信息;Based on the current lens orientation information of the virtual camera, determine the current direction information of the unit vector direction in camera space;
根据所述虚拟相机的世界空间变换矩阵,将所述单位矢量方向在所述相机空间的当前方向信息转换到世界空间,得到所述世界空间的光照方向数据,并将所述世界空间的光照方向数据作为所述目标光照方向数据。According to the world space transformation matrix of the virtual camera, convert the current direction information of the unit vector direction in the camera space into the world space, obtain the light direction data of the world space, and convert the light direction data of the world space The data is used as the target illumination direction data.
本公开实施例中,由于初始光照方向数据以相对于所述虚拟相机的单位矢量方向表示,因此,在获得虚拟相机的当前镜头朝向信息后,即可确定所述单位矢量方向在相机空间的当前方向信息,然后通过虚拟相机的世界空间变换矩阵,即可确定世界空间的光照方向数据,得到目标光照方向数据,如此,可以提升目标光照方向数据的确定效率。In the embodiment of the present disclosure, since the initial illumination direction data is represented by the unit vector direction relative to the virtual camera, after obtaining the current lens orientation information of the virtual camera, the current position of the unit vector direction in the camera space can be determined. Direction information, and then through the world space transformation matrix of the virtual camera, the light direction data in the world space can be determined, and the target light direction data can be obtained. In this way, the determination efficiency of the target light direction data can be improved.
在一种可能的实施方式中,所述初始光照位置数据以相对于所述虚拟相机的预设距离表示,所述根据所述目标光照方向数据、所述目标对象模型的当前位置信息以及所述初始光照位置数据,确定目标光照位置数据,包括:In a possible implementation manner, the initial lighting position data is represented by a preset distance relative to the virtual camera, and the data is based on the target lighting direction data, the current position information of the target object model, and the The initial lighting position data, determine the target lighting position data, including:
按照所述目标光照方向数据所指示的方向,以所述目标对象模型的当前位置信息为起点偏移所述预设距离,得到世界空间的光照位置数据,并将所述世界空间的光照位置数据作为所述目标光照位置数据。According to the direction indicated by the target lighting direction data, the current position information of the target object model is used as the starting point to offset the preset distance to obtain the lighting position data of the world space, and the lighting position data of the world space As the target illumination position data.
本公开实施例中,由于初始光照位置数据以相对于所述虚拟相机的预设距离表示,因此,在得到目标光照方向数据后,即可按照所述目标光照方向数据所指示的方向,以所述目标对象模型的当前位置信息为起点偏移所述预设距离,得到世界空间的光照位置数据。如此,可以提升目标光照位置数据的确定效率。In the embodiment of the present disclosure, since the initial lighting position data is represented by a preset distance relative to the virtual camera, after obtaining the target lighting direction data, the target lighting direction data can be used according to the direction indicated by the target lighting direction data. The current position information of the target object model is offset by the preset distance from the starting point to obtain the light position data in the world space. In this way, the efficiency of determining the target illumination position data can be improved.
在一种可能的实施方式中,所述模型初始光照数据还包括初始光照颜色数据以及初始光照强度数据;所述基于所述模型目标光照数据以及所述模型初始光照数据,生成所述目标对象模型对应的第一光照信息,包括:In a possible implementation manner, the model initial illumination data further includes initial illumination color data and initial illumination intensity data; the target object model is generated based on the model target illumination data and the model initial illumination data The corresponding first lighting information includes:
根据所述目标对象模型的当前位置信息以及所述目标光照位置数据,对所述初始光照强度进行处理,得到基于所述目标对象模型表面的目标光照强度数据;Processing the initial illumination intensity according to the current position information of the target object model and the target illumination position data to obtain target illumination intensity data based on the surface of the target object model;
基于所述目标光照强度数据、所述初始光照颜色数据以及所述目标光照方向数据,生成所述目标对象模型对应的第一光照信息。First illumination information corresponding to the target object model is generated based on the target illumination intensity data, the initial illumination color data, and the target illumination direction data.
本公开实施例中,将处理好的目标光照强度数据、目标光照方向数据以及初始光照颜色数据进行组合,即可生成目标对象模型的对应的第一光照信息,进而可以实现目标对象模型对应光源的光照效果。In the embodiment of the present disclosure, by combining the processed target light intensity data, target light direction data and initial light color data, the corresponding first light information of the target object model can be generated, and then the light source corresponding to the target object model can be realized. lighting effects.
在一种可能的实施方式中,所述根据所述目标对象模型的当前位置信息以及所述目标光照位置数据,对所述初始光照强度进行处理,得到基于所述目标对象模型表面的目标光照强度数据,包括:In a possible implementation manner, the initial illumination intensity is processed according to the current position information of the target object model and the target illumination position data to obtain the target illumination intensity based on the surface of the target object model data, including:
根据所述目标对象模型的当前位置信息以及所述目标光照位置数据,确定所述目标对象模型与所述目标光照位置数据所指示的光照位置之间的距离;According to the current position information of the target object model and the target lighting position data, determine the distance between the target object model and the lighting position indicated by the target lighting position data;
基于所述目标对象模型与所述光照位置之间的距离,确定所述述初始光照强度的线性衰减量;determining the linear attenuation of the initial illumination intensity based on the distance between the target object model and the illumination position;
根据所述线性衰减量对所述初始光照强度进行处理,得到所述目标光照强度。The initial light intensity is processed according to the linear attenuation amount to obtain the target light intensity.
本公开实施例中,通过对初始光照强度进行衰减处理,可以使得目标对象模型所接收到的光照强度更接近真实的光照效果,进而可以进一步提升模型的渲染效果。In the embodiment of the present disclosure, by performing attenuation processing on the initial light intensity, the light intensity received by the target object model can be made closer to the real light effect, thereby further improving the rendering effect of the model.
在一种可能的实施方式中,所述基于所述第一光照信息和第二光照信息对所述目标对象模型进行光照渲染,包括:In a possible implementation manner, performing lighting rendering on the target object model based on the first lighting information and the second lighting information includes:
基于所述第一光照信息对所述目标对象模型进行第一光照渲染,得到第一光照渲染结果;Performing first lighting rendering on the target object model based on the first lighting information to obtain a first lighting rendering result;
基于所述第二光照信息对所述目标对象模型进行第二光照渲染,得到第二光照渲染结果;Performing second lighting rendering on the target object model based on the second lighting information to obtain a second lighting rendering result;
将所述第一光照渲染结果与所述第二光照渲染结果融合,得到所述目标对象模型的光照渲染结果。The first lighting rendering result is fused with the second lighting rendering result to obtain the lighting rendering result of the target object model.
本公开实施例中,通过第一光照信息和第二光照信息对目标对象模型分别进行渲染,并将分别渲染的结果进行融合,即可实现模型在场景中的独立渲染效果,进而可以提升场景中多个模型的整体渲染效果。In the embodiment of the present disclosure, the target object model is rendered separately through the first lighting information and the second lighting information, and the rendering results are fused to realize the independent rendering effect of the model in the scene, thereby improving the rendering effect of the scene. Overall rendering of multiple models.
本公开实施例提供了一种光照渲染装置,包括:An embodiment of the present disclosure provides an illumination rendering device, including:
数据获取模块,用于获取与目标对象模型对应的模型初始光照数据,所述模型初始光照数据由用户预先配置生成;A data acquisition module, configured to acquire model initial lighting data corresponding to the target object model, where the model initial lighting data is generated by pre-configuration by the user;
数据处理模块,用于获取所述目标对象模型在目标场景内的当前位置信息以及虚拟相机的当前镜头信息,并基于所述当前位置信息以及所述当前镜头信息对所述模型初始光照数据进行处理,得到模型目标光照数据;A data processing module, configured to obtain the current position information of the target object model in the target scene and the current lens information of the virtual camera, and process the initial lighting data of the model based on the current position information and the current lens information , to obtain the illumination data of the model target;
信息生成模块,用于基于所述模型目标光照数据以及所述模型初始光照数据,生成所述目标对象模型对应的第一光照信息;An information generating module, configured to generate first lighting information corresponding to the target object model based on the model target lighting data and the model initial lighting data;
模型渲染模块,用于获取所述目标场景的场景光源的第二光照信息,基于所述第一光照信息和所述第二光照信息对所述目标对象模型进行光照渲染。A model rendering module, configured to acquire second lighting information of a scene light source of the target scene, and perform lighting rendering on the target object model based on the first lighting information and the second lighting information.
在一种可能的实施方式中,所述模型初始光照数据包括初始光照方向数据以及初始光照位置数据;所述数据处理模块具体用于:In a possible implementation manner, the model initial illumination data includes initial illumination direction data and initial illumination position data; the data processing module is specifically used for:
基于所述虚拟相机的当前镜头朝向信息,对所述初始光照方向数据进行处理,得到目标光照方向数据;Based on the current lens orientation information of the virtual camera, the initial illumination direction data is processed to obtain target illumination direction data;
根据所述目标光照方向数据、所述目标对象模型的当前位置信息以及所述初始光照位置数据,确定目标光照位置数据;Determine target lighting position data according to the target lighting direction data, current position information of the target object model, and the initial lighting position data;
基于所述目标光照方向数据以及所述目标光照位置数据,得到所述模型目标光照数据。Obtain the model target illumination data based on the target illumination direction data and the target illumination position data.
在一种可能的实施方式中,所述初始光照方向数据以相对于所述虚拟相机的单位矢量方向表示,所述数据处理模块具体用于:In a possible implementation manner, the initial illumination direction data is represented by a unit vector direction relative to the virtual camera, and the data processing module is specifically configured to:
基于所述虚拟相机的当前镜头朝向信息,确定所述单位矢量方向在相机空间的当前方向信息;Based on the current lens orientation information of the virtual camera, determine the current direction information of the unit vector direction in camera space;
根据所述虚拟相机的世界空间变换矩阵,将所述单位矢量方向在所述相机空间的当前方向信息转换到世界空间,得到所述世界空间的光照方向数据,并将所述世界空间的光照方向数据作为所述目标光照方向数据。According to the world space transformation matrix of the virtual camera, convert the current direction information of the unit vector direction in the camera space into the world space, obtain the light direction data of the world space, and convert the light direction data of the world space The data is used as the target illumination direction data.
在一种可能的实施方式中,所述初始光照位置数据以相对于所述虚拟相机的预设距离表示,所述数据处理模块具体用于:In a possible implementation manner, the initial lighting position data is represented by a preset distance relative to the virtual camera, and the data processing module is specifically configured to:
按照所述目标光照方向数据所指示的方向,以所述目标对象模型的当前位置信息为起点偏移所述预设距离,得到世界空间的光照位置数据,并将所述世界空间的光照位置数据作为所述目标光照位置数据。According to the direction indicated by the target lighting direction data, the current position information of the target object model is used as the starting point to offset the preset distance to obtain the lighting position data of the world space, and the lighting position data of the world space As the target illumination position data.
在一种可能的实施方式中,所述模型初始光照数据还包括初始光照颜色数据以及初始光照强度数据;所述信息生成模块具体用于:In a possible implementation manner, the initial illumination data of the model also includes initial illumination color data and initial illumination intensity data; the information generating module is specifically used for:
根据所述目标对象模型的当前位置信息以及所述目标光照位置数据,对所述初始光照强度进行处理,得到基于所述目标对象模型表面的目标光照强度数据;Processing the initial illumination intensity according to the current position information of the target object model and the target illumination position data to obtain target illumination intensity data based on the surface of the target object model;
基于所述目标光照强度数据、所述初始光照颜色数据以及所述目标光照方向数据,生成所述目标对象模型对应的第一光照信息。First illumination information corresponding to the target object model is generated based on the target illumination intensity data, the initial illumination color data, and the target illumination direction data.
在一种可能的实施方式中,所述信息生成模块具体用于:In a possible implementation manner, the information generating module is specifically configured to:
根据所述目标对象模型的当前位置信息以及所述目标光照位置数据,确定所述目标对象模型与所述目标光照位置数据所指示的光照位置之间的距离;According to the current position information of the target object model and the target lighting position data, determine the distance between the target object model and the lighting position indicated by the target lighting position data;
基于所述目标对象模型与所述光照位置之间的距离,确定所述述初始光照强度的线性衰减量;determining the linear attenuation of the initial illumination intensity based on the distance between the target object model and the illumination position;
根据所述线性衰减量对所述初始光照强度进行处理,得到所述目标光照强度。The initial light intensity is processed according to the linear attenuation amount to obtain the target light intensity.
在一种可能的实施方式中,所述模型渲染模块具体用于:In a possible implementation manner, the model rendering module is specifically configured to:
基于所述第一光照信息对所述目标对象模型进行第一光照渲染,得到第一光照渲染结果;Performing first lighting rendering on the target object model based on the first lighting information to obtain a first lighting rendering result;
基于所述第二光照信息对所述目标对象模型进行第二光照渲染,得到第二光照渲染结果;Performing second lighting rendering on the target object model based on the second lighting information to obtain a second lighting rendering result;
将所述第一光照渲染结果与所述第二光照渲染结果融合,得到所述目标对象模型的光照渲染结果。The first lighting rendering result is fused with the second lighting rendering result to obtain the lighting rendering result of the target object model.
本公开实施例提供了一种电子设备,包括:处理器、存储器和总线,所述存储器存储有所述处理器可执行的机器可读指令,当电子设备运行时,所述处理器与所述存储器之间通过总线通信,所述机器可读指令被所述处理器执行时执行上述任一实施方式中所述的光照渲染方法。An embodiment of the present disclosure provides an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the The memories communicate through a bus, and the machine-readable instructions are executed by the processor to execute the light rendering method described in any one of the above-mentioned implementation manners.
本公开实施例提供了一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述任一实施方式中所述的光照渲染方法。An embodiment of the present disclosure provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, the illumination rendering method described in any one of the foregoing implementation manners is executed.
为使本公开的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。In order to make the above-mentioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments will be described in detail below together with the accompanying drawings.
附图说明Description of drawings
为了更清楚地说明本公开实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,此处的附图被并入说明书中并构成本说明书中的一部分,这些附图示出了符合本公开的实施例,并与说明书一起用于说明本公开的技术方案。应当理解,以下附图仅示出了本公开的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to illustrate the technical solutions of the embodiments of the present disclosure more clearly, the following will briefly introduce the accompanying drawings used in the embodiments. The accompanying drawings here are incorporated into the specification and constitute a part of the specification. The drawings show the embodiments consistent with the present disclosure, and are used together with the description to explain the technical solution of the present disclosure. It should be understood that the following drawings only show some embodiments of the present disclosure, and therefore should not be regarded as limiting the scope. For those skilled in the art, they can also make From these drawings other related drawings are obtained.
图1示出了本公开一些实施例所提供的光照渲染方法的流程图;FIG. 1 shows a flow chart of a lighting rendering method provided by some embodiments of the present disclosure;
图2示出了本公开一些实施例所提供的对模型初始光照数据进行处理的方法流程图;Fig. 2 shows a flowchart of a method for processing initial lighting data of a model provided by some embodiments of the present disclosure;
图3示出了本公开一些实施例所提供的基于光照信息对目标对象模型进行光照渲染的方法流程图;Fig. 3 shows a flowchart of a method for performing lighting rendering on a target object model based on lighting information provided by some embodiments of the present disclosure;
图4示出了本公开一些实施例所提供的光照渲染装置的结构示意图;Fig. 4 shows a schematic structural diagram of an illumination rendering device provided by some embodiments of the present disclosure;
图5示出了本公开一些实施例所提供的电子设备的示意图。Fig. 5 shows a schematic diagram of an electronic device provided by some embodiments of the present disclosure.
具体实施方式Detailed ways
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本公开一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本公开实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本公开的实施例的详细描述并非旨在限制要求保护的本公开的范围,而是仅仅表示本公开的选定实施例。基于本公开的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本公开保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only It is a part of the embodiments of the present disclosure, but not all of them. The components of the disclosed embodiments generally described and illustrated in the figures herein may be arranged and designed in a variety of different configurations. Accordingly, the following detailed description of the embodiments of the present disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed disclosure, but merely represents selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative effort shall fall within the protection scope of the present disclosure.
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。It should be noted that like numerals and letters denote similar items in the following figures, therefore, once an item is defined in one figure, it does not require further definition and explanation in subsequent figures.
本文中术语“和/或”,仅仅是描述一种关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中术语“至少一种”表示多种中的任意一种或多种中的至少两种的任意组合,例如,包括A、B、C中的至少一种,可以表示包括从A、B和C构成的集合中选择的任意一个或多个元素。The term "and/or" in this article only describes an association relationship, which means that there can be three kinds of relationships, for example, A and/or B can mean: there is A alone, A and B exist at the same time, and B exists alone. situation. In addition, the term "at least one" herein means any one of a variety or any combination of at least two of the more, for example, including at least one of A, B, and C, which may mean including from A, Any one or more elements selected from the set formed by B and C.
网络游戏因其所具有的游戏场景真实性较高、观赏性和操作性较好而深受用户的喜欢。经研究发现,为了满足用户更高的视觉效果需求,在渲染过程中,除了采用场景光源外,通常还为每个角色的模型单独设置一个光源。然而,该方法虽然能够凸显角色在场景中的动态视觉效果,但由于每个角色模型对应一个单独的灯光,在不同角色模型之间靠的较近时,角色模型之间的灯光会相互影响,进而影响整体的视觉展示效果。此外,由于灯光数量增多,在渲染过程中会增加渲染管线的计算压力,导致性能的开销变□,进而影响游戏的流畅度。Online games are very popular among users because of their high authenticity of game scenes, good viewing and operability. After research, it is found that in order to meet the higher visual effect requirements of users, in the rendering process, in addition to using scene light sources, a separate light source is usually set for each character model. However, although this method can highlight the dynamic visual effect of the character in the scene, since each character model corresponds to a separate light, when different character models are close together, the lights between the character models will affect each other. And then affect the overall visual display effect. In addition, due to the increase in the number of lights, the calculation pressure of the rendering pipeline will be increased during the rendering process, resulting in a decrease in performance overhead, which in turn will affect the smoothness of the game.
基于上述研究,本公开提供一种光照渲染方法,首先获取与目标对象模型对应的模型初始光照数据,所述模型初始光照数据由用户预先配置生成;然后获取所述目标对象模型在目标场景内的当前位置信息以及虚拟相机的当前镜头信息,并基于所述当前位置信息以及所述当前镜头信息对所述模型初始光照数据进行处理,得到模型目标光照数据;接着基于所述模型目标光照数据以及所述模型初始光照数据,生成所述目标对象模型对应的第一光照信息;最后获取所述目标场景的场景光源的第二光照信息,并基于所述第一光照信息和所述第二光照信息对所述目标对象模型进行光照渲染。Based on the above research, the present disclosure provides a lighting rendering method. First, the initial lighting data of the model corresponding to the target object model is obtained, and the initial lighting data of the model is generated by the user's pre-configuration; The current position information and the current lens information of the virtual camera, and based on the current position information and the current lens information, process the initial lighting data of the model to obtain the model target lighting data; then based on the model target lighting data and the obtained The initial lighting data of the model is generated to generate the first lighting information corresponding to the target object model; finally, the second lighting information of the scene light source of the target scene is obtained, and based on the first lighting information and the second lighting information The target object model performs lighting rendering.
本公开实施例中,由于目标对象模型对应的第一光照信息为通过用户预先配置的模型初始光照数据生成,因此无需为目标对象模型设置单独的光源,即可实现对目标对象模型的单独光照效果,进而在不同的模型靠近时不会相互影响,从而可以提升模型渲染效果。此外,由于各个模型之间可以共用模型初始光照数据,因此,在生成各个模型的第一光照信息的过程中,部分数据只需要计算一次即可,进而可以降低渲染管线的计算压力,也即,可以在保证渲染画面的流畅度的同时提升渲染效果。In the embodiment of the present disclosure, since the first lighting information corresponding to the target object model is generated by the initial lighting data of the model pre-configured by the user, it is not necessary to set a separate light source for the target object model to achieve a separate lighting effect on the target object model , and then different models will not affect each other when they are close together, so that the rendering effect of the model can be improved. In addition, since the initial lighting data of each model can be shared among the models, in the process of generating the first lighting information of each model, part of the data only needs to be calculated once, which can reduce the calculation pressure of the rendering pipeline, that is, It can improve the rendering effect while ensuring the smoothness of the rendered image.
为便于对本实施例进行理解,首先对本公开实施例所提供的光照渲染方法的执行主体进行详细介绍。本公开实施例所提供的光照渲染方法的执行主体为电子设备。该电子设备可以为终端设备或者服务器。其中,该终端设备可以为移动设备、用户终端、终端、手持设备、计算设备、车载设备、可穿戴设备等。该服务器可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云存储、大数据和人工智能平台等基础云计算服务的云服务器。其他实施方式中,该光照渲染方法还可以通过处理器调用存储器中存储的计算机可读指令的方式来实现。In order to facilitate the understanding of this embodiment, firstly, a detailed introduction will be given to the execution subject of the illumination rendering method provided by the embodiment of the present disclosure. The execution subject of the lighting rendering method provided by the embodiment of the present disclosure is an electronic device. The electronic device may be a terminal device or a server. Wherein, the terminal device may be a mobile device, a user terminal, a terminal, a handheld device, a computing device, a vehicle-mounted device, a wearable device, and the like. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a basic cloud that provides cloud services, cloud databases, cloud computing, cloud storage, big data and artificial intelligence platforms. Cloud server for computing services. In other implementation manners, the light rendering method may also be implemented by a processor calling computer-readable instructions stored in a memory.
下面结合附图对本申请实施例所提供的光照渲染方法进行详细说明。参见图1所示,为本公开实施例提供的一种光照渲染方法的流程图,该光照渲染方法包括以下S101~S104:The lighting rendering method provided by the embodiment of the present application will be described in detail below with reference to the accompanying drawings. Referring to FIG. 1 , which is a flowchart of a lighting rendering method provided by an embodiment of the present disclosure, the lighting rendering method includes the following S101-S104:
S101,获取与目标对象模型对应的模型初始光照数据,所述模型初始光照数据由用户预先配置生成。S101. Acquire model initial lighting data corresponding to a target object model, where the model initial lighting data is generated by pre-configuration by a user.
示例性地,目标对象可以为虚拟场景中的虚拟对象,虚拟对象是指虚拟场景中的事物,虚拟对象包括但不限于是虚拟的人物、动物、植物、家具或建筑物等中的至少一种。本公开实施例中,目标对象为虚拟场景中可被控制的动态对象。Exemplarily, the target object may be a virtual object in a virtual scene, and a virtual object refers to a thing in a virtual scene, and a virtual object includes but is not limited to at least one of virtual characters, animals, plants, furniture or buildings, etc. . In the embodiments of the present disclosure, the target object is a controllable dynamic object in the virtual scene.
可以理解,虚拟场景是指计算机通过数字通讯技术勾勒出的数字化场景,包括二维虚拟场景和三维虚拟场景,可以用虚拟化技术手段来真实模拟出现世界的各种物质形态、空间关系等信息。其中,三维虚拟场景能够更加美观地展示物体对象的形态,同时也能更加直观地展示虚拟现实世界。例如,三维虚拟场景下的物体对象可以包括地形、房屋、树木、人物等中的至少一种。It can be understood that a virtual scene refers to a digital scene drawn by a computer through digital communication technology, including two-dimensional virtual scenes and three-dimensional virtual scenes. Virtualization technology can be used to simulate various material forms and spatial relationships in the world. Among them, the three-dimensional virtual scene can display the shape of the object more beautifully, and can also display the virtual reality world more intuitively. For example, objects in the three-dimensional virtual scene may include at least one of terrain, houses, trees, characters, and the like.
对于虚拟场景,可以通过计算机三维图形显示,可以在屏幕上展示三维的仿真环境,虚拟场景中的所有目标对象都可以通过三维场景数据描述。例如,可以把三维场景数据加载到三维场景中,以展示出三维的仿真环境。其中,三维场景数据可以包括模型数据、纹理数据、光照数据、地形数据、栅格体数据等中的至少一种。For the virtual scene, it can be displayed by computer three-dimensional graphics, and a three-dimensional simulation environment can be displayed on the screen, and all target objects in the virtual scene can be described by three-dimensional scene data. For example, 3D scene data can be loaded into the 3D scene to display a 3D simulation environment. Wherein, the three-dimensional scene data may include at least one of model data, texture data, illumination data, terrain data, grid volume data, and the like.
本公开实施例中,虚拟场景为用于供玩家控制目标对象完成游戏逻辑的场景,该虚拟场景可以是对真实世界的仿真环境,或者是半仿真半虚构的虚拟环境,或者是纯虚构的虚拟环境。虚拟环境可以为天空、陆地、海洋等,其中,该陆地包括沙漠、城市等环境元素。In the embodiment of the present disclosure, the virtual scene is a scene for the player to control the target object to complete the game logic. The virtual scene can be a simulation environment of the real world, or a half-simulation and half-fictional virtual environment, or a purely fictitious virtual environment. environment. The virtual environment may be sky, land, ocean, etc., wherein the land includes environmental elements such as deserts and cities.
此外,本公开实施例中,光照数据除了包括场景光源外,还包括各个模型对应模型初始光照数据,该模型初始光照数据由用户预先配置生成。例如,用户可以先在Excel表中为各个模型配置相应的模型初始光照数据,在使用时,将数据导入到对应的项目即可。In addition, in the embodiment of the present disclosure, besides the scene light source, the illumination data also includes the initial illumination data of each model corresponding to the model, and the initial illumination data of the model is pre-configured and generated by the user. For example, users can first configure the corresponding model initial lighting data for each model in the Excel table, and then import the data into the corresponding project when using it.
可选地,所述模型初始光照数据包括初始光照方向数据、初始光照位置数据、初始光照颜色数据以及初始光照强度数据等。Optionally, the model initial illumination data includes initial illumination direction data, initial illumination position data, initial illumination color data, initial illumination intensity data, and the like.
可以理解,在进行目标对象模型的渲染之前,需要获取需要建立三维模型的场景文件,并根据该场景文件建立虚拟场景,然后在该虚拟场景中进行目标对象模型的展示和处理。It can be understood that before rendering the target object model, it is necessary to obtain the scene file for which the 3D model needs to be built, and create a virtual scene according to the scene file, and then display and process the target object model in the virtual scene.
需要说明的是,在本发明实施例中,在进行三维模型处理的时候,可以先采用三维模型设计工具进行模型的建立,然后再利用三维模型开发工具进行模型的进一步处理,最终得到需要的三维模型。It should be noted that, in the embodiment of the present invention, when processing the 3D model, the 3D model design tool can be used to establish the model first, and then the 3D model development tool is used to further process the model, and finally the required 3D model can be obtained. Model.
进一步地,在建立好目标对象的三维模型后,可以将三维模型导出,供三维模型开发工具进行进一步的模型处理。本发明实施例中主要描述的是在建立好三维模型之后,在游戏过程中对该三维模型进行渲染的过程。Furthermore, after the 3D model of the target object is established, the 3D model can be exported for further model processing by the 3D model development tool. The embodiment of the present invention mainly describes the process of rendering the 3D model during the game after the 3D model is established.
S102,获取所述目标对象模型在目标场景内的当前位置信息以及虚拟相机的当前镜头信息,并基于所述当前位置信息以及所述当前镜头信息对所述模型初始光照数据进行处理,得到模型目标光照数据。S102. Obtain the current position information of the target object model in the target scene and the current lens information of the virtual camera, and process the initial lighting data of the model based on the current position information and the current lens information to obtain a model target lighting data.
其中,目标场景可以为前述的虚拟场景,可以理解,由于目标对象为虚拟场景中动态控制对象,目标对象在虚拟场景的位置会发生改变,而目标对象处于不同位置时,在虚拟场景中接收到的光照效果是不同的,也即,当虚拟场景中光源发生变化时,虚拟场景中的环境光照效果也会随之发生变化。此外,随着虚拟对象位置的改变,屏幕所呈现的视觉展示内容也不同。Wherein, the target scene can be the aforementioned virtual scene. It can be understood that since the target object is a dynamic control object in the virtual scene, the position of the target object in the virtual scene will change, and when the target object is in a different position, the received The lighting effect is different, that is, when the light source in the virtual scene changes, the ambient lighting effect in the virtual scene will also change accordingly. In addition, as the position of the virtual object changes, the visual display content presented on the screen is also different.
因此,在一些实施例中,需要获取所述目标对象模型在目标场景内的当前位置信息以及虚拟相机的当前镜头信息,并基于所述当前位置信息以及所述当前镜头信息对所述模型初始光照数据进行处理,得到模型目标光照数据,以使得目标光照数据与目标对象模型当前的状态匹配。Therefore, in some embodiments, it is necessary to obtain the current position information of the target object model in the target scene and the current lens information of the virtual camera, and initially illuminate the model based on the current position information and the current lens information The data is processed to obtain the model target lighting data, so that the target lighting data matches the current state of the target object model.
示例性地,可以基于所述当前位置信息以及所述当前镜头信息,对所述模型初始光照数据中的初始光照方向数据以及初始光照位置数据进行处理,以得到相对于模型以及虚拟相机的模型目标光照数据。Exemplarily, based on the current position information and the current lens information, the initial lighting direction data and the initial lighting position data in the model's initial lighting data can be processed to obtain the model target relative to the model and the virtual camera lighting data.
在一种可能的实施方式中,参见图2所示,针对步骤S102,在基于所述当前位置信息以及所述当前镜头信息对所述模型初始光照数据进行处理,得到模型目标光照数据时,可以包括以下S1021~S1023:In a possible implementation manner, as shown in FIG. 2, for step S102, when the model initial lighting data is processed based on the current position information and the current lens information to obtain the model target lighting data, Including the following S1021~S1023:
S1021,基于所述虚拟相机的当前镜头朝向信息,对所述初始光照方向数据进行处理,得到目标光照方向数据。S1021. Based on the current lens orientation information of the virtual camera, process the initial illumination direction data to obtain target illumination direction data.
可以理解,由于初始光照方向数据是相机空间的,因此,需要对初始光照方向数据进行处理,得到世界空间的光照方向数据,以便后续进行光照渲染。在一些实施例中,所述初始光照方向数据可以以相对于所述虚拟相机的单位矢量方向表示,因此,在获取到所述虚拟相机的当前镜头朝向信息,即可确定所述单位矢量方向在相机空间的当前方向信息;然后根据所述虚拟相机的世界空间变换矩阵,将所述单位矢量方向在所述相机空间的当前方向信息转换到世界空间,得到所述世界空间的光照方向数据,并将所述世界空间的光照方向数据作为所述目标光照方向数据。如此,可以提升目标光照方向数据的确定效率。It can be understood that since the initial lighting direction data is in the camera space, it is necessary to process the initial lighting direction data to obtain the lighting direction data in the world space for subsequent lighting rendering. In some embodiments, the initial illumination direction data may be represented by a unit vector direction relative to the virtual camera. Therefore, after obtaining the current lens orientation information of the virtual camera, it can be determined that the unit vector direction is The current direction information of the camera space; then according to the world space transformation matrix of the virtual camera, the current direction information of the unit vector direction in the camera space is transformed into the world space to obtain the light direction data of the world space, and The light direction data of the world space is used as the target light direction data. In this way, the efficiency of determining the target illumination direction data can be improved.
S1022,根据所述目标光照方向数据、所述目标对象模型的当前位置信息以及所述初始光照位置数据,确定目标光照位置数据。S1022. Determine target lighting position data according to the target lighting direction data, current position information of the target object model, and the initial lighting position data.
示例性地,所述初始光照位置数据以相对于所述虚拟相机的预设距离表示,因此,在得到目标光照方向数据后,可以按照所述目标光照方向数据所指示的方向,以所述目标对象模型的当前位置信息为起点偏移所述预设距离,得到世界空间的光照位置数据,并将所述世界空间的光照位置数据作为所述目标光照位置数据。如此,可以提升目标光照位置数据的确定效率。本实施方式中,初始光照位置数据为世界空间的一个偏移值。Exemplarily, the initial lighting position data is represented by a preset distance relative to the virtual camera, therefore, after obtaining the target lighting direction data, the target can be The current position information of the object model is that the starting point is offset by the preset distance to obtain the lighting position data in the world space, and use the lighting position data in the world space as the target lighting position data. In this way, the efficiency of determining the target illumination position data can be improved. In this embodiment, the initial lighting position data is an offset value in the world space.
S1023,基于所述目标光照方向数据以及所述目标光照位置数据,得到所述模型目标光照数据。S1023. Obtain the model target lighting data based on the target lighting direction data and the target lighting position data.
可以理解,在得到世界空间的光照方向数据以及世界空间的光照位置数据后,即可生成模型目标光照数据。It can be understood that after obtaining the light direction data in the world space and the light position data in the world space, the model target light data can be generated.
本公开实施例中,通过虚拟相机的当前镜头朝向信息对所述初始光照方向数据进行处理,以及通过目标对象模型的当前位置信息对初始光照位置数据进行调整,使得调整后的光照方向是相对于虚拟相机的且调整后的光照位置是相对于目标对象模型的,而不是相对于场景的,且由于每个模型的渲染着色器仅接收模型本身对应的模型初始光照数据以及模型目标光照数据,进而生成与模型本身对应的第一光照信息,而不会涉及到其他模型,因此,可保证在不同模型相互靠近时模型之间的光照不会相互影响。In the embodiment of the present disclosure, the initial illumination direction data is processed through the current lens orientation information of the virtual camera, and the initial illumination position data is adjusted through the current position information of the target object model, so that the adjusted illumination direction is relative to The adjusted lighting position of the virtual camera is relative to the target object model, not relative to the scene, and since the rendering shader of each model only receives the model's initial lighting data and model target lighting data corresponding to the model itself, and then The first lighting information corresponding to the model itself is generated without involving other models, so it can be ensured that the lighting between the models will not affect each other when different models are close to each other.
S103,基于所述模型目标光照数据以及所述模型初始光照数据,生成所述目标对象模型对应的第一光照信息。S103. Based on the model target lighting data and the model initial lighting data, generate first lighting information corresponding to the target object model.
可以理解,模型初始光照数据除了包括初始光照方向数据以及初始光照位置数据外,还包括初始光照颜色数据以及初始光照强度数据。其中,初始光照方向数据以及初始光照位置数据,经过前述过程的处理,得到了目标光照方向数据以及所述目标光照位置数据。因此,将目标光照方向数据、所述目标光照位置数据、初始光照颜色数据以及初始光照强度数据进行组合,即可得到对应于所述目标对象模型的模拟光源。需要说明的是,该模拟光源仅仅是针对该目标对象模型的,并不会对其他模型产生影响。It can be understood that the initial illumination data of the model includes not only initial illumination direction data and initial illumination position data, but also initial illumination color data and initial illumination intensity data. Wherein, the initial illumination direction data and the initial illumination position data are processed through the aforementioned process to obtain the target illumination direction data and the target illumination position data. Therefore, the simulated light source corresponding to the target object model can be obtained by combining the target illumination direction data, the target illumination position data, the initial illumination color data and the initial illumination intensity data. It should be noted that the simulated light source is only for the target object model and will not affect other models.
但是,由于模拟光源的光照位置与目标对象模型之间存在距离,为了提升光照的真实效果,需要根据所述目标对象模型的当前位置信息以及所述目标光照位置数据,对所述初始光照强度进行处理,得到基于所述目标对象模型表面的目标光照强度数据,然后将目标光照方向数据以及目标光照位置数据与目标光照强度数据进行组合,即可得到目标对象模型对应的第一光照信息。However, since there is a distance between the illumination position of the simulated light source and the target object model, in order to improve the real effect of illumination, the initial illumination intensity needs to be adjusted according to the current position information of the target object model and the target illumination position data. processing to obtain the target illumination intensity data based on the surface of the target object model, and then combine the target illumination direction data and target illumination position data with the target illumination intensity data to obtain the first illumination information corresponding to the target object model.
在一种可能的实施方式中,渲染着色器可以根据目标对象模型表□到光照位置的远近,确定初始光照强度的线性衰减量,得到模型表□接收到的目标灯光强度。也即,渲染着色器可以先根据所述目标对象模型的当前位置信息以及所述目标光照位置数据,确定所述目标对象模型与所述目标光照位置数据所指示的光照位置之间的距离;然后基于所述目标对象模型与所述光照位置之间的距离,确定所述述初始光照强度的线性衰减量;再根据所述线性衰减量对所述初始光照强度进行处理,得到所述目标光照强度。In a possible implementation manner, the rendering shader may determine the linear attenuation of the initial light intensity according to the distance from the target object model table □ to the light position, and obtain the target light intensity received by the model table □. That is, the rendering shader may first determine the distance between the target object model and the lighting position indicated by the target lighting position data according to the current position information of the target object model and the target lighting position data; and then Determine the linear attenuation of the initial illumination intensity based on the distance between the target object model and the illumination position; then process the initial illumination intensity according to the linear attenuation to obtain the target illumination intensity .
S104,获取所述目标场景的场景光源的第二光照信息,并基于所述第一光照信息和第二光照信息对所述目标对象模型进行光照渲染。S104. Acquire second lighting information of a scene light source of the target scene, and perform lighting rendering on the target object model based on the first lighting information and the second lighting information.
其中,在计算机图形中,渲染是指将三维场景中的各个对象模型,按照设定好的环境、材质、光照及渲染参数,二维投影成数字图像的过程。其中,光照渲染,是指对目标对象模型进行渲染过程中的光照计算处理,以使目标对象模型表面的像素点具有光照效果。Among them, in computer graphics, rendering refers to the process of two-dimensionally projecting each object model in a three-dimensional scene into a digital image according to the set environment, material, lighting and rendering parameters. Wherein, the lighting rendering refers to performing lighting calculation processing on the target object model during the rendering process, so that pixels on the surface of the target object model have lighting effects.
虚拟场景中的光源,是能够真实地模拟现实中的光源的光照效果的一系列光照数据。与现实中的光源类似,当虚拟场景中的有色光源,投射到有色物体表面上时,最终渲染出的颜色取决于光线的反射和吸收情况。而区别于现实中的光源,虚拟场景中的光源可以是没有形状或者轮廓的虚拟光源节点。其中,现实中的光源是指能够自行发光且正在发光的物体,例如太阳、电灯、燃烧的物质等。The light source in the virtual scene is a series of lighting data that can truly simulate the lighting effect of the light source in reality. Similar to the light source in reality, when the colored light source in the virtual scene is projected onto the surface of the colored object, the final rendered color depends on the reflection and absorption of the light. Different from real light sources, the light source in the virtual scene can be a virtual light source node without shape or outline. Wherein, the light source in reality refers to an object that can emit light by itself and is emitting light, such as the sun, an electric lamp, burning substances, and the like.
在一些可能的实施例中,可以基于所述第一光照信息和第二光照信息同时对目标对象模型进行渲染,得到光照渲染结果。而在另一些可能的实施例中,参见图3所示,在基于所述第一光照信息和第二光照信息对所述目标对象模型进行光照渲染时,还可以包括以下S1041~S1043:In some possible embodiments, the target object model may be rendered simultaneously based on the first lighting information and the second lighting information to obtain a lighting rendering result. In some other possible embodiments, as shown in FIG. 3 , when performing lighting rendering on the target object model based on the first lighting information and the second lighting information, the following steps S1041-S1043 may also be included:
S1041,基于所述第一光照信息对所述目标对象模型进行第一光照渲染,得到第一光照渲染结果。S1041. Perform first lighting rendering on the target object model based on the first lighting information to obtain a first lighting rendering result.
S1042,基于所述第二光照信息对所述目标对象模型进行第二光照渲染,得到第二光照渲染结果。S1042. Perform second lighting rendering on the target object model based on the second lighting information to obtain a second lighting rendering result.
S1043,将所述第一光照渲染结果与所述第二光照渲染结果融合,得到所述目标对象模型的光照渲染结果。S1043. Merge the first lighting rendering result and the second lighting rendering result to obtain a lighting rendering result of the target object model.
本公开实施例中,通过第一光照信息和第二光照信息对目标对象模型分别进行渲染,并将分别渲染的结果进行融合,即可实现模型在场景中的独立渲染效果,进而可以提升场景中多个模型的整体渲染效果。In the embodiment of the present disclosure, the target object model is rendered separately through the first lighting information and the second lighting information, and the rendering results are fused to realize the independent rendering effect of the model in the scene, thereby improving the rendering effect of the scene. Overall rendering of multiple models.
本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的撰写顺序并不意味着严格的执行顺序而对实施过程构成任何限定,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。Those skilled in the art can understand that in the above method of specific implementation, the writing order of each step does not mean a strict execution order and constitutes any limitation on the implementation process. The specific execution order of each step should be based on its function and possible The inner logic is OK.
基于同一技术构思,本公开实施例中还提供了与光照渲染方法对应的光照渲染装置,由于本公开实施例中的装置解决问题的原理与本公开实施例上述光照渲染方法相似,因此装置的实施可以参见方法的实施,重复之处不再赘述。Based on the same technical idea, the embodiment of the present disclosure also provides an illumination rendering device corresponding to the illumination rendering method. Since the problem-solving principle of the device in the embodiment of the disclosure is similar to that of the above-mentioned illumination rendering method in the embodiment of the disclosure, the implementation of the device Reference can be made to the implementation of the method, and repeated descriptions will not be repeated.
参照图4所示,为本公开实施例提供的一种光照渲染装置400的示意图,所述装置包括:Referring to FIG. 4 , which is a schematic diagram of an illumination rendering device 400 provided by an embodiment of the present disclosure, the device includes:
数据获取模块401,用于获取与目标对象模型对应的模型初始光照数据,所述模型初始光照数据由用户预先配置生成;A data acquisition module 401, configured to acquire model initial lighting data corresponding to the target object model, the model initial lighting data being generated by user pre-configuration;
数据处理模块402,用于获取所述目标对象模型在目标场景内的当前位置信息以及虚拟相机的当前镜头信息,并基于所述当前位置信息以及所述当前镜头信息对所述模型初始光照数据进行处理,得到模型目标光照数据;The data processing module 402 is configured to acquire the current position information of the target object model in the target scene and the current lens information of the virtual camera, and perform the initial illumination data of the model based on the current position information and the current lens information Processing to obtain model target illumination data;
信息生成模块403,用于基于所述模型目标光照数据以及所述模型初始光照数据,生成所述目标对象模型对应的第一光照信息;An information generating module 403, configured to generate first lighting information corresponding to the target object model based on the model target lighting data and the model initial lighting data;
模型渲染模块404,用于获取所述目标场景的场景光源的第二光照信息,基于所述第一光照信息和所述第二光照信息对所述目标对象模型进行光照渲染。The model rendering module 404 is configured to acquire second lighting information of a scene light source of the target scene, and perform lighting rendering on the target object model based on the first lighting information and the second lighting information.
在一种可能的实施方式中,所述模型初始光照数据包括初始光照方向数据以及初始光照位置数据;所述数据处理模块402具体用于:In a possible implementation manner, the model initial illumination data includes initial illumination direction data and initial illumination position data; the data processing module 402 is specifically used for:
基于所述虚拟相机的当前镜头朝向信息,对所述初始光照方向数据进行处理,得到目标光照方向数据;Based on the current lens orientation information of the virtual camera, the initial illumination direction data is processed to obtain target illumination direction data;
根据所述目标光照方向数据、所述目标对象模型的当前位置信息以及所述初始光照位置数据,确定目标光照位置数据;Determine target lighting position data according to the target lighting direction data, current position information of the target object model, and the initial lighting position data;
基于所述目标光照方向数据以及所述目标光照位置数据,得到所述模型目标光照数据。Obtain the model target illumination data based on the target illumination direction data and the target illumination position data.
在一种可能的实施方式中,所述初始光照方向数据以相对于所述虚拟相机的单位矢量方向表示,所述数据处理模块402具体用于:In a possible implementation manner, the initial illumination direction data is represented by a unit vector direction relative to the virtual camera, and the data processing module 402 is specifically configured to:
基于所述虚拟相机的当前镜头朝向信息,确定所述单位矢量方向在相机空间的当前方向信息;Based on the current lens orientation information of the virtual camera, determine the current direction information of the unit vector direction in camera space;
根据所述虚拟相机的世界空间变换矩阵,将所述单位矢量方向在所述相机空间的当前方向信息转换到世界空间,得到所述世界空间的光照方向数据,并将所述世界空间的光照方向数据作为所述目标光照方向数据。According to the world space transformation matrix of the virtual camera, convert the current direction information of the unit vector direction in the camera space into the world space, obtain the light direction data of the world space, and convert the light direction data of the world space The data is used as the target illumination direction data.
在一种可能的实施方式中,所述初始光照位置数据以相对于所述虚拟相机的预设距离表示,所述数据处理模块402具体用于:In a possible implementation manner, the initial lighting position data is represented by a preset distance relative to the virtual camera, and the data processing module 402 is specifically configured to:
按照所述目标光照方向数据所指示的方向,以所述目标对象模型的当前位置信息为起点偏移所述预设距离,得到世界空间的光照位置数据,并将所述世界空间的光照位置数据作为所述目标光照位置数据。According to the direction indicated by the target lighting direction data, the current position information of the target object model is used as the starting point to offset the preset distance to obtain the lighting position data of the world space, and the lighting position data of the world space As the target illumination position data.
在一种可能的实施方式中,所述模型初始光照数据还包括初始光照颜色数据以及初始光照强度数据;所述信息生成模块403具体用于:In a possible implementation manner, the initial illumination data of the model also includes initial illumination color data and initial illumination intensity data; the information generation module 403 is specifically used for:
根据所述目标对象模型的当前位置信息以及所述目标光照位置数据,对所述初始光照强度进行处理,得到基于所述目标对象模型表面的目标光照强度数据;Processing the initial illumination intensity according to the current position information of the target object model and the target illumination position data to obtain target illumination intensity data based on the surface of the target object model;
基于所述目标光照强度数据、所述初始光照颜色数据以及所述目标光照方向数据,生成所述目标对象模型对应的第一光照信息。First illumination information corresponding to the target object model is generated based on the target illumination intensity data, the initial illumination color data, and the target illumination direction data.
在一种可能的实施方式中,所述信息生成模块403具体用于:In a possible implementation manner, the information generating module 403 is specifically configured to:
根据所述目标对象模型的当前位置信息以及所述目标光照位置数据,确定所述目标对象模型与所述目标光照位置数据所指示的光照位置之间的距离;According to the current position information of the target object model and the target lighting position data, determine the distance between the target object model and the lighting position indicated by the target lighting position data;
基于所述目标对象模型与所述光照位置之间的距离,确定所述述初始光照强度的线性衰减量;determining the linear attenuation of the initial illumination intensity based on the distance between the target object model and the illumination position;
根据所述线性衰减量对所述初始光照强度进行处理,得到所述目标光照强度。The initial light intensity is processed according to the linear attenuation amount to obtain the target light intensity.
在一种可能的实施方式中,所述模型渲染模块404具体用于:In a possible implementation manner, the model rendering module 404 is specifically configured to:
基于所述第一光照信息对所述目标对象模型进行第一光照渲染,得到第一光照渲染结果;Performing first lighting rendering on the target object model based on the first lighting information to obtain a first lighting rendering result;
基于所述第二光照信息对所述目标对象模型进行第二光照渲染,得到第二光照渲染结果;Performing second lighting rendering on the target object model based on the second lighting information to obtain a second lighting rendering result;
将所述第一光照渲染结果与所述第二光照渲染结果融合,得到所述目标对象模型的光照渲染结果。The first lighting rendering result is fused with the second lighting rendering result to obtain the lighting rendering result of the target object model.
关于装置中的各模块的处理流程、以及各模块之间的交互流程的描述可以参照上述方法实施例中的相关说明,这里不再详述。For the description of the processing flow of each module in the device and the interaction flow between the modules, reference may be made to the relevant description in the above method embodiment, and details will not be described here.
基于同一技术构思,本公开实施例还提供了一种电子设备。参照图5所示,为本公开实施例提供的电子设备500的结构示意图,包括处理器501、存储器502、和总线503。其中,存储器502用于存储执行指令,包括内存5021和外部存储器5022;这里的内存5021也称内存储器,用于暂时存放处理器501中的运算数据,以及与硬盘等外部存储器5022交换的数据,处理器501通过内存5021与外部存储器5022进行数据交换。Based on the same technical idea, an embodiment of the present disclosure also provides an electronic device. Referring to FIG. 5 , it is a schematic structural diagram of an electronic device 500 provided by an embodiment of the present disclosure, including a
本申请实施例中,存储器502具体用于存储执行本申请方案的应用程序代码,并由处理器501来控制执行。也即,当电子设备500运行时,处理器501与存储器502之间通过总线503通信,使得处理器501执行存储器502中存储的应用程序代码,进而执行前述任一实施例中所述的方法。In the embodiment of the present application, the
其中,存储器502可以是,但不限于,随机存取存储器(Random Access Memory,RAM),只读存储器(Read Only Memory,ROM),可编程只读存储器(Programmable Read-Only Memory,PROM),可擦除只读存储器(Erasable Programmable Read-Only Memory,EPROM),电可擦除只读存储器(Electric Erasable Programmable Read-Only Memory,EEPROM)等。Wherein, the
处理器501可能是一种集成电路芯片,具有信号的处理能力。上述的处理器可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(NetworkProcessor,NP)等;还可以是数字信号处理器(Digital Signal Processing,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(FieldProgrammable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本发明实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。The
可以理解的是,本申请实施例示意的结构并不构成对电子设备500的具体限定。在本申请另一些实施例中,电子设备500可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that, the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 500 . In other embodiments of the present application, the electronic device 500 may include more or fewer components than shown in the figure, or combine certain components, or separate certain components, or arrange different components. The illustrated components can be realized in hardware, software or a combination of software and hardware.
本公开实施例还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述方法实施例中的光照渲染方法的步骤。其中,该存储介质可以是易失性或非易失的计算机可读取存储介质。An embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is run by a processor, the steps of the illumination rendering method in the foregoing method embodiments are executed. Wherein, the storage medium may be a volatile or non-volatile computer-readable storage medium.
本公开实施例还提供一种计算机程序产品,该计算机程序产品承载有程序代码,所述程序代码包括的指令可用于执行上述方法实施例中的光照渲染方法的步骤,具体可参见上述方法实施例,在此不再赘述。Embodiments of the present disclosure also provide a computer program product, the computer program product carries a program code, and the instructions included in the program code can be used to execute the steps of the lighting rendering method in the above method embodiment, for details, please refer to the above method embodiment , which will not be repeated here.
其中,上述计算机程序产品可以具体通过硬件、软件或其结合的方式实现。在一个可选实施例中,所述计算机程序产品具体体现为计算机存储介质,在另一个可选实施例中,计算机程序产品具体体现为软件产品,例如软件开发包(Software Development Kit,SDK)等等。Wherein, the above-mentioned computer program product may be specifically implemented by means of hardware, software or a combination thereof. In an optional embodiment, the computer program product is embodied as a computer storage medium. In another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK), etc. wait.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统和装置的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。在本公开所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working process of the above-described system and device can refer to the corresponding process in the foregoing method embodiments, which will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods may be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or May be integrated into another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some communication interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本公开各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个处理器可执行的非易失的计算机可读取存储介质中。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本公开各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器、随机存取存储器、磁碟或者光盘等各种可以存储程序代码的介质。If the functions are realized in the form of software function units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium executable by a processor. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in various embodiments of the present disclosure. The aforementioned storage medium includes: various media capable of storing program codes such as U disk, mobile hard disk, read-only memory, random access memory, magnetic disk or optical disk.
最后应说明的是:以上所述实施例,仅为本公开的具体实施方式,用以说明本公开的技术方案,而非对其限制,本公开的保护范围并不局限于此,尽管参照前述实施例对本公开进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本公开揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本公开实施例技术方案的精神和范围,都应涵盖在本公开的保护范围之内。因此,本公开的保护范围应所述以权利要求的保护范围为准。Finally, it should be noted that: the above-mentioned embodiments are only specific implementations of the present disclosure, and are used to illustrate the technical solutions of the present disclosure, rather than limit them, and the protection scope of the present disclosure is not limited thereto, although referring to the aforementioned The embodiments have described the present disclosure in detail, and those skilled in the art should understand that any person familiar with the technical field can still modify the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present disclosure Changes can be easily imagined, or equivalent replacements can be made to some of the technical features; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in this disclosure. within the scope of protection. Therefore, the protection scope of the present disclosure should be defined by the protection scope of the claims.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211510885.0A CN115761105A (en) | 2022-11-29 | 2022-11-29 | Illumination rendering method, device, electronic device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211510885.0A CN115761105A (en) | 2022-11-29 | 2022-11-29 | Illumination rendering method, device, electronic device and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115761105A true CN115761105A (en) | 2023-03-07 |
Family
ID=85340167
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211510885.0A Pending CN115761105A (en) | 2022-11-29 | 2022-11-29 | Illumination rendering method, device, electronic device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115761105A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116347003A (en) * | 2023-05-30 | 2023-06-27 | 湖南快乐阳光互动娱乐传媒有限公司 | Virtual lamplight real-time rendering method and device |
-
2022
- 2022-11-29 CN CN202211510885.0A patent/CN115761105A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116347003A (en) * | 2023-05-30 | 2023-06-27 | 湖南快乐阳光互动娱乐传媒有限公司 | Virtual lamplight real-time rendering method and device |
CN116347003B (en) * | 2023-05-30 | 2023-08-11 | 湖南快乐阳光互动娱乐传媒有限公司 | Virtual lamplight real-time rendering method and device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109427088B (en) | Rendering method for simulating illumination and terminal | |
CN112215934B (en) | Game model rendering method and device, storage medium and electronic device | |
CN113648652B (en) | Object rendering method and device, storage medium and electronic equipment | |
US20220230375A1 (en) | Three-dimensional avatar generation and customization | |
CN114022607B (en) | Data processing method, device and readable storage medium | |
CN114119853B (en) | Image rendering method, apparatus, device and medium | |
CN111199573B (en) | A virtual-real interreflection method, device, medium and equipment based on augmented reality | |
US10762697B1 (en) | Directional occlusion methods and systems for shading a virtual object rendered in a three-dimensional scene | |
CN116012520B (en) | Shadow rendering method, device, computer equipment and storage medium | |
CN108043027B (en) | Storage medium, electronic device, game screen display method and device | |
WO2023098358A1 (en) | Model rendering method and apparatus, computer device, and storage medium | |
US20250054228A1 (en) | Illumination control in a virtual environment | |
KR20230013099A (en) | Geometry-aware augmented reality effects using real-time depth maps | |
CN115984449A (en) | Illumination rendering method and device, electronic equipment and storage medium | |
CN115761105A (en) | Illumination rendering method, device, electronic device and storage medium | |
CN114385289B (en) | Rendering display method and device, computer equipment and storage medium | |
US10754498B2 (en) | Hybrid image rendering system | |
CN115526976A (en) | Virtual scene rendering method and device, storage medium and electronic equipment | |
WO2025050797A1 (en) | Rendering method and apparatus, electronic device, computer-readable storage medium, and computer program product | |
CN112473135B (en) | Real-time illumination simulation method, device and equipment for mobile game and storage medium | |
CN114399572A (en) | Dynamic shadow generation method and device, electronic equipment and storage medium | |
CN114494548A (en) | Method, device and electronic device for generating virtual model | |
CN115035231A (en) | Shadow baking method, shadow baking device, electronic apparatus, and storage medium | |
CN119516080A (en) | Light source component control method, device, electronic device and storage medium for rendering engine | |
WO2023164244A1 (en) | Methods and systems for facilitating the cooperation of large numbers of computing devices with particular application to maintaining, presenting and editing a shared 3-dimensional virtual space to multiple users |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |