A virtual scope rendering method and device, an electronic device, and a storage medium

By transforming the view vector and generating layers in the virtual scope rendering, and utilizing pixel blending processing within the target shader, the problems of unrealistic visual effects and high performance pressure in existing technologies are solved, achieving efficient optical effect synchronization and stable rendering.

CN122368286APending Publication Date: 2026-07-10NETEASE (SHANGHAI) NETWORK CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NETEASE (SHANGHAI) NETWORK CO LTD
Filing Date
2026-04-15
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing virtual scope rendering methods suffer from harsh visual effects, significant differences from realistic optical perception, high computational overhead, and large resource consumption. This results in high performance pressure and unstable image quality under high frame rate operation or multi-instance scenarios, making it difficult to balance effect and efficiency.

Method used

By calculating the world space view vector frame by frame and converting it into the tangent space view vector, a crosshair, mask, and reflection layer are generated. Pixel fusion processing within the target shader is used to achieve realistic optical effects while reducing redundant drawing and interaction.

Benefits of technology

Significantly reduces operating costs, improves image stability and aiming immersion, and ensures synchronized and stable optical effects at high frame rates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122368286A_ABST
    Figure CN122368286A_ABST
Patent Text Reader

Abstract

This application relates to the field of game technology, specifically to a rendering method, device, electronic device, and storage medium for a virtual sight. The method includes: in response to an activation operation of the virtual sight, calculating a world space view vector and converting it into a tangent space view vector; in response to a view movement operation following a target virtual object, performing calculations within a target shader based on the tangent space view vector to generate a crosshair layer and a mask layer; in response to aiming at the target virtual object, sampling a spherical normal map on the sight rendering model, and calculating a reflection vector based on the tangent space view vector to generate a reflection layer; and in the target shader, performing pixel blending processing on the three layers, and displaying the virtual sight's image based on the blending result. This approach, while making the optical effects more realistic, reduces redundant drawing and interaction, lowers runtime overhead, and improves image stability and aiming immersion by completing integrated rendering within the same shader.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of game technology, and more specifically, to a rendering method, apparatus, electronic device, and storage medium for a virtual aiming scope. Background Technology

[0002] In shooting games, the virtual scope is a core interactive component for players to aim and engage in combat. Its visual presentation directly affects aiming accuracy, operational smoothness, tactical decision-making, and game immersion. Rendering effects that closely resemble realistic optics enhance the realism of the visuals and the player's immersion, making it an important design direction for improving game quality.

[0003] Most existing methods for implementing the visual effects of scopes rely on traditional rendering logic to achieve various optical representations. These methods generally suffer from issues such as harsh visual effects and significant differences from realistic optical perception, impacting the aiming experience and image quality. Furthermore, these implementations typically suffer from high computational overhead and resource consumption, easily leading to performance pressure during high frame rate operation or multi-instance scenarios. This can result in unstable visuals and asynchronous responses, making it difficult to achieve a good balance between performance and operational efficiency.

[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 disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0005] In view of this, the purpose of this application is to provide a rendering method, device, electronic device and storage medium for a virtual sight, which significantly reduces operating overhead, makes the optical effects more realistic, and thus improves the stability of the image and the immersive feeling of aiming.

[0006] This application mainly includes the following aspects: In a first aspect, embodiments of this application provide a rendering method for a virtual aiming scope, which provides a graphical user interface through a terminal device, the graphical user interface displaying at least a portion of the game scene, the method comprising: In response to the activation of the virtual sight, the sight rendering model is invoked, and the world space view vector of the virtual camera pointing to the surface fragment of the sight rendering model is calculated frame by frame. The world space view vector is then converted into the tangent space view vector in the local coordinate system of the sight surface. In response to the view movement operation following the target virtual object in the game scene, based on the tangent space view vector, a parallax offset operation is performed in the target shader to generate a crosshair layer, and a radial gradient operation is performed to generate a mask layer. In response to aiming at the target virtual object, the system obtains the spherical normal map corresponding to the sight rendering model, calculates the reflection vector based on the spherical normal map and the tangent space view vector, and performs specular calculations using a geometric Gaussian distribution specular algorithm to generate a reflection layer. In the target shader, pixel fusion processing is performed on the crosshair layer, the mask layer, and the reflection layer. Based on the fusion result, the image of the virtual sight is rendered and displayed in the graphical user interface.

[0007] Secondly, embodiments of this application also provide a rendering device for a virtual aiming scope, which provides a graphical user interface through a terminal device. The graphical user interface displays at least a portion of the game scene, and the device includes: The view vector generation module is used to respond to the opening operation of the virtual sight, call the sight rendering model, calculate the world space view vector of the virtual camera pointing to the surface fragment of the sight rendering model frame by frame, and convert the world space view vector into the tangent space view vector in the local coordinate system of the sight surface. The first layer generation module is used to respond to the view movement operation of following the target virtual object in the game scene, and to perform parallax offset operation in the target shader to generate a crosshair layer and perform radial gradient operation to generate a mask layer based on the tangent space view vector. The second layer generation module is used to respond to aiming at the target virtual object, obtain the spherical normal map corresponding to the sight rendering model, calculate the reflection vector based on the spherical normal map and the tangent space view vector, and complete the specular operation through the geometric Gaussian distribution specular algorithm to generate a reflection layer; The display module is used to perform pixel fusion processing on the crosshair layer, the mask layer and the reflection layer in the target shader, and render and display the image of the virtual sight in the graphical user interface based on the fusion result. Thirdly, embodiments of this application also provide an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory through the bus. The machine-readable instructions are executed by the processor to perform the steps of the virtual aiming scope rendering method described in the first aspect or any possible implementation of the first aspect.

[0008] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the virtual aiming scope rendering method described in the first aspect or any possible implementation of the first aspect.

[0009] This application provides a rendering method, apparatus, electronic device, and storage medium for a virtual sight. After activating the sight, a tangential space view vector is obtained. Based on this vector, a crosshair and mask layer are generated in the same target shader. A reflection layer is generated by calculating the reflection vector using a normal map. Finally, the three layers are fused to render the virtual sight image. Compared to existing technologies that suffer from high computational overhead and resource consumption, and are prone to performance stress in high frame rate or multi-instance scenarios, this application, while making the optical effects more realistic, reduces redundant rendering and interaction, significantly lowering operational overhead, thereby improving image stability and aiming immersion.

[0010] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0011] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0012] Figure 1 A flowchart illustrating a rendering method for a virtual sight provided in an embodiment of this application is shown; Figure 2 This illustration shows one of the functional block diagrams of a rendering device for a virtual aiming scope provided in an embodiment of this application; Figure 3 This illustration shows a second functional block diagram of a rendering device for a virtual aiming scope provided in an embodiment of this application; Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation

[0013] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.

[0014] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0015] In order to enable those skilled in the art to use the content of this application, and in combination with the specific application scenario of "game screen rendering", the following implementation method is given. For those skilled in the art, the general principles defined herein can be applied to other embodiments and application scenarios without departing from the spirit and scope of this application.

[0016] The methods, apparatus, electronic devices, or computer-readable storage media described in this application can be applied to any scenario that requires game screen rendering. This application does not limit the specific application scenario. Any scheme using the virtual aiming scope rendering method and apparatus provided in this application is within the protection scope of this application.

