Method, system, medium and device for improving depth conflict in three-dimensional scene rendering
By dynamically adjusting the near-plane value of the camera, the problem of tearing caused by depth conflict in three-dimensional scene rendering is solved, and the picture quality is automatically adaptively improved without affecting the rendering performance.
Patent Information
- Application Number
- CN202210519832.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-12
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-05-12
AI Technical Summary
The prior art surface tearing phenomenon caused by depth buffer accuracy problems in three-dimensional scene rendering affects the rendering quality and is difficult to effectively solve.
By initializing the camera's target observation point position and the point density range of the rendered scene, dynamically adjust the camera's near-plane value, combined with the rendered object pickup candidate set, the camera's near-plane value is automatically adaptively adjusted to improve picture tearing caused by depth conflict.
While maintaining rendering performance, the camera's near-plane value is automatically adapted, which solves the problem of picture tearing caused by most depth conflicts and reduces the difficulty of developers in coding the camera's near-plane value.
Smart Images

Figure CN114943798B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a method, system, medium and device for improving depth conflict in three-dimensional scene rendering. Background Art
[0002] Currently, in existing technologies, the rendering process of 3D scenes is likely to cause z-fighting due to depth buffer accuracy issues, thereby reducing the rendering quality of the scene. To effectively solve the z-fighting problem in 3D scene rendering, there are currently several main solutions:
[0003] 1. Adjust the distance between rendered objects.
[0004] This method will cause the position of the rendered object to change. Although it can solve the depth conflict problem, it will also cause the actual rendering effect to change (because the position has changed).
[0005] 2. Set the appropriate camera's near and far values.
[0006] If a more appropriate value is set, this method can fix most depth conflict problems, but it is difficult to calculate the appropriate value without reducing rendering performance as much as possible.
[0007] 3. Set the polygon offset.
[0008] When the depth of polygon rendering is calculated, the depth offset is calculated based on the set factor, which affects the near and far relationship of the polygon rendering. It needs to be associated with the position of the camera. Once the position of the camera changes, the value also needs to be reset. How to determine the appropriate value is also relatively complicated.
[0009] 4. Set the object rendering order.
[0010] This method can only be applied to simple scenes. If the positions of the rendered objects in the scene intersect or are too close to each other, no matter how the rendering order is adjusted, the depth conflict problem cannot be completely solved.
[0011] 5. Use a higher precision depth buffer, such as a logarithmic depth buffer.
[0012] While this solution produces a more pronounced depth curve, thus improving depth-fighting (most noticeably for distant rendered objects), it ultimately relies on optimal near and far plane values to reduce depth-fighting.
[0013] In order to solve the problems existing in the existing technology, it is urgent to develop a method to better solve the depth conflict (Z-fighting) problem in three-dimensional scene rendering, and at the same time solve the problem of depth buffer accuracy leading to surface tearing (Z-fighting), thereby reducing the rendering quality of the scene. Summary of the Invention
[0014] The technical problem to be solved by the present invention is to address the deficiencies of the existing technology and provide a method, system, medium and device for improving depth conflict in three-dimensional scene rendering.
[0015] The technical solution of the present invention to solve the above technical problems is as follows:
[0016] The present invention provides a method for improving depth conflict in three-dimensional scene rendering, the method comprising:
[0017] Initialize the target observation point position of the camera, initially set the point density range of the rendering scene sampling and the time interval for triggering calculation, obtain the screen pixel sampling point list based on the point density range, and pre-provide a preset rendering object picking candidate set;
[0018] Based on the screen pixel sampling point list and the rendering object picking candidate set, the camera's near plane value is dynamically adjusted in combination with the rendering scene at the time interval that triggers the calculation. The calculation of the dynamic setting of the camera's near plane value is completed. After automatic adaptive dynamic adjustment according to the rendering scene, the screen tearing caused by rendering depth conflict is improved.
[0019] Preferably, the above initialization sets the target observation point position of the camera, initially sets the point density range of the rendering scene sampling and the time interval for triggering calculation, and provides a preset object picking candidate set, further including:
[0020] Construct two mutually perpendicular plane data and set the origin of the plane data as the target observation point of the camera;
[0021] According to the preset point density range of the rendering scene sampling, a plane pixel point list is calculated;
[0022] Set the time interval for triggering calculations based on the consumption of rendering performance;
[0023] According to the picking efficiency of the rendering scene, a set of rendering object picking candidates is pre-provided.
[0024] Preferably, the method for dynamically adjusting the camera's near plane value in combination with the rendering scene to complete the calculation of the dynamic setting of the camera's near plane value, after automatically adaptively adjusting the value dynamically according to the rendering scene to improve the screen tearing caused by the rendering depth conflict, further includes:
[0025] Based on the time interval of trigger calculation, wait for the calculation trigger of the near plane value;
[0026] Traverse the screen pixel sampling point list and perform ray picking operations on the rendered scene based on the position of the pixel points;
[0027] Based on the candidate set of rendering objects, the polygon of the rendering object is calculated by intersecting with the ray to obtain the 3D coordinate position in the rendering scene, and the list of all screen pixel sampling points is traversed in a loop;
[0028] Based on the three-dimensional coordinate position, the best three-dimensional coordinate point is obtained by averaging calculation;
[0029] Set the camera's near plane value to the depth value of the optimal 3D coordinate point.
[0030] Preferably, the above calculation to obtain a plane pixel point list further includes:
[0031] Taking the midpoint pixel position of the screen as the starting point, obtain half of the screen diagonal length, divide it evenly according to the set point density range, and use the center point of the screen as the reference to obtain the screen pixel sampling point positions on multiple line segments;
[0032] Taking the center point of the screen as the reference, the screen pixel sampling point positions on multiple line segments in the horizontal and vertical directions are calculated by evenly dividing the points according to the set point density range;
[0033] The screen pixel sampling point location stores a list of screen pixel sampling points.
[0034] Preferably, the above-mentioned performing a ray picking operation on the rendered scene based on the positions of the pixel points further includes:
[0035] Convert pixel positions to normalized device coordinate space based on the viewport size of the rendered scene;
[0036] Set the ray starting point to the camera coordinate position, the ray observation point to the viewpoint coordinates in the normalized device coordinate space after removing the effect of the projection matrix, and then obtain the ray's three-dimensional ray observation point in the world coordinate system based on the matrix in the camera's world coordinate system;
[0037] The ray direction is the normalized vector obtained by subtracting the starting point from the observation point.
[0038] The present invention further provides a system for improving depth conflict in three-dimensional scene rendering, which adopts any one of the methods for improving depth conflict in three-dimensional scene rendering, and the system comprises:
[0039] Initialization module: Initializes the target observation point position of the camera, initially sets the point density range of the rendering scene sampling and the time interval for triggering calculation, obtains the screen pixel sampling point list based on the point density range, and pre-provides a preset rendering object picking candidate set;
[0040] Near plane value calculation module: Based on the screen pixel sampling point list and the rendering object picking candidate set, the camera's near plane value is dynamically adjusted in combination with the rendering scene at the time interval that triggers the calculation. The calculation of the dynamic setting of the camera's near plane value is completed. After automatic adaptive dynamic adjustment according to the rendering scene, the screen tearing caused by rendering depth conflict is improved.
[0041] Preferably, the initialization module further includes:
[0042] Data construction module: construct two mutually perpendicular plane data and set the origin position of the plane data as the target observation point position of the camera;
[0043] Point density setting module: calculates and obtains a plane pixel list based on the preset point density range of the rendering scene sampling;
[0044] Calculation time interval setting module: Set the time interval for triggering calculation according to the consumption of rendering performance;
[0045] Picking candidate set module: pre-provides a set of rendering object picking candidates based on the picking efficiency of the rendering scene.
[0046] Preferably, the above-mentioned near-plane numerical calculation module further comprises:
[0047] Calculation trigger module: based on the time interval of trigger calculation, waits for the calculation trigger of the near plane value;
[0048] Traversal calculation module: traverses the screen pixel sampling point list and performs ray picking operations on the rendered scene based on the position of the pixel points;
[0049] 3D coordinate acquisition module: Based on the candidate set of rendering objects, the 3D coordinate position in the rendering scene is obtained by calculating the intersection of the rendering object polygon and the ray, and the list of all screen pixel sampling points is traversed in a loop;
[0050] 3D coordinate point calculation module: Based on the 3D coordinate position, the optimal 3D coordinate point is obtained by average calculation;
[0051] Near plane value setting module: sets the near plane value of the camera to the depth value of the optimal three-dimensional coordinate point.
[0052] The present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-mentioned method for improving depth conflict in three-dimensional scene rendering.
[0053] The present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the above-mentioned method for improving depth conflict in three-dimensional scene rendering are implemented.
[0054] The beneficial effects of this method invention are:
[0055] 1) The present invention proposes a method for dynamically setting the near plane value of a camera while maintaining rendering performance. After automatically and dynamically adjusting the value based on the rendering scene, it can solve most of the screen tearing problems caused by depth conflict.
[0056] 2) The present invention can reduce the coding difficulty of developers by automatically adapting the rendering scene. Developers do not need to actively set the value of the camera's near plane. The solution of the present invention automatically adapts according to the rendering scene, thereby reducing the coding difficulty of developers to repair rendering torn surfaces due to depth conflicts.
[0057] Advantages of additional aspects of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0059] Figure 1 This is a flow chart of the method for improving depth conflict in three-dimensional scene rendering according to the present invention;
[0060] Figure 2 This is a schematic diagram of the surface tearing problem that occurs on the ground in the scene rendered using existing technology;
[0061] Figure 3 A schematic diagram of a rendering scene with automatic adjustment of the camera near plane according to a specific embodiment of the present invention;
[0062] Figure 4 This is a schematic diagram of the scene rendering effect when the camera near plane is set to a value of 0.005 according to a specific embodiment of the present invention;
[0063] Figure 5 This is a schematic diagram of the scene rendering effect when the camera near plane is set to a value of 10 according to a specific embodiment of the present invention;
[0064] Figure 6 Schematic diagram of the system for improving depth conflict in three-dimensional scene rendering according to the present invention. DETAILED DESCRIPTION
[0065] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0066] The present invention aims to solve the problem of screen tearing caused by most depth conflicts by dynamically adjusting the near plane value of the camera in combination with the rendering scene, while maintaining the rendering performance as much as possible.
[0067] The technical solution of the present invention to solve the above technical problems is as follows: Figure 1 As shown, the present invention provides a method for improving depth conflict in three-dimensional scene rendering, the method comprising:
[0068] S10: Initialize the target observation point position of the camera, initially set the point density range of the rendering scene sampling and the time interval for triggering calculation, obtain the screen pixel sampling point list based on the point density range, and pre-provide a preset rendering object picking candidate set;
[0069] S20: Based on the screen pixel sampling point list and the rendering object picking candidate set, the camera's near plane value is dynamically adjusted in combination with the rendering scene at the time interval that triggers the calculation. The calculation of the dynamic setting of the camera's near plane value is completed. After automatic adaptive dynamic adjustment according to the rendering scene, the screen tearing caused by rendering depth conflict is improved.
[0070] Preferably, the initialization step S10 sets the target observation point position of the camera, initially sets the point density range of the rendered scene sampling and the time interval for triggering the calculation, and provides a preset object picking candidate set, further comprising:
[0071] Construct two mutually perpendicular plane data and set the origin of the plane data as the target observation point of the camera;
[0072] According to the preset point density range of the rendering scene sampling, a plane pixel point list is calculated;
[0073] Set the time interval for triggering calculations based on the consumption of rendering performance;
[0074] According to the picking efficiency of the rendering scene, a set of rendering object picking candidates is pre-provided.
[0075] Preferably, the above S20 dynamically adjusts the near plane value of the camera in combination with the rendering scene to complete the calculation method of dynamically setting the near plane value of the camera, and after automatically adaptively and dynamically adjusting according to the rendering scene to improve the screen tearing caused by the rendering depth conflict, further includes:
[0076] Based on the time interval of trigger calculation, wait for the calculation trigger of the near plane value;
[0077] Traverse the screen pixel sampling point list and perform ray picking operations on the rendered scene based on the position of the pixel points;
[0078] Based on the candidate set of rendering objects, the polygon of the rendering object is calculated by intersecting with the ray to obtain the 3D coordinate position in the rendering scene, and the list of all screen pixel sampling points is traversed in a loop;
[0079] Based on the three-dimensional coordinate position, the best three-dimensional coordinate point is obtained by averaging calculation;
[0080] Set the camera's near plane value to the depth value of the optimal 3D coordinate point.
[0081] Preferably, the above calculation to obtain a plane pixel point list further includes:
[0082] Taking the midpoint pixel position of the screen as the starting point, obtain half of the screen diagonal length, divide it evenly according to the set point density range, and use the center point of the screen as the reference to obtain the screen pixel sampling point positions on multiple line segments;
[0083] Taking the center point of the screen as the reference, the screen pixel sampling point positions on multiple line segments in the horizontal and vertical directions are calculated by evenly dividing the points according to the set point density range;
[0084] The screen pixel sampling point location stores a list of screen pixel sampling points.
[0085] Preferably, the above-mentioned performing a ray picking operation on the rendered scene based on the positions of the pixel points further includes:
[0086] Convert pixel positions to normalized device coordinate space based on the viewport size of the rendered scene;
[0087] Set the ray starting point to the camera coordinate position, the ray observation point to the viewpoint coordinates in the normalized device coordinate space after removing the effect of the projection matrix, and then obtain the ray's three-dimensional ray observation point in the world coordinate system based on the matrix in the camera's world coordinate system;
[0088] The ray direction is the normalized vector obtained by subtracting the starting point from the observation point.
[0089] The following describes in detail the specific embodiments of the present invention with reference to the accompanying drawings:
[0090] The present invention adopts the following steps to automatically adapt the near plane of camera rendering:
[0091] 1. Preparation stage (this step only needs to be done once)
[0092] 1.1 Construct two mutually perpendicular plane data, and set their origin position to the target observation point position of the camera (this setting can synchronously follow the target observation position of the camera).
[0093] 1.2 Set the scene sampling point density range (used to calculate a more suitable camera near plane value). At least one point needs to be set for calculation, so the minimum density range is 1. Calculate a list of multiple pixel positions relative to the rendering screen based on the set sampling point density range. The calculation method is as follows:
[0094] 1.2.1 The starting point is the midpoint pixel position of the screen
[0095] 1.2.2 Obtain half of the screen diagonal length, divide it equally according to the set density value, and use the center of the screen as the reference to obtain the screen pixel positions on the four line segments (upper left, upper right, lower right, and lower left).
[0096] 1.2.3 Based on the center point of the screen, divide the area evenly according to the set density value and calculate the positions of the screen pixels on the four horizontal and vertical line segments (up, down, left, and right).
[0097] 1.2.4 Save the screen pixel sampling point list obtained above for use in the calculation stage.
[0098] 1.3 Set the calculation trigger time interval (used to balance the near plane numerical calculation and rendering frame rate. If the rendering performance is reduced due to calculation consumption, the calculation millisecond interval can be appropriately increased to improve the rendering frame rate).
[0099] 1.4 Provide an object picking candidate set (optional, if not provided, the entire scene will be picked). If this candidate set is provided, the impact on the rendering frame rate will be reduced because the number of objects to be picked will be reduced (for example, objects with larger areas and volumes can be defined as candidate objects for picking, while other objects with smaller areas and volumes can be ignored, thereby improving picking efficiency).
[0100] 2. Calculation stage
[0101] 2.1 Wait for the calculation to be triggered according to the set time interval.
[0102] 2.2 Traverse the list of screen pixel sampling points and perform ray picking operations on the rendered scene according to the position of the pixel points. The ray construction steps are as follows:
[0103] 2.2.1 Convert the pixel position to the Normalized Device Coordinate (NDC) space between [-1, 1] according to the viewport size.
[0104] 2.2.2 The starting point of the ray is the camera coordinate position.
[0105] 2.2.3 The ray observation point is the viewpoint coordinate in the NDC space after removing the influence of the projection matrix (multiplied by the inverse matrix of the camera projection matrix), and then multiplied by the matrix in the world coordinate system of the camera, the three-dimensional observation point of the ray based on the world coordinate system can be obtained.
[0106] 2.2.4 The ray direction is the normalized vector obtained by subtracting the starting point from the observation point.
[0107] 2.3 The above process is repeated, and the intersection calculation of the polygon of the rendering object (obtained from the rendering object candidate set) and the ray can be used to obtain the three-dimensional coordinate position in the rendering scene (if the screen pixel position and the rendering scene do not have intersecting three-dimensional coordinate points, the two mutually perpendicular plane data established in the preparation stage are used to calculate the three-dimensional coordinate point (x, y, z) to ensure that the picked three-dimensional coordinate point is obtained). This step ends until the last sampling point is calculated.
[0108] 2.4 Calculate a three-dimensional coordinate point (x, y, z) by averaging the three-dimensional coordinate information obtained in the above steps.
[0109] 2.5 Set the camera's near plane value to the depth value (z) of the three-dimensional coordinate point obtained in the above step.
[0110] In the prior art, the scene rendering effect before using the technology of the present invention is as follows Figure 2As shown in the figure, it is obvious that the ground is torn. Because the ground rendered in the scene has multiple layers and the distance is too close, it may cause depth conflict and thus torn surface.
[0111] After using the processing technology of the present invention to automatically repair the near plane of the camera, Figure 3 As shown, the tearing problem has been basically fixed.
[0112] Can be achieved through Figure 4 It is observed that if the camera near plane is too small, it may cause the tearing phenomenon. By adjusting the camera near plane value, the tearing problem can be well fixed without affecting the rendering effect, such as Figure 5 shown.
[0113] The above effect uses only one sampling point density (that is, only the pixel position of the center point of the screen is operated), which can basically complete the repair of the torn surface. If the sampling density point is increased, better results will be achieved.
[0114] However, if the scene is too complex and automatic repair is enabled, resulting in a drop in frame rate, the frame rate can be increased by reducing the sampling density and increasing the calculation time interval.
[0115] The present invention also provides a three-dimensional scene rendering depth conflict improvement system, such as Figure 6 As shown, using any one of the three-dimensional scene rendering depth conflict improvement methods, the system includes:
[0116] Initialization module 10: Initializes the target observation point position of the camera, initially sets the point density range of the rendering scene sampling and the time interval for triggering calculation, obtains the screen pixel sampling point list based on the point density range, and pre-provides a preset rendering object picking candidate set;
[0117] Near plane value calculation module 20: Based on the screen pixel sampling point list and the rendering object picking candidate set, the camera's near plane value is dynamically adjusted in combination with the rendering scene at the time interval that triggers the calculation, and the calculation of the near plane value of the dynamic setting camera is completed. After automatic adaptive dynamic adjustment according to the rendering scene, the screen tearing caused by rendering depth conflict is improved.
[0118] Preferably, the initialization module 10 further includes:
[0119] Data construction module: construct two mutually perpendicular plane data and set the origin position of the plane data as the target observation point position of the camera;
[0120] Point density setting module: calculates and obtains a plane pixel list based on the preset point density range of the rendering scene sampling;
[0121] Calculation time interval setting module: Set the time interval for triggering calculation according to the consumption of rendering performance;
[0122] Picking candidate set module: pre-provides a set of rendering object picking candidates based on the picking efficiency of the rendering scene.
[0123] Preferably, the above-mentioned near-plane numerical calculation module 20 further comprises:
[0124] Calculation trigger module: based on the time interval of trigger calculation, waits for the calculation trigger of the near plane value;
[0125] Traversal calculation module: traverses the screen pixel sampling point list and performs ray picking operations on the rendered scene based on the position of the pixel points;
[0126] 3D coordinate acquisition module: Based on the candidate set of rendering objects, the 3D coordinate position in the rendering scene is obtained by calculating the intersection of the rendering object polygon and the ray, and the list of all screen pixel sampling points is traversed in a loop;
[0127] 3D coordinate point calculation module: Based on the 3D coordinate position, the optimal 3D coordinate point is obtained by average calculation;
[0128] Near plane value setting module: sets the near plane value of the camera to the depth value of the optimal three-dimensional coordinate point.
[0129] The present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-mentioned method for improving depth conflict in three-dimensional scene rendering.
[0130] The present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes the program, the steps of the above-mentioned method for improving depth conflict in three-dimensional scene rendering are implemented.
[0131] Compared with the existing technology, the key point of the solution of the present invention is to repair the tearing problem as much as possible without affecting the rendering efficiency, and the repair needs to be performed automatically without increasing the technical threshold of developers as much as possible.
[0132] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0133] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0134] In the embodiments provided by the present invention, it should be understood that the disclosed systems / terminal devices and methods can be implemented in other ways. For example, the system / terminal device embodiments described above are merely illustrative. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the system or unit can be electrical, mechanical or other forms.
[0135] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0136] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0137] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
[0138] Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, it can implement the steps of the above-mentioned various method embodiments. The computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or system that can carry the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0139] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.
[0140] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and such modifications or substitutions are intended to be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.
Claims
1. A method for improving depth conflict in three-dimensional scene rendering, characterized in that: The method comprises: Initialize the target observation point position of the camera, initially set the point density range of the rendering scene sampling and the time interval for triggering calculation, obtain the screen pixel sampling point list based on the point density range, and pre-provide a preset rendering object picking candidate set; Based on the screen pixel sampling point list and the rendering object picking candidate set, dynamically adjusting the near plane value of the camera in combination with the rendering scene at the time interval of the trigger calculation, completing the calculation of dynamically setting the near plane value of the camera, and automatically and adaptively adjusting the near plane value according to the rendering scene to improve screen tearing caused by rendering depth conflict; Also includes: Waiting for triggering calculation of the near plane value based on the time interval for triggering calculation; Traversing the screen pixel sampling point list, and performing a ray picking operation on the rendering scene based on the positions of the pixel points; Based on the candidate set of rendering objects, the three-dimensional coordinate position in the rendering scene is obtained by performing intersection calculation between the rendering object polygon and the ray, and all the screen pixel sampling point lists are traversed in a loop; Based on the three-dimensional coordinate positions, an optimal three-dimensional coordinate point is obtained by averaging and calculating; The near plane value of the camera is set to the depth value of the optimal three-dimensional coordinate point.
2. The method for improving depth conflict in three-dimensional scene rendering according to claim 1, characterized in that: The initialization sets the target observation point position of the camera, initially sets the point density range of the rendering scene sampling and the time interval for triggering calculation, and provides a preset object picking candidate set, further including: Constructing two mutually perpendicular plane data, and setting the origin position of the plane data as the target observation point position of the camera; Calculating and obtaining the plane pixel point list according to a preset point density range of the rendering scene sampling; According to the consumption of rendering performance, the time interval for triggering the calculation is set; The rendering object picking candidate set is pre-provided according to the picking efficiency of the rendering scene.
3. The method for improving depth conflict in three-dimensional scene rendering according to claim 2, characterized in that: The calculating and obtaining the plane pixel point list further includes: Taking the midpoint pixel position of the screen as the starting point, obtain half of the screen diagonal length, divide it evenly according to the set point density range, and obtain the screen pixel sampling point positions on multiple line segments with the center point of the screen as the reference; Taking the center point of the screen as a reference, the screen pixel sampling point positions on multiple line segments in the horizontal and vertical directions are calculated by evenly dividing the points according to the set point density range; The screen pixel sampling point position stores the screen pixel sampling point list.
4. The method for improving depth conflict in three-dimensional scene rendering according to claim 1, characterized in that: The performing a ray picking operation on the rendered scene based on the positions of the pixels further comprises: Converting pixel positions to normalized device coordinate space according to the viewport size of the rendered scene; Set the ray starting point to the camera coordinate position, the ray observation point to the viewpoint coordinates after removing the effect of the projection matrix from the coordinates in the standardized device coordinate space, and then obtain the three-dimensional ray observation point of the ray based on the world coordinate system based on the matrix in the world coordinate system of the camera; The ray direction is a normalized vector obtained by subtracting the starting point from the observation point.
5. A system for improving depth conflict in three-dimensional scene rendering, using the method for improving depth conflict in three-dimensional scene rendering according to any one of claims 1 to 4, characterized in that: The system comprises: Initialization module: Initializes the target observation point position of the camera, initially sets the point density range of the rendering scene sampling and the time interval for triggering calculation, obtains the screen pixel sampling point list based on the point density range, and pre-provides a preset rendering object picking candidate set; A near plane value calculation module: based on the screen pixel sampling point list and the rendering object picking candidate set, dynamically adjusts the near plane value of the camera in combination with the rendering scene at the time interval of the trigger calculation, completes the calculation of the near plane value of the camera that is dynamically set, and automatically and dynamically adjusts the adaptive value according to the rendering scene to improve the screen tearing caused by rendering depth conflict; The near-plane numerical calculation module further comprises: A calculation trigger module: waiting for a calculation trigger of the near plane value based on a time interval of the trigger calculation; A traversal calculation module: traverses the screen pixel sampling point list and performs a ray picking operation on the rendering scene based on the positions of the pixel points; A three-dimensional coordinate acquisition module: based on the candidate set of rendering objects, the module uses the intersection calculation between the rendering object polygon and the ray to obtain the three-dimensional coordinate position in the rendering scene, and loops through all the screen pixel sampling point lists; Three-dimensional coordinate point calculation module: based on the three-dimensional coordinate position, average calculation is performed to obtain the best three-dimensional coordinate point; A near plane value setting module is configured to set the near plane value of the camera to the depth value of the optimal three-dimensional coordinate point.
6. The 3D scene rendering depth conflict improvement system according to claim 5, characterized in that: The initialization module further includes: Data construction module: construct two mutually perpendicular plane data, and set the origin position of the plane data as the target observation point position of the camera; Point density setting module: calculates and obtains the plane pixel point list according to a preset point density range of the rendering scene sampling; Calculation time interval setting module: setting the time interval for triggering calculation according to the consumption of rendering performance; Picking candidate set module: pre-provides the rendering object picking candidate set according to the picking efficiency of the rendering scene.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method for improving depth conflict in three-dimensional scene rendering described in any one of claims 1 to 4 are implemented.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the steps of the method for improving depth conflict in three-dimensional scene rendering as described in any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Built-in real tri-dimension rendering process oriented to AutoCAD and 3DS MAX
CN101477701A
Border covering method and system based on key point ray collision detection and electronic device
CN103529959A