Method, device, storage medium and electronic device for generating a projection in a game scene
Patent Information
- Application Number
- CN202310575960.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-17
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2043-05-17
AI Technical Summary
[0005]本申请至少部分实施例提供了一种游戏场景中生成投影的方法、装置、存储介质及电子装置,以至少解决现有技术中采用实时投影计算或者光照贴图烘焙投影信息的方法导致难以兼顾投影生成过程中的设备性能消耗和美术效果快速迭代需求的技术问题
[0010] In at least some embodiments of this application, the scene depth information of a 3D game scene captured by a virtual camera is recorded to a rendering target texture; multiple 3D virtual models within the 3D game scene are spatially transformed to obtain a target transformation result, wherein the multiple 3D virtual models are virtual models to be projected; the rendering target texture is sampled based on the target transformation result to obtain a target material; the target material is assigned to the multiple 3D virtual models to generate a projection effect adapted to the multiple 3D virtual models. Thus, the method provided by this application achieves the goal of generating projection effects in a 3D game scene based on the spatial transformation results of the rendering target texture corresponding to the scene depth information and the multiple 3D virtual models to be projected. This reduces the device performance consumption and the difficulty of rapid iteration of artistic effects during the projection generation process in the game scene, thereby solving the technical problem in the prior art where the methods of real-time projection calculation or lightmap baking of projection information are difficult to balance the device performance consumption and the need for rapid iteration of artistic effects during the projection generation process.
Smart Images

