WO2021253642A1 - 图像渲染方法、装置、计算机程序和可读介质 - Google Patents

图像渲染方法、装置、计算机程序和可读介质 Download PDF

Info

Publication number
WO2021253642A1
WO2021253642A1 PCT/CN2020/112579 CN2020112579W WO2021253642A1 WO 2021253642 A1 WO2021253642 A1 WO 2021253642A1 CN 2020112579 W CN2020112579 W CN 2020112579W WO 2021253642 A1 WO2021253642 A1 WO 2021253642A1
Authority
WO
WIPO (PCT)
Prior art keywords
target object
patch
patch map
map corresponding
viewport
Prior art date
Application number
PCT/CN2020/112579
Other languages
English (en)
French (fr)
Inventor
胡梓楠
Original Assignee
完美世界(北京)软件科技发展有限公司
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 完美世界(北京)软件科技发展有限公司 filed Critical 完美世界(北京)软件科技发展有限公司
Publication of WO2021253642A1 publication Critical patent/WO2021253642A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/10Geometric effects
    • G06T15/20Perspective computation
    • G06T15/205Image-based rendering
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • G06T17/20Finite element generation, e.g. wire-frame surface description, tesselation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • G06T7/62Analysis of geometric attributes of area, perimeter, diameter or volume
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/70Determining position or orientation of objects or cameras
    • G06T7/73Determining position or orientation of objects or cameras using feature-based methods