[0017] It is worth noting that prior to this application, most existing visual implementations of sights employed traditional rendering logic to achieve various optical effects, which generally resulted in harsh visual effects and significant differences from realistic optical perception, impacting the aiming experience and image quality. Furthermore, these implementations typically suffer from high computational overhead and resource consumption, easily leading to performance pressure during high frame rate operation or multi-instance scenarios, potentially causing unstable image quality and asynchronous responses, making it difficult to achieve a good balance between performance and operational efficiency.

[0018] To address the aforementioned issues, this application provides a rendering method, apparatus, electronic device, and storage medium for a virtual sight. The method includes: responding to an activation operation of the virtual sight, calculating a world space view vector and converting it into a tangent space view vector; responding to a view movement operation following a target virtual object, performing calculations within a target shader based on the tangent space view vector to generate a crosshair layer and a mask layer; responding to aiming at the target virtual object, sampling a spherical normal map on the sight rendering model, and calculating a reflection vector based on the tangent space view vector to generate a reflection layer; and performing pixel fusion processing on the three layers in the target shader, displaying the virtual sight's image based on the fusion result. This approach, while making the optical effects more realistic, reduces redundant drawing and interaction, lowers runtime overhead, and improves image stability and aiming immersion by completing integrated rendering within the same shader.

[0019] In one optional implementation, the terminal device involved in this application mainly refers to a terminal used to provide a graphical user interface and to control virtual characters. The terminal device can be a local terminal device as mentioned below, or a client device in a cloud interaction system. This terminal device can include, but is not limited to, any of the following devices: laptops, smartphones, tablets, desktop computers, game consoles, MP4 players (Moving Picture Experts Group Audio Layer IV), personal digital assistants (PDAs), e-book readers, etc. The terminal device has a game-supporting application installed and running, such as an application supporting 3D or 2D games. In this application, where the application is described as a game application, optionally, the application can be a standalone application, such as a standalone 3D game program, or a network-connected application.

[0020] In one alternative implementation, a graphical user interface is a human-computer communication interface display format that allows users to manipulate icons, icons, or menu options on the screen using input devices such as a mouse or keyboard. It also allows users to manipulate icons or menu options on the screen by performing touch operations on the touch screen of a touch terminal to select commands, launch programs, or perform other tasks.

[0021] In one alternative implementation, a UI control refers to any visual control or element that can be seen on the user interface of an application, such as images, input boxes, text boxes, buttons, labels, etc. Some of these UI controls respond to user actions. UI controls, such as game controls, include skill controls, movement controls, dodging controls, item controls, scope activation controls, etc. Users can activate the scope by triggering the scope activation control.

[0022] In one optional implementation, the game scene is a scene displayed (or provided) by the application while it is running on a terminal or server; that is, the scene used during normal gameplay. In other words, the game scene refers to the virtual game controls that carry the virtual character during gameplay. The virtual character can move, perform skills, and perform other actions within the game scene under the control of operation commands issued by the user (i.e., the player) to the terminal device. Optionally, the game scene can be a simulation of the real world, a semi-simulated / semi-fictional virtual environment, or a purely fictional virtual environment. The game scene can be any one of a two-dimensional virtual interactive scene, a 2.5-dimensional virtual interactive scene, or a three-dimensional virtual interactive scene.

[0023] In one optional implementation, this application provides a game control system, which may include at least one terminal device, at least one server, at least one database, and a network. The user's terminal device can connect to different game servers via the network. The terminal device is any device with computing hardware capable of supporting and executing software products corresponding to the game. Furthermore, when the system includes multiple terminal devices, multiple servers, and multiple networks, different terminal devices can connect to each other through different networks and servers. The network can be a wireless network or a wired network, such as a wireless local area network (WLAN), local area network (LAN), cellular network, 2G network, 3G network, 4G network, 5G network, etc. Additionally, different terminal devices can also connect to other terminal devices or to servers using their own Bluetooth networks or hotspot networks. For example, multiple users can connect online through different terminal devices via appropriate networks and synchronize with each other to support multiplayer games. Furthermore, the system may include multiple databases coupled to different servers, and can continuously store game environment-related identifiers in the databases as different users play multiplayer games online.

[0024] This application provides a rendering method for a virtual aiming scope, in one embodiment of which the rendering method can run on a local terminal device or a server. When the rendering method runs on a server, it can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and client devices.

[0025] In an optional implementation, various cloud applications, such as cloud gaming, can run under the cloud interaction system. Taking cloud gaming as an example, cloud gaming refers to a gaming method based on cloud computing. In the cloud gaming operating mode, the game program and the game screen presentation are separated. The storage and execution of the virtual scope rendering method are completed on the cloud gaming server. The client device is used for data reception, transmission, and game screen presentation. For example, the client device can be a display device with data transmission capabilities located close to the user, such as a mobile terminal, television, computer, or PDA; however, the identification processing is performed by the cloud gaming server in the cloud. When playing the game, the player operates the client device to send operation commands to the cloud gaming server. The cloud gaming server runs the game according to the operation commands, encodes and compresses the game screen and other data, returns it to the client device via the network, and finally, the client device decodes and outputs the game screen.

[0026] In an optional implementation, taking a game as an example, the local terminal device stores the game program and is used to display the game screen. The local terminal device is used to interact with the player through a graphical user interface (GUI), i.e., conventionally by downloading, installing, and running the game program via an electronic device. The local terminal device can provide the GUI to the player in various ways, such as rendering it on the terminal's display screen or providing it to the player via holographic projection. For example, the local terminal device can include a display screen for displaying the GUI, which includes game screens, and a processor for running the game, generating the GUI, and controlling the display of the GUI on the display screen.

[0027] In one optional implementation, this application provides a method for rendering a virtual aiming scope, which provides a graphical user interface through a terminal device. The terminal device can be either the aforementioned local terminal device or a client device in the aforementioned cloud interaction system. The following description uses the example of the virtual aiming scope rendering method running on a local terminal device (hereinafter referred to as the terminal device).

[0028] To facilitate understanding of this application, the technical solutions provided in this application will be described in detail below with reference to specific embodiments.

[0029] Figure 1 This is a flowchart illustrating a rendering method for a virtual sight provided in an embodiment of this application. Figure 1 As shown in the embodiments of this application, the rendering method for a virtual scope provides a graphical user interface through a terminal device. The graphical user interface displays at least a portion of the game scene. The rendering method for the virtual scope includes the following steps: S101: In response to the activation operation of the virtual sight, the sight rendering model is invoked, the world space view vector of the virtual camera pointing to the surface fragment of the sight rendering model is calculated frame by frame, and the world space view vector is converted into the tangent space view vector in the local coordinate system of the sight surface.

[0030] It should be noted that in a typical shooting game, players repeatedly perform the following operations: scope in, aim and move, fire, and close the scope. The scope-in ​​operation is the activation of the virtual scope; in this application, the virtual scope is a virtual implementation of the in-game scope. In response to the player triggering the aiming control, the graphical user interface switches from the regular game view to the virtual scope's aiming view, at which point the complete virtual scope image needs to be rendered immediately.

[0031] Here, the virtual scope's image (i.e., the scope view) comprises three core visual elements: the dynamic effect of the crosshair, the effect of the scope barrel mask, and the reflection effect of the lens glass. These three are not independent of each other, but together constitute a complete optical simulation system. They must be calculated and output sequentially in each frame following a unified rendering pipeline, and maintain stable performance at high frame rates.

[0032] In practice, in response to the activation of the virtual sight, a single model rendering process is initiated. The sight rendering model is called to calculate the world space view vector frame by frame, and the world space view vector is converted into a tangent space view vector for subsequent collaborative driving. The sight rendering model is a single-faceted mesh, which serves as a unified carrier for running the target shader. Without the need for additional models, the three major optical effects of crosshair parallax, dynamic masking, and spherical reflection can be achieved in real time on the Graphics Processing Unit Side (GPU).