Figure CN116726501B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a method, apparatus, storage medium, and electronic device for generating projections in a game scene. Background Technology
[0002] For creating lighting and projection in game scenes, existing technologies commonly use the following methods to generate projections: The first method uses a real-time lighting system to achieve real-time projection of the scene. This method is costly, involves a large number of mesh faces and computational data, making it difficult to apply to mobile devices. The second method uses lightmaps to bake projection information, but the resulting lightmaps... Figure 1 Baking data makes it impossible to modify. When there are many levels to be built in a game scene, baking projection information generates a large amount of build data, affecting the game's data package size. In summary, existing technologies are insufficient to meet the performance requirements of mobile devices and the need for rapid iteration of artistic effects.
[0003] There is currently no effective solution to the above problems.
[0004] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this application, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0005] At least some embodiments of this application provide a method, apparatus, storage medium, and electronic device for generating projections in a game scene, so as to at least solve the technical problem in the prior art that the method of using real-time projection calculation or lightmap baking of projection information makes it difficult to balance the device performance consumption and the need for rapid iteration of artistic effects during the projection generation process.
[0006] According to one embodiment of this application, a method for generating projection in a game scene is provided, comprising: recording scene depth information of a three-dimensional game scene captured by a virtual camera to a rendering target texture; performing spatial transformation on multiple three-dimensional virtual models in the three-dimensional game scene to obtain a target transformation result, wherein the multiple three-dimensional virtual models are virtual models to be projected; sampling the rendering target texture based on the target transformation result to obtain a target material; and assigning the target material to the multiple three-dimensional virtual models to generate a projection effect adapted to the multiple three-dimensional virtual models.
[0007] According to one embodiment of this application, an apparatus for generating projections in a game scene is also provided, comprising: a recording module for recording scene depth information of a three-dimensional game scene captured by a virtual camera to a rendering target texture; a transformation module for performing spatial transformation on multiple three-dimensional virtual models within the three-dimensional game scene to obtain a target transformation result, wherein the multiple three-dimensional virtual models are virtual models to be projected; a sampling module for sampling the rendering target texture based on the target transformation result to obtain a target material; and a generation module for assigning the target material to the multiple three-dimensional virtual models to generate a projection effect adapted to the multiple three-dimensional virtual models.
[0008] According to one embodiment of this application, a computer-readable storage medium is also provided, in which a computer program is stored, wherein the computer program is configured to execute, at runtime, the method for generating projections in the game scene described in any of the above claims.
[0009] According to one embodiment of this application, an electronic device is also provided, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the method of generating a projection in a game scene as described above.
[0010] In at least some embodiments of this application, the scene depth information of a 3D game scene captured by a virtual camera is recorded to a rendering target texture; multiple 3D virtual models within the 3D game scene are spatially transformed to obtain a target transformation result, wherein the multiple 3D virtual models are virtual models to be projected; the rendering target texture is sampled based on the target transformation result to obtain a target material; the target material is assigned to the multiple 3D virtual models to generate a projection effect adapted to the multiple 3D virtual models. Thus, the method provided by this application achieves the goal of generating projection effects in a 3D game scene based on the spatial transformation results of the rendering target texture corresponding to the scene depth information and the multiple 3D virtual models to be projected. This reduces the device performance consumption and the difficulty of rapid iteration of artistic effects during the projection generation process in the game scene, thereby solving the technical problem in the prior art where the methods of real-time projection calculation or lightmap baking of projection information are difficult to balance the device performance consumption and the need for rapid iteration of artistic effects during the projection generation process. Attached Figure Description
[0011] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0012] Figure 1 This is a hardware structure block diagram of a mobile terminal for a method of generating projections in a game scene according to an embodiment of this application.
[0013] Figure 2 This is a flowchart of a method for generating projections in a game scene according to one embodiment of this application;
[0014] Figure 3 This is a schematic diagram of an optional rendering target texture according to one embodiment of this application;
[0015] Figure 4 This is a schematic diagram of an optional process for constructing a rotation vector according to one embodiment of this application;
[0016] Figure 5 This is a schematic diagram of an optional process for constructing an observation matrix according to one embodiment of this application;
[0017] Figure 6 This is a schematic diagram of a scene projection effect based on existing technology;
[0018] Figure 7 This is a schematic diagram of an optional scene projection effect according to one embodiment of this application;
[0019] Figure 8 This is a structural block diagram of a device for generating projections in a game scene according to one embodiment of this application;
[0020] Figure 9 This is a schematic diagram of an electronic device according to one embodiment of the present application. Detailed Implementation
[0021] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0022] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0023] It should be noted that, in the specification of this application, the word "for example" is used to mean "used as an example, illustration, or description." Any embodiment described as "for example" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to make and use this application. In the following description, details are set forth for purposes of explanation. It should be understood that those skilled in the art will recognize that this application can be made without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid unnecessarily obscuring the description of this application. Therefore, this application is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in this application.
[0024] In the description of the embodiments of this application, some nouns or terms appearing shall be interpreted as follows:
[0025] Render Target (RT): This refers to a contiguous memory area in a 3D graphics interface. The 3D scene is rendered onto the RT to obtain the Render Target Texture (RTT), and then other effects are applied to the image by manipulating the RTT through pixel shaders.
[0026] In one possible implementation of this application, the inventors, after practice and careful research, found that the real-time projection calculation method or the method of baking projection information with lightmaps commonly used in computer technology and video game scenarios involving projection generation still has the technical problem of difficulty in balancing the device performance consumption and the need for rapid iteration of artistic effects during the projection generation process. Based on this, the scenario applied to the embodiments of this application can be a scenario involving projection generation in the fields of computer technology and video games. In particular, the game type targeted by the game scene in the field of video games that generates projections can be action, adventure, simulation, role-playing, and casual games, etc.
[0027] This application proposes a method for generating projections in a game scene. The method involves recording the scene depth information of a 3D game scene captured by a virtual camera onto a rendering target texture; performing spatial transformation on multiple 3D virtual models within the 3D game scene to obtain a target transformation result, where these multiple 3D virtual models are virtual models to be projected; sampling the rendering target texture based on the target transformation result to obtain a target material; and assigning the target material to the multiple 3D virtual models to generate projection effects adapted to them. This technical concept reduces the device performance consumption and the difficulty of rapid iteration of artistic effects during the projection generation process in game scenes. It also solves the technical problem in existing technologies that use real-time projection calculation or lightmap baking of projection information, which makes it difficult to simultaneously address the device performance consumption and the need for rapid iteration of artistic effects during the projection generation process.
[0028] The methods described in this application can be executed in a terminal device (e.g., a mobile terminal, a computer terminal, or a similar computing device). Taking a mobile terminal as an example, the mobile terminal can be a smartphone, tablet computer, PDA, mobile internet device, game console, or other terminal device.
[0029] Figure 1 This is a hardware structure block diagram of a mobile terminal illustrating a method for generating projections in a game scene according to one embodiment of this application. Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 (Only one is shown) Processor 102, memory 104, transmission device 106, input / output device 108, and display device 110. Taking the method of generating projections in a game scene applied to a video game scene via this mobile terminal as an example, processor 102 calls and runs the computer program stored in memory 104 to execute the method of generating projections in the game scene. The projection effect adapted to the 3D virtual model in the generated video game scene is transmitted to input / output device 108 and / or display device 110 through transmission device 106, thereby providing the projection effect to the player.
[0030] Still as Figure 1As shown, the processor 102 may include, but is not limited to, processing devices such as: Central Processing Unit (CPU), Graphics Processing Unit (GPU), Digital Signal Processing (DSP) chip, Microcontroller Unit (MCU), Field Programmable Gate Array (FPGA), Neural-Network Processing Unit (NPU), Tensor Processing Unit (TPU), Artificial Intelligence (AI) type processor, etc.
[0031] Those skilled in the art will understand that Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0032] In some optional embodiments primarily focused on gaming scenarios, the aforementioned terminal device may also provide a human-computer interaction interface with a touch-sensitive surface. This interface can sense finger contact and / or gestures to interact with a graphical user interface (GUI). The human-computer interaction functions may include the following: creating web pages, drawing, word processing, creating electronic documents, playing games, video conferencing, instant messaging, sending and receiving emails, call interfaces, playing digital videos, playing digital music, and / or web browsing, etc. Executable instructions for performing the aforementioned human-computer interaction functions are configured / stored in one or more processor-executable computer program products or readable storage media.
[0033] The methods described in this application can also be executed on a server. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Taking the method of generating projections in a game scene applied to a video game scene via a video game server as an example, the video game server can generate a projection effect adapted to the 3D virtual model in the video game scene based on the method of generating projections in the game scene, and provide this projection effect to the player (e.g., it can be rendered and displayed on the player's terminal screen, or it can be provided to the player through holographic projection, etc.).
[0034] According to one embodiment of this application, an embodiment of a method for generating projections in a game scene is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0035] This embodiment provides a method for generating projections in a game scene running on the aforementioned mobile terminal. Figure 2 This is a flowchart of a method for generating projections in a game scene according to one embodiment of this application, such as... Figure 2 As shown, the method includes the following steps:
[0036] Step S21: Record the scene depth information of the 3D game scene captured by the virtual camera into the rendering target texture;
[0037] Step S22: Perform spatial transformation on multiple 3D virtual models in the 3D game scene to obtain the target transformation result, wherein the multiple 3D virtual models are virtual models to be projected.
[0038] Step S23: Sample the target texture based on the target transformation result to obtain the target material;
[0039] Step S24: Assign the target material to multiple 3D virtual models to generate projection effects that fit the multiple 3D virtual models.
[0040] The game types corresponding to the aforementioned 3D game scenes can be: action games (e.g., first-person or third-person shooter games, 2D or 3D fighting games, war action games, and sports action games), adventure games (e.g., exploration games, collection games, puzzle games), simulation games (e.g., simulation sandbox games, simulation management games, strategy simulation games, city building simulation games, business simulation games), role-playing games, and casual games (e.g., board games, casual competitive games, music rhythm games, dress-up and simulation games), etc.
[0041] The method provided in this application embodiment can be developed based on Unreal Engine (UE). The method provided in this application embodiment can reduce the adverse impact on mobile device performance caused by the additional number of model faces added by the mesh for calculating projection under dynamic lighting, while supporting rapid iterative adjustments to the visual effects of mobile game scene projection. Furthermore, the aforementioned rendering target texture can be an RTT stored in the RT; therefore, the method provided in this application embodiment can support offline generation of game scene projections.
[0042] In at least some embodiments of this application, the scene depth information of a 3D game scene captured by a virtual camera is recorded to a rendering target texture; multiple 3D virtual models within the 3D game scene are spatially transformed to obtain a target transformation result, wherein the multiple 3D virtual models are virtual models to be projected; the rendering target texture is sampled based on the target transformation result to obtain a target material; the target material is assigned to the multiple 3D virtual models to generate a projection effect adapted to the multiple 3D virtual models. Thus, the method provided by this application achieves the goal of generating projection effects in a 3D game scene based on the spatial transformation results of the rendering target texture corresponding to the scene depth information and the multiple 3D virtual models to be projected. This reduces the device performance consumption and the difficulty of rapid iteration of artistic effects during the projection generation process in the game scene, thereby solving the technical problem in the prior art where the methods of real-time projection calculation or lightmap baking of projection information are difficult to balance the device performance consumption and the need for rapid iteration of artistic effects during the projection generation process.
[0043] Optionally, in step S21, recording the scene depth information of the 3D game scene captured by the virtual camera onto the rendering target texture may include the following steps:
[0044] Step S211: Create the object class blueprint;
[0045] Step S212: Add a camera component to the object class blueprint, wherein the camera component is used to generate a virtual camera in the 3D game scene;
[0046] Step S213: Set the capture source of the camera component to the monochrome channel of the depth buffer corresponding to the virtual camera to obtain scene depth information;
[0047] Step S214: Record the scene depth information to the rendering target texture.
[0048] The object class blueprint mentioned above is the Actor class blueprint in the game engine. The camera component mentioned above is the SceneCaptureComponent2D component in the game engine. The camera component is used to generate a virtual camera within the 3D game scene. The virtual camera is used to capture scene image data within the 3D game scene. The virtual camera has multiple color channels, such as R channel, G channel, B channel, and Alpha channel.
[0049] In one optional implementation, the camera component is used to capture scene depth data of the 3D game scene; that is, in the game engine, the scene depth data of the game scene is stored in the depth buffer of the camera component. Since grayscale values are used to represent scene depth during the projection generation process in the game scene in this application, the capture source of the camera component is set to the monochrome channel of the depth buffer corresponding to the virtual camera to obtain scene depth information. For example, the monochrome channel uses the R channel, and the capture source is Scene Depth in R. The grayscale image of the scene depth information obtained through the above method steps is shown below. Figure 3 As shown, it is easy to see that in Figure 3 Based on the grayscale value of a pixel, the scene depth data of the game scene corresponding to that pixel can be determined.
[0050] Furthermore, the scene depth information is recorded to the Render Target Texture (RTT), and the resolution of the RTT is set to a preset resolution (e.g., 1024×1024), and the format of the RTT is set to a preset format (e.g., RTF R16f). Optionally, the aforementioned RTT can be a default texture in the game engine (e.g., UE, etc.) (e.g., denoted as Render Target 2D). Thus, by manipulating the RTT, the scene rendering effect can be easily controlled, which is beneficial for subsequent adjustments and iterations of the projection rendering results in the game scene.
[0051] Optionally, the projection type of the camera component is orthographic projection, and the shooting width of the camera component is a preset value.
[0052] To simulate the effect of parallel light illuminating a scene, the camera component in the game engine is created with its projection type set to orthographic. Furthermore, the camera component's shooting width is set to a preset value. This preset value can be specified in advance by the technician or set by the game engine based on the current display size of the game scene. For example, in one optional implementation, the technician sets the camera component's shooting width to 100,000 pixels. Based on this, a virtual camera within the 3D game scene is generated using the configured camera component.
[0053] Optionally, in step S22, spatial transformation is performed on multiple 3D virtual models within the 3D game scene to obtain the target transformation result, which may include the following execution steps:
[0054] Step S221: Create a material parameter set, wherein the material parameter set is used to determine the transformation matrix to be used during the spatial transformation process;
[0055] Step S222: Based on the material parameter set, observe and transform the world space positions of multiple 3D virtual models in the 3D game scene to obtain the initial transformation result, and perform projection transformation on the initial transformation result to obtain the target transformation result.
[0056] The aforementioned spatial transformation can be performed according to a transformation matrix. The aforementioned material parameter set includes multiple material parameters, which are used to determine the transformation matrix to be used during the spatial transformation process. Based on the material parameter set, matrix transformations are performed on the world space positions of multiple 3D virtual models to be projected within the 3D game scene to obtain the target transformation result.
[0057] In one optional embodiment of this application, a world space position node is created in the material panel to obtain the world space positions of multiple 3D virtual models in the aforementioned 3D game scene. Using the observation matrix to be used determined by the material parameter set, the world space position of each of the multiple 3D virtual models is observed and transformed to obtain an initial transformation result. The initial transformation result includes a first transformation position obtained by transforming the world space position of each 3D virtual model. Further, using the projection matrix to be used determined by the material parameter set, the first transformation position corresponding to each 3D virtual model in the initial transformation result is projected and transformed to obtain a target transformation result. The target transformation result includes a second transformation position corresponding to each 3D virtual model.
[0058] It is easy to understand that the target transformation result can characterize the projection position of each of the multiple 3D virtual models to be projected. In other words, the technical concept of the method for generating projections in a game scene provided in this application embodiment is: to generate projections based on the 2D rendering target texture corresponding to the game scene and the 3D transformation matrix corresponding to the 3D virtual model to be projected. This method can quickly and easily adjust and iterate the projection effect during subsequent operation and maintenance, and the number of mesh faces of the virtual model in the game scene does not increase throughout the process, resulting in low computational cost and low consumption of device performance.
[0059] Optionally, creating a material parameter set in step S221 may include the following steps:
[0060] Step S223: Construct the observation matrix and projection matrix within the object class blueprint;
[0061] Step S224: Create a material parameter set using the observation matrix and projection matrix.
[0062] Within the Actor class blueprint of the game engine, a view matrix and a projection matrix are constructed. Using multiple view vectors from the view matrix and multiple projection vectors from the projection matrix, a material parameter set is created. In other words, the material parameter set is constructed by building transformation matrices to be used during spatial transformations, including both the view matrix and the projection matrix.
[0063] In another alternative implementation, the transformation matrix to be used can be determined by MVP matrix transformation. Specifically, a matrix transformation is performed based on the observation matrix V, projection matrix P, and model matrix M to obtain the MVP matrix as the transformation matrix to be used. The above matrix transformation is calculated as MVP = M × V × P. The model matrix M is used to transform the model from model space to world space, the observation matrix V is used to transform world space to view space, and the projection matrix P is used to transform view space to projection space.
[0064] Optionally, in step S223, constructing the observation matrix within the object class blueprint may include the following execution steps:
[0065] Step S2231: Obtain the first column of world space direction vector, the second column of world space direction vector, and the third column of world space direction vector by obtaining the object direction vector. Any two vectors in the first column of world space direction vector, the second column of world space direction vector, and the third column of world space direction vector are perpendicular to each other.
[0066] Step S2232: Obtain the object's coordinate position by obtaining the object's position.
[0067] Step S2233: Calculate the rotation vector using the first column of world space direction vectors, the second column of world space direction vectors, the third column of world space direction vectors, and the object's coordinate position.
[0068] Step S2234: Within the object class blueprint, construct the observation matrix based on the sum and rotation vector of the first column of world space direction vectors, the second column of world space direction vectors, and the third column of world space direction vectors.
[0069] The game scene described above uses a three-dimensional Cartesian coordinate system, with the coordinate axes represented as the X, Y, and Z axes, which are mutually perpendicular. In the game engine, the first, second, and third columns of world space downward direction vectors are obtained using the `Get ActorVector` method. For example, the first column of world space downward direction vectors is the X vector, the second column is the Y vector, and the third column is the Z vector. Specifically, the right direction of the virtual camera in the world coordinate system is obtained as the X vector (x1, y1, z1), the up direction of the virtual camera in the world coordinate system is obtained as the Y vector (x2, y2, z2), and the forward direction of the virtual camera in the world coordinate system is obtained as the Z vector (x3, y3, z3).
[0070] Furthermore, in the game engine, the coordinates of an object (Actor) are obtained by using the "Get Actor Location" method. Specifically, by obtaining the object location, the coordinates of each virtual object among multiple virtual objects to be projected are obtained. For example, three virtual objects are denoted as A1(x01, y01, z01), A2(x02, y02, z02), and A3(x03, y03, z03).
[0071] Furthermore, using the first column of world space direction vectors, the second column of world space direction vectors, the third column of world space direction vectors, and the object's coordinate position, a rotation vector is calculated. For example, the rotation vector is denoted as the W vector. Within the object class blueprint in the game engine, an observation matrix is constructed based on the aforementioned X vector (x1, y1, z1), Y vector (x2, y2, z2), Z vector (x3, y3, z3), and W vector.
[0072] Optionally, in step S2233, the rotation vector is calculated using the first column of world space direction vectors, the second column of world space direction vectors, the third column of world space direction vectors, and the object's coordinate position. This may include the following steps:
[0073] Step S2235: Perform a dot product between the object's coordinate position and the first column of the world space down direction vector to obtain a first dot product result; perform a dot product between the object's coordinate position and the second column of the world space down direction vector to obtain a second dot product result; and perform a dot product between the object's coordinate position and the third column of the world space down direction vector to obtain a third dot product result.
[0074] Step S2236: Invert the first dot product result to obtain a first inverted result, invert the second dot product result to obtain a second inverted result, and invert the third dot product result to obtain a third inverted result;
[0075] Step S2237: Determine the rotation vector based on the first inversion result, the second inversion result, and the third inversion result.
[0076] The aforementioned rotation vectors correspond to multiple 3D virtual models to be projected in the game scene; that is, each 3D virtual model corresponds to a rotation vector.
[0077] In one optional embodiment of this application, the rotation vector is determined as follows: Figure 4 As shown. Taking the three-dimensional virtual model A1(x01, y01, z01) to be projected as an example, the dot product of the X vector (x1, y1, z1) and A1(x01, y01, z01) is calculated to obtain the first dot product result. The dot product of the Y vector (x2, y2, z2) and A1(x01, y01, z01) is calculated to obtain the second dot product result. The dot product of the Z vector (x3, y3, z3) and A1(x01, y01, z01) is calculated to obtain the third dot product result.
[0078] Still as Figure 4 As shown, the first dot product result is inverted to obtain a first inverted result, the second dot product result is inverted to obtain a second inverted result, and the third dot product result is inverted to obtain a third inverted result. Further, a rotation vector W1(x41, y41, z41) is determined based on the first, second, and third inverted results. This rotation vector W1(x41, y41, z41) corresponds to the three-dimensional virtual model A1(x01, y01, z01).
[0079] Optionally, in step S2234, constructing the observation matrix within the object class blueprint based on the sum and rotation vector of the first column of world space direction vectors, the second column of world space direction vectors, and the third column of world space direction vectors may include the following execution steps:
[0080] Step S2238: Within the object class blueprint, the first column of world space direction vectors, the second column of world space direction vectors, and the third column of world space direction vectors are recombined using the vector breaking method to obtain the combined result;
[0081] Step S2239: Construct the observation matrix using the combined results and rotation vectors.
[0082] Furthermore, to improve the randomness of the observation matrix and the accuracy of observation transformations, the X, Y, and Z vectors are broken and recombinated using the break vector technique from the game engine, resulting in updated X, Y, and Z vectors. The observation matrix is then constructed using the updated X, Y, and Z vectors and the rotation vector W.
[0083] For example, in an optional implementation of this application, the observation matrix is constructed in the following way: Figure 5 As shown, the X vector (x1, y1, z1), Y vector (x2, y2, z2), and Z vector (x3, y3, z3) are broken and recombined to obtain the updated X vector (x1, x2, x3), updated Y vector (y1, y2, y3), and updated Z vector (z1, z2, z3). Further, using the updated X vector (x1, x2, x3), updated Y vector (y1, y2, y3), and updated Z vector (z1, z2, z3), and as shown... Figure 4 The rotation vector W1(x41, y41, z41) obtained by the process shown is used to construct the observation matrix TA1. The observation matrix TA1 is used to perform observation transformation on the three-dimensional virtual model A1 to be projected.
[0084] It should be noted that for the multiple 3D virtual models to be projected in the game scene, excluding 3D virtual model A1, the process of generating the corresponding observation matrices (e.g., observation matrix TA2 for 3D virtual model A2, and observation matrix TA3 for 3D virtual model A3) can refer to the process of constructing observation matrix TA1 described above, and will not be repeated here. Based on the material parameter set, the initial transformation result obtained by performing observation transformation on the world space position of multiple 3D virtual models in the 3D game scene includes: the transformation result obtained by performing observation transformation on the 3D virtual model using the observation matrix corresponding to each of the multiple 3D virtual models. This transformation result can be the transformed world space position coordinates of the 3D virtual model.
[0085] Optionally, in step S223, constructing the projection matrix within the object class blueprint may include the following steps:
[0086] Step S22310: Obtain the display size of the game scene screen corresponding to the virtual camera and the shooting size of the virtual camera;
[0087] Step S22311: Within the object class blueprint, construct a projection matrix based on the display size and the shooting size.
[0088] In one optional embodiment of this application, the display size of the game scene corresponding to the virtual camera and the shooting size of the virtual camera are obtained using the Get Ortho Width node in the game engine. For example, the width of the display size of the game scene is represented as w, and the height as h; the distance between the near clipping plane corresponding to the game scene and the reference plane is denoted as n, and the distance between the far clipping plane corresponding to the game scene and the reference plane is denoted as f; at this time, the projection matrix P constructed in the object class blueprint in the game engine... e It can be represented as follows:
[0089]
[0090] It's important to note that in perspective projection, the area between the near clipping plane and the far clipping plane is the visible region, and objects within this visible region are rendered. The values of n and f determine the depth of the visible region, and these values typically need to be set based on the size of the scene and the objects to be displayed in the scene.
[0091] Let's denote the four 3D vectors corresponding to the projection matrix as P1, P2, P3, and P4. Then, the eight material parameters in the material parameter set are X, Y, Z, and W corresponding to the view matrix, and P1, P2, P3, and P4 corresponding to the projection matrix. In the game engine, these eight material parameters are used to read from the object class blueprint or to calculate in the pixel shader. For example, a `Direction` function can be created in the pixel shader, containing a `SetVector Parameter Value` node. This node retrieves the material parameters corresponding to the constructed view and projection matrices.
[0092] Optionally, in step S23, sampling the rendered target texture based on the target transformation result to obtain the target material may include the following steps:
[0093] Step S231: In the pixel shader, the rendering target texture is sampled based on the target transformation result to obtain the initial material;
[0094] Step S232: The target material is obtained by adjusting the projection properties of the initial material in the pixel shader.
[0095] In an optional embodiment of this application, in the pixel shader, based on the second transformation position corresponding to each 3D virtual model in the target transformation result, the pixel shader is configured to... Figure 3 The grayscale image of the game scene shown is sampled to obtain the initial material.
[0096] Specifically, in order to simulate the projection effect produced by parallel light illumination in a game scene, based on a plane perpendicular to the shooting direction of the virtual camera, the coordinate components of the second transformation position corresponding to each 3D virtual model in the target transformation result are used to... Figure 3 The grayscale image of the game scene shown is sampled to obtain the initial material. For example, if the virtual camera's shooting direction is the Y direction in the game scene coordinate system, then the X and Z coordinate components of the second transformation position corresponding to each 3D virtual model in the target transformation result are used to sample the initial material. Figure 3 The grayscale image of the game scene shown is sampled to obtain the initial material.
[0097] Furthermore, adjusting the projection properties of the initial material to obtain the target material includes: adjusting the projection color of the initial material according to preset color parameters to obtain a first adjustment result; adjusting the projection intensity of the first adjustment result according to preset intensity parameters to obtain a second adjustment result; adjusting the projection blur of the second adjustment result according to preset blur parameters to obtain a third adjustment result; and adjusting the projection distance of the third adjustment result according to preset distance parameters to obtain the target material.
[0098] It should be noted that the matrix transformation method corresponding to the above target transformation result can also be the VP matrix transformation. Similar to the MVP transformation, the calculation formula for the VP matrix transformation is: VP = V × P. The observation matrix V is used to transform world space to view space, and the projection matrix P is used to transform view space (3D) to projection space (2D).
[0099] It is easy to understand that the projection results generated by the method provided in this application embodiment can support the adjustment of the projection material through the pixel shader in the later process or operation and maintenance process, so as to adjust the projection attributes according to the needs of the scene. The above method is highly flexible, facilitates the adjustment and iteration of artistic effects, and is beneficial to the application in actual scenes.
[0100] Furthermore, in one alternative implementation, the target material is applied to multiple 3D virtual models to generate projection effects adapted to the multiple 3D virtual models. For example... Figure 6 The image shows a scene projection effect generated based on a real-time lighting system using existing technology, such as... Figure 7 The image shows a scene projection effect generated according to an embodiment of this application. It is readily apparent that the scene projection effect generated according to this embodiment achieves the same visual quality as the scene projection effect generated by a real-time lighting system. However, generating... Figure 6 The scene projection effect shown occupies the ShadowDepth thread, and the number of faces of the model mesh in the scene is approximately 810,000, requiring 404 scene renderings. However, the scene generated using the embodiment of this application... Figure 7 During the scene projection process shown, the Shadow Depth thread was not used, and the number of faces of the model mesh in the scene is approximately 530,000, with the scene being rendered 337 times. Clearly, the method for generating projections in game scenes provided in this application embodiment can reduce device performance consumption while ensuring the visual quality of the scene projection effect, making it more user-friendly for mobile devices.
[0101] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as a magnetic disk or optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0102] This embodiment also provides an apparatus for generating projections in a game scene. This apparatus is used to implement the above embodiments and preferred embodiments, and details already described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0103] Figure 8 This is a structural block diagram of a device for generating projections in a game scene according to one embodiment of this application, such as... Figure 8 As shown, the device includes: a recording module 801, used to record the scene depth information of the 3D game scene captured by the virtual camera to the rendering target texture; a transformation module 802, used to perform spatial transformation on multiple 3D virtual models in the 3D game scene to obtain the target transformation result, wherein the multiple 3D virtual models are virtual models to be projected; a sampling module 803, used to sample the rendering target texture based on the target transformation result to obtain the target material; and a generation module 804, used to assign the target material to the multiple 3D virtual models to generate a projection effect adapted to the multiple 3D virtual models.
[0104] Optionally, the recording module 801 described above is further configured to: create an object class blueprint; add a camera component to the object class blueprint, wherein the camera component is used to generate a virtual camera in the 3D game scene; set the capture source of the camera component to the monochrome channel of the depth buffer corresponding to the virtual camera to obtain scene depth information; and record the scene depth information to the rendering target texture.
[0105] Optionally, in the device for generating projections in the above game scene, the projection type of the camera component is orthographic projection, and the shooting width of the camera component is a preset value.
[0106] Optionally, the transformation module 802 described above is further configured to: create a material parameter set, wherein the material parameter set is used to determine the transformation matrix to be used during the spatial transformation process; based on the material parameter set, perform observation transformation on the world space positions of multiple three-dimensional virtual models in the three-dimensional game scene to obtain an initial transformation result, and perform projection transformation on the initial transformation result to obtain a target transformation result.
[0107] Optionally, the transformation module 802 described above is also used to: construct an observation matrix and a projection matrix within the object class blueprint; and create a material parameter set using the observation matrix and the projection matrix.
[0108] Optionally, the transformation module 802 is further configured to: obtain the first column of world space direction vectors, the second column of world space direction vectors, and the third column of world space direction vectors by obtaining the object direction vectors, wherein any two vectors among the first column of world space direction vectors, the second column of world space direction vectors, and the third column of world space direction vectors are perpendicular to each other; obtain the object coordinate position by obtaining the object position; calculate the rotation vector using the first column of world space direction vectors, the second column of world space direction vectors, the third column of world space direction vectors, and the object coordinate position; and construct an observation matrix within the object class blueprint based on the sum of the first column of world space direction vectors, the second column of world space direction vectors, the third column of world space direction vectors, and the rotation vector.
[0109] Optionally, the transformation module 802 is further configured to: perform a dot product between the object's coordinate position and the first column of world space direction vectors to obtain a first dot product result; perform a dot product between the object's coordinate position and the second column of world space direction vectors to obtain a second dot product result; and perform a dot product between the object's coordinate position and the third column of world space direction vectors to obtain a third dot product result; invert the first dot product result to obtain a first inverted result; invert the second dot product result to obtain a second inverted result; and invert the third dot product result to obtain a third inverted result; and determine a rotation vector based on the first inverted result, the second inverted result, and the third inverted result.
[0110] Optionally, the transformation module 802 described above is further configured to: within the object class blueprint, recombine the first column of world space direction vectors, the second column of world space direction vectors, and the third column of world space direction vectors using a vector breaking method to obtain a combination result; and construct an observation matrix using the combination result and the rotation vector.
[0111] Optionally, the transformation module 802 is further configured to: obtain the display size of the game scene screen corresponding to the virtual camera and the shooting size of the virtual camera; and construct a projection matrix based on the display size and the shooting size within the object class blueprint.
[0112] Optionally, the sampling module 803 described above is further configured to: sample the rendering target texture based on the target transformation result in the pixel shader to obtain an initial material; and obtain the target material by adjusting the projection properties of the initial material in the pixel shader.
[0113] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.
[0114] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when run.
[0115] Optionally, in this embodiment, the computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0116] Optionally, in this embodiment, the computer-readable storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0117] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0118] S1 records the scene depth information of the 3D game scene captured by the virtual camera to the rendering target texture;
[0119] S2, spatial transformation is performed on multiple 3D virtual models in the 3D game scene to obtain the target transformation result, wherein the multiple 3D virtual models are virtual models to be projected;
[0120] S3, sample the target texture based on the target transformation result to obtain the target material;
[0121] S4 assigns the target material to multiple 3D virtual models, generating projection effects that fit the multiple 3D virtual models.
[0122] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: creating an object class blueprint; adding a camera component within the object class blueprint, wherein the camera component is used to generate a virtual camera within a 3D game scene; setting the capture source of the camera component to a monochrome channel of the depth buffer corresponding to the virtual camera to obtain scene depth information; and recording the scene depth information to a rendering target texture.
[0123] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: the projection type of the camera component is orthographic projection, and the shooting width of the camera component is a preset value.
[0124] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: creating a material parameter set, wherein the material parameter set is used to determine the transformation matrix to be used during the spatial transformation process; based on the material parameter set, performing an observation transformation on the world space positions of multiple 3D virtual models in the 3D game scene to obtain an initial transformation result, and performing a projection transformation on the initial transformation result to obtain a target transformation result.
[0125] Optionally, the aforementioned computer-readable storage medium is also configured to store program code for performing the following steps: constructing an observation matrix and a projection matrix within an object class blueprint; and creating a set of material parameters using the observation matrix and the projection matrix.
[0126] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: obtaining a first column of world space direction vectors, a second column of world space direction vectors, and a third column of world space direction vectors by obtaining object direction vectors, wherein any two vectors among the first column of world space direction vectors, the second column of world space direction vectors, and the third column of world space direction vectors are perpendicular to each other; obtaining the object coordinate position by obtaining object position; calculating a rotation vector using the first column of world space direction vectors, the second column of world space direction vectors, the third column of world space direction vectors, and the object coordinate position; and constructing an observation matrix within the object class blueprint based on the sum of the first column of world space direction vectors, the second column of world space direction vectors, the third column of world space direction vectors, and the rotation vector.
[0127] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: taking a dot product of the object's coordinate position with a first column of world space direction vectors to obtain a first dot product result; taking a dot product of the object's coordinate position with a second column of world space direction vectors to obtain a second dot product result; and taking a dot product of the object's coordinate position with a third column of world space direction vectors to obtain a third dot product result; inverting the first dot product result to obtain a first inverted result; inverting the second dot product result to obtain a second inverted result; and inverting the third dot product result to obtain a third inverted result; and determining a rotation vector based on the first inverted result, the second inverted result, and the third inverted result.
[0128] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: within an object class blueprint, recombining the first column of world space direction vectors, the second column of world space direction vectors, and the third column of world space direction vectors using a vector breaking method to obtain a combination result; and constructing an observation matrix using the combination result and rotation vectors.
[0129] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: obtaining the display size of the game scene screen corresponding to the virtual camera and the shooting size of the virtual camera; and constructing a projection matrix based on the display size and the shooting size within an object class blueprint.
[0130] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: in a pixel shader, sampling the target texture based on the target transformation result to obtain an initial material; and obtaining a target material by adjusting the projection properties of the initial material in the pixel shader.
[0131] In the computer-readable storage medium of the above embodiments, a technical solution is provided for a method of generating projections in a game scene. The method involves recording the scene depth information of a 3D game scene captured by a virtual camera onto a rendering target texture; performing spatial transformation on multiple 3D virtual models within the 3D game scene to obtain a target transformation result, wherein the multiple 3D virtual models are virtual models to be projected; sampling the rendering target texture based on the target transformation result to obtain a target material; and assigning the target material to the multiple 3D virtual models to generate projection effects adapted to the multiple 3D virtual models. Therefore, the method provided by this application achieves the goal of generating projection effects in a 3D game scene based on the spatial transformation results of the rendering target texture corresponding to the scene depth information and the multiple 3D virtual models to be projected. This reduces the device performance consumption and the difficulty of rapid iteration of artistic effects during the projection generation process in the game scene, thereby solving the technical problem in the prior art where the methods of real-time projection calculation or lightmap baking of projection information are difficult to balance the device performance consumption and the need for rapid iteration of artistic effects during the projection generation process.
[0132] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this application.
[0133] In exemplary embodiments of this application, a computer-readable storage medium stores a program product capable of implementing the methods described above in this embodiment. In some possible implementations, various aspects of the embodiments of this application may also be implemented as a program product including program code, which, when the program product is run on a terminal device, causes the terminal device to perform the steps described in the "Exemplary Methods" section of this embodiment according to various exemplary embodiments of this application.
[0134] The program product for implementing the above-described method according to embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the embodiments of this application is not limited thereto. In the embodiments of this application, the computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0135] The aforementioned program product may take the form of any combination of one or more computer-readable media. Such computer-readable storage media may be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples (not exhaustive) of computer-readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0136] It should be noted that the program code contained on the computer-readable storage medium can be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0137] Embodiments of this application also provide an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0138] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0139] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0140] S1 records the scene depth information of the 3D game scene captured by the virtual camera to the rendering target texture;
[0141] S2, spatial transformation is performed on multiple 3D virtual models in the 3D game scene to obtain the target transformation result, wherein the multiple 3D virtual models are virtual models to be projected;
[0142] S3, sample the target texture based on the target transformation result to obtain the target material;
[0143] S4 assigns the target material to multiple 3D virtual models, generating projection effects that fit the multiple 3D virtual models.
[0144] Optionally, the processor described above can also be configured to perform the following steps via a computer program: creating an object class blueprint; adding a camera component within the object class blueprint, wherein the camera component is used to generate a virtual camera within the 3D game scene; setting the capture source of the camera component to the monochrome channel of the depth buffer corresponding to the virtual camera to obtain scene depth information; and recording the scene depth information to the rendering target texture.
[0145] Optionally, the processor may also be configured to perform the following steps via a computer program: the projection type of the camera component is orthographic projection, and the shooting width of the camera component is a preset value.
[0146] Optionally, the processor may also be configured to perform the following steps via a computer program: creating a material parameter set, wherein the material parameter set is used to determine the transformation matrix to be used during the spatial transformation process; based on the material parameter set, performing observation transformation on the world space positions of multiple 3D virtual models in the 3D game scene to obtain an initial transformation result, and performing projection transformation on the initial transformation result to obtain a target transformation result.
[0147] Optionally, the processor described above can also be configured to perform the following steps via a computer program: constructing an observation matrix and a projection matrix within an object class blueprint; and creating a set of material parameters using the observation matrix and the projection matrix.
[0148] Optionally, the processor described above can also be configured to perform the following steps via a computer program: obtaining a first column of world space direction vectors, a second column of world space direction vectors, and a third column of world space direction vectors by obtaining object direction vectors, wherein any two vectors in the first column of world space direction vectors, the second column of world space direction vectors, and the third column of world space direction vectors are perpendicular to each other; obtaining the object coordinate position by obtaining object position; calculating a rotation vector using the first column of world space direction vectors, the second column of world space direction vectors, the third column of world space direction vectors, and the object coordinate position; and constructing an observation matrix within the object class blueprint based on the sum of the first column of world space direction vectors, the second column of world space direction vectors, the third column of world space direction vectors, and the rotation vector.
[0149] Optionally, the processor described above can also be configured to perform the following steps via a computer program: taking a dot product of the object's coordinate position with a first column of world space down direction vectors to obtain a first dot product result; taking a dot product of the object's coordinate position with a second column of world space down direction vectors to obtain a second dot product result; and taking a dot product of the object's coordinate position with a third column of world space down direction vectors to obtain a third dot product result; inverting the first dot product result to obtain a first inverted result; inverting the second dot product result to obtain a second inverted result; and inverting the third dot product result to obtain a third inverted result; and determining a rotation vector based on the first inverted result, the second inverted result, and the third inverted result.
[0150] Optionally, the processor described above can also be configured to perform the following steps via a computer program: within the object class blueprint, recombine the first column of world space direction vectors, the second column of world space direction vectors, and the third column of world space direction vectors using a vector breaking method to obtain a combined result; and construct an observation matrix using the combined result and rotation vectors.
[0151] Optionally, the processor described above can also be configured to perform the following steps via a computer program: obtain the display size of the game scene corresponding to the virtual camera and the shooting size of the virtual camera; and construct a projection matrix based on the display size and the shooting size within the object class blueprint.
[0152] Optionally, the processor described above can also be configured to perform the following steps via a computer program: in the pixel shader, sampling the target texture based on the target transformation result to obtain an initial material; and by adjusting the projection properties of the initial material in the pixel shader to obtain the target material.
[0153] In the electronic device described in the above embodiments, a technical solution is provided for generating projections in a game scene. The method involves recording the scene depth information of a 3D game scene captured by a virtual camera onto a rendering target texture; performing spatial transformation on multiple 3D virtual models within the 3D game scene to obtain a target transformation result, wherein the multiple 3D virtual models are virtual models to be projected; sampling the rendering target texture based on the target transformation result to obtain a target material; and assigning the target material to the multiple 3D virtual models to generate projection effects adapted to the multiple 3D virtual models. Therefore, the method provided in this application achieves the goal of generating projection effects in a 3D game scene based on the spatial transformation results of the rendering target texture corresponding to the scene depth information and the multiple 3D virtual models to be projected. This reduces the device performance consumption and the difficulty of rapid iteration of artistic effects during the projection generation process in the game scene, thereby solving the technical problem in the prior art where the methods of real-time projection calculation or lightmap baking of projection information are difficult to balance the device performance consumption and the need for rapid iteration of artistic effects during the projection generation process.
[0154] Figure 9 This is a schematic diagram of an electronic device according to one embodiment of this application. Figure 9 As shown, the electronic device 900 is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0155] like Figure 9 As shown, the electronic device 900 is presented in the form of a general-purpose computing device. The components of the electronic device 900 may include, but are not limited to: at least one processor 910, at least one memory 920, a bus 930 connecting different system components (including memory 920 and processor 910), and a display 940.
[0156] The memory 920 stores program code that can be executed by the processor 910, causing the processor 910 to perform the steps described in the method section of the embodiments of this application according to various exemplary implementations of this application.
[0157] The memory 920 may include a readable medium in the form of volatile memory cells, such as random access memory (RAM) 9201 and / or cache memory 9202, and may further include read-only memory (ROM) 9203, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
[0158] In some instances, memory 920 may also include a program / utility 9204 having a set (at least one) of program modules 9205, including but not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Memory 920 may further include memory remotely located relative to processor 910, which can be connected to electronic device 900 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0159] Bus 930 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, peripheral bus, graphics acceleration port, processor 910, or a local bus using any of the various bus structures.
[0160] The display 940 may be, for example, a touch-screen liquid crystal display (LCD) that allows a user to interact with the user interface of the electronic device 900.
[0161] Optionally, the electronic device 900 can also communicate with one or more external devices 1000 (e.g., keyboard, pointing device, Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 900, and / or any device that enables the electronic device 900 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via the input / output (I / O) interface 950. Furthermore, the electronic device 900 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via the network adapter 960. Figure 9 As shown, network adapter 960 communicates with other modules of electronic device 900 via bus 930. It should be understood that, although... Figure 9 As not shown, other hardware and / or software modules may be used in conjunction with electronic device 900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, Redundant Arrays of Independent Disks (RAID) systems, tape drives, and data backup storage systems.
[0162] The aforementioned electronic device 900 may also include: a keyboard, a cursor control device (such as a mouse), an input / output interface (I / O interface), a network interface, a power supply, and / or a camera.
[0163] Those skilled in the art will understand that Figure 9 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, the electronic device 900 may also include components that are more... Figure 9 The more or fewer components shown, or having the same Figure 9 Different configurations are shown. The memory 920 can be used to store computer programs and corresponding data, such as the computer program and corresponding data corresponding to the method for generating projections in the game scene in this embodiment. The processor 910 executes various functional applications and data processing by running the computer program stored in the memory 920, thereby implementing the aforementioned method for generating projections in the game scene.
[0164] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0165] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0166] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0167] The units described as separate components may or may not be physically separate. 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 units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0168] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0169] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0170] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for generating projections in a game scene, characterized in that, include: Record the scene depth information of the 3D game scene captured by the virtual camera into the rendering target texture; Create a material parameter set, wherein the material parameter set is used to determine the transformation matrix to be used during the spatial transformation process; Based on the material parameter set, the world space positions of multiple 3D virtual models in the 3D game scene are observed and transformed to obtain an initial transformation result, and the initial transformation result is projected and transformed to obtain a target transformation result, wherein the multiple 3D virtual models are virtual models to be projected; Based on the target transformation result, the rendered target texture is sampled to obtain the target material; The target material is applied to the multiple 3D virtual models to generate a projection effect adapted to the multiple 3D virtual models.
2. The method according to claim 1, characterized in that, Recording the scene depth information of the 3D game scene captured by the virtual camera into the rendering target texture includes: Create an object class blueprint; Add a camera component to the object class blueprint, wherein the camera component is used to generate the virtual camera in the 3D game scene; The scene depth information is obtained by setting the capture source of the camera component to the monochrome channel of the depth buffer corresponding to the virtual camera; The scene depth information is recorded into the rendering target texture.
3. The method according to claim 2, characterized in that, The camera component uses orthographic projection for its projection and has a preset shooting width.
4. The method according to claim 2, characterized in that, Creating the material parameter set includes: Construct the observation matrix and projection matrix within the object class blueprint; The material parameter set is created using the observation matrix and the projection matrix.
5. The method according to claim 4, characterized in that, Constructing the observation matrix within the object class blueprint includes: By obtaining the object direction vector, the first column of world space direction vector, the second column of world space direction vector, and the third column of world space direction vector are obtained, wherein any two vectors in the first column of world space direction vector, the second column of world space direction vector, and the third column of world space direction vector are perpendicular to each other; Obtain the object's coordinates by using the object's position method; The rotation vector is calculated using the first column of world space direction vectors, the second column of world space direction vectors, the third column of world space direction vectors, and the object's coordinate position. Within the object class blueprint, the observation matrix is constructed based on the sum of the first column of world space direction vectors, the second column of world space direction vectors, the third column of world space direction vectors, and the rotation vector.
6. The method according to claim 5, characterized in that, The rotation vector is calculated using the first column of world space direction vectors, the second column of world space direction vectors, the third column of world space direction vectors, and the object's coordinate position. The first dot product result is obtained by taking the dot product of the object's coordinate position with the first column of world space downward direction vectors; the second dot product result is obtained by taking the dot product of the object's coordinate position with the second column of world space downward direction vectors; and the third dot product result is obtained by taking the dot product of the object's coordinate position with the third column of world space downward direction vectors. Invert the first dot product result to obtain a first inverted result, invert the second dot product result to obtain a second inverted result, and invert the third dot product result to obtain a third inverted result; The rotation vector is determined based on the first inversion result, the second inversion result, and the third inversion result.
7. The method according to claim 5, characterized in that, Within the object class blueprint, constructing the observation matrix based on the sum of the first column of world space direction vectors, the second column of world space direction vectors, the third column of world space direction vectors, and the rotation vector includes: Within the object class blueprint, the first column of world space down-direction vectors, the second column of world space down-direction vectors, and the third column of world space down-direction vectors are recombined using a vector breaking method to obtain a combined result; The observation matrix is constructed using the combined result and the rotation vector.
8. The method according to claim 4, characterized in that, Constructing the projection matrix within the object class blueprint includes: Obtain the display size of the game scene corresponding to the virtual camera and the shooting size of the virtual camera; Within the object class blueprint, the projection matrix is constructed based on the display size and the shooting size.
9. The method according to claim 1, characterized in that, Based on the target transformation result, the rendered target texture is sampled to obtain the target material, which includes: In the pixel shader, the rendering target texture is sampled based on the target transformation result to obtain the initial material; The target material is obtained by adjusting the projection properties of the initial material in the pixel shader.
10. A device for generating projections in a game scene, characterized in that, include: The recording module is used to record the scene depth information of the 3D game scene captured by the virtual camera to the rendering target texture; A transformation module is used to create a material parameter set; based on the material parameter set, the world space positions of multiple 3D virtual models in the 3D game scene are observed and transformed to obtain an initial transformation result, and the initial transformation result is projected and transformed to obtain a target transformation result, wherein the material parameter set is used to determine the transformation matrix to be used in the spatial transformation process, and the multiple 3D virtual models are virtual models to be projected; The sampling module is used to sample the rendered target texture based on the target transformation result to obtain the target material; The generation module is used to apply the target material to the multiple three-dimensional virtual models and generate a projection effect adapted to the multiple three-dimensional virtual models.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program is configured to be executed by a processor to perform the method for generating projections in a game scene as described in any one of claims 1 to 9.
12. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method for generating projections in a game scene as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Shadow map generation method and device
CN108038897A
Shadow rendering method and device, terminal and storage medium
CN109993823A