Definitions

  • the present invention relates to the field of image processing technology, and in particular to an image rendering method, device, computer program and readable medium.
  • the static objects will correspond to information such as model vertex data, rendering materials, and the position and posture of the static objects in the 3D scene.
  • static objects in the 3D scene will be queried through the viewport camera. In this way, objects that can be queried by the viewport camera can be collected.
  • rendering will be performed in units of these objects, so that rendering each object of this type requires at least one drawing operation. If multiple materials are attached to different parts of the object, more times need to be drawn.
  • the embodiments of the present invention provide an image rendering method, device, equipment, and storage medium, which are used to reduce the number of drawn vertices and improve the efficiency of game operation.
  • an embodiment of the present invention provides an image rendering method, which includes:
  • an image rendering device including:
  • the determination module is used to determine whether the target object is visible in the first viewport camera
  • a calculation module configured to determine the area of the projection area occupied by the target object in the scene viewport if the target object is visible in the first viewport camera;
  • An acquiring module configured to acquire a patch map corresponding to the target object if the area is less than a first preset threshold
  • the drawing module is used to draw the patch map corresponding to the target object to the scene viewport.
  • a computer program comprising computer readable code, when the computer readable code runs on an electronic device, causes the electronic device to execute the Any one of the image rendering methods described above.
  • the vertex data of the model itself can be replaced by a rectangular facet, the number of drawing vertices is reduced, and the rendering efficiency is improved.
  • the patch maps of these objects can be merged into a set of vertex buffers to be drawn by one drawing operation, which can reduce the number of drawing as a whole.
  • the lighting calculation can be carried out again, saving The computational cost of performing lighting calculations.
  • the rendering calculation cost can be significantly reduced under the condition that the rendering effect of the static object is basically not affected.
  • FIG. 1 is a schematic flowchart of an image rendering method provided by an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a flowchart of an image rendering method provided by an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of an image rendering device provided by an embodiment of the present invention.
  • Fig. 4 is a block diagram of an electronic device for executing the method according to the present invention provided by an embodiment of the present invention.
  • Fig. 5 is a storage unit for holding or carrying program codes for implementing the method according to the present invention provided by an embodiment of the present invention.
  • the words “if” and “if” as used herein can be interpreted as “when” or “when” or “in response to determination” or “in response to detection”.
  • the phrase “if determined” or “if detected (statement or event)” can be interpreted as “when determined” or “in response to determination” or “when detected (statement or event) )” or “in response to detection (statement or event)”.
  • Fig. 1 is a flowchart of an image rendering method provided by an embodiment of the present invention. As shown in Fig. 1, the method includes the following steps:
  • the target object can be rendered into the 3D scene in the game, otherwise Then there is no need to render the target object into the three-dimensional scene.
  • the target object may be a static object in the game scene. Since the change of static objects is small, the rendering of static objects can be reduced to improve rendering efficiency.
  • the target object can be rendered.
  • the area of the projection area occupied by the target object in the scene viewport can be determined first, and if the occupied area is less than the first preset threshold, the patch map corresponding to the target object can be obtained.
  • the patch map can also be considered a snapshot image of the target object. It is understandable that if the patch map corresponding to the target object is drawn and stored in advance, the patch map can be directly obtained. If the patch map corresponding to the target object is not drawn and stored in advance, the patch map corresponding to the target object can be drawn and stored, and the patch map can be used.
  • the patch map here refers to the image obtained by drawing the target object separately according to the angle of the current first viewport camera.
  • the patch map corresponding to the target object can be stored in the image data on the additional texture.
  • the pixel format can be RGBA, and the A channel is responsible for the hollowing effect. It should be noted that the specific implementation of drawing patch maps will be introduced later, so I won’t repeat them here.
  • the above process of determining the area of the projection area occupied by the target object in the scene viewport can be implemented as: determining the side length of the patch corresponding to the target object; determining the distance between the center of the patch and the first viewport camera; determining the side length and The ratio between the distances; if the ratio is less than the first preset threshold, the patch map corresponding to the target object is obtained.
  • the ratio of the side length of the patch corresponding to the target object to the distance between the center of the patch and the first viewport camera is less than the first preset threshold, it can be approximately considered that the target object is in the camera viewport. If the opening angle of is small, then you can use snapshots to render the target object.
  • the side length and the center position of the patch corresponding to the target object need to be determined.
  • the side length and center position of the patch can be determined in the following way: Determine according to the bounding box and placement position of the static object model The side length and center position of the patch. If you are not satisfied with the determined result, the technician can also make manual adjustments in the editor.
  • the patch corresponding to the target object may be set in a square shape, and the side length of the patch may be set to a preset multiple of the diagonal length of the bounding box of the target object model.
  • the preset multiple may be 1.05, for example.
  • the obtained center position of the patch can be set as the position of the center point of the bounding box of the target object model in the three-dimensional scene. It can be understood that in the embodiment of the present invention, the default configuration can meet the needs of most situations. In actual work, there are fewer static objects that need to manually adjust the side length and center position of the patch, and the workload in the editing phase is small. .
  • the patch map corresponding to the target object After the patch map corresponding to the target object is obtained, the patch map corresponding to the target object can be drawn into the scene viewport.
  • the attribute parameter corresponding to the target object can also be obtained.
  • the attribute parameter includes an identifier for indicating whether to enable the real-time snapshot.
  • the ImposterManager class is a global subsystem and a singleton.
  • the ImposterManager class can mainly realize the creation and deletion of patch maps, as well as the allocation of regional blocks in the image array to the target object.
  • the ImposterManager class can also maintain the rendering material used to render the snapshot of the target object to the 3D scene.
  • the ImposterManager class can also store global configurable parameters related to the patch map. These global configurable parameters can include the number of patch maps, the size of each patch, and the area occupied by the patch map of each object on the image array. The size and so on. In the default configuration, two 1024x1024 RGBA8 image arrays can be allocated to store the patch maps of different objects. Each image array can be divided with 64x64 pixels as the basic unit, so that an area of 16 rows and 16 columns can be obtained. Blocks, each area block corresponds to a patch map of a static object. It should be noted that, in practical applications, a depth map with the same number of pixels as the above-mentioned image array can also be set.
  • the texture information corresponding to the target object can be stored in ImposterData, and the texture information includes information indicating the storage location of the patch texture corresponding to the target object in the image array. Therefore, the texture information corresponding to the target object can be obtained from ImposterData, and the patch texture corresponding to the target object can be obtained from the image array according to the texture information corresponding to the target object.
  • the texture information corresponding to the target object may also include information such as a pointer to a patch texture parameter and the number of consecutive unused times of the current ImposterData.
  • the ImposterImage class corresponds to a patch map, and it also corresponds to a drawing batch that renders the patch map to a three-dimensional scene.
  • the ImposterImage class can contain 1 snapshot texture object, 1 set of vertex buffer and index buffer for drawing the snapshot texture to the 3D scene.
  • Each area block on the snapshot map corresponds to an ImposterData object, which can be maintained and managed by the ImposterImage class.
  • each ImposterImage class can collect snapshots that need to be updated again and draw them to their respective area blocks.
  • the vertex positions and texture data of the snapshots that need to be drawn to the 3D scene can be written into the vertex buffer, and then they are drawn to the scene in a unified order.
  • ObjectImposterParam is the object pointed to by the patch map parameter pointer in ImposterData, which is maintained by each static object that uses snapshots. Through this object, it can be associated with the snapshot parameters of the corresponding static object, the model drawn by itself, the material, the batch and other information.
  • an image array for storing multiple object patch maps can be created in advance.
  • the image array includes a plurality of area blocks, and each area block is used to store a patch map of an object; set a preset number of Patch map parameter pointer; one of the preset number of patch map parameter pointers is allocated to each area block, and the initial point of the allocated patch map parameter pointer is empty; after any area block is assigned to any object, Set the patch map parameter pointer of any area block to point to any object; after any area block is assigned to any object, record the consecutive unused times of the patch map corresponding to the object in any area block.
  • the patch map of the target object can be drawn at this time. Before drawing, you can first determine whether there is a first resource with an empty patch map parameter pointer; if there is a first resource with an empty patch map parameter pointer, assign the first resource to the target object to be in the first resource Draw the patch map corresponding to the target object; if there is no first resource whose patch map parameter pointer is empty, determine other objects whose continuous unused times of the patch map exceeds the second preset threshold, and take the first resource occupied by other objects. The second resource is allocated to the target object to draw a patch map corresponding to the target object in the second resource.
  • ImposterData with an empty patch map parameter pointer can be assigned to the target object first. If there is no ImposterData with an empty patch map parameter pointer, the number of consecutive unused times can be accumulated to exceed the second preset threshold. ImposterData is assigned to the target object.
  • the second preset threshold may be set to 100 frames in the embodiment of the present invention, for example. If there is no ImposterData that can be allocated, you can first render the target object according to the normal drawing method.
  • ImposterImage can traverse all ImposterData managed by the ImposterImage during each frame rendering, adding 1 to the consecutive unused times of ImposterData that do not need to be rendered to the scene. If the ImposterData corresponding to an object is used in the rendering process of any frame, you can also directly set the number of consecutive unused ImposterData to 0.
  • the patch map parameter pointer in ImposterData can be set to the ObjectImposterParam pointing to the target object, and the target object can also record the index position of the corresponding ImposterData in the ImposterManager. .
  • ImposterData When you need to use a snapshot to render the target object, you can first determine whether the ImposterData has been allocated to the target object. If the ImposterData has been allocated, then you can determine whether the allocated ImposterData has been allocated to other objects, and if the allocated ImposterData has been allocated again For other objects, ImposterData can be reassigned to the target object. Since the newly allocated ImposterData will not store the snapshot of the target object, the snapshot of the target object needs to be redrawn in the area block corresponding to the ImposterData.
  • the ImposterData stores a snapshot of the target object.
  • the snapshot stored in ImposterData can be used directly, or the snapshot can be updated and reused under certain conditions.
  • the amount of change between the first orientation angle of the current first viewport camera and the second orientation angle of the first viewport camera when the patch map corresponding to the target object was updated last time; Based on the amount of change, determine whether to update the patch map corresponding to the target object; if the amount of change is greater than the third preset threshold, update the patch map corresponding to the target object; if the amount of change is less than or equal to the third preset threshold , Adjust the rotation posture of the patch map corresponding to the target object.
  • the above process of determining the amount of change between the first orientation angle of the current first viewport camera and the second orientation angle of the first viewport camera when the patch map corresponding to the target object was updated last time can be implemented To: determine the first orientation angle of the current first viewport camera; determine the second orientation angle of the first viewport camera when the patch map corresponding to the target object was updated last time; determine the first orientation angle and the second orientation angle The number product.
  • the cosine value of the third preset threshold can also be determined; if the quantity product is less than the cosine value, the patch map corresponding to the target object is updated.
  • the aforementioned quantitative product may represent the cosine value of the angle.
  • the quantitative product is less than the cosine value of the preset angle, it means that the change angle of the first viewport camera has changed beyond the preset angle, and the snapshot can be refreshed.
  • the preset angle may be set to 12 degrees in the embodiment of the present invention, for example.
  • the following methods can be used: determine the position of the second viewport camera; pass the target object Corresponding model vertex data, rendering material, and rendering parameters, draw the patch map corresponding to the target object.
  • a second viewport camera can be set, and the second viewport camera can adopt parallel projection.
  • the length and width of the second viewport camera's field of view can be set to the same value as the length and width of the rectangular patch of the target object.
  • the orientation of the second viewport camera and the near and far clipping plane can be set to be consistent with the first viewport camera.
  • the vector from the position of the second viewport camera to the center of the surface of the target object is the projection of the vector from the first viewport camera to the center of the surface of the target object in the direction of the first viewport camera. In this way, the position of the second viewport camera can be determined.
  • the snapshot drawing viewport can be calculated based on the row and column position of the snapshot drawing area in the entire snapshot texture.
  • the model vertex data, the rendering material, and the rendering parameters are the same as those in normal rendering when drawing snapshots.
  • the overall depth map can be cleared to 1.0, and the color map can be cleared by drawing a square patch.
  • the process of updating the patch map corresponding to the target object can be implemented as: determining the local coordinates of the patch map; determining the world transformation matrix; based on the local coordinates of the patch map And the world transformation matrix determines the vertex data of the patch map corresponding to the target object; based on the vertex data, the patch map corresponding to the target object is updated.
  • the texture coordinates of the vertices of the snapshot patch can be calculated according to the row and column positions of the snapshot drawing area in the entire snapshot texture.
  • the position coordinates of the vertices of the snapshot face are the coordinates in the world space, which can be calculated by superimposing the world transformation matrix on the local coordinates.
  • the process of determining the local coordinates of the patch map can be implemented as follows: set the z values of the four vertices of the patch map to 0, and use the origin as the center to determine the four vertices according to the side length of the patch map. Local coordinates.
  • the position of the snapshot patch in world space is the position of its center point, and the posture is the viewport camera posture quaternion rotation 180 degrees around the viewport camera Y axis.
  • the process of determining the world transformation matrix can be implemented as: obtaining the pose of the first viewport camera; determining the center position of the patch map; determining the world transformation based on the pose of the first viewport camera and the center position of the patch map matrix.
  • a simplified algorithm for the symmetry of the rectangular patch in the model space can be used.
  • the positions of the four vertices of the square patch can be exchanged symmetrically about the Y axis, and then the camera pose and the position of the center of the snapshot patch are used to form a world transformation matrix.
  • the coordinates of the vertices of the snapshot face in the world space can be obtained.
  • the target object can be acquired to determine whether the target object can be rendered through a snapshot. If the rendering can be performed through a snapshot, it can be determined whether the snapshot data is allocated to the target object. If the snapshot cannot be used for rendering, the target object will be rendered according to the normal rendering method. If snapshot data has been assigned to the target object, you can determine whether the snapshot data still belongs to the target object. If the snapshot data is not assigned to the target object, you can assign the snapshot data to the target object, and if it is determined that the assignment is successful, you can redraw the snapshot For texture maps, if it is judged that the assignment is unsuccessful, the target object can be rendered according to the normal rendering method.
  • the step of redrawing the snapshot map can be performed. If only the rotation posture of the patch needs to be adjusted, then You can adjust the rotation posture of the snapshot face. After redrawing the snapshot texture or adjusting the rotation posture of the snapshot surface, you can draw the snapshot texture into the 3D scene.
  • the drawn vertex data in the process of rendering a three-dimensional scene, when there are many static objects in the viewport camera, the drawn vertex data can be simplified without affecting the artistic effect as a whole, and the drawing batches can be performed Merge to improve rendering efficiency.
  • the vertex data of the model itself can be replaced by a rectangular facet, the number of drawing vertices is reduced, and the rendering efficiency is improved.
  • the patch maps of these objects can be merged into a set of vertex buffers to be drawn by one drawing operation, which can reduce the number of drawing as a whole.
  • the lighting calculation can be carried out again, saving The computational cost of performing lighting calculations.
  • the rendering calculation cost can be significantly reduced under the condition that the rendering effect of the static object is basically not affected.
  • FIG. 3 is a schematic structural diagram of an image rendering device provided by an embodiment of the present invention. As shown in FIG. 3, the device includes:
  • the determining module 31 is used to determine whether the target object is visible in the first viewport camera
  • the calculation module 32 is configured to determine the area of the projection area occupied by the target object in the scene viewport if the target object is visible in the first viewport camera;
  • the obtaining module 33 is configured to obtain a patch map corresponding to the target object if the area is less than a first preset threshold
  • the drawing module 34 is configured to draw the patch map corresponding to the target object to the scene viewport.
  • the calculation module 32 is configured to determine the side length of the patch corresponding to the target object; determine the distance between the center of the patch and the first viewport camera; determine the side length The ratio to the distance;
  • the acquiring module 33 is configured to acquire a patch map corresponding to the target object if the ratio is less than a first preset threshold.
  • the obtaining module 33 is configured to:
  • a patch texture corresponding to the target object is obtained.
  • the device further includes:
  • a creation module for pre-creating an image array for storing patch maps of multiple objects includes a plurality of area blocks, and each area block is used to store a patch map of an object;
  • An allocation module configured to allocate one of the preset number of patch texture parameter pointers to each area block, and the initial point of the allocated patch texture parameter pointer is null;
  • the setting module is configured to set the patch mapping parameter pointer of any area block to point to any object after any area block is allocated to any object;
  • the number of consecutive unused times of the patch map corresponding to the object in the any area block is recorded.
  • the obtaining module 33 is configured to:
  • the device further includes an update module, and the update module is configured to:
  • the rotation posture of the patch map corresponding to the target object is adjusted.
  • the update module is used to:
  • the patch map corresponding to the target object is updated.
  • the update module is used to:
  • the patch map corresponding to the target object is updated.
  • the update module is used to:
  • the z values of the four vertices of the patch map are set to 0, and the origin is the center and the local coordinates of the four vertices are determined according to the side length of the patch map.
  • the update module is used to:
  • a world transformation matrix is determined.
  • the obtaining module 33 is configured to:
  • the patch map corresponding to the target object is drawn.
  • the device shown in FIG. 3 can execute the image rendering method provided in the embodiments shown in FIG. 1 to FIG. 2.
  • the various component embodiments of the present invention may be implemented by hardware, or by software modules running on one or more processors, or by a combination of them.
  • a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in the electronic device according to the embodiments of the present invention.
  • DSP digital signal processor
  • the present invention can also be implemented as a device or device program (for example, a computer program and a computer program product) for executing part or all of the methods described herein.
  • Such a program for realizing the present invention may be stored on a computer-readable medium, or may have the form of one or more signals.
  • Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
  • FIG. 4 shows an electronic device that can be implemented to perform the method according to the present invention.
  • the electronic device traditionally includes a processor 410 and a computer program product in the form of a memory 420 or a computer-readable medium.
  • the memory 420 may be an electronic memory such as flash memory, EEPROM (Electrically Erasable Programmable Read Only Memory), EPROM, hard disk, or ROM.
  • the memory 420 has a storage space 430 for executing the program code 431 of any method step in the foregoing method.
  • the storage space 430 for storing program codes may include various program codes 431 respectively used to implement various steps in the above method. These program codes can be read from or written into one or more computer program products.
  • These computer program products include program code carriers such as hard disks, laser disks (CDs), memory cards, or floppy disks.
  • Such a computer program product is usually a portable or fixed storage unit as described with reference to FIG. 5.
  • the storage unit may have storage segments, storage spaces, etc., arranged similarly to the storage 420 in the electronic device of FIG. 4.
  • the program code can be compressed, for example, in a suitable form.
  • the storage unit includes computer-readable codes 431', that is, codes that can be read by, for example, a processor such as 410. These codes, when run by an electronic device, cause the electronic device to execute each of the methods described above. step.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Geometry (AREA)
  • Computer Graphics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Image Generation (AREA)
  • Processing Or Creating Images (AREA)