[0033] Here, the world space view vector and the tangent space view vector are mathematical expressions of the same physical line of sight in different coordinate systems, differing only in their reference datum. The world space view vector, based on the global 3D coordinate system, directly represents the spatial relationship between the virtual camera and the surface fragments of the sight rendering model within the global game scene. It accurately represents the player's real-time line of sight. Since the world space view vector only depends on the updated camera position and fragment world coordinates per frame, it only needs to be calculated once per frame and is shared and reused throughout the game for the three main effects: crosshair parallax, mask offset, and spherical reflection, thus preventing redundant calculations within the same frame.

[0034] Furthermore, the tangent space view vector is used to characterize the line-of-sight relationship of surface fragments in the local coordinate system of the virtual sight. It is obtained by projecting the world space view vector onto the local coordinate system of the surface where the fragment is located, retaining only its two-dimensional component on the model surface plane. The tangent space view vector will directly serve as the core input parameter for the three major visual effects of subsequent crosshair layer generation, mask layer generation, and reflection layer generation, and can be reused throughout the process without repeated calculations. This method replaces the preset projection matrix, realizes pixel-by-pixel dynamic view perception, eliminates inter-frame view parameter delay, and lays the foundation for end-to-end visual effect synchronization.

[0035] S102: In response to the view movement operation following the target virtual object in the game scene, based on the tangent space view vector, perform a parallax offset operation in the target shader to generate a crosshair layer and perform a radial gradient operation to generate a mask layer.

[0036] It should be noted that when the player moves their view to track virtual objects in the game scene, the offset of the virtual camera position will cause natural parallax in the lens plane of the sight's rendering model. If this is not compensated for, it will break the optical illusion that the crosshair "is at infinity". Current technology usually calculates the crosshair parameters frame by frame in the game logic script before rendering, which easily leads to data synchronization overhead and crosshair jump problems due to frame rate fluctuations.

[0037] To address the aforementioned issues, this application responds to the viewpoint movement operation of the target virtual object in the game scene by employing a parallax offset algorithm within the target shader based on the tangent space viewpoint vector to reverse the coordinates of the aligner star texture, thereby accurately offsetting the visual parallax displacement caused by the static lens plane under perspective projection due to camera movement.

[0038] Here, the tangent space view vector accurately represents the projection component of the virtual camera's line of sight incident direction relative to the surface fragment of the sight rendering model within the local tangent plane, reflecting the deflection direction and relative angle of the line of sight within the tangent plane. Therefore, the reverse offset calculated based on this tangent space view vector can precisely cancel the visual parallax displacement caused by camera movement and the perspective projection of the static lens plane, making their directions opposite and their proportions matched, thus achieving precise cancellation. Ultimately, this keeps the crosshair stable relative to the background scene, restoring the optical effect of the red dot crosshair "virtual image at infinity," and generating a crosshair layer. This method completes the parallax offset calculation entirely within the target shader, eliminating the need to pass parameters frame by frame, thus eliminating data synchronization overhead, avoiding crosshair jump, and improving aiming visual stability.

[0039] It is understandable that when a player tracks a target virtual object, changes in the position and orientation of the virtual camera cause the line of sight to deflect relative to the lens plane. Here, this embodiment reuses the calculated tangent space view vector and performs a radial gradient operation within the target shader to dynamically generate a mask layer with a center offset, in order to simulate the exit pupil occlusion effect caused by the eye deviating from the optical axis.

[0040] S103: In response to aiming at the target virtual object, obtain the spherical normal map corresponding to the sight rendering model, calculate the reflection vector based on the spherical normal map and the tangent space view vector, and complete the specular operation through the geometric Gaussian distribution specular algorithm to generate a reflection layer.

[0041] It's important to note that when a player aims at a virtual target, the surface of a real scope's lens exhibits two optical effects: first, environmental reflection, where the surrounding environment forms a spherically distorted image on the curved lens surface; and second, direct light highlights, where sunlight or strong light sources create bright spots on the lens. These effects enhance the realism and material texture of the scope. From an optical principle perspective, although the lens is curved, the final image falls on a flat two-dimensional plane; therefore, this characteristic needs to be simulated to achieve a realistic optical effect.

[0042] To simulate the optical effects of real lenses, existing technologies typically employ a separate reflection rendering channel. This involves re-rendering the scene from the reflection perspective onto an off-screen rendering texture, and then sampling and overlaying the off-screen rendering texture onto the lens surface. This approach results in repeated rendering of the scene, and the off-screen rendering texture consumes additional video memory and bandwidth, leading to significant rendering overhead.

[0043] To address this issue, this application, in response to targeting a virtual object, obtains the spherical normal map corresponding to the spherical normal map of the sight rendering model, calculates the reflection vector by combining it with the tangent space view vector, and completes the specular rendering using a geometric Gaussian distribution specular algorithm. Simultaneously, it achieves ambient reflection and direct light specular rendering, generating a reflection layer. This application abandons independent reflection rendering channels and off-screen rendering textures, reuses the tangent space view vector, requires only one environment map sampling, and eliminates the need for additional rendering steps. While maintaining equivalence to optical effects, it significantly reduces memory usage and bandwidth consumption, enhances the realism of lens materials, and lowers rendering overhead, thus having low performance requirements for terminal devices.

[0044] S104: In the target shader, pixel fusion processing is performed on the crosshair layer, the mask layer, and the reflection layer, and the image of the virtual sight is rendered and displayed in the graphical user interface based on the fusion result.

[0045] In practice, after generating the crosshair layer, mask layer, and reflection layer, pixel blending is performed on these three layers in the target shader. A single shader performs pixel-level blending and overlay on the red dot texture sampling results after parallax offset processing, the radial gradient mask, and the reflection layer data containing environment map reflections and geometric Gaussian distribution specular highlights within the same rendering pass. Based on the blending results, the image of the virtual sight is rendered and displayed in the graphical user interface. The entire process is completed within a single model, a single material, and a single rendering pass, without the need for additional drawing calls, off-screen rendering textures, or processor scripts.

[0046] The target shader refers to the single, integrated pixel shader designed and deployed on the sight rendering model in this application. It fully encapsulates three major functional modules: crosshair parallax offset, dynamic lens barrel mask generation, and spherical normal reflection and specular calculation. It also achieves data flow coupling and optical behavior coordination through shared view vectors.

[0047] In this embodiment, in response to player actions such as aiming down sights and tracking targets, the view vector is calculated and transformed frame by frame. Based on this vector, a crosshair and mask layers are generated through parallax offset and radial gradient operations. A reflection layer is generated by combining spherical normal sampling and geometric Gaussian distribution specular highlight algorithm. Finally, the layers are blended and rendered in the target shader. This application simplifies the rendering architecture with a single model and a single shader, reuses the view vector to reduce redundant calculations, and effectively reduces the rendering overhead caused by multiple models and shaders while achieving simulated visual effects such as crosshairs, masks, and reflections.

[0048] In one possible implementation, in step S101, in response to the activation operation of the virtual sight, the sight rendering model is invoked, the world space view vector of the virtual camera pointing to the surface fragment of the sight rendering model is calculated frame by frame, and the world space view vector is converted into the tangent space view vector in the local coordinate system of the sight surface, including the following steps: Step 1011: In response to the activation of the virtual scope, call the scope rendering model, switch the game view to the aiming view of the virtual scope, and initialize the target shader's runtime environment.

