CN112750191B - Method for manufacturing soft shadow in real-time rendering - Google Patents

Method for manufacturing soft shadow in real-time rendering Download PDF

Info

Publication number
CN112750191B
CN112750191B CN202110033977.3A CN202110033977A CN112750191B CN 112750191 B CN112750191 B CN 112750191B CN 202110033977 A CN202110033977 A CN 202110033977A CN 112750191 B CN112750191 B CN 112750191B
Authority
CN
China
Prior art keywords
frame buffer
rendering
shadow
gaussian blur
objects
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.)
Active
Application number
CN202110033977.3A
Other languages
Chinese (zh)
Other versions
CN112750191A (en
Inventor
郭辰
董理
杨萍
张晓朝
梁思超
卜照军
冯笑丹
王森
蒋贲
王志勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Langrun Zhitian Technology Co ltd
Huaneng Clean Energy Research Institute
Huaneng Group Technology Innovation Center Co Ltd
Huaneng Renewables Corp Ltd
Original Assignee
Beijing Langrun Zhitian Technology Co ltd
Huaneng Clean Energy Research Institute
Huaneng Group Technology Innovation Center Co Ltd
Huaneng Renewables Corp Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Langrun Zhitian Technology Co ltd, Huaneng Clean Energy Research Institute, Huaneng Group Technology Innovation Center Co Ltd, Huaneng Renewables Corp Ltd filed Critical Beijing Langrun Zhitian Technology Co ltd
Priority to CN202110033977.3A priority Critical patent/CN112750191B/en
Publication of CN112750191A publication Critical patent/CN112750191A/en
Application granted granted Critical
Publication of CN112750191B publication Critical patent/CN112750191B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/60Shadow generation
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/52Controlling the output signals based on the game progress involving aspects of the displayed game scene
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/60Methods for processing data by generating or executing the game program
    • A63F2300/66Methods for processing data by generating or executing the game program for rendering three dimensional images
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02TCLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO TRANSPORTATION
    • Y02T10/00Road transport of goods or passengers
    • Y02T10/10Internal combustion engine [ICE] based vehicles
    • Y02T10/40Engine management systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Graphics (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Image Generation (AREA)

Abstract

The invention relates to a method for making soft shadow in real-time rendering, which relates to the technical field of image processing and solves the problems that most of soft shadow generated by the prior method has poor quality or has high requirement on hardware and is difficult to be directly applied in games; giving an ID for each model, and rendering to a pickup frame buffer; rendering the original shadow to obtain an unoptimized shadow; and for the original shadow, carrying out horizontal Gaussian blur and vertical Gaussian blur according to the pickup frame buffer, synthesizing to obtain an optimized shadow, and on the basis of rendering the pickup frame buffer, softening the hard shadow by using the two-dimensional Gaussian blur step by step. With this method, high quality shadows can be generated in a shorter time.

Description

一种实时渲染中软阴影的制作方法A method for making soft shadows in real-time rendering

技术领域Technical field

本发明涉及图像处理技术领域,具体涉及一种实时渲染中软阴影的制作方法。The invention relates to the technical field of image processing, and in particular to a method for producing soft shadows in real-time rendering.

背景技术Background technique

游戏中对于不同物体的识别,通常需要借助拾取帧缓冲来实现。游戏中常用阴影映射(Shadow Mapping)的方式实现软阴影效果,通常采用的方法是:在阴影边界进行高精度超级采样的方法,这就是软阴影消耗系统资源大的原因,因此这种方法对于硬件的要求较高。而在硬件条件较差的情况下,高效率软阴影的生成较为困难。The recognition of different objects in the game usually requires the help of picking up the frame buffer. Shadow Mapping is commonly used in games to achieve soft shadow effects. The commonly used method is: high-precision super sampling at the shadow boundary. This is why soft shadows consume a lot of system resources, so this method is very difficult for the hardware. The requirements are higher. In the case of poor hardware conditions, it is more difficult to generate high-efficiency soft shadows.

现有的方法生成的软阴影大多数质量较差,或者是对硬件需求较高,在游戏中难以直接应用。OpenGL(Open Graphics Library,开放图形库或者开放式图形库)用于渲染2D、3D矢量图形的跨语言、跨平台的应用程序编程接口(API)。这个接口由近350个不同的函数调用组成,用来绘制从简单的图形比特到复杂的三维景象。OpenGL常用于CAD、虚拟现实、科学可视化程序和电子游戏开发。Most of the soft shadows generated by existing methods are of poor quality or have high hardware requirements, making them difficult to apply directly in games. OpenGL (Open Graphics Library, open graphics library or open graphics library) is a cross-language and cross-platform application programming interface (API) used to render 2D and 3D vector graphics. This interface consists of nearly 350 different function calls used to draw everything from simple graphics bits to complex three-dimensional scenes. OpenGL is commonly used in CAD, virtual reality, scientific visualization programs, and video game development.

着色器(Shader)用于实现图像渲染的,用来替代固定渲染管线的可编辑程序。其中Vertex Shader主要负责顶点的几何关系等的运算,Pixel Shader主要负责片源颜色等的计算。Shader is an editable program used to implement image rendering and replace the fixed rendering pipeline. Among them, the Vertex Shader is mainly responsible for the calculation of the geometric relationships of vertices, etc., and the Pixel Shader is mainly responsible for the calculation of the source color, etc.

游戏中对于不同物体的识别,通常需要借助拾取帧缓冲来实现。渲染拾取帧缓冲的开销不低,而用途单一。The recognition of different objects in the game usually requires the help of picking up the frame buffer. Rendering the pickup framebuffer is expensive and has a single purpose.

发明内容Contents of the invention

本发明为解决现有方法生成的软阴影大多数质量较差,或者是对硬件需求较高,在游戏中难以直接应用的问题,提供一种实时渲染中软阴影的制作方法。In order to solve the problem that most of the soft shadows generated by existing methods are of poor quality or have high hardware requirements and are difficult to be directly applied in games, the present invention provides a method for making soft shadows in real-time rendering.

一种实时渲染中软阴影的制作方法,该方法由以下步骤实现:A method for making soft shadows in real-time rendering, which is implemented by the following steps:

步骤一、初始化OpenGL设备,加载需要渲染阴影的3D模型;Step 1. Initialize the OpenGL device and load the 3D model that needs to render shadows;

步骤二、设定每个模型具体唯一的ID,渲染到拾取帧缓冲;Step 2: Set a specific and unique ID for each model and render it to the pickup frame buffer;

步骤三、直接渲染原始阴影,获得未经优化的阴影;Step 3: Directly render the original shadow to obtain an unoptimized shadow;

步骤四、根据拾取帧缓冲,对未经优化的阴影进行两步高斯模糊,分别包括根据拾取帧缓冲进行水平方向高斯模糊和根据拾取帧缓冲进行垂直方向高斯模糊;Step 4: Perform two-step Gaussian blur on the unoptimized shadow based on the picked frame buffer, including horizontal Gaussian blur based on the picked frame buffer and vertical Gaussian blur based on the picked frame buffer;

步骤五、将步骤二和步骤四的结果进行合成,获得优化后的阴影。Step 5: Combine the results of Step 2 and Step 4 to obtain optimized shadows.

本发明的有益效果:Beneficial effects of the present invention:

1、本发明通过对于拾取帧缓冲的利用,能实现软阴影的制作,提高了资源利用率。1. The present invention can realize the production of soft shadows and improve resource utilization by utilizing the picked-up frame buffer.

2、本发明在渲染所得的拾取帧缓冲(3D Picking Texture)的基础上,使用分步的二维高斯模糊(Two Pass Gaussian Blur),实现对硬阴影的软化。使用该方法,可以在更短的时间内生成高质量的阴影。2. The present invention uses a step-by-step two-dimensional Gaussian Blur (Two Pass Gaussian Blur) based on the picked frame buffer (3D Picking Texture) obtained by rendering to achieve softening of hard shadows. Using this method, high-quality shadows can be generated in less time.

附图说明Description of the drawings

图1为本发明所述的一种实时渲染中软阴影的制作方法的流程图;Figure 1 is a flow chart of a method for producing soft shadows in real-time rendering according to the present invention;

图2为渲染的拾取帧缓冲效果图;Figure 2 shows the rendering of the picked frame buffer;

图3为渲染的原始阴影效果图;Figure 3 shows the original shadow rendering;

图4为优化后的阴影效果图。Figure 4 shows the optimized shadow rendering.

具体实施方式Detailed ways

结合图1至图4说明本实施方式,一种实时渲染中软阴影的制作方法,该方法由以下步骤实现:This embodiment, a method for making soft shadows in real-time rendering, is described with reference to Figures 1 to 4. The method is implemented by the following steps:

步骤S1、使用OpenGL渲染,初始化OpenGL设备,加载模型;Step S1, use OpenGL rendering, initialize the OpenGL device, and load the model;

初始化OpenGL,加载模型到顶点数组对象(Vertex Array Object,VAO),顶点缓冲区对象(Vertex Buffer Object,VBO),索引缓冲区对象(Indices Buffer Object,IBO),生成拾取帧缓冲。Initialize OpenGL, load the model into Vertex Array Object (VAO), Vertex Buffer Object (VBO), Index Buffer Object (IBO), and generate a pickup frame buffer.

步骤S2、设定每个模型具体唯一的ID,渲染到拾取帧缓冲;Step S2: Set a specific and unique ID for each model and render it to the pickup frame buffer;

渲染的拾取帧缓冲每个模型的唯一ID作为三维向量渲染到帧缓冲(Frame BufferObject)中。The unique ID of each model in the rendered pickup frame buffer is rendered into the frame buffer (Frame BufferObject) as a three-dimensional vector.

步骤S3、直接渲染原始阴影,获得未经优化的阴影;Step S3: Directly render the original shadow to obtain an unoptimized shadow;

步骤S4、对所述原始阴影,根据拾取帧缓冲,进行两步高斯模糊;Step S4: Perform two-step Gaussian blur on the original shadow according to the picked-up frame buffer;

采用二维高斯模糊,将二维高斯模糊拆分成两步实现,比起直接使用二维高斯卷积核(Gaussian Convolution Kernel),具有更高的效率。Two-dimensional Gaussian blur is used to split the two-dimensional Gaussian blur into two steps, which is more efficient than directly using the two-dimensional Gaussian Convolution Kernel.

步骤S5、根据拾取帧缓冲进行水平方向高斯模糊;Step S5: Perform horizontal Gaussian blur according to the picked-up frame buffer;

步骤S6、根据拾取帧缓冲进行垂直方向高斯模糊;Step S6: Perform vertical Gaussian blur according to the picked frame buffer;

根据步骤S2的拾取帧缓冲,使得分布进行的模糊过程不会影响到其他物体,渲染时进行判断,如果渲染了其他物体(具有不同的id),便停止渲染,使得模糊的阴影约束在同一个物体上。According to the frame buffer picked up in step S2, the blurring process of distribution will not affect other objects. It will be judged during rendering. If other objects (with different ids) are rendered, the rendering will be stopped so that the blurred shadows are constrained to the same object. on objects.

判断不同id的关键是通过比较两个id的距离,进而判断不同的物体。The key to judging different IDs is to judge different objects by comparing the distance between the two IDs.

本实施方式中,使用的图形库为OpenGL,但实现的方式不仅限于OpenGL。使用相同的渲染管线,稍加改进便可用于Direct3D,Metal等其他图形库,也可用于Unity3D,Unreal等游戏引擎的shader设计中。可以方便地移植到Windows,Android,IOS等各种平台上。In this implementation, the graphics library used is OpenGL, but the implementation method is not limited to OpenGL. Using the same rendering pipeline, with slight improvements, it can be used in other graphics libraries such as Direct3D and Metal, as well as in the shader design of game engines such as Unity3D and Unreal. It can be easily ported to Windows, Android, IOS and other platforms.

以上所述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above-described embodiments can be combined in any way. To simplify the description, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, All should be considered to be within the scope of this manual.

以上所述实施例仅表达了本发明的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only express several implementation modes of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention. It should be noted that, for those of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the scope of protection of the patent of the present invention should be determined by the appended claims.

Claims (2)

1. A method for producing soft shadows in real-time rendering, comprising the steps of:
initializing OpenGL equipment, and loading a 3D model needing shadow rendering;
loading a 3D model to the vertex group object, the vertex buffer object, and the index buffer object to generate a pickup frame buffer;
setting a specific unique ID of each model, and rendering to a pickup frame buffer;
step three, directly rendering an original shadow to obtain an unoptimized shadow;
step four, performing two-step Gaussian blur on the non-optimized shadow according to the picked-up frame buffer, wherein the two-step Gaussian blur comprises horizontal Gaussian blur according to the picked-up frame buffer and vertical Gaussian blur according to the picked-up frame buffer;
in the process of carrying out Gaussian blur in the horizontal direction and Gaussian blur in the vertical direction, judging according to the pickup frame buffer in the second step during rendering, and stopping rendering when other objects are rendered, so that blurred shadows are constrained on the same object;
judging whether the two objects are the same object by comparing the distances of the IDs of the two objects, and judging the two objects as different objects when the Euclidean distance of the IDs of the two objects is greater than a certain threshold value;
and step five, synthesizing the results of the step two and the step four to obtain the optimized shadow.
2. The method for producing soft shadows in real-time rendering according to claim 1, wherein: in the second step, the unique ID of each model of the rendered pickup frame buffer is rendered into the frame buffer as a three-dimensional vector.
CN202110033977.3A 2021-01-12 2021-01-12 Method for manufacturing soft shadow in real-time rendering Active CN112750191B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110033977.3A CN112750191B (en) 2021-01-12 2021-01-12 Method for manufacturing soft shadow in real-time rendering

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110033977.3A CN112750191B (en) 2021-01-12 2021-01-12 Method for manufacturing soft shadow in real-time rendering

Publications (2)

Publication Number Publication Date
CN112750191A CN112750191A (en) 2021-05-04
CN112750191B true CN112750191B (en) 2023-11-10

Family

ID=75650792

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110033977.3A Active CN112750191B (en) 2021-01-12 2021-01-12 Method for manufacturing soft shadow in real-time rendering

Country Status (1)

Country Link
CN (1) CN112750191B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105611386A (en) * 2015-12-23 2016-05-25 小米科技有限责任公司 Video picture processing method and device
KR20160103926A (en) * 2015-02-25 2016-09-02 삼성전자주식회사 Shadow rendering method and shadow rendering apparatus
CN106485776A (en) * 2016-11-23 2017-03-08 北京三体高创科技有限公司 A kind of method and system of 3D game real-time rendering large scale scene

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7212206B2 (en) * 2003-08-20 2007-05-01 Sony Computer Entertainment Inc. Method and apparatus for self shadowing and self interreflection light capture
US7542038B2 (en) * 2005-06-30 2009-06-02 Intel Corporation Method and system for pivot-point based adaptive soft shadow estimation
US7969438B2 (en) * 2007-01-23 2011-06-28 Pacific Data Images Llc Soft shadows for cinematic lighting for computer graphics
GB2537973B (en) * 2015-03-03 2018-01-10 Imagination Tech Ltd Systems and methods for soft shadowing in 3-D rendering

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20160103926A (en) * 2015-02-25 2016-09-02 삼성전자주식회사 Shadow rendering method and shadow rendering apparatus
CN105611386A (en) * 2015-12-23 2016-05-25 小米科技有限责任公司 Video picture processing method and device
CN106485776A (en) * 2016-11-23 2017-03-08 北京三体高创科技有限公司 A kind of method and system of 3D game real-time rendering large scale scene

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Soft Shadow Maps:Efficient Sampling of Light Source Visibility;Lionel A. et al.;《Computer graphics forum》;第25卷(第4期);第725-741页 *
实时阴影渲染技术的研究与应用;赵丹;《中国优秀硕士学位论文全文数据库 (信息科技辑)》;第I138-1335页 *

Also Published As

Publication number Publication date
CN112750191A (en) 2021-05-04

Similar Documents

Publication Publication Date Title
JP7142162B2 (en) Posture variation 3D facial attribute generation
TWI618030B (en) Method and system of graphics processing enhancement by tracking object and/or primitive identifiers, graphics processing unit and non-transitory computer readable medium
US20180204307A1 (en) Performing spatiotemporal filtering
US8044955B1 (en) Dynamic tessellation spreading for resolution-independent GPU anti-aliasing and rendering
US20140362100A1 (en) Scheme for compressing vertex shader output parameters
CN109358852B (en) Method for realizing skin changing of vehicle-mounted GUI (graphical user interface) by using shader
US20140292803A1 (en) System, method, and computer program product for generating mixed video and three-dimensional data to reduce streaming bandwidth
EP3580726B1 (en) Buffer index format and compression
US10713844B2 (en) Rendering based generation of occlusion culling models
CN111724313B (en) Shadow map generation method and device
CN109785417B (en) Method and device for realizing OpenGL cumulative operation
CN115512073A (en) 3D texture mesh reconstruction method based on multi-stage training under differentiable rendering
CN110503146A (en) Data enhancement method, device, computing device and computer storage medium
CN105574931A (en) Electronic map road drawing method and device
CN117765204A (en) Tessellation method, apparatus, and graphics processing unit
US20230316626A1 (en) Image rendering method and apparatus, computer device, and computer-readable storage medium
WO2018039936A1 (en) Fast uv atlas generation and texture mapping
CN111951345B (en) GPU-based real-time image video oil painting stylization method
CN106251291A (en) Utilize OpenGL with OpenCL to cooperate and realize the method and system of image scaling
US20150015574A1 (en) System, method, and computer program product for optimizing a three-dimensional texture workflow
US9275487B1 (en) System and method for performing non-affine deformations
CN112750191B (en) Method for manufacturing soft shadow in real-time rendering
CN108010113B (en) Deep learning model execution method based on pixel shader
CN110874856A (en) Optimization method for real-time rendering of GUI (graphical user interface) based on GPU (graphics processing Unit) characteristics
CN110136235B (en) Three-dimensional BIM model shell extraction method and device and computer equipment

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
GR01 Patent grant
GR01 Patent grant