Abstract

一种图像渲染方法、装置、计算机程序和可读介质,该方法包括:确定目标物体在第一视口相机中是否可见(101);若所述目标物体在所述第一视口相机中可见,则确定所述目标物体在场景视口中占据投影区域的面积(102);若所述面积小于第一预设阈值,则获取所述目标物体对应的面片贴图(103);将所述目标物体对应的面片贴图绘制到所述场景视口(104)。通过面片贴图代替模型本身的顶点数据,减少绘制顶点数,提高渲染效率。

Description

图像渲染方法、装置、计算机程序和可读介质
本申请要求于2020年6月18日提交的申请号为202010560369.3、发明名称为“图像渲染方法、装置、设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及图像处理技术领域,尤其涉及一种图像渲染方法、装置、计算机程序和可读介质。
背景技术
对于三维场景中的静态物体,静态物体会对应有模型顶点数据、渲染材质、静态物体在三维场景中摆放的位置与姿态等信息。在游戏运行过程中会通过视口相机对三维场景中的静态物体进行查询,通过这样的方式可以收集视口相机可以查询到的物体。对于视口相机可以查询到的物体中的静态物体,会以这些物体为单位进行渲染,这样渲染每个这种类型的物体至少需要通过一次绘制操作。如果物体不同部位贴了多种材质,那么需要进行绘制的次数更多。
大型的三维游戏场景中往往会摆放很多的物体,用以保证游戏美术内容的丰富和层次感。即使经过视口相机对物体的剔除,剩余物体的数量也不可小视。如果视口相机查询到的每个静态物体都至少需要通过一次绘制操作进行渲染,那么就会造成三维游戏场景中每帧产生的绘制操作次数较多,同时绘制顶点数量也较大,从而会影响游戏运行效率。
发明内容
本发明实施例提供一种图像渲染方法、装置、设备和存储介质,用以实现降低绘制顶点数量,提高游戏运行效率。
第一方面,本发明实施例提供一种图像渲染方法,该方法包括:
确定目标物体在第一视口相机中是否可见;
若所述目标物体在所述第一视口相机中可见,则确定所述目标物体在场景视口中占据投影区域的面积;
若所述面积小于第一预设阈值,则获取所述目标物体对应的面片贴图;
将所述目标物体对应的面片贴图绘制到所述场景视口。
第二方面,本发明实施例提供一种图像渲染装置,包括:
确定模块,用于确定目标物体在第一视口相机中是否可见;
计算模块,用于若所述目标物体在所述第一视口相机中可见,则确定所述目标物体在场景视口中占据投影区域的面积;
获取模块,用于若所述面积小于第一预设阈值,则获取所述目标物体对应的面片贴图;
绘制模块,用于将所述目标物体对应的面片贴图绘制到所述场景视口。
根据本发明的又一个方面,提供了一种计算机程序,其包括计算机可读代码,当所述计算机可读代码在电子设备上运行时,导致所述电子设备执行根据权利要求1-11中的任一个所述的图像渲染方法。
根据本发明的再一个方面,提供了一种计算机可读介质,其中存储了如权利要求23所述的计算机程序。
采用本发明,可以通过矩形面片代替模型本身的顶点数据,减少绘制顶点数,提高渲染效率。对于位于相同快照贴图也即图像阵列中的面片贴图的物体,可以将这些物体的面片贴图合并到一组顶点缓冲中通过一次绘制操作进行绘制,从总体上可以减少绘制的次数。另外,可以对面片贴图预先进行光照处理,那么在图像阵列中保存的面片贴图已经是经过光照处理的结果,在将面片贴图绘制到三维场景中时,可以虚无再进行光照计算,节省了进行光照计算的计算开销。最后,通过本发明,在静态物体的绘制效果基本不受影响的情况下,能够显著降低渲染计算开销。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种图像渲染方法的流程图示意图;
图2为本发明实施例提供的一种图像渲染方法的流程图示意图;
图3为本发明实施例提供的一种图像渲染装置的结构示意图;
图4为本发明实施例提供的一种用于执行根据本发明的方法的电子设备的框图;以及
图5为本发明实施例提供的一种用于保持或者携带实现根据本发明的方法的程序代码的存储单元。
具体实施方式
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
在本发明实施例中使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本发明。在本发明实施例和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义,“多种”一般包含至少两种。
取决于语境,如在此所使用的词语“如果”、“若”可以被解释成为“在……时”或“当……时”或“响应于确定”或“响应于检测”。类似地,取决于语境,短语“如果确定”或“如果检测(陈述的条件或事件)”可以被解释成为“当确定时”或“响应于确定”或“当检测(陈述的条件或事件)时”或“响应于检 测(陈述的条件或事件)”。
另外,下述各方法实施例中的步骤时序仅为一种举例,而非严格限定。
图1为本发明实施例提供的一种图像渲染方法的流程图,如图1所示,该方法包括如下步骤:
101、确定目标物体在第一视口相机中是否可见。
102、若目标物体在第一视口相机中可见,则确定目标物体在场景视口中占据投影区域的面积。
103、若面积小于第一预设阈值,则获取目标物体对应的面片贴图。
104、将目标物体对应的面片贴图绘制到场景视口。
在实际应用中,在游戏过程中,可以通过第一视口相机进行查询,如果该第一视口相机能够看目标物体,那么就可以将该目标物体渲染到游戏中的三维场景中,否则的话则就无需将该目标物体渲染到三维场景中。需要说明的是,目标物体可以是游戏场景中的静态物体。由于静态物体的变化较小,可以减少对静态物体的渲染,以提高渲染效率。
在本发明实施例中,如果确定出目标物体在第一视口相机中可见,则可以对目标物体进行渲染。在渲染的过程中,首先可以确定目标物体在场景视口中占据投影区域的面积,如果占据的面积小于第一预设阈值,则可以获取目标物体对应的面片贴图。该面片贴图也可以认为是目标物体的快照图像。可以理解的是,如果预先绘制并存储了目标物体对应的面片贴图,则可以直接获取该面片贴图。如果未预先绘制并存储目标物体对应的面片贴图,则可以绘制和存储目标物体对应的面片贴图,并使用该面片贴图。这里的面片贴图是指将目标物体单独按照当前第一视口相机的角度进行绘制得到的图像,可以将目标物体对应的面片贴图存储到额外的贴图上的图片数据中,该图片数据的像素格式可以是RGBA,A通道负责镂空效果。需要说明的是,后文将会介绍绘制面片贴图的具体实现方式,在此暂不赘述。
上述确定目标物体在场景视口中占据投影区域的面积的过程可以实现为:确定目标物体对应的面片的边长;确定面片的中心到第一视口相机之间的距离; 确定边长与距离之间的比值;若比值小于第一预设阈值,则获取目标物体对应的面片贴图。
在实际应用中,当目标物体对应的面片的边长与面片的中心到第一视口相机之间的距离的比值小于第一预设阈值时,可以近似认为该目标物体在相机视口中的张角较小,那么可以采用快照对目标物体进行渲染。
在上述过程中需要确定目标物体对应的面片的边长以及面片的中心位置,可以通过下面的方式确定面片的边长和中心位置:依照静态物体模型的包围盒和摆放位置,确定面片的边长和中心位置。如果对确定出的结果不满意,技术人员也可在编辑器中进行手动调整。
目标物体对应的面片可以设置为正方形形状,可以将面片的边长设置为目标物体模型的包围盒的斜对角线长度的预设倍数,该预设倍数例如可以是1.05。面片得到中心位置可以设置为目标物体模型的包围盒的中心点在三维场景中的位置。可以理解的是,在本发明实施例中,默认的配置可以满足大多数情况的需要,实际工作中需要手动调整面片的边长和中心位置的静态物体较少,编辑阶段的工作量较小。
在获取到目标物体对应的面片贴图之后,可以将目标物体对应的面片贴图绘制到场景视口中。
需要说明的是,在本发明实施例中还可以获取目标物体对应的属性参数,该属性参数包括用于指示是否开启实时快照的标识,当目标物体对应的属性参数用于指示开启实时快照时,可以采用目标物体的快照对目标物体进行渲染,在默认的情况下可以设置每个静态物体都开启实时快照。对于某些重要的或者形状比较特殊的物体,可通过这些物体的属性参数关闭通过实时快照渲染,这样在游戏的运行期间可以完全按照普通渲染方式对这些物体进行渲染。
下面将介绍绘制面片贴图的具体实现方式。在绘制面片贴图之前,需要预先创建一些在游戏运行期间实现快照相关信息的组织和管理功能的类,这些类主要可以包括ImposterManager类、ImposterImage类、ImposterData、ObjectImposterParam。下面先一一介绍一下这些类能够实现的功能。
对于ImposterManager类,是全局分系统,为单例。ImposterManager类主要可以实现面片贴图的创建与删除,以及为目标物体分配图像阵列中的区域块。ImposterManager类还可以维护将目标物体的快照渲染到三维场景中使用的渲染材质。
ImposterManager类还可以存储与面片贴图相关的全局可配置参数,这些全局可配置参数可以包括面片贴图数目、每个面片贴图的大小,每个物体的面片贴图在图像阵列上所占区域的大小等。在默认的配置下,可以分配2张1024x1024大小的RGBA8图像阵列用于存储不同物体的面片贴图,可以以64x64像素为基本单位对每张图像阵列进行划分,这样可以得到16行16列的区域块,每个区域块对应一个静态物体的面片贴图。需要说明的是,在实际应用中还可以设置一张与上述图像阵列具有相同数量的像素的深度图。
由于目标物体的贴图面片可以存储在图像阵列中,而图像阵列是一张大图,图像阵列被划分为多个区域块,不同区域块存储着不同物体的贴图面片。因此,在使用目标物体的贴图面片时,首先需要在图像阵列中定位到用于存储目标物体的贴图面片的区域块。ImposterData中可以存储目标物体对应的贴图信息,贴图信息包括用于指示目标物体对应的面片贴图在图像阵列中的存储位置的信息。因此可以从ImposterData中获取目标物体对应的贴图信息,根据目标物体对应的贴图信息,从图像阵列中获取目标物体对应的面片贴图。目标物体对应的贴图信息还可以包括面片贴图参数指针以及当前ImposterData连续未使用次数等信息。
对于ImposterImage类,ImposterImage类对应一张面片贴图,同时也对应将面片贴图渲染到三维场景的一个绘制批次。ImposterImage类内部可以包含1个快照贴图对象、1组将快照贴图绘制到三维场景的顶点缓冲和索引缓冲。该快照贴图上的每个区域块对应一个ImposterData对象,可以由ImposterImage类负责维护和管理。
在每帧渲染流程中,在面片贴图更新阶段,每个ImposterImage类可以收集需要重新更新的快照,将它们绘制到各自的区域块中。在三维场景渲染阶段, 可以先将需要绘制到三维场景的快照的顶点位置和贴图纹理数据写入到顶点缓冲中,再按照统一的顺序将它们绘制到场景中。
对于ObjectImposterParam,ObjectImposterParam是ImposterData中面片贴图参数指针所指向的对象,由每个使用快照的静态物体维护。通过该对象可关联到相应静态物体的快照参数、本身绘制的模型、材质、批次等信息。
在本发明实施例中,可以预先创建用于存储多个物体面片贴图的图像阵列,图像阵列包括多个区域块,每个区域块用于存储一个物体的面片贴图;设置预设数量的面片贴图参数指针;为每个区域块分配预设数量的面片贴图参数指针中的一个指针,分配的面片贴图参数指针的初始指向为空;在任一区域块分配给任一物体之后,将任一区域块的面片贴图参数指针设置为指向任一物体;在任一区域块分配给任一物体之后,记录任一区域块中的物体对应的面片贴图的连续未使用次数。
假设当前需要使用目标物体的面片贴图,预先未绘制目标物体的面片贴图,那么此时可以对目标物体的面片贴图进行绘制。在绘制之前,首先可以确定是否存在面片贴图参数指针为空的第一资源;若存在面片贴图参数指针为空的第一资源,将第一资源分配给目标物体,以在第一资源中绘制目标物体对应的面片贴图;若不存在面片贴图参数指针为空的第一资源,则确定面片贴图的连续未使用次数超过第二预设阈值的其他物体,将其他物体占用的第二资源分配给目标物体,以在第二资源中绘制目标物体对应的面片贴图。
在实际应用中,可以优先将面片贴图参数指针为空的ImposterData分配给目标物体,若不存在面片贴图参数指针为空的ImposterData,则可以将连续未使用次数累计超过第二预设阈值的ImposterData分配给目标物体。第二预设阈值在本发明实施例中例如可以设置为100帧。如果没有可分配的ImposterData,则可以先按照普通绘制方式渲染目标物体。
由于需要统计ImposterData的连续未使用次数,因此在每帧渲染时ImposterImage可以遍历该ImposterImage所管理的全部ImposterData,将不需要渲染到场景的ImposterData的连续未使用次数加1。如果在任一帧的渲染 过程中使用到了某个物体对应的ImposterData,也可以将该ImposterData的连续未使用次数直接设置为0。
对于目标物体和ImposterData关联关系的处理,当ImposterData分配给目标物体时,ImposterData中的面片贴图参数指针可以设置为指向目标物体的ObjectImposterParam,同时目标物体也可以记录对应的ImposterData在ImposterManager中的索引位置。当按照快照对目标物体进行渲染时,可以确认已分配给目标物体的ImposterData是否已经因为太久未使用而分配给了其他物体,这个过程可以通过判断ImposterData中的面片贴图参数指针是否仍指向目标物体的ObjectImposterParam实现。在删除目标物体的快照时,也可以做此判断,即如果面片贴图参数指针仍指向目标物体,则可以将该面片贴图参数指针置空,这样面片贴图参数指针被置空的ImposterData就可以分配给其他物体。
当需要采用快照渲染目标物体时,首先可以判断是否已为目标物体分配ImposterData,如果已分配ImposterData,那么可以判断已分配的ImposterData是否被分配给了其他物体,若已分配的ImposterData又被分配给了其他物体,则可以重新分配ImposterData给目标物体,由于新分配的ImposterData中不会存储有目标物体的快照,因此需要重新将目标物体的快照绘制在ImposterData对应的区域块中。
如果已分配的ImposterData未被分配给其他物体,那么ImposterData中存储有目标物体的快照。可以直接使用ImposterData中存储的快照,也可以在满足一定条件下对快照进行更新再使用。基于此,可选地,可以确定当前第一视口相机的第一朝向角度与上一次对目标物体对应的面片贴图进行更新时第一视口相机的第二朝向角度之间的变化量;基于变化量,确定是否对目标物体对应的面片贴图进行更新;若变化量大于第三预设阈值,则对目标物体对应的面片贴图进行更新;若变化量小于或者等于第三预设阈值,则对目标物体对应的面片贴图的旋转姿态进行调整。
在实际应用中,如果已分配的ImposterData未被分配给其他物体,则可以判断当前状态下和上次刷新快照时相机朝向的角度变化,若超过一定数值则可 以刷新快照,否则可以仅只略微调整目标物体对应的面片的旋转姿态。
可选地,上述确定当前第一视口相机的第一朝向角度与上一次对目标物体对应的面片贴图进行更新时第一视口相机的第二朝向角度之间的变化量的过程可以实现为:确定当前第一视口相机的第一朝向角度;确定上一次对目标物体对应的面片贴图进行更新时第一视口相机的第二朝向角度;确定第一朝向角度与第二朝向角度的数量积。相应地,还可以确定第三预设阈值的余弦值;若数量积小于余弦值,则对目标物体对应的面片贴图进行更新。
上述数量积可以表示角度的余弦值,当数量积小于预设角度的余弦值时,表示第一视口相机的变化角度已变化超过该预设角度,可以刷新快照。其中,该预设角度在本发明实施例中例如可以设置为12度。
在未绘制并存储目标物体的面片贴图或者需要对目标物体的面片贴图进行刷新的情况下,可选地,都可以采用下面的方式进行:确定第二视口相机的位置;通过目标物体对应的模型顶点数据、渲染材质以及渲染参数,绘制目标物体对应的面片贴图。
在实际应用中,可以设置第二视口相机,该第二视口相机可以采用平行投影。可以将第二视口相机视域的长、宽设置为与目标物体的矩形面片的长、宽为相同的数值。第二视口相机的朝向、远近裁减面可以设置为与第一视口相机一致。第二视口相机的位置到目标物体的面片中心位置的向量即为第一视口相机到目标物体的面片中心位置的向量在第一视口相机的朝向上的投影。通过这样的方式可以确定出第二视口相机的位置。
快照绘制视口可以根据该快照绘制区域在整个快照贴图的行列位置来计算。绘制快照时使用模型顶点数据,渲染材质,渲染参数与普通渲染时相同。
在绘制面片贴图的具体内容之前,可以预先清理使用的区域块的颜色和深度。具体可以将深度图整体清空为1.0,将颜色图通过绘制方形面片的方式进行清空。在通过绘制方形面片的方式对颜色图清空的过程中,可以使用与正式绘制面片贴图时相同的场景视口,不读取深度值,且将颜色RGBA通道全部填充为0。
可选地,对目标物体对应的面片贴图进行更新的过程也即快照面片顶点数据的计算过程可以实现为:确定面片贴图的局部坐标;确定世界变换矩阵;基于面片贴图的局部坐标以及世界变换矩阵,确定目标物体对应的面片贴图的顶点数据;基于顶点数据,对目标物体对应的面片贴图进行更新。
在实际应用中,快照面片顶点的纹理坐标可以根据该快照绘制区域在整个快照贴图的行列位置来计算。快照面片顶点的位置坐标是世界空间下的坐标,可由局部坐标叠加世界变换矩阵计算。
可选地,确定面片贴图的局部坐标的过程可以实现为:将面片贴图的四个顶点的z值设置为0,并以原点为中心且根据面片贴图的边长确定四个顶点的局部坐标。
需要说明的是,快照面片在世界空间下的位置就是其中心点的位置,姿态为视口相机姿态四元数绕视口相机Y轴旋转180度。
可选地,确定世界变换矩阵的过程可以实现为:获取第一视口相机的姿态;确定面片贴图的中心位置;基于第一视口相机的姿态以及面片贴图的中心位置,确定世界变换矩阵。
可以理解的是,在本发明实施例中,可以采用矩形面片在模型空间下对称性的一种简化算法。在模型空间下可以将正方形面片的四个顶点位置作关于Y轴的对称交换,然后用相机姿态和快照面片中心的位置构成世界变换矩阵。对经过对称交换处理的四个顶点位置进行模型空间到世界空间的变换,就可以得到快照面片顶点在世界空间下的坐标。
综上,如图2所示,在本发明实施例中可以获取目标物体,确定目标物体是否可以通过快照进行渲染,若可以通过快照进行渲染,则可以确定是否为目标物体分配了快照数据,若不可以通过快照进行渲染,则按照普通渲染方式对目标物体进行渲染。若已为目标物体分配快照数据,则可以判断快照数据是否仍然属于该目标物体,若未为目标物体分配快照数据,则可以为目标物体分配快照数据,并且如果判断分配成功,则可以重新绘制快照贴图,如果判断分配不成功,则可以按照普通渲染方式对目标物体进行渲染。在确定快照数据仍然 属于目标物体之后,可以判断是否仅需要调整面片旋转姿态,如果不能仅调整面片旋转姿态,则可以执行重新绘制快照贴图的步骤,如果仅需要调整面片旋转姿态,则可以调整快照面片的旋转姿态。在重新绘制快照贴图或者调整快照面片的旋转姿态之后,可以将快照贴图绘制到三维场景中。
在本发明实施例中,在渲染三维场景的过程中,当视口相机中查询到的静态物体比较多时,可以在整体上不影响美术效果的前提下简化绘制的顶点数据,对绘制批次进行合并,以提升渲染效率。
采用本发明,可以通过矩形面片代替模型本身的顶点数据,减少绘制顶点数,提高渲染效率。对于位于相同快照贴图也即图像阵列中的面片贴图的物体,可以将这些物体的面片贴图合并到一组顶点缓冲中通过一次绘制操作进行绘制,从总体上可以减少绘制的次数。另外,可以对面片贴图预先进行光照处理,那么在图像阵列中保存的面片贴图已经是经过光照处理的结果,在将面片贴图绘制到三维场景中时,可以虚无再进行光照计算,节省了进行光照计算的计算开销。最后,通过本发明,在静态物体的绘制效果基本不受影响的情况下,能够显著降低渲染计算开销。
以下将详细描述本发明的一个或多个实施例的图像渲染装置。本领域技术人员可以理解,这些图像渲染装置均可使用市售的硬件组件通过本方案所教导的步骤进行配置来构成。
图3为本发明实施例提供的一种图像渲染装置的结构示意图,如图3所示,该装置包括:
确定模块31,用于确定目标物体在第一视口相机中是否可见;
计算模块32,用于若所述目标物体在所述第一视口相机中可见,则确定所述目标物体在场景视口中占据投影区域的面积;
获取模块33,用于若所述面积小于第一预设阈值,则获取所述目标物体对应的面片贴图;
绘制模块34,用于将所述目标物体对应的面片贴图绘制到所述场景视口。
可选地,所述计算模块32,用于确定所述目标物体对应的面片的边长;确 定所述面片的中心到所述第一视口相机之间的距离;确定所述边长与所述距离之间的比值;
所述获取模块33,用于若所述比值小于第一预设阈值,则获取所述目标物体对应的面片贴图。
可选地,所述获取模块33,用于:
获取所述目标物体对应的贴图信息,所述贴图信息用于指示所述目标物体对应的面片贴图在图像阵列中的存储位置;
根据所述贴图信息,获取所述目标物体对应的面片贴图。
可选地,所述装置还包括:
创建模块,用于预先创建用于存储多个物体面片贴图的图像阵列,所述图像阵列包括多个区域块,每个区域块用于存储一个物体的面片贴图;
设置模块,用于设置预设数量的面片贴图参数指针;
分配模块,用于为每个区域块分配所述预设数量的面片贴图参数指针中的一个指针,分配的面片贴图参数指针的初始指向为空;
所述设置模块,用于在任一区域块分配给任一物体之后,将所述任一区域块的面片贴图参数指针设置为指向所述任一物体;
在所述任一区域块分配给所述任一物体之后,记录所述任一区域块中的物体对应的面片贴图的连续未使用次数。
可选地,所述获取模块33,用于:
若未预先绘制所述目标物体对应的面片贴图,则确定是否存在面片贴图参数指针为空的第一资源;
若存在面片贴图参数指针为空的第一资源,将所述第一资源分配给所述目标物体,以在所述第一资源中绘制所述目标物体对应的面片贴图;
若不存在面片贴图参数指针为空的第一资源,则确定面片贴图的连续未使用次数超过第二预设阈值的其他物体,将所述其他物体占用的第二资源分配给所述目标物体,以在所述第二资源中绘制所述目标物体对应的面片贴图。
可选地,所述装置还包括更新模块,所述更新模块,用于:
确定当前第一视口相机的第一朝向角度与上一次对所述目标物体对应的面片贴图进行更新时所述第一视口相机的第二朝向角度之间的变化量;
基于所述变化量,确定是否对所述目标物体对应的面片贴图进行更新;
若所述变化量大于第三预设阈值,则对所述目标物体对应的面片贴图进行更新;
若所述变化量小于或者等于所述第三预设阈值,则对所述目标物体对应的面片贴图的旋转姿态进行调整。
可选地,所述更新模块,用于:
确定当前第一视口相机的第一朝向角度;
确定上一次对所述目标物体对应的面片贴图进行更新时所述第一视口相机的第二朝向角度;
确定所述第一朝向角度与所述第二朝向角度的数量积;
确定所述第三预设阈值的余弦值;
若所述数量积小于所述余弦值,则对所述目标物体对应的面片贴图进行更新。
可选地,所述更新模块,用于:
确定面片贴图的局部坐标;
确定世界变换矩阵;
基于所述面片贴图的局部坐标以及所述世界变换矩阵,确定所述目标物体对应的面片贴图的顶点数据;
基于所述顶点数据,对所述目标物体对应的面片贴图进行更新。
可选地,所述更新模块,用于:
将所述面片贴图的四个顶点的z值设置为0,并以原点为中心且根据所述面片贴图的边长确定所述四个顶点的局部坐标。
可选地,所述更新模块,用于:
获取所述第一视口相机的姿态;
确定所述面片贴图的中心位置;
基于所述第一视口相机的姿态以及所述面片贴图的中心位置,确定世界变换矩阵。
可选地,所述获取模块33,用于:
确定第二视口相机的位置;
通过所述目标物体对应的模型顶点数据、渲染材质以及渲染参数,绘制所述目标物体对应的面片贴图。
图3所示装置可以执行前述图1至图2所示实施例中提供的图像渲染方法,详细的执行过程和技术效果参见前述实施例中的描述,在此不再赘述。
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的电子设备中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。
例如,图4示出了可以实现用于执行根据本发明的方法的电子设备。该电子设备传统上包括处理器410和以存储器420形式的计算机程序产品或者计算机可读介质。存储器420可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。存储器420具有用于执行上述方法中的任何方法步骤的程序代码431的存储空间430。例如,用于存储程序代码的存储空间430可以包括分别用于实现上面的方法中的各种步骤的各个程序代码431。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。这些计算机程序产品包括诸如硬盘,激光盘(CD)、存储卡或者软盘之类的程序代码载体。这样的计算机程序产品通常为如参考图5所述的便携式或者固定存储单元。该存储单元可以具有与图4的电子设备中的存储器420类似布置的存储段、存储空间等。程序代码可以例如以 适当形式进行压缩。通常,存储单元包括计算机可读代码431’,即可以由例如诸如410之类的处理器读取的代码,这些代码当由电子设备运行时,导致该电子设备执行上面所描述的方法中的各个步骤。
本文中所称的“一个实施例”、“实施例”或者“一个或者多个实施例”意味着,结合实施例描述的特定特征、结构或者特性包括在本发明的至少一个实施例中。此外,请注意,这里“在一个实施例中”的词语例子不一定全指同一个实施例。
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下被实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。
此外,还应当注意,本说明书中使用的语言主要是为了可读性和教导的目的而选择的,而不是为了解释或者限定本发明的主题而选择的。因此,在不偏离所附权利要求书的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。对于本发明的范围,对本发明所做的公开是说明性的,而非限制性的,本发明的范围由所附权利要求书限定。