[0049] Here, during the rendering initialization phase, in response to the virtual scope activation operation, the game view is quickly switched, smoothly transitioning from the regular game view to the scope's aiming view. Simultaneously, the target shader rendering environment is initialized, and core rendering parameter settings such as view vector preset calculations and texture sampling configurations are completed, clarifying the initial thresholds and calling logic of each rendering parameter. By executing view switching and rendering environment initialization in parallel, subsequent rendering effect calculations are triggered the instant the scope is opened, avoiding issues such as multi-model loading lag and rendering parameter initialization delays, thus preventing screen stuttering when the scope is opened.

[0050] In this context, the conventional game perspective specifically refers to the basic perspective displayed by the graphical user interface when the virtual scope is not activated, and when the player does not perform the operation of activating the scope to observe the game scene.

[0051] Step 1012: Frame by frame, obtain the position coordinates of the virtual camera in world space and the world coordinates of the surface fragments of the sight rendering model. Through coordinate difference normalization operation, solve for the world space view vector.

[0052] In practice, the virtual camera's position coordinates in world space are obtained frame-by-frame through the rendering pipeline, and the world coordinates of the surface fragments of the sight rendering model are read fragment by fragment. A vector subtraction operation is performed between the virtual camera's position coordinates and the world coordinates of the surface fragments of the sight rendering model to obtain a difference vector, which represents the spatial relationship between the fragment and the virtual camera. This difference vector is then normalized to eliminate the interference of vector length on subsequent calculations, resulting in the world space view vector of the virtual camera pointing towards the surface fragments of the sight rendering model. This world space view vector represents the real-time gaze direction of the controlled virtual character.

[0053] Step 1013: Based on the tangent vector and subtangent vector of the sight rendering model, construct a mapping relationship to convert the world space view vector into the tangent space view vector.

[0054] In practice, the world tangent vector and world subtangent vector are obtained from the sight rendering model data. These two sets of vectors are fixed parameters preset during the modeling stage, which can accurately represent the local coordinate system direction on the model surface and ensure the uniformity of the tangent space construction. Based on the above tangent vector and subtangent vector and the world space view vector, a projection mapping relationship is constructed, and finally the world space view vector is transformed into the tangent space view vector.

[0055] The tangent vector refers to the unit tangent direction vector of each fragment on the model surface in world space, corresponding to the geometric extension direction of the U-axis (horizontal direction) in 3D space in UV coordinates. It is used to construct the local tangent space and is a key basis vector for projecting the view vector onto the surface plane. The bitangent vector refers to the unit bitangent direction vector of each fragment on the model surface in world space, corresponding to the geometric extension direction of the V-axis (vertical direction) in 3D space in UV coordinates. It is usually obtained by the cross product of the world normal and the tangent, and together with the tangent and normal, it forms a right-handed orthogonal basis, jointly defining the local tangent space of the fragment's location.

[0056] In one possible implementation, step 1013, which involves converting the world space view vector into the tangent space view vector, includes the following steps: reading the tangent vector and the secondary tangent vector of the sight rendering model from the model data of the sight rendering model; calculating the dot product of the world space view vector with the tangent vector and the secondary tangent vector respectively to obtain a first projection component of the world space view vector in the tangent direction and a second projection component in the secondary tangent direction; and combining the first projection component and the second projection component to obtain the tangent space view vector.

[0057] In practice, a projection mapping relationship is constructed based on the above-mentioned tangent vector, secondary tangent vector and world space view vector. The world space view vector is projected onto the tangent direction and secondary tangent direction respectively by dot product operation. The corresponding components are extracted (the two-dimensional components of the view vector in the tangent direction and secondary tangent direction are obtained) and combined. Finally, the world space view vector is transformed into the tangent space view vector.

[0058] In one possible implementation, generating the crosshair layer in step S102 includes the following steps: Step 1021a: In response to the viewpoint movement operation, multiply the tangent space viewpoint vector with the crosshair parallax preset intensity coefficient to generate the crosshair parallax coordinate offset.

[0059] Step 1022a: After superimposing the crosshair parallax coordinate offsets, perform a crosshair texture mapping coordinate normalization operation.

[0060] Step 1023a: Call the crosshair texture preset sampling function, read the crosshair texture based on the normalized crosshair texture mapping coordinates, perform pixel sampling, and generate the crosshair layer.

[0061] In practice, in response to viewpoint movement, the tangent space viewpoint vector is multiplied by the crosshair parallax preset intensity coefficient to obtain the crosshair parallax coordinate offset, providing a basis for the calculation of parallax offset; after superimposing the offset, the texture mapping coordinates are normalized to ensure that the coordinate values ​​are legal and valid; the preset sampling function is called to complete the crosshair texture pixel sampling based on the normalized coordinates, and finally a crosshair layer that conforms to the parallax effect is generated.

[0062] Here, coordinate normalization operations include, but are not limited to, coordinate scaling, centering constraints, and value truncation. Since texture sampling requires coordinate values ​​to be within the standard range of [0, 1], coordinates exceeding this range will directly cause texture sampling anomalies and display errors. Therefore, coordinate normalization is necessary. Thus, the crosshair texture mapping coordinate normalization operation is a process that constrains the coordinates after superimposed parallax offset to the standard texture sampling range of [0, 1]. Through coordinate truncation / normalization operations, it avoids coordinate out-of-bounds errors that could lead to texture sampling failure, ensuring normal execution of crosshair texture reading and pixel rendering.

[0063] For example, step 1022a, which involves superimposing the crosshair disparity coordinate offset and then performing crosshair texture mapping coordinate normalization, includes the following steps: superimposing the crosshair disparity coordinate offset onto the base texture mapping coordinates of the crosshair texture to obtain initial crosshair texture mapping coordinates; performing scaling operations on the initial crosshair texture mapping coordinates based on a preset scaling factor for the crosshair; performing centering correction processing on the scaled crosshair texture mapping coordinates through coordinate offset operations; and constraining the corrected crosshair texture mapping coordinates to a standard value range using a value range constraint function.

[0064] In this way, by superimposing offset, scaling, centering correction and value range constraints, the display position and size of the crosshair texture can be precisely controlled, avoiding abnormal texture sampling or display out of bounds, and ensuring that the crosshair smoothly shifts with the parallax of the sight and is stably centered.

[0065] In one possible implementation, step 1023a involves calling a crosshair texture preset sampling function and reading the crosshair texture based on the normalized crosshair texture mapping coordinates, performing pixel sampling, and generating a crosshair layer. This includes the following steps: using the normalized crosshair texture mapping coordinates, calling the crosshair texture preset sampling function on the crosshair texture; configuring a fixed deviation parameter for crosshair sampling for the crosshair texture preset sampling function and completing texture sampling to obtain crosshair texture pixel color data; and transmitting the crosshair texture pixel color data to the target shader to generate a crosshair layer.

[0066] Here, the preset sampling function for the crosshair texture is a standard texture reading interface built into the shader, such as the tex2D sampling function; the fixed deviation parameter for crosshair sampling can be set to a small offset value to avoid jagged edges in the sampling. By standardizing sampling and configuring parameters, accurate texture pixel color data is obtained and then transmitted to the shader to generate a clear and stable crosshair layer, improving the sight's display effect.

[0067] In one possible implementation, generating the mask layer in step S102 includes the following steps: Step 1021b: Configure the exponential operation function and the radial gradient operation function in the target shader in advance to construct the circular gradient calculation model.