Claims (24)

  1. 一种图像渲染方法,其特征在于,包括:
    确定目标物体在第一视口相机中是否可见;
    若所述目标物体在所述第一视口相机中可见,则确定所述目标物体在场景视口中占据投影区域的面积;
    若所述面积小于第一预设阈值,则获取所述目标物体对应的面片贴图;
    将所述目标物体对应的面片贴图绘制到所述场景视口。
  2. 根据权利要求1所述的方法,其特征在于,所述确定所述目标物体在场景视口中占据投影区域的面积,包括:
    确定所述目标物体对应的面片的边长;
    确定所述面片的中心到所述第一视口相机之间的距离;
    确定所述边长与所述距离之间的比值;
    所述若所述面积小于第一预设阈值,则获取所述目标物体对应的面片贴图,包括:
    若所述比值小于第一预设阈值,则获取所述目标物体对应的面片贴图。
  3. 根据权利要求1所述的方法,其特征在于,所述获取所述目标物体对应的面片贴图,包括:
    获取所述目标物体对应的贴图信息,所述贴图信息用于指示所述目标物体对应的面片贴图在图像阵列中的存储位置;
    根据所述贴图信息,获取所述目标物体对应的面片贴图。
  4. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    预先创建用于存储多个物体面片贴图的图像阵列,所述图像阵列包括多个区域块,每个区域块用于存储一个物体的面片贴图;
    设置预设数量的面片贴图参数指针;
    为每个区域块分配所述预设数量的面片贴图参数指针中的一个指针,分配的面片贴图参数指针的初始指向为空;
    在任一区域块分配给任一物体之后,将所述任一区域块的面片贴图参数指针设置为指向所述任一物体;
    在所述任一区域块分配给所述任一物体之后,记录所述任一区域块中的物体对应的面片贴图的连续未使用次数。
  5. 根据权利要求4所述的方法,其特征在于,所述获取所述目标物体对应的面片贴图,包括:
    若未预先绘制所述目标物体对应的面片贴图,则确定是否存在面片贴图参数指针为空的第一资源;
    若存在面片贴图参数指针为空的第一资源,将所述第一资源分配给所述目标物体,以在所述第一资源中绘制所述目标物体对应的面片贴图;
    若不存在面片贴图参数指针为空的第一资源,则确定面片贴图的连续未使用次数超过第二预设阈值的其他物体,将所述其他物体占用的第二资源分配给所述目标物体,以在所述第二资源中绘制所述目标物体对应的面片贴图。
  6. 根据权利要求1所述的方法,其特征在于,在获取所述目标物体对应的面片贴图之前,所述方法还包括:
    确定当前第一视口相机的第一朝向角度与上一次对所述目标物体对应的面片贴图进行更新时所述第一视口相机的第二朝向角度之间的变化量;
    基于所述变化量,确定是否对所述目标物体对应的面片贴图进行更新;
    若所述变化量大于第三预设阈值,则对所述目标物体对应的面片贴图进行更新;
    若所述变化量小于或者等于所述第三预设阈值,则对所述目标物体对应的面片贴图的旋转姿态进行调整。
  7. 根据权利要求6所述的方法,其特征在于,所述确定当前第一视口相机的第一朝向角度与上一次对所述目标物体对应的面片贴图进行更新时所述第一视口相机的第二朝向角度之间的变化量,包括:
    确定当前第一视口相机的第一朝向角度;
    确定上一次对所述目标物体对应的面片贴图进行更新时所述第一视口相机 的第二朝向角度;
    确定所述第一朝向角度与所述第二朝向角度的数量积;
    所述若所述变化量大于第三预设阈值,则对所述目标物体对应的面片贴图进行更新,包括:
    确定所述第三预设阈值的余弦值;
    若所述数量积小于所述余弦值,则对所述目标物体对应的面片贴图进行更新。
  8. 根据权利要求6所述的方法,其特征在于,所述对所述目标物体对应的面片贴图进行更新,包括:
    确定面片贴图的局部坐标;
    确定世界变换矩阵;
    基于所述面片贴图的局部坐标以及所述世界变换矩阵,确定所述目标物体对应的面片贴图的顶点数据;
    基于所述顶点数据,对所述目标物体对应的面片贴图进行更新。
  9. 根据权利要求8所述的方法,其特征在于,所述确定面片贴图的局部坐标,包括:
    将所述面片贴图的四个顶点的z值设置为0,并以原点为中心且根据所述面片贴图的边长确定所述四个顶点的局部坐标。
  10. 根据权利要求8所述的方法,其特征在于,所述确定世界变换矩阵,包括:
    获取所述第一视口相机的姿态;
    确定所述面片贴图的中心位置;
    基于所述第一视口相机的姿态以及所述面片贴图的中心位置,确定世界变换矩阵。
  11. 根据权利要求1所述的方法,其特征在于,所述获取所述目标物体对应的面片贴图,包括:
    确定第二视口相机的位置;
    通过所述目标物体对应的模型顶点数据、渲染材质以及渲染参数,绘制所述目标物体对应的面片贴图。
  12. 一种图像渲染装置,其特征在于,包括:
    确定模块,用于确定目标物体在第一视口相机中是否可见;
    计算模块,用于若所述目标物体在所述第一视口相机中可见,则确定所述目标物体在场景视口中占据投影区域的面积;
    获取模块,用于若所述面积小于第一预设阈值,则获取所述目标物体对应的面片贴图;
    绘制模块,用于将所述目标物体对应的面片贴图绘制到所述场景视口。
  13. 根据权利要求12所述的装置,其特征在于,所述计算模块,用于确定所述目标物体对应的面片的边长;确定所述面片的中心到所述第一视口相机之间的距离;确定所述边长与所述距离之间的比值;
    所述获取模块,用于若所述比值小于第一预设阈值,则获取所述目标物体对应的面片贴图。
  14. 根据权利要求12所述的装置,其特征在于,所述获取模块,用于:
    获取所述目标物体对应的贴图信息,所述贴图信息用于指示所述目标物体对应的面片贴图在图像阵列中的存储位置;
    根据所述贴图信息,获取所述目标物体对应的面片贴图。
  15. 根据权利要求12所述的装置,其特征在于,所述装置还包括:
    创建模块,用于预先创建用于存储多个物体面片贴图的图像阵列,所述图像阵列包括多个区域块,每个区域块用于存储一个物体的面片贴图;
    设置模块,用于设置预设数量的面片贴图参数指针;
    分配模块,用于为每个区域块分配所述预设数量的面片贴图参数指针中的一个指针,分配的面片贴图参数指针的初始指向为空;
    所述设置模块,用于在任一区域块分配给任一物体之后,将所述任一区域块的面片贴图参数指针设置为指向所述任一物体;
    在所述任一区域块分配给所述任一物体之后,记录所述任一区域块中的物 体对应的面片贴图的连续未使用次数。
  16. 根据权利要求15所述的装置,其特征在于,所述获取模块,用于:
    若未预先绘制所述目标物体对应的面片贴图,则确定是否存在面片贴图参数指针为空的第一资源;
    若存在面片贴图参数指针为空的第一资源,将所述第一资源分配给所述目标物体,以在所述第一资源中绘制所述目标物体对应的面片贴图;
    若不存在面片贴图参数指针为空的第一资源,则确定面片贴图的连续未使用次数超过第二预设阈值的其他物体,将所述其他物体占用的第二资源分配给所述目标物体,以在所述第二资源中绘制所述目标物体对应的面片贴图。
  17. 根据权利要求12所述的装置,其特征在于,所述装置还包括更新模块,所述更新模块,用于:
    确定当前第一视口相机的第一朝向角度与上一次对所述目标物体对应的面片贴图进行更新时所述第一视口相机的第二朝向角度之间的变化量;
    基于所述变化量,确定是否对所述目标物体对应的面片贴图进行更新;
    若所述变化量大于第三预设阈值,则对所述目标物体对应的面片贴图进行更新;
    若所述变化量小于或者等于所述第三预设阈值,则对所述目标物体对应的面片贴图的旋转姿态进行调整。
  18. 根据权利要求17所述的装置,其特征在于,所述更新模块,用于:
    确定当前第一视口相机的第一朝向角度;
    确定上一次对所述目标物体对应的面片贴图进行更新时所述第一视口相机的第二朝向角度;
    确定所述第一朝向角度与所述第二朝向角度的数量积;
    确定所述第三预设阈值的余弦值;
    若所述数量积小于所述余弦值,则对所述目标物体对应的面片贴图进行更新。
  19. 根据权利要求17所述的装置,其特征在于,所述更新模块,用于:
    确定面片贴图的局部坐标;
    确定世界变换矩阵;
    基于所述面片贴图的局部坐标以及所述世界变换矩阵,确定所述目标物体对应的面片贴图的顶点数据;
    基于所述顶点数据,对所述目标物体对应的面片贴图进行更新。
  20. 根据权利要求19所述的装置,其特征在于,所述更新模块,用于:
    将所述面片贴图的四个顶点的z值设置为0,并以原点为中心且根据所述面片贴图的边长确定所述四个顶点的局部坐标。
  21. 根据权利要求19所述的装置,其特征在于,所述更新模块,用于:
    获取所述第一视口相机的姿态;
    确定所述面片贴图的中心位置;
    基于所述第一视口相机的姿态以及所述面片贴图的中心位置,确定世界变换矩阵。
  22. 根据权利要求12所述的装置,其特征在于,所述获取模块,用于:
    确定第二视口相机的位置;
    通过所述目标物体对应的模型顶点数据、渲染材质以及渲染参数,绘制所述目标物体对应的面片贴图。
  23. 一种计算机程序,包括计算机可读代码,当所述计算机可读代码在电子设备上运行时,导致所述电子设备执行根据权利要求1-11中的任一个所述的深度抗锯齿数据读取方法。
  24. 一种计算机可读介质,其中存储了如权利要求23所述的计算机程序。