[0068] Step 1022b: Multiply the tangent space view vector by the mask preset coefficient to calculate the mask coordinate offset.

[0069] Step 1023b: Overlay the mask coordinate offset onto the base texture mapping coordinates of the sight rendering model, call the radial gradient operation function to generate a gradient mask, perform a domain inversion on the gradient mask and perform a fusion operation with the pixel data of the sight rendering model to generate a mask layer.

[0070] It should be noted that when the player's view deviates from the optical axis, a corresponding black shadow will be generated at the edge of the field of view. Therefore, it is necessary to simulate the dynamic black circle effect of the scope's exit pupil to restore the physical performance of a real optical scope.

[0071] For example, the construction of the circular gradient calculation model in step 1021b includes the following steps: configuring depth input parameters and mask density coefficients for the exponential operation function, and performing exponential decay operation based on the depth input parameters and mask density coefficients; configuring mask texture mapping coordinates, mask center position, mask radius parameters and mask density coefficients for the radial gradient operation function in the target shader, calling the exponential operation function to calculate pixel gradient decay values, and constructing a circular gradient calculation model.

[0072] Among them, the exponential operation function is a general operation interface for realizing distance decay, and the prototype is the fog effect calculation logic for softening edges; the depth input parameter can be set to the normalized distance from the pixel to the center, and the mask density coefficient can be set to 1.2. The gradient model constructed in this way can make the mask edges natural and soft, adapting to different eye distances.

[0073] Existing technologies typically employ independent masking models for occlusion, requiring additional rendering overhead and script synchronization, which can easily lead to performance degradation and alignment errors. This application directly constructs a circular gradient model in the target shader using a preset exponent and radial gradient function. It reuses the tangent space view vector to calculate the mask offset, generates a gradient mask after overlaying coordinates, and then inverts and blends it, ultimately outputting a dynamic mask layer. This enables real-time dynamic mask offset with the viewpoint, eliminating the need for additional models and synchronization operations, reducing performance overhead, ensuring consistent movement logic between the crosshair and the mask, and improving the visual realism and rendering efficiency of the sight.

[0074] Further, in step 1023b, the radial gradient operation function is called to generate a gradient mask. The gradient mask is then subjected to value domain inversion and fused with the pixel data of the sight rendering model to generate a mask layer. This includes the following steps: superimposing the mask coordinate offset onto the base texture mapping coordinates of the sight rendering model to obtain corrected mask texture mapping coordinates; inputting the radial gradient operation function based on the corrected mask texture mapping coordinates, and generating a circular gradient mask by combining the mask radius parameter and the mask density coefficient; performing value domain inversion processing on the circular gradient mask; and performing a multiplication fusion operation between the value domain inverted mask and the pixel data of the sight rendering model to generate a mask layer.

[0075] In practice, the radial gradient operation function is a circular gradient calculation interface based on exponential density, which can generate a softened mask from the center to the edge. The mask radius parameter simulates the pupil diameter, and the mask density coefficient controls the softness or hardness of the edge. Through coordinate correction, mask generation and inversion fusion, the effect of pupil occlusion is accurately simulated, ensuring that the mask edge is natural and dynamically fits the changes in viewing angle.

[0076] In one possible implementation, generating the reflection layer in step S103 includes the following steps: Step 1031: In response to aiming at the target virtual object, obtain the spherical normal map corresponding to the sight rendering model, and calculate the reflection vector based on the spherical normal map and the tangent space view vector; Step 1032: Convert the reflection vector into texture mapping coordinates, determine the texture sampling level according to the roughness parameters of the sight rendering model, and perform sampling processing on the environment map based on the texture mapping coordinates; Step 1033: Obtain scene lighting direction parameters, calculate half-angle vector by combining the tangent space view vector, and complete the specular calculation to obtain specular data by using the geometric Gaussian distribution specular algorithm; Step 1034: Merge the specular data with the sampling data of the environment map to generate a reflection layer.

[0077] In practice, the core purpose of generating the reflection layer is to simulate the optical effect of a real scope lens, present environmental reflections and direct light highlights, enhance the realism and material texture of the scope, and adapt to the planar scope rendering model to ensure the normal operation of the preceding parallax algorithm.

[0078] Existing technologies employ independent reflection rendering channels, requiring the scene to be re-rendered to an off-screen texture, consuming additional video memory and bandwidth, resulting in significant rendering overhead. This application, based on spherical normal maps and tangent space view vectors, separately performs reflection vector calculations and environment map sampling, half-angle vector calculations and specular operations, ultimately merging the two types of data to generate a reflection layer. This application eliminates the need for additional reflection rendering channels and off-screen textures, significantly reducing rendering overhead. Furthermore, it reuses tangent space view vectors, ensuring consistent and coordinated reflection effects with the crosshair and mask responses, accurately reproducing the optical reflection characteristics of a real lens.

[0079] In one possible implementation, step 1033, which involves obtaining the scene lighting direction parameters, calculating the half-angle vector in conjunction with the tangent space view vector, and performing specular calculations using a geometric Gaussian distribution specular algorithm to obtain specular data, includes the following steps: obtaining the scene lighting direction parameters; performing a merge operation on the scene lighting direction parameters and the tangent space view vector, and normalizing the result to obtain the half-angle vector; calculating the dot product of the spherical normal of the sight rendering model and the half-angle vector, and applying a range constraint function to the dot product to obtain a range-constrained dot product result; inputting the dot product result into the geometric Gaussian distribution specular algorithm to calculate the base specular intensity; performing a softening correction operation and a shadow culling operation on the base specular intensity to obtain a softened and shadow-cullinged base specular intensity; and performing a correction operation on the softened and shadow-cullinged base specular intensity based on the light source color parameters corresponding to the scene lighting direction parameters and the specular preset coefficient to obtain specular data.

[0080] In practice, by combining the scene's lighting direction and the tangent space viewpoint vector, multi-step calculations are performed to generate highlight data that conforms to realistic optical effects. The half-angle vector is the intermediate vector after normalizing the lighting and viewpoint vectors; the base highlight intensity is the original highlight intensity of the lens calculated using a geometric Gaussian distribution algorithm; and the highlight data are the final highlight display parameters after correction and softening processes. This allows for precise control of highlight intensity, elimination of jagged edges and shadow interference, and ensures that the highlight effect closely matches the light-receiving characteristics of a real lens, resulting in a natural and textured appearance.

[0081] In one possible implementation, the display of the virtual sight's image in step S104 includes the following steps: reading the pixel color data corresponding to the crosshair layer; reading the mask data of the mask layer, performing a multiplication operation between the mask data and the basic pixel data of the sight rendering model to achieve a scope barrel occlusion effect; reading the pixel data of the reflection layer, and performing a superposition and synthesis operation with the result of the multiplication operation between the mask data and the basic pixel data of the sight rendering model according to a preset weight ratio to obtain the final pixel data of the virtual sight's image, and rendering and displaying the virtual sight image in the graphical user interface based on the final pixel data.

[0082] In practice, the pixel color data of the reticle layer is first read to ensure accurate display of the aiming markers. Then, the mask data of the mask layer is called and works in conjunction with the base pixel data of the sight rendering model to achieve a realistic optical effect of scope barrel occlusion. Finally, the pixel data of the reflection layer is read and, according to a preset weight ratio, overlaid and synthesized with the previously processed pixel data to complete the final image rendering. Through the collaborative synthesis of multiple layers of pixel data, the physical consistency of the reticle, occlusion, and reflection effects is ensured, presenting a high-quality sight image and accurately restoring the imaging characteristics of a real sight.