PCT/CN2020/112579 2020-06-18 2020-08-31 图像渲染方法、装置、计算机程序和可读介质 WO2021253642A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010560369.3 2020-06-18
CN202010560369.3A CN111798556B (zh) 2020-06-18 2020-06-18 图像渲染方法、装置、设备和存储介质

Publications (1)

Publication Number Publication Date
WO2021253642A1 true WO2021253642A1 (zh) 2021-12-23

Family

ID=72804482

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/112579 WO2021253642A1 (zh) 2020-06-18 2020-08-31 图像渲染方法、装置、计算机程序和可读介质

Country Status (2)

Country Link
CN (1) CN111798556B (zh)
WO (1) WO2021253642A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114202634A (zh) * 2022-02-17 2022-03-18 深圳消安科技有限公司 一种应用于城市三维模型数据的轻量化方法

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112489203B (zh) * 2020-12-08 2024-06-04 网易(杭州)网络有限公司 模型处理方法、模型处理装置、电子设备及存储介质
CN113160378B (zh) * 2021-03-25 2023-05-05 网易(杭州)网络有限公司 一种地面裂纹处理方法及装置
CN113283543B (zh) * 2021-06-24 2022-04-15 北京优锘科技有限公司 一种基于WebGL的图像投影融合方法、装置、存储介质和设备
CN114004925B (zh) * 2021-09-16 2022-11-22 北京城市网邻信息技术有限公司 基于WebGL的模型渲染方法、电子设备及存储介质
CN117078868B (zh) * 2023-10-17 2023-12-15 北京太极信息系统技术有限公司 基于信创软硬件的虚拟现实引擎及其建模和渲染方法

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009112875A (ja) * 2009-03-05 2009-05-28 Namco Bandai Games Inc ゲーム装置及び情報記憶媒体
CN103325138A (zh) * 2013-07-11 2013-09-25 乐淘(中国)有限公司 通过网页进行3d场景装饰并渲染的方法
CN105335993A (zh) * 2014-08-01 2016-02-17 联想(北京)有限公司 一种信息处理方法及电子设备
CN107481312A (zh) * 2016-06-08 2017-12-15 腾讯科技(深圳)有限公司 一种基于体绘制的图像渲染及装置
CN108154553A (zh) * 2018-01-04 2018-06-12 中测新图(北京)遥感技术有限责任公司 一种三维模型与监控视频的无缝融合方法及装置
CN109448099A (zh) * 2018-09-21 2019-03-08 腾讯科技(深圳)有限公司 画面的渲染方法、装置、存储介质及电子装置
CN109816762A (zh) * 2019-01-30 2019-05-28 网易(杭州)网络有限公司 一种图像渲染方法、装置、电子设备和存储介质

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1801218A (zh) * 2004-12-31 2006-07-12 英业达股份有限公司 三维对象渲染系统及方法
CN102446048B (zh) * 2010-09-30 2014-04-02 联想(北京)有限公司 信息处理设备以及信息处理方法
CN105654542B (zh) * 2015-12-22 2018-11-20 成都艾尔伯特科技有限责任公司 虚拟机场模型地表纹理投影渲染方法
CN106327532B (zh) * 2016-08-31 2019-06-11 北京天睿空间科技股份有限公司 一种单幅图像的三维配准方法
CN109344126B (zh) * 2018-09-12 2021-11-30 网易(杭州)网络有限公司 贴图的处理方法、装置、存储介质和电子装置

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009112875A (ja) * 2009-03-05 2009-05-28 Namco Bandai Games Inc ゲーム装置及び情報記憶媒体
CN103325138A (zh) * 2013-07-11 2013-09-25 乐淘(中国)有限公司 通过网页进行3d场景装饰并渲染的方法
CN105335993A (zh) * 2014-08-01 2016-02-17 联想(北京)有限公司 一种信息处理方法及电子设备
CN107481312A (zh) * 2016-06-08 2017-12-15 腾讯科技(深圳)有限公司 一种基于体绘制的图像渲染及装置
CN108154553A (zh) * 2018-01-04 2018-06-12 中测新图(北京)遥感技术有限责任公司 一种三维模型与监控视频的无缝融合方法及装置
CN109448099A (zh) * 2018-09-21 2019-03-08 腾讯科技(深圳)有限公司 画面的渲染方法、装置、存储介质及电子装置
CN109816762A (zh) * 2019-01-30 2019-05-28 网易(杭州)网络有限公司 一种图像渲染方法、装置、电子设备和存储介质

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114202634A (zh) * 2022-02-17 2022-03-18 深圳消安科技有限公司 一种应用于城市三维模型数据的轻量化方法
CN114202634B (zh) * 2022-02-17 2022-06-14 深圳消安科技有限公司 一种应用于城市三维模型数据的轻量化方法