[0083] For example, in the target shader, pixel fusion processing is performed on the crosshair layer, the mask layer, and the reflection layer, including: in the target shader, sequentially retrieving the pixel data of the crosshair layer, the mask layer, and the reflection layer in optical hierarchy order; performing a weighted composite operation on the pixel data of the crosshair layer, the mask layer, and the reflection layer to complete the multi-layer pixel fusion processing, and providing fused pixel data for the rendering of the virtual sight's image.

[0084] In one possible implementation, after displaying the image of the virtual sight, the method further includes the following steps: in response to the closing operation of the virtual sight, exiting the aiming operation state of the virtual sight; stopping the frame-by-frame calculation of the world space view vector and the conversion logic of the tangent space view vector, terminating the generation operations of the crosshair layer, mask layer and reflection layer; releasing the video memory resources corresponding to the crosshair texture, spherical normal map and environment map; stopping the calling of the sight rendering model, terminating the various operation logics in the target shader, and restoring the graphical user interface from the aiming view to the game view for display.

[0085] In practice, in response to the virtual scope closing operation, the system orderly terminates scope-related calculations, releases resources, and restores the viewpoint. It exits the aiming state, terminates viewpoint vector calculations and layer generation to avoid unnecessary calculations, releases texture memory resources to reduce performance consumption, stops scope rendering and shader calculations, restores the game viewpoint, ensures a smooth closing operation, eliminates redundant calculations and resource consumption, and guarantees game stability.

[0086] Based on the same concept, this application also provides a virtual aiming scope rendering device corresponding to the virtual aiming scope rendering method provided in the above embodiments. Since the principle of the device in this application is similar to the virtual aiming scope rendering method in the above embodiments of this application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.

[0087] like Figures 2 to 3 As shown, Figure 2 This is one of the functional block diagrams of a virtual aiming scope rendering device 200 provided in an embodiment of this application. Figure 3 This is a second functional block diagram of a rendering device 200 for a virtual aiming scope provided in an embodiment of this application. (See diagram below.) Figure 2 As shown, a graphical user interface is provided through a terminal device, which displays at least a portion of the game scene. The rendering device 200 for the virtual scope includes: The view vector generation module 210 is used to respond to the opening operation of the virtual sight, call the sight rendering model, calculate the world space view vector of the virtual camera pointing to the surface fragment of the sight rendering model frame by frame, and convert the world space view vector into the tangent space view vector in the local coordinate system of the sight surface. The first layer generation module 220 is used to respond to the view movement operation of following the target virtual object in the game scene, and to perform parallax offset operation in the target shader to generate a crosshair layer and perform radial gradient operation to generate a mask layer based on the tangent space view vector. The second layer generation module 230 is used to obtain the spherical normal map corresponding to the sight rendering model in response to aiming at the target virtual object, and to calculate the reflection vector based on the spherical normal map and the tangent space view vector, and to complete the specular operation through the geometric Gaussian distribution specular algorithm to generate a reflection layer. The display module 240 is used to perform pixel fusion processing on the crosshair layer, the mask layer and the reflection layer in the target shader, and render and display the image of the virtual sight in the graphical user interface based on the fusion result.

[0088] In one possible implementation, such as Figure 2As shown, the view vector generation module 210 is specifically used for: responding to the activation operation of the virtual sight, calling the sight rendering model, switching the game view to the aiming view of the virtual sight, and initializing the target shader's runtime environment; acquiring the position coordinates of the virtual camera in world space and the world coordinates of the surface fragments of the sight rendering model frame by frame, and solving for the world space view vector through coordinate difference normalization operation; constructing a mapping relationship based on the tangent vector and the subtangent vector of the sight rendering model, and converting the world space view vector into the tangent space view vector.

[0089] In one possible implementation, such as Figure 2 As shown, when the view vector generation module 210 converts the world space view vector into the tangent space view vector, it is specifically used to: read the tangent vector and subtangent vector of the sight rendering model from the model data of the sight rendering model; calculate the dot product operation of the world space view vector with the tangent vector and the subtangent vector respectively to obtain the first projection component of the world space view vector in the tangent direction and the second projection component in the subtangent direction; and combine the first projection component and the second projection component to obtain the tangent space view vector.

[0090] In one possible implementation, such as Figure 2 As shown, the first layer generation module 220 is specifically used for: responding to the viewpoint movement operation, multiplying the tangent space viewpoint vector with the crosshair parallax preset intensity coefficient to generate a crosshair parallax coordinate offset; superimposing the crosshair parallax coordinate offset and performing a crosshair texture mapping coordinate normalization operation; calling the crosshair texture preset sampling function, and reading the crosshair texture based on the normalized crosshair texture mapping coordinates, performing pixel sampling, and generating a crosshair layer.

[0091] In one possible implementation, such as Figure 2 As shown, when the first layer generation module 220 performs the crosshair texture mapping coordinate normalization operation, it is specifically used to: superimpose the crosshair parallax coordinate offset onto the base texture mapping coordinates of the crosshair texture to obtain the initial crosshair texture mapping coordinates; perform scaling operation on the initial crosshair texture mapping coordinates based on the crosshair preset scaling factor; perform centering correction processing on the scaled crosshair texture mapping coordinates through coordinate offset operation; and constrain the corrected crosshair texture mapping coordinates to the standard value range using a value range restriction function.

[0092] In one possible implementation, such as Figure 2As shown, when generating the crosshair layer, the first layer generation module 220 is specifically used to: use the normalized crosshair texture mapping coordinates to call the crosshair texture preset sampling function; configure the crosshair sampling fixed deviation parameter for the crosshair texture preset sampling function and complete the texture sampling to obtain the crosshair texture pixel color data; and transmit the crosshair texture pixel color data to the target shader to generate the crosshair layer.

[0093] In one possible implementation, such as Figure 2 As shown, the first layer generation module 220 is also used to: pre-configure an exponential operation function and a radial gradient operation function in the target shader to construct a circular gradient calculation model; multiply the tangent space view vector with the mask preset coefficient to calculate the mask coordinate offset; superimpose the mask coordinate offset onto the basic texture mapping coordinates of the sight rendering model; call the radial gradient operation function to generate a gradient mask; perform a value domain inversion on the gradient mask and perform a fusion operation with the pixel data of the sight rendering model to generate a mask layer.

[0094] In one possible implementation, such as Figure 2 As shown, the first layer generation module 220 is specifically used for: superimposing the mask coordinate offset onto the base texture mapping coordinates of the sight rendering model to obtain the corrected mask texture mapping coordinates; inputting the radial gradient operation function based on the corrected mask texture mapping coordinates, and generating a circular gradient mask by combining the mask radius parameter and the mask density coefficient; performing a value domain inversion process on the circular gradient mask; and performing a multiplication and fusion operation on the value domain inverted mask and the pixel data of the sight rendering model to generate a mask layer.

[0095] In one possible implementation, such as Figure 2 As shown, the second layer generation module 230 is specifically used for: in response to aiming at the target virtual object, obtaining the spherical normal map corresponding to the sight rendering model, calculating the reflection vector based on the spherical normal map and the tangent space view vector; converting the reflection vector into texture mapping coordinates, determining the texture sampling level according to the roughness parameters of the sight rendering model, and performing sampling processing on the environment map based on the texture mapping coordinates; obtaining scene lighting direction parameters, calculating the half-angle vector in combination with the tangent space view vector, and completing the specular operation using the geometric Gaussian distribution specular algorithm to obtain specular data; merging the specular data with the sampled data of the environment map to generate a reflection layer.