Also Published As

Publication number Publication date
CN111798556A (zh) 2020-10-20
CN111798556B (zh) 2023-10-13

Similar Documents

Publication Publication Date Title
WO2021253642A1 (zh) 图像渲染方法、装置、计算机程序和可读介质
CN112270756B (zh) 一种应用于bim模型文件的数据渲染方法
CN110956673B (zh) 一种地图绘制方法及装置
TWI515716B (zh) 具備緩衝區限制處理的世界空間與螢幕空間管線間之圖元重新排序
EP3570253B1 (en) Method and device for reconstructing three-dimensional point cloud
US9019271B2 (en) Z-culling method, three-dimensional graphics processing method and apparatus threrof
US8736599B2 (en) Method for unified visualisation of heterogeneous datasets
US9013479B2 (en) Apparatus and method for tile-based rendering
US9286858B2 (en) Hit testing method and apparatus
US11170555B2 (en) Graphics processing systems
JPH11195132A (ja) テクスチャマッピング用バッファ、3次元グラフィクス処理装置、3次元グラフィクス処理システム、3次元グラフィクス処理方法および処理プログラムが記憶された記憶媒体
CN110503718B (zh) 三维工程模型轻量化显示方法
TWI550551B (zh) 景深網格化
US10699427B2 (en) Method and apparatus for obtaining sampled positions of texturing operations
CN103679785A (zh) 用于部分帧缓冲区更新的系统和方法
CN111143502A (zh) 一种地图瓦片高效生成方法及装置
EP2040223A1 (en) Method and aircraft display system for generating three dimensional image
RU2604674C2 (ru) Системы и способы для создания трехмерного текстурного атласа
CN111090759B (zh) 一种海量真景大数据跨级加载的算法
CN1739117A (zh) 使用最小深度遮挡剔除和z字形遍历的图形处理设备、方法和计算机程序产品
CN112686992A (zh) 用于智慧城市occ树的几何图形视锥体实现方法、装置及存储介质
CN112446959B (zh) 一种倾斜摄影模型优化方法
US20240193720A1 (en) Graphics processing systems
KR100738097B1 (ko) 3차원 디스플레이를 위한 쿼리의 효율적 처리 방법 및 장치
CN117453095A (zh) 一种三维对象选择方法、装置、介质和设备

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20941159

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20941159

Country of ref document: EP

Kind code of ref document: A1