[0096] In one possible implementation, such as Figure 2As shown, the second layer generation module 230 is further configured to: obtain the scene lighting direction parameters; perform a merging operation on the scene lighting direction parameters and the tangent space view vector; normalize the operation result to obtain a half-angle vector; calculate the dot product of the spherical normal of the sight rendering model and the half-angle vector; call the value range constraint function to perform value range constraint processing on the dot product value to obtain the value range-constrained dot product result; input the dot product result into the geometric Gaussian distribution specular algorithm to calculate the specular base intensity; perform a softening correction operation and a shadow culling operation on the specular base intensity to obtain the softened and shadow-culling specular base intensity; and perform a correction operation on the softened and shadow-culling specular base intensity based on the light source color parameters and specular preset coefficients corresponding to the scene lighting direction parameters to obtain specular data.

[0097] In one possible implementation, such as Figure 2 As shown, the display module 240 is specifically used for: reading the pixel color data corresponding to the crosshair layer; reading the mask data of the mask layer, performing a multiplication operation between the mask data and the basic pixel data of the sight rendering model to achieve the scope barrel occlusion effect; reading the pixel data of the reflection layer, and performing superposition and synthesis with the result of the multiplication operation of the mask data and the basic pixel data of the sight rendering model according to a preset weight ratio to obtain the final pixel data of the virtual sight image, and rendering and displaying the virtual sight image in the graphical user interface based on the final pixel data.

[0098] In one possible implementation, such as Figure 3 As shown, after displaying the image of the virtual sight, the rendering device 200 of the virtual sight further includes a release module 250; the release module 250 is specifically used to: exit the aiming operation state of the virtual sight in response to the closing operation of the virtual sight; stop the frame-by-frame calculation of the world space view vector and the conversion logic of the tangent space view vector, and terminate the generation operation of the crosshair layer, mask layer and reflection layer; release the video memory resources corresponding to the crosshair texture, spherical normal map and environment map; stop calling the sight rendering model, terminate the various operation logics in the target shader, and restore the graphical user interface from the aiming view to the game view for display.

[0099] Based on the same application concept, see [link / reference] Figure 4The diagram shown is a structural schematic of an electronic device 400 provided in an embodiment of this application, including: a processor 410, a memory 420, and a bus 430. The memory 420 stores machine-readable instructions executable by the processor 410. When the electronic device 400 is running, the processor 410 and the memory 420 communicate through the bus 430. When the machine-readable instructions are executed by the processor 410, the processor executes the steps of the virtual aiming scope rendering method as described in any of the above embodiments.

[0100] Specifically, when the machine-readable instructions are executed by the processor 410, the following processing can be performed: In response to the activation of the virtual sight, the sight rendering model is invoked, and the world space view vector of the virtual camera pointing to the surface fragment of the sight rendering model is calculated frame by frame. The world space view vector is then converted into the tangent space view vector in the local coordinate system of the sight surface. In response to the view movement operation following the target virtual object in the game scene, based on the tangent space view vector, a parallax offset operation is performed in the target shader to generate a crosshair layer, and a radial gradient operation is performed to generate a mask layer. In response to aiming at the target virtual object, the system obtains the spherical normal map corresponding to the sight rendering model, calculates the reflection vector based on the spherical normal map and the tangent space view vector, and performs specular calculations using a geometric Gaussian distribution specular algorithm to generate a reflection layer. In the target shader, pixel fusion processing is performed on the crosshair layer, the mask layer, and the reflection layer. Based on the fusion result, the image of the virtual sight is rendered and displayed in the graphical user interface.

[0101] In this embodiment, in response to the activation of the virtual scope, a world space view vector is calculated and converted into a tangent space view vector; in response to the view movement operation following the target virtual object, calculations are performed in the target shader based on the tangent space view vector to generate a crosshair layer and a mask layer; in response to aiming at the target virtual object, a spherical normal map is sampled on the scope rendering model, and a reflection vector is calculated based on the tangent space view vector to generate a reflection layer; in the target shader, pixel fusion processing is performed on the three layers, and the image of the virtual scope is displayed based on the fusion result. In this way, while making the optical effects more realistic, by completing integrated rendering within the same shader, redundant drawing and interaction can be reduced, runtime overhead can be lowered, and image stability and aiming immersion can be improved.

[0102] Based on the same concept, this application also provides a computer-readable storage medium storing a computer program, which, when run by a processor, executes the steps of the virtual aiming scope rendering method provided in the above embodiments.

[0103] Specifically, the storage medium can be a general-purpose storage medium, such as a portable disk or hard disk. When the computer program on the storage medium is run, it can execute the above-mentioned rendering method of the virtual sight. While making the optical effects more realistic, it can reduce redundant drawing and interaction, reduce operating costs, and improve screen stability and aiming immersion by completing integrated rendering in the same shader.

[0104] In this embodiment, the computer program, when run by the processor, can also execute other machine-readable instructions to perform other methods as described in the embodiments. For details on the specific execution steps and principles, please refer to the description of the embodiments, which will not be repeated here.

[0105] The computer program product for rendering a virtual aiming scope provided in this application includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation details, please refer to the method embodiments, which will not be repeated here.

[0106] The virtual aiming scope rendering device provided in this application embodiment can be specific hardware on the device or software or firmware installed on the device. The implementation principle and technical effects of the device provided in this application embodiment are the same as those in the foregoing method embodiments. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the foregoing method embodiments. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can all be referred to the corresponding processes in the above method embodiments, and will not be repeated here.

[0107] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.

[0108] 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 network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0109] In addition, the functional units in the embodiments provided in 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.

[0110] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they 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 a portion 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 USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0111] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0112] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The protection scope of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application. All should be covered within the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the claims.

Claims

1. A rendering method for a virtual sight, characterized in that, The method includes providing a graphical user interface (GUI) via a terminal device, wherein the GUI displays at least a portion of the game scene, the method comprising: In response to the activation of the virtual sight, the sight rendering model is invoked, and the world space view vector of the virtual camera pointing to the surface fragment of the sight rendering model is calculated frame by frame. The world space view vector is then converted into the tangent space view vector in the local coordinate system of the sight surface. In response to the view movement operation following the target virtual object in the game scene, based on the tangent space view vector, a parallax offset operation is performed in the target shader to generate a crosshair layer, and a radial gradient operation is performed to generate a mask layer. In response to aiming at the target virtual object, the system obtains the spherical normal map corresponding to the sight rendering model, calculates the reflection vector based on the spherical normal map and the tangent space view vector, and performs specular calculations using a geometric Gaussian distribution specular algorithm to generate a reflection layer. In the target shader, pixel fusion processing is performed on the crosshair layer, the mask layer, and the reflection layer. Based on the fusion result, the image of the virtual sight is rendered and displayed in the graphical user interface.

2. The method according to claim 1, characterized in that, In response to the activation of the virtual sight, the following steps are taken: The sight rendering model is invoked, and the world space view vector of the virtual camera pointing towards the surface fragments of the sight rendering model is calculated frame by frame. This world space view vector is then transformed into a tangent space view vector in the local coordinate system of the sight surface, including: In response to the activation of the virtual scope, the scope rendering model is invoked, the game view is switched to the aiming view of the virtual scope, and the target shader runtime environment is initialized; The position coordinates of the virtual camera in world space and the world coordinates of the surface fragments of the sight rendering model are obtained frame by frame. The world space view vector is obtained by normalizing the coordinate difference. Based on the tangent vector and subtangent vector of the sight rendering model, a mapping relationship is constructed to convert the world space view vector into the tangent space view vector.

3. The method according to claim 2, characterized in that, The step of converting the world space view vector to obtain the tangent space view vector includes: Read the tangent vector and subtangent vector of the sight rendering model from the model data of the sight rendering model; Calculate the dot product of the world space view vector with the tangent vector and the subtangent vector respectively to obtain the first projection component of the world space view vector in the tangent direction and the second projection component in the subtangent direction; The first projection component and the second projection component are combined to obtain the tangent space view vector.

4. The method according to claim 1, characterized in that, The step of generating the crosshair layer includes: In response to the viewpoint movement operation, the tangent space viewpoint vector is multiplied by the crosshair parallax preset intensity coefficient to generate the crosshair parallax coordinate offset. After superimposing the crosshair parallax coordinate offsets, a crosshair texture mapping coordinate normalization operation is performed; Call the crosshair texture preset sampling function, read the crosshair texture based on the normalized crosshair texture mapping coordinates, perform pixel sampling, and generate the crosshair layer.

5. The method according to claim 4, characterized in that, The step of superimposing the crosshair parallax coordinate offsets and then performing crosshair texture mapping coordinate normalization includes: The crosshair parallax coordinate offset is superimposed on the base texture mapping coordinates of the crosshair texture to obtain the initial crosshair texture mapping coordinates; The initial crosshair texture mapping coordinates are scaled based on the crosshair's preset scaling factor. Centering correction is performed on the scaled crosshair texture mapping coordinates using coordinate offset calculations; A range constraint function is used to constrain the corrected reticle texture mapping coordinates to a standard range.

6. The method according to claim 4, characterized in that, The process of calling the crosshair texture preset sampling function, reading the crosshair texture based on the normalized crosshair texture mapping coordinates, performing pixel sampling, and generating a crosshair layer includes: Using the normalized crosshair texture mapping coordinates, the crosshair texture preset sampling function is called; Configure the fixed deviation parameters for crosshair sampling in the preset sampling function of the crosshair texture and complete the texture sampling to obtain the crosshair texture pixel color data; The crosshair texture pixel color data is transferred to the target shader to generate a crosshair layer.

7. The method according to claim 1, characterized in that, The step of generating the mask layer includes: Pre-configure exponential and radial gradient operation functions within the target shader to construct a circular gradient calculation model; The mask coordinate offset is calculated by multiplying the tangent space view vector by the mask preset coefficient. The mask coordinate offset is superimposed onto the base texture mapping coordinates of the sight rendering model, the radial gradient operation function is called to generate a gradient mask, the value domain is reversed on the gradient mask and fused with the pixel data of the sight rendering model to generate a mask layer.

8. The method according to claim 7, characterized in that, The process of calling the radial gradient operation function to generate a gradient mask, performing a range inversion on the gradient mask, and performing a fusion operation with the pixel data of the sight rendering model to generate a mask layer includes: The mask coordinate offset is superimposed on the base texture mapping coordinates of the sight rendering model to obtain the corrected mask texture mapping coordinates. Based on the corrected mask texture mapping coordinates, the radial gradient operation function is input, and a circular gradient mask is generated by combining the mask radius parameter and the mask density coefficient. Perform a range inversion process on the circular gradient mask; The mask with inverted value range is multiplied and fused with the pixel data of the sight rendering model to generate a mask layer.

9. The method according to claim 1, characterized in that, The step of generating the reflection layer includes: In response to aiming at the target virtual object, the spherical normal map corresponding to the sight rendering model is obtained, and the reflection vector is calculated based on the spherical normal map and the tangent space view vector; The reflection vector is converted into texture mapping coordinates, the texture sampling level is determined according to the roughness parameters of the sight rendering model, and the environment map is sampled based on the texture mapping coordinates. Obtain scene lighting direction parameters, calculate half-angle vector by combining the tangent space view vector, and complete the specular calculation to obtain specular data by using the geometric Gaussian distribution specular algorithm; The specular data is merged with the sampling data of the environment map to generate a reflection layer.

10. The method according to claim 9, characterized in that, The process of obtaining scene illumination direction parameters, calculating half-angle vectors by combining the tangent space view vectors, and performing specular calculations using a geometric Gaussian distribution specular algorithm to obtain specular data includes: The scene lighting direction parameters are obtained, and the scene lighting direction parameters are merged with the tangent space view vector. The result of the operation is then normalized to obtain a half-angle vector. Calculate the dot product of the spherical normal of the sight rendering model and the half-angle vector, and call the range constraint function to perform range constraint processing on the dot product value to obtain the range-constrained dot product result; The dot product result is input into the geometric Gaussian distribution specular algorithm to calculate the basic intensity of the specular highlight. Perform softening correction and shadow removal operations on the aforementioned highlight base intensity to obtain the softened and shadow-removed highlight base intensity; Based on the light source color parameters and specular preset coefficients corresponding to the scene illumination direction parameters, the basic intensity of the specular highlights after softening and shadow removal is corrected to obtain specular data.

11. The method according to claim 1, characterized in that, The step of displaying the image from the virtual sight includes: Read the pixel color data corresponding to the crosshair layer; Read the mask data of the mask layer, and perform a multiplication operation between the mask data and the basic pixel data of the sight rendering model to achieve the scope barrel occlusion effect; The pixel data of the reflection layer is read, and the result of the multiplication operation with the mask data and the basic pixel data of the sight rendering model is superimposed and synthesized according to the preset weight ratio to obtain the final pixel data of the virtual sight image. The virtual sight image is then rendered and displayed in the graphical user interface based on the final pixel data.

12. The method according to claim 1, characterized in that, After displaying the image from the virtual sight, the method further includes: In response to the closing operation of the virtual sight, exit the aiming state of the virtual sight; Stop the frame-by-frame calculation of the world space view vector and the conversion logic of the tangent space view vector, and terminate the generation operation of the crosshair layer, mask layer and reflection layer; Release the video memory resources corresponding to the crosshair texture, spherical normal map, and environment map; Stop calling the sight rendering model, terminate all computational logic within the target shader, and restore the graphical user interface from the aiming perspective to the game perspective.

13. A rendering device for a virtual sight, characterized in that, The device provides a graphical user interface (GUI) via a terminal device, the GUI displaying at least a portion of the game scene, the device comprising: The view vector generation module is used to respond to the opening operation of the virtual sight, call the sight rendering model, calculate the world space view vector of the virtual camera pointing to the surface fragment of the sight rendering model frame by frame, and convert the world space view vector into the tangent space view vector in the local coordinate system of the sight surface. The first layer generation module is used to respond to the view movement operation of following the target virtual object in the game scene, and to perform parallax offset operation in the target shader to generate a crosshair layer and perform radial gradient operation to generate a mask layer based on the tangent space view vector. The second layer generation module is used to respond to aiming at the target virtual object, obtain the spherical normal map corresponding to the sight rendering model, calculate the reflection vector based on the spherical normal map and the tangent space view vector, and complete the specular operation through the geometric Gaussian distribution specular algorithm to generate a reflection layer; The display module is used to perform pixel fusion processing on the crosshair layer, the mask layer and the reflection layer in the target shader, and render and display the image of the virtual sight in the graphical user interface based on the fusion result.

14. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the memory via the bus, and the machine-readable instructions are executed by the processor to perform the steps of the rendering method of the virtual sight as described in any one of claims 1 to 12.

15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the rendering method for the virtual sight as described in any one of claims 1 to 12.