Light spot rendering method and device and electronic equipment

By obtaining pixel world coordinates on the mobile device to divide the grid cells and using a pseudo-random function to generate light spot position offsets and sizes, combined with interactive position adjustment, the problem of insufficient light spot rendering effect on mobile devices is solved, achieving efficient, random and visually coherent light spot rendering.

CN122066844APending Publication Date: 2026-05-19GUANGZHOU BOGUAN TELECOMM TECH LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGZHOU BOGUAN TELECOMM TECH LTD
Filing Date
2026-01-26
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

Existing technologies struggle to achieve efficient light spot rendering effects on mobile devices while maintaining both performance and interactivity, especially for the "blue tears" effect. Texture shading methods lack interactivity, while particle systems consume too much performance.

Method used

By obtaining the world coordinates of the pixels to be rendered, dividing them into mesh units, using a pseudo-random function to generate the position offset and size of the light spot, adjusting the display position of the light spot according to the position of the interactive object, and finally rendering the output.

Benefits of technology

It achieves highly efficient dynamic light spot rendering effects, improves image rendering quality and generation efficiency, while ensuring the randomness and visual coherence of light spot distribution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122066844A_ABST
    Figure CN122066844A_ABST
Patent Text Reader

Abstract

The invention provides a light spot rendering method. The method comprises the following steps: acquiring world coordinates of a pixel to be rendered; dividing a rendering area into a plurality of grid units based on the world coordinates, and determining a target grid unit to which the to-be-rendered pixel belongs and local coordinates in the target grid unit; generating a light spot position offset and a light spot size through a pseudo-random function based on the index of the target grid unit; generating a light spot in the target grid unit according to the light spot position offset and the light spot size; obtaining the position of an interaction object, and calculating a first distance and a direction relation between the interaction object and the light spot; adjusting the display position of the light spot based on the distance and direction relation; and rendering and outputting the adjusted light spots. By establishing a gridding light spot generation mechanism and combining with an interactive position adjustment technology, a high-efficiency dynamic light spot rendering effect can be realized, and the image rendering quality and the generation efficiency are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of game technology, and in particular to a light spot rendering method and apparatus, storage medium, and electronic device. Background Technology

[0002] With the increasing graphics processing power of mobile devices, mobile applications are demanding more realistic rendering of special light spot effects such as "blue tears" in ocean scenes. Currently, the technical solutions for achieving such light spot effects mainly fall into two categories: one is a non-particle approach based on texture shading. This method samples pre-made textures and overlays them onto the sea surface using shaders, offering the advantage of low performance overhead. However, information such as the position and brightness of the light spot is pre-fixed in the texture, making it unable to react in real-time to changes in the position of dynamic objects in the scene, resulting in a lack of interactivity. The other is a particle system approach based on the Central Processing Unit (CPU). This treats each light spot as an independent particle entity, with the CPU responsible for particle lifecycle management and collision detection. While this allows for rich physical interactions, it faces significant performance challenges on mobile devices. The CPU needs to manage the frame-by-frame updates and collision checks of a large number of particles, and the frequent data transfer between the CPU and the Graphics Processing Unit (GPU) also incurs significant bandwidth overhead, leading to a drop in frame rate. Therefore, existing technical solutions struggle to simultaneously achieve high-performance and highly interactive light spot rendering effects on mobile platforms.

[0003] 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

[0004] The purpose of this invention is to provide a light spot rendering method and apparatus, storage medium, and electronic device, thereby overcoming, to at least to some extent, one or more problems caused by the limitations and defects of related technologies.

[0005] According to one aspect of this disclosure, a light spot rendering method is provided, the method further comprising:

[0006] Get the world coordinates of the pixel to be rendered; Based on the world coordinates, the rendering area is divided into multiple grid cells, and the target grid cell to which the pixel to be rendered belongs and its local coordinates within the target grid cell are determined. Based on the index of the target grid cell, the spot position offset and spot size are generated using a pseudo-random function; Based on the spot position offset and spot size, a spot is generated within the target grid cell; Obtain the position of the interactive object, and calculate the first distance and directional relationship between the interactive object and the light spot; Based on the distance and direction relationship, the display position of the light spot is adjusted; Render and output the adjusted light spots.

[0007] According to another aspect of this disclosure, A light spot rendering device, the device comprising: The acquisition module is used to obtain the world coordinates of the pixel to be rendered. The determination module is used to divide the rendering area into multiple grid cells based on the world coordinates, and to determine the target grid cell to which the pixel to be rendered belongs and the local coordinates within the target grid cell; The first generation module is used to generate the spot position offset and spot size based on the index of the target grid cell using a pseudo-random function; The second generation module is used to generate a light spot within the target grid cell based on the light spot position offset and the light spot size. The calculation module is used to obtain the position of the interactive object and calculate the first distance and directional relationship between the interactive object and the light spot; An adjustment module is used to adjust the display position of the light spot based on the distance and direction relationship; The rendering module is used to render and output the adjusted light spots.

[0008] According to another aspect of this disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the light spot rendering method described in any of the preceding claims.

[0009] According to another aspect of this disclosure, an electronic device is provided, comprising: Processor, display device; and Memory for storing the executable instructions of the processor; The processor is configured to execute any of the above-described spot rendering methods by executing the executable instructions.

[0010] The light spot rendering method provided in this application involves: obtaining the world coordinates of the pixel to be rendered; dividing the rendering area into multiple grid cells based on the world coordinates, and determining the target grid cell to which the pixel to be rendered belongs and its local coordinates within the target grid cell; generating a light spot position offset and a light spot size using a pseudo-random function based on the index of the target grid cell; generating a light spot within the target grid cell according to the light spot position offset and light spot size; obtaining the position of an interactive object and calculating a first distance and directional relationship between the interactive object and the light spot; adjusting the display position of the light spot based on the distance and directional relationship; and rendering the adjusted light spot. This method, by establishing a gridded light spot generation mechanism combined with interactive position adjustment technology, achieves highly efficient dynamic light spot rendering, significantly improving image rendering quality and generation efficiency, while ensuring the randomness and visual coherence of the light spot distribution. Attached Figure Description

[0011] The above and other features and advantages of this disclosure will become more apparent from the detailed description of exemplary embodiments thereof with reference to the accompanying drawings. Obviously, the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings: Figure 1 This is a cloud interaction system architecture diagram according to an exemplary embodiment of the present disclosure; Figure 2 This is a flowchart of a light spot rendering method according to an exemplary embodiment of the present disclosure; Figure 3 This is a schematic diagram of a game scene according to an exemplary embodiment of this disclosure; Figure 4 This is a schematic diagram of a mesh cell according to an exemplary embodiment of the present disclosure; Figure 5 This is a schematic diagram of a "blue tears" phenomenon according to an exemplary embodiment of this disclosure; Figure 6 This is a schematic diagram of a light spot rendering according to an exemplary embodiment of the present disclosure; Figure 7 This is a diagram illustrating the composition of a light spot rendering apparatus according to an exemplary embodiment of this disclosure; Figure 8 This is a schematic diagram of the structure of a computer-readable storage medium according to an exemplary embodiment of the present disclosure; Figure 9 This is a composition diagram of an electronic device according to an exemplary embodiment of the present disclosure. Detailed Implementation

[0012] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.

[0013] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0014] It should be noted that the information (including but not limited to user input information, such as information entered by the user into input boxes), data (including but not limited to data used for analysis, stored data, and displayed data, such as context code, all code of the current project, the service pressure corresponding to operations performed on all code of the current project, and the code development status of the current project), and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with relevant laws, regulations, and standards. For example, the context code, operations performed on all code of the current project, the corresponding service pressure, and the code development status involved in this application were all obtained with full authorization.

[0015] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention 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 for the embodiments of the invention 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.

[0016] It should also be noted that the various trigger events disclosed in this manual can be preset, and different trigger events can trigger the execution of different functions.

[0017] Blue tears refers to the phenomenon where bioluminescent planktonic organisms in the ocean (mainly Noctiluca scintillans, sea fireflies, etc.) emit blue bioluminescence when stimulated by physical stimuli. These tiny organisms are distributed in seawater, and when waves crash or objects disturb them, they produce specks of blue light, creating the dreamlike "blue tears" phenomenon.

[0018] A spot rendering method in one embodiment of this disclosure can run on a terminal device or a server. The terminal device can be a local terminal device. When the display control method runs on a server, the method can be implemented and executed based on a cloud interaction system, which includes a server and client devices. Figure 1 The figure shows a cloud interaction system architecture diagram provided in this disclosure. As shown, the cloud interaction system may include: a client device 10 and a server 20, wherein the client device 10 can be connected to the server 20 via a network 30.

[0019] 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 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 terminal device for information processing is 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.

[0020] In an alternative implementation, the terminal device can be a local terminal device. 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, that is, conventionally downloading, installing, and running the game program via an electronic device. The local terminal device can provide the graphical user interface to the player in various ways, such as rendering it on the terminal's display screen, or providing it to the player through holographic projection. For example, the local terminal device can include a display screen for displaying the graphical user interface, which includes game screens, and a processor for running the game, generating the graphical user interface, and controlling the display of the graphical user interface on the display screen.

[0021] This embodiment provides a light spot rendering method. Figure 2 This is a flowchart of a light spot rendering method according to an embodiment of the present disclosure, such as... Figure 2 As shown, the process includes the following steps: Step S1: Obtain the world coordinates of the pixel to be rendered; Step S2: Based on the world coordinates, the rendering area is divided into multiple grid cells, and the target grid cell to which the pixel to be rendered belongs and its local coordinates within the target grid cell are determined. Step S3: Based on the index of the target grid cell, generate the spot position offset and spot size using a pseudo-random function; Step S4: Generate a light spot within the target grid cell based on the light spot position offset and light spot size; Step S5: Obtain the position of the interactive object and calculate the first distance and directional relationship between the interactive object and the light spot; Step S6: Adjust the display position of the light spot based on the distance and direction relationship; Step S7: Render and output the adjusted light spots.

[0022] The method provided in this embodiment enables highly efficient dynamic light spot rendering by establishing a gridded light spot generation mechanism combined with interactive position adjustment technology, significantly improving image rendering quality and generation efficiency, while ensuring the randomness and visual coherence of light spot distribution.

[0023] The steps described above are explained in detail below.

[0024] In step S1, the world coordinates of the pixel to be rendered are obtained.

[0025] The pixel to be rendered is the screen pixel currently being processed, and its world coordinates represent the absolute position information of the pixel in the three-dimensional scene space.

[0026] In an optional implementation, the world coordinates of the pixel to be rendered are obtained by converting screen space coordinates to world space coordinates, taking into account the camera's view matrix and projection matrix parameters. For example, the terminal device first obtains the screen coordinates (x, y) of the current pixel, and then calculates the corresponding world coordinates (worldX, worldY, worldZ) of the pixel through inverse projection transformation and inverse view transformation, where the worldX and worldY components will be used for subsequent mesh generation calculations.

[0027] In an alternative implementation, obtaining world coordinates also involves processing depth information, using depth values ​​in a depth buffer to determine the precise location of a pixel in world space. For example, the terminal device samples the depth value of the current pixel from a depth texture, combines this depth value with screen coordinates, and calculates the precise world coordinates using the camera's inverse transformation matrix, ensuring that the light spot is rendered in the correct 3D position.

[0028] In a specific application, when a user moves interactive objects within a game scene (such as...) Figure 3 The diagram shows a game scene. The terminal device obtains the world coordinates of each pixel to be rendered on the screen in real time. This coordinate information provides the basic data support for the subsequent generation of spatially consistent light spot effects.

[0029] In step S2, based on the world coordinates, the rendering area is divided into multiple grid cells, and the target grid cell to which the pixel to be rendered belongs and its local coordinates within the target grid cell are determined.

[0030] The grid cell is a rectangular area formed by regularly dividing the rendering area. It is used to discretize the continuous world coordinate space into manageable cells, and each grid cell has a unique index identifier.

[0031] In an optional implementation, grid partitioning is achieved by dividing the horizontal component of the world coordinates by a preset grid size and rounding down, ensuring that the spatial continuity of adjacent pixels can be mapped to the same or neighboring grid cells. For example, the terminal device divides the world coordinates (worldX, worldY) by the grid size gridSize to obtain the grid index (gridX, gridY) = (floor(worldX / gridSize), floor(worldY / gridSize)), which uniquely identifies the grid cell to which the current pixel belongs.

[0032] In an optional implementation, local coordinates are calculated by subtracting the reference coordinates of the grid cell from the world coordinates. These local coordinates represent the relative position of the pixel within the current grid cell. For example, the terminal device calculates the local coordinates localCoord = (worldX - gridXgridSize, worldY - gridYgridSize), where the coordinate values ​​range from [0, gridSize), providing a reference for subsequent precise positioning of the light spot within the grid cell.

[0033] The target mesh cell is the mesh region to which the pixel to be rendered belongs, determined by a mesh partitioning algorithm. This mesh cell will serve as the basic spatial unit for light point generation, such as... Figure 4 The diagram shows a type of grid cell.

[0034] In an optional implementation, the determination of the target grid cell takes into account boundary processing and spatial continuity, ensuring that pixels located at the grid boundary can be correctly assigned to the appropriate grid cell. For example, when the pixel world coordinates are negative, the terminal device uses a special rounding algorithm to ensure the correct calculation of the grid index, avoiding abnormal spot distribution caused by index errors.

[0035] In one alternative implementation, the accuracy of the local coordinates directly affects the positioning accuracy of the light spot within the grid cell. Maintaining sufficient floating-point precision ensures smooth changes in the light spot's position. For example, the terminal device uses high-precision floating-point numbers to store the local coordinates, ensuring continuous positional changes during light spot interpolation calculations within the grid cell.

[0036] In a specific application, when rendering a complex starry sky background, the terminal device divides the screen into 64x64 grid cells, with each grid cell corresponding to a region in the sky. Through precise grid division and local coordinate calculation, it ensures that the star points maintain a stable spatial distribution under different viewing angles.

[0037] In step S3, the spot position offset and spot size are generated by a pseudo-random function based on the index of the target grid cell.

[0038] Among them, the pseudo-random function is a random number generation function based on a deterministic algorithm. It can generate a seemingly random but reproducible numerical sequence based on the input seed value, ensuring that the same grid cell generates consistent light spot attributes across different frames.

[0039] In an optional implementation, the pseudo-random function employs a grid-index-based hash algorithm, which converts the two-dimensional index of the grid into a random seed through mathematical operations, and then generates pseudo-random values ​​through mathematical functions such as trigonometric functions.

[0040] In an alternative implementation, the spot position offset is determined by mapping pseudo-random values ​​to an offset range within the grid cells. This offset prevents the spots from being strictly distributed along the grid center, increasing the naturalness of the visual appearance. For example, the terminal device multiplies the generated random value by the grid size and subtracts half of the grid size to obtain a position offset in the range of [-gridSize / 2, gridSize / 2], causing the spots to appear randomly distributed within the grid cells.

[0041] Among them, the light spot size is a parameter that controls the rendering size of a single light spot. Pseudo-random generation ensures that the light spots in different grid units have varying sizes, enhancing the visual sense of hierarchy.

[0042] In an optional implementation, the spot size is generated by scaling and offsetting a pseudo-random value to ensure that the size varies within a reasonable range. For example, the terminal device multiplies the pseudo-random value by the size variation magnitude and adds it to a base size value to obtain the spot size = baseSize + randomValue. sizeVariation, where baseSize is the base size and sizeVariation is the range of size variation.

[0043] In an alternative implementation, the position offset and size are generated using different random seeds or random sequences to ensure independence between the two attributes and avoid unnatural correlations. For example, the terminal device generates two independent sets of pseudo-random values ​​by performing different hash transformations on the grid index, which are used to calculate the position offset and spot size respectively, ensuring the diversity of spot attributes.

[0044] In a specific application, when rendering particle effects, the terminal device generates unique light spot position offsets and size parameters for each mesh unit, so that the entire particle system presents a natural random distribution effect, while ensuring that the rendering results are consistent under the same conditions.

[0045] In step S4, a light spot is generated within the target grid cell based on the light spot position offset and the light spot size.

[0046] Among them, light spot generation is the process of creating a set of pixels with specific visual attributes within a specified grid cell based on position offset and size parameters. This process determines the final visual appearance of the light spots.

[0047] In one optional implementation, the light spot is generated by calculating the distance between the current pixel and the center position of the light spot, and then determining the pixel's transparency or intensity value using a mathematical function based on this distance and the light spot size. For example, the terminal device first determines the center position of the light spot as the grid center plus a position offset, then calculates the Euclidean distance from the current pixel to the center of the light spot, and finally maps the distance to a transparency value using a smooth interpolation function to achieve a gradient edge effect for the light spot.

[0048] In an alternative implementation, the generation of the light spot also involves edge softening, using a smoothing function to ensure that the edges of the light spot have a natural gradient effect rather than a hard boundary. For example, the terminal device uses the smoothstep function to process the distance value, outputting a high transparency value when the distance is less than the radius of the light spot, and smoothly reducing the transparency to zero when the distance is close to the boundary of the light spot, thus achieving a soft edge effect for the light spot.

[0049] In a specific application, when rendering the star effect of "Blue Tears" (i.e., the effect of randomly distributed light spots generated by a program algorithm), the terminal device creates star spots with different brightness and size within the grid based on the position offset and size parameters generated for each grid cell. Distance field calculations ensure that each star spot has a natural halo effect; for example... Figure 5 The diagram shown illustrates a type of "blue tears".

[0050] In step S5, the position of the interactive object is obtained, and the first distance and directional relationship between the interactive object and the light spot is calculated.

[0051] The interactive object is a dynamic element in the scene that can influence the behavior of the light spot. Its position information is used to calculate the spatial relationship between it and the light spot to achieve an interactive visual effect.

[0052] In one optional implementation, the position of the interactive object is obtained in real time through a scene management system. This position information includes three-dimensional world coordinates, which are used to calculate the spatial distance to the light point position. For example, the terminal device obtains the world coordinates of the mouse cursor, character, or other interactive object from the scene graph and converts them into the same coordinate system as the light point for subsequent calculations.

[0053] In an alternative implementation, the first distance is calculated using the Euclidean distance formula, and the precise spatial distance is determined by comparing the coordinate difference between the interactive object and the center position of the light point.

[0054] Among them, the directional relationship is the vector information pointing from the light point to the interactive object or in the opposite direction, which determines the direction of the light point position adjustment.

[0055] In an alternative implementation, the directional relationship is determined by calculating a direction vector from the light spot to the interactive object, which is then normalized to obtain a unit direction vector.

[0056] In an optional implementation, the directional relationship also takes into account the interaction type. Different types of interactive objects may produce pushing or pulling effects, affecting the movement direction of the light spot. For example, when the interactive object is a repulsive object, the terminal device calculates the direction from the interactive object to the light spot to achieve a pushing effect; when it is an attractive object, the opposite direction is calculated to achieve a gathering effect.

[0057] In a specific application, when a user moves their finger on a touchscreen, the terminal device obtains the screen coordinates of the touch point and converts them into world coordinates, calculates the distance and directional relationship between the touch point and the surrounding light points, and provides a data basis for realizing the dynamic response effect of the light points around the finger.

[0058] In step S6, the display position of the light spot is adjusted based on the distance and direction relationship.

[0059] The position adjustment process involves calculating the new position of the light spot based on the influence of the interactive object, which realizes the dynamic response relationship between the light spot and the interactive object.

[0060] In an alternative implementation, position adjustment is achieved through a force field model, where the strength of the force field generated by the interactive object is inversely proportional to the distance, with closer light spots being more strongly affected.

[0061] In an optional implementation, the position of the light spot is adjusted using an incremental update method, which achieves a smooth position transition effect by adding the calculated position offset to the current position of the light spot.

[0062] In a specific application, in an interactive particle system, when the user moves the mouse, the terminal device calculates in real time the distance and direction relationship between the mouse position and each light point on the screen, and applies a pushing or pulling force to the light points that are close to the mouse, creating a visual effect of light points dynamically flowing around the mouse.

[0063] In step S7, the adjusted light spots are rendered and output.

[0064] The rendering output is the process of converting the calculated light spot data into the final pixel color and displaying it on the screen. This process completes the final visual presentation of the light spot.

[0065] In an alternative implementation, the rendering output is achieved by alpha blending the transparency information of the light spots with the background image, ensuring that the light spots can be naturally superimposed on the existing image.

[0066] In an optional implementation, the rendering output also includes the calculation of the light spot color, which determines the final color representation of the light spot by combining light spot attributes, ambient lighting, and material parameters. For example, the terminal device calculates the light spot color based on the light spot size, distance attenuation, and ambient hue, so that the light spot presents an appropriate visual effect in different environments.

[0067] In a specific application, in a real-time rendering scenario, the terminal device submits all the adjusted light spot data to the graphics rendering pipeline, and the GPU performs batch rendering of the light spots through parallel processing, ultimately presenting a dynamic light spot effect with interactive responsiveness on the screen.

[0068] like Figure 6 The diagram illustrates a point-of-view rendering technique. The terminal device overlays the "blue tears" effect onto a water surface shade. First, the world coordinates of each pixel on the screen are obtained. The rendering area is divided into a regular grid. Random star point positions and size parameters are generated for each grid. Star points with soft edges are generated within the grid. Based on the real-time position of the interactive object in the game scene, its distance and directional relationship with each star point are calculated. A pushing force is applied to nearby star points to deviate them from the touch point. Finally, the adjusted star points are rendered onto the screen, achieving the "blue tears" dynamic avoidance effect.

[0069] In a light spot rendering method provided in one embodiment of this application, region processing based on coordinate information includes: Step S21: Extract the horizontal coordinate component from the world coordinates; Step S22: Scale the horizontal coordinate components to obtain scaled coordinates; Step S23: The scaled coordinates are divided into grids using the grid density value, and the grid index is determined by rounding down.

[0070] The method provided in this embodiment enables efficient spatial management of complex scenes through precise coordinate extraction and scaling, improves the regularity and consistency of light point generation, and thus enhances the quality of rendering effects and operating efficiency.

[0071] The above plan will be explained in detail below.

[0072] In step S21, the horizontal coordinate component in the world coordinates is extracted.

[0073] The horizontal coordinate components are the X-axis and Z-axis coordinate values ​​selected from the three-dimensional coordinate system, which are used to determine the specific position information of the pixel on the horizontal plane.

[0074] In an optional implementation, the horizontal coordinate components are extracted through a coordinate deconstruction operation, which decomposes the three-dimensional coordinate vector into independent coordinate components. For example, after receiving the three-dimensional coordinates (x, y, z) of the pixel to be rendered, the terminal device directly extracts the x and z components to form a two-dimensional planar coordinate pair (x, z), which represents the projection position of the pixel on the horizontal plane.

[0075] In an optional implementation, the coordinate component extraction process considers the transformation relationships of the coordinate system to ensure that the extracted components are consistent with the current rendering environment. For example, when the scene uses a right-handed coordinate system, the terminal device extracts the x and z components according to the standard coordinate axis definition, while considering possible coordinate system rotation or translation transformations and performing corresponding transformation processing on the extracted coordinate components.

[0076] In step S22, the horizontal coordinate components are scaled to obtain scaled coordinates.

[0077] Scaling is a process of adjusting the range of coordinate values ​​through mathematical transformations, with the aim of mapping the original coordinates to a range of values ​​suitable for subsequent processing.

[0078] In an optional implementation, the scaling process employs a linear transformation, multiplying the coordinate components using a preset scaling factor. For example, the terminal device sets the scaling factor to 0.1, converting the extracted horizontal coordinate component (100, 200) into scaled coordinates (10, 20), ensuring that the coordinate values ​​fall within a reasonable processing range, facilitating subsequent calculations.

[0079] In one optional implementation, the scaling factor is dynamically determined based on the spatial scale of the scene to achieve adaptive coordinate adjustment. For example, for large-scale scenes, the terminal device selects a smaller scaling factor to compress the coordinate range; for small-scale scenes, a larger scaling factor is selected to expand the coordinate accuracy, ensuring optimal processing results in different scenes.

[0080] In step S23, the scaled coordinates are divided into grids using the grid density value, and the grid index is determined by rounding down.

[0081] Among them, the grid density value is a parameter that controls the fineness of spatial segmentation and determines the number of grids generated per unit length.

[0082] In an alternative implementation, the meshing process is achieved by discretizing a continuous coordinate space into a regular mesh structure. For example, the terminal device sets the mesh density value to 2, divides the scaled coordinates (10.7, 20.3) by the mesh density value to obtain (5.35, 10.15), and then obtains the mesh index (5, 10) by rounding down. This index uniquely identifies the mesh position to which the pixel belongs.

[0083] The floor function is a mathematical floor function that converts a floating-point number into the largest integer not greater than that number.

[0084] In one optional implementation, the floor function ensures the consistency and determinism of the grid index, with all pixels within the same grid corresponding to the same index value. For example, the terminal device performs floor function on the calculated grid coordinate value (5.35, 10.15) to obtain the integer index (5, 10). All pixels falling within this grid range will receive the same index value, ensuring the regularity of light spot generation.

[0085] In a specific application, when processing the starry sky effect in a game scene, the terminal device first extracts the horizontal coordinate component of each star pixel, then uses a preset scaling factor to adjust the coordinate values ​​to a suitable processing range, and finally divides the continuous starry sky region into discrete grid units through the grid density parameter, providing a stable spatial basis for the subsequent generation of star light effects.

[0086] In a specific application of this embodiment, when rendering night scene city lighting effects, the terminal device extracts the horizontal coordinate components of the pixels on the surface of buildings, performs appropriate scaling on these coordinates to adapt to the processing range of the rendering pipeline, and then uses a preset grid density value to orderly divide the entire city area into regular processing units. Each unit obtains a unique index identifier through a rounding down operation, which lays a precise spatial positioning foundation for generating light spot effects with different characteristics in each area.

[0087] In a light spot rendering method provided in one embodiment of this application, generating the light spot position offset and light spot size through a pseudo-random function includes: Step S31: Use the index of the target grid cell as a random seed; Step S32: Based on the random seed, generate a first random value and a second random value through trigonometric function operations; Step S33: Determine the position offset of the light spot based on the first random value; Step S34: Determine the size of the light spot based on the second random value.

[0088] The method provided in this embodiment ensures the consistency and reproducibility of light spot generation through the index-based random seed mechanism. At the same time, the random values ​​generated by trigonometric function operations ensure the naturalness of the distribution of light spot positions and sizes, avoiding the clustering or regularity problems that may occur in traditional random number generation, thereby improving the visual quality and rendering efficiency of light spot rendering.

[0089] The above plan will be explained in detail below.

[0090] In step S31, the index of the target grid cell is used as a random seed.

[0091] The index value serves as a unique identifier for the current processing unit within the overall layout structure. The index value is determined based on the unit's position coordinates in two-dimensional or three-dimensional space, which are converted into numerical identifiers using a specific encoding algorithm. This identification mechanism ensures that each unit possesses unique and reproducible numerical characteristics, providing a stable input foundation for subsequent numerical calculations.

[0092] In an alternative implementation, the index value is generated using a coordinate hashing algorithm, which converts the row and column coordinates of the cell into a single integer value. For example, for a cell with coordinates (x, y), this can be achieved using the formula index = x + y. The width is calculated to obtain a unique index value, where width represents the total number of cells in the horizontal direction.

[0093] In an alternative implementation, the index value may also contain hierarchy information to distinguish units at different levels of detail. For example, in a multi-level rendering system, the index value may be encoded as level_id. The expression is in the form of max_units + unit_id, where level_id represents the current level and unit_id represents the unit identifier within that level.

[0094] In step S32, based on the random seed, a first random value and a second random value are generated through trigonometric function operations.

[0095] Among them, trigonometric function operations are numerical transformation processes based on periodic mathematical functions. Utilizing the properties of periodic functions such as sine and cosine, trigonometric function operations map the input seed value to a specific numerical range, producing output results with pseudo-random distribution characteristics. This operation method has the advantages of high computational efficiency, reproducible results, and uniform distribution, making it particularly suitable for performance-critical applications in real-time graphics rendering.

[0096] In an optional implementation, the trigonometric function operations are performed using a combination of sine and cosine functions, through sin(seed) factor1) and cos(seed) factor2) generates two independent random values. For example, when the seed value is 123, sin(123) can be calculated. 12.9898) and cos(123) 78.233), resulting in two random values ​​in the range [-1, 1].

[0097] In an alternative implementation, trigonometric function operations may also include multiple nested calculations, increasing randomness through the form of sin(cos(seed)) or cos(sin(seed)).

[0098] In step S33, the position offset of the light spot is determined based on the first random value.

[0099] Position offset refers to the spatial displacement of the light spot relative to a reference position. Position offset achieves randomized distribution of light spot positions by mapping random values ​​to a spatial coordinate system. This offset mechanism breaks regular arrangement patterns, creating a more natural and realistic visual effect while maintaining the overall layout's harmony and controllability.

[0100] In an alternative implementation, the position offset maps the random value to a specified offset range through a linear transformation, calculated as offset = (random_value - 0.5). max_offset. For example, when the first random value random_value is 0.7 and the maximum offset max_offset is 2.0, the position offset in the x-direction is (0.7 - 0.5). 2.0 = 0.4 units.

[0101] In an alternative implementation, the positional offset can also employ a non-linear mapping method, adjusting the offset distribution characteristics through a power function or exponential function. For example, using pow(random_value, 2.0) can make the offset values ​​more inclined to approach the boundary, while using sqrt(random_value) will concentrate the offset values ​​more in the central region, thereby achieving different visual distribution effects.

[0102] In step S34, the size of the light spot is determined based on the second random value.

[0103] Among them, the size parameter is a numerical attribute that controls the visual size of the light spot. The size parameter determines the coverage area and visual intensity of the light spot in the screen space, and the size of the light spot can be varied by adjusting this parameter. A reasonable size distribution can enhance the sense of layering and realism of the scene, and avoid the artificial feeling caused by an overly uniform size distribution.

[0104] In an alternative implementation, the size parameter is determined by mapping random values ​​to a preset size range, calculated as size = min_size + random_value. (max_size - min_size); where min_size represents the minimum size, max_size represents the maximum size, and random_value represents a random value.

[0105] In an alternative implementation, the size parameters can also incorporate a non-uniform distribution mechanism, adjusting the size distribution curve using a logarithmic or exponential function. For example, log(1 + random_value) can be used. 9) It can produce a distribution effect of more small light spots and a small number of large light spots, simulating the distribution characteristics of particle size in the natural environment.

[0106] In a specific application of this embodiment, when the terminal device needs to generate a light spot for a specific unit, the system extracts the index value of the unit as the basis for calculation and quickly generates two sets of random values ​​through the built-in trigonometric function algorithm. The first set of values ​​is transformed by coordinates to determine the spatial offset of the light spot, and the second set of values ​​is mapped by size to determine the display size of the light spot. The whole process ensures the randomness and consistency of the light spot parameters.

[0107] In a light spot rendering method provided in one embodiment of this application, generating light spots within a target mesh cell based on the light spot position offset and the light spot size includes: Step S41: Determine the center position of the light spot. The center position of the light spot is determined based on the center coordinates of the target mesh cell and the offset of the light spot position. Step S42: Calculate the second distance between the pixel to be rendered and the center position of the light spot; Step S43: Calculate pixel transparency using a preset smooth interpolation function based on the second distance and the size of the light spot; Step S44: Generate light spots based on pixel transparency.

[0108] The method provided in this embodiment enables the generation of high-quality light spots with smooth edge transitions through precise calculation of the center position of the light spot and distance-based transparency interpolation, thereby improving the visual effect and realism of the light spot rendering. At the same time, the use of mathematical functions ensures the efficiency and stability of the rendering process.

[0109] The above plan will be explained in detail below.

[0110] In step S41, the center position of the light spot is determined based on the center coordinates of the target grid cell and the offset of the light spot position.

[0111] The center position of the light spot is the final core positioning point of the light spot obtained by performing vector operations on the reference center coordinates of the target grid cell and the randomly generated position offset.

[0112] In an optional implementation, the center position of the light spot is determined through coordinate superposition operations. Specifically, this involves using the geometric center of the target mesh cell as a basic positioning reference, and then performing vector addition operations between the pre-calculated position offset vector and the basic coordinates. For example, when the center coordinates of the target mesh cell are (50, 50) and the position offset is (3, -2), the terminal device calculates the center position of the light spot as (53, 48), which will serve as the core reference point for subsequent distance calculations and transparency distribution.

[0113] In an optional implementation, the determination of the light spot center position also considers mesh boundary constraints. A boundary detection mechanism ensures that the light spot center position is always within the effective rendering range, avoiding rendering anomalies caused by excessive positional offset. For example, when the calculated light spot center position exceeds the boundary range of the current mesh cell, the terminal device will automatically perform coordinate correction, clamping the excess portion to ensure that the light spot is always rendered correctly within the expected display area.

[0114] In step S42, the second distance between the pixel to be rendered and the center position of the light spot is calculated.

[0115] The second distance is the measured spatial geometric distance between the coordinates of the pixel to be rendered and the coordinates of the center of the light spot.

[0116] In an optional implementation, the second distance is calculated using the Euclidean distance formula, specifically by calculating the straight-line distance between two coordinate points on a two-dimensional plane. This distance value directly affects the pixel's transparency distribution and the visual boundary effect of the light spot. For example, when the pixel to be rendered is located at (55, 50) and the center of the light spot is located at (53, 48), the second distance calculated by the terminal device is √[(55-53)²+(50-48)²] = √8 ≈ 2.83. This distance value will be used for subsequent transparency interpolation calculations.

[0117] In an optional implementation, the calculation of the second distance also supports multiple distance metrics, including Manhattan distance and Chebyshev distance. Different distance calculation methods will produce different light spot shape characteristics and edge transition effects. For example, when Manhattan distance is used, the terminal device will produce a light spot effect with diamond-shaped boundary characteristics, while when Chebyshev distance is used, a light spot with square boundary characteristics will be generated, providing flexible choices for different visual needs.

[0118] In step S43, the pixel transparency is calculated using a preset smooth interpolation function based on the second distance and the size of the light spot.

[0119] Among them, pixel transparency is a pixel transparency value calculated by mathematical interpolation function based on the distance attenuation principle, which is used to control the smooth transition effect of the light spot edge.

[0120] In an optional implementation, pixel transparency is calculated using a smooth interpolation function that takes the ratio of a second distance to the spot size as input and outputs a transparency coefficient ranging from 0 to 1, achieving a smooth transparency transition from the center to the edge of the spot. For example, when the second distance is 2.83 and the spot size is 5.0, the terminal device first calculates the distance ratio 2.83 / 5.0 = 0.566, and then uses the smoothstep function to calculate a transparency value of approximately 0.68, which indicates that the current pixel has medium transparency.

[0121] In one optional implementation, the preset smooth interpolation function supports multiple interpolation algorithms, including linear interpolation, cubic interpolation, and exponential interpolation. Different interpolation methods produce different light spot edge characteristics and visual effects. For example, when using the cubic interpolation algorithm, the terminal device can generate light spot effects with more natural and smooth edge transitions, avoiding the harsh boundaries that may be produced by linear interpolation, and improving the overall visual quality and realism.

[0122] In step S44, light spots are generated based on pixel transparency.

[0123] Among them, light spot generation involves applying the calculated transparency value to the pixel color information to form visual light spot elements with a transparency gradient effect.

[0124] In an optional implementation, the light spot generation is achieved by mixing the pixel transparency with a preset light spot color. Specifically, this includes using the transparency value as an alpha channel component and combining it with the RGB color components to form complete pixel color information. For example, when the pixel transparency is 0.68 and the preset light spot color is white (255, 255, 255), the final pixel color generated by the terminal device is (255, 255, 255, 173), where 173 is the 8-bit alpha value corresponding to a transparency of 0.68.

[0125] In an optional implementation, the light spot generation also supports multiple color blending modes, including additive blending, multiplicative blending, and overlay blending. Different blending modes can produce different visual effects and scene blending characteristics of the light spots. For example, when using the additive blending mode, the terminal device will perform an additive operation on the light spot color and the background color to produce a bright halo effect, which is particularly suitable for rendering scenes that simulate luminous objects and particle effects.

[0126] In a specific application, when the terminal device processes the rendering of a starry sky scene, it first determines the center position of each star point as the grid center coordinates (100, 100) plus a random offset (2, -3) to obtain (102, 97). Then, it calculates the distance between the current pixel to be rendered (105, 99) and the center of the star point as √13≈3.6. Next, it calculates the distance ratio of 0.45 based on the star point size of 8.0, and obtains the transparency of 0.85 through a smooth interpolation function, finally generating a bright star point pixel with 85% transparency.

[0127] In a light spot rendering method provided in one embodiment of this application, adjusting the display position of the light spot based on a first distance and direction relationship includes: Step S51: Calculate the direction vector from the light spot to the interactive object; Step S52: Calculate the thrust intensity based on the first distance, wherein the thrust intensity is inversely proportional to the distance; Step S53: Calculate the position adjustment vector based on the direction vector and thrust intensity; Step S54: Apply the position adjustment vector to the center position of the light spot to obtain the adjusted center position of the light spot.

[0128] The method provided in this embodiment enables intelligent position adjustment and dynamic response between the light spot and the interactive object through direction vector calculation and distance-based thrust intensity adjustment, improving the smoothness of the interactive experience and the realism of the visual feedback. At the same time, mathematical vector operations ensure the accuracy and real-time performance of the position adjustment.

[0129] The above plan will be explained in detail below.

[0130] In step S51, the direction vector from the light spot to the interactive object is calculated.

[0131] The direction vector is a standardized two-dimensional vector pointing from the current position of the light spot to the position of the interactive object, used to determine the specific direction of position adjustment.

[0132] In an optional implementation, the direction vector is obtained through coordinate difference calculation and vector standardization. Specifically, this includes calculating the difference vector between the coordinates of the interactive object and the coordinates of the light point, and then normalizing the length of this vector to obtain a unit direction vector. For example, when the light point position is (50, 60) and the interactive object position is (80, 90), the terminal device first calculates the difference vector (30, 30), then calculates the vector length √(30² + 30²) ≈ 42.4, and finally obtains the standardized direction vector (0.707, 0.707).

[0133] In an optional implementation, the calculation of the direction vector also considers boundary case handling. When the position of the light point coincides with that of the interactive object or the distance is extremely small, the system will use a default direction vector or a random direction vector to avoid calculation anomalies caused by a zero vector. For example, when the position difference between two objects is less than 0.01 pixels, the terminal device will automatically set the direction vector to a preset value such as (1,0) or (0,1) to ensure the stability and reliability of subsequent calculations.

[0134] In step S52, the thrust intensity is calculated based on the first distance, wherein the thrust intensity is inversely proportional to the distance.

[0135] The thrust intensity is a force coefficient calculated based on the distance between the light spot and the interactive object, used to control the strength of the position adjustment. In an optional implementation, the thrust intensity is calculated using an inverse proportional function. Specifically, a base intensity coefficient is set and divided by the distance value to achieve an interactive effect where the closer the distance, the stronger the thrust. This mechanism simulates the repulsive or attractive properties in the physical world. For example, when the first distance is 10.0 and the base intensity coefficient is set to 100, the thrust intensity calculated by the terminal device is 100 / 10.0 = 10.0. This intensity value will directly affect the magnitude of the light spot position adjustment.

[0136] In an optional implementation, the thrust strength calculation also includes a strength limiting mechanism. By setting a maximum and a minimum strength threshold, it prevents thrust anomalies caused by excessively small or large distances, ensuring the rationality and controllability of the position adjustment effect. For example, when the calculated thrust strength exceeds the set maximum value of 50.0, the terminal device will automatically limit the strength value to 50.0 to avoid excessively drastic jumps in the position of the light spot.

[0137] In step S53, the position adjustment vector is calculated based on the direction vector and thrust intensity.

[0138] The position adjustment vector is a two-dimensional vector obtained by scalar multiplication of the direction vector and the thrust intensity, representing the specific offset that the position of the light spot needs to be adjusted.

[0139] In an optional implementation, the position adjustment vector is calculated using vector scalar multiplication. Specifically, each component of the standardized direction vector is multiplied by the thrust intensity value to obtain an adjustment vector with a defined direction and magnitude. For example, when the direction vector is (0.707, 0.707) and the thrust intensity is 10.0, the position adjustment vector calculated by the terminal device is (7.07, 7.07), which indicates that the light spot needs to move 7.07 pixels to the upper right.

[0140] In an optional implementation, the calculation of the position adjustment vector also supports multiple adjustment modes, including linear adjustment, exponential adjustment, and damping adjustment. Different adjustment modes can produce different dynamic response characteristics and visual effects. For example, when using the damping adjustment mode, the terminal device introduces a damping coefficient into the position adjustment vector calculation, making the position change of the light spot gradually slow down, resulting in a smoother and more natural animation effect.

[0141] In step S54, the position adjustment vector is applied to the center position of the light spot to obtain the adjusted center position of the light spot.

[0142] The adjusted center position of the light spot is the new coordinate position obtained by adding the original center position of the light spot and the position adjustment vector.

[0143] In an optional implementation, the adjusted center position of the light spot is determined by vector addition. Specifically, the coordinate components of the original center position of the light spot are added to the corresponding components of the position adjustment vector to obtain the final display position of the light spot under the influence of interaction. For example, when the original center position of the light spot is (50, 60) and the position adjustment vector is (7.07, 7.07), the terminal device calculates the adjusted center position of the light spot as (57.07, 67.07), which will be used as the display coordinates of the light spot in the final rendering.

[0144] In an optional implementation, the adjusted center position of the light spot also needs to be validated, including boundary checks and reasonableness judgments, to ensure that the adjusted position is still within the effective rendering range and to avoid display anomalies caused by excessive position adjustment. For example, when the adjusted position exceeds the screen boundary, the terminal device will automatically perform position correction and perform boundary constraint processing on the excess part to ensure that the light spot is always correctly displayed within the visible area.

[0145] In a specific application, when the terminal device processes the interaction between the mouse pointer and the particle system, it first calculates the direction vector (0.707, 0.707) of the particle (100, 200) pointing to the mouse position (150, 250). Then, it calculates the thrust intensity of 1.41 based on the distance of 70.7. Next, it calculates the position adjustment vector (1.0, 1.0) and finally adjusts the particle position to (101, 201) to achieve the dynamic effect of the particle being repelled by the mouse.

[0146] In a light spot rendering method provided in one embodiment of this application, after dividing the rendering area into multiple grid units based on world coordinates, the method further includes: Step S61: Determine the adjacent grid cells of the target grid cell; Step S62: Generate corresponding spot position offsets and spot sizes for each of the adjacent grid cells; Step S63: Generate light spots in the adjacent grid cells respectively; Step S64: Combine the light spots in the target grid cell and the adjacent grid cells.

[0147] The method provided in this embodiment enables the light points of adjacent grid units to participate in the rendering process, avoiding the boundary discontinuity problem that may occur when rendering a single grid unit. Through the light point synthesis processing of multiple grid units, a more natural and continuous light point distribution effect is achieved, improving the visual quality and realism of the final rendered image.

[0148] The above plan will be explained in detail below.

[0149] In step S61, the adjacent grid cells of the target grid cell are determined.

[0150] Among them, the adjacent grid cell is the grid cell that is adjacent to or close to the target grid cell in space. It is used to expand the influence range of the light spot rendering and ensure the continuity of the light spot distribution.

[0151] In one optional implementation, the determination of adjacent grid cells is based on the grid topology. By analyzing the position index of the target grid cell in the grid system, the index coordinates of its surrounding grid cells are calculated. For example, when the index of the target grid cell is (i,j), the terminal device can determine its eight adjacent grid cells, including grid cells at positions such as (i-1,j-1), (i-1,j), (i-1,j+1), (i,j-1), (i,j+1), (i+1,j-1), (i+1,j), and (i+1,j+1).

[0152] In an optional implementation, the selection of adjacent grid cells can also be based on a distance threshold. By calculating the distance between each candidate grid cell and the center point of the target grid cell, grid cells with a distance less than a preset threshold are selected as adjacent grid cells. For example, if the terminal device sets the adjacent distance threshold to the width of two grid cells, then all grid cells whose distance from the center of the target grid cell is within this threshold are considered adjacent grid cells.

[0153] In step S62, corresponding spot position offsets and spot sizes are generated for each of the adjacent grid cells.

[0154] Among them, the light spot position offset is the offset relative to the center of the grid cell when determining the specific position of the light spot in the adjacent grid cell, and the light spot size is the size parameter of the light spot generated in the adjacent grid cell. By generating these parameters independently for each adjacent grid cell, it is ensured that the light spots in different grid cells have their own characteristics.

[0155] In an optional implementation, the generation process of the spot position offset and spot size of adjacent grid cells is similar to that of the target grid cell. This involves using the index of each adjacent grid cell as a random seed input into a pseudo-random function to generate corresponding random values. For example, for an adjacent grid cell with index (i+1,j), the terminal device converts this index value into a seed value and generates the unique position offset and size parameters of that grid cell through trigonometric function calculations.

[0156] In an optional implementation, to maintain the correlation of light spot characteristics between adjacent grid cells, an adjacency influence factor can be introduced during the generation process, so that the parameters generated by adjacent grid cells have a certain degree of continuity while maintaining randomness. For example, when generating light spot sizes for adjacent grid cells, the terminal device will consider the light spot size of the target grid cell and adjust the light spot sizes of adjacent grid cells by weighted averaging, so that the overall light spot distribution is more harmonious.

[0157] In step S63, light spots are generated in the adjacent grid cells respectively.

[0158] Generating light spots within adjacent grid cells refers to creating the geometric shape and transparency distribution of light spots within the corresponding grid cell space based on the position offset and size of the light spots in each adjacent grid cell, thus providing light spot data for subsequent compositing processing.

[0159] In an optional implementation, the generation process of light spots within adjacent mesh cells follows the same algorithm as the target mesh cell, involving steps such as determining the center position of the light spot, calculating pixel distances, and applying a smooth interpolation function. For example, for an adjacent mesh cell, the terminal device first determines the center of the light spot based on the center coordinates of the mesh cell and the generated position offset, then calculates the distance between the pixel to be rendered and the center of the light spot, and finally calculates the corresponding transparency value using a smooth interpolation function.

[0160] In an optional implementation, the generation of light spots within adjacent mesh cells also needs to consider boundary handling. When adjacent mesh cells are located at the boundary of the rendering area, the parts that exceed the boundary need to be clipped or specially processed. For example, when part of an adjacent mesh cell exceeds the current rendering viewport range, the terminal device will limit the range of influence of the light spots, only performing light spot calculations on pixels within the viewport to avoid unnecessary computational overhead.

[0161] In step S64, the light spots in the target grid cell and the adjacent grid cells are combined.

[0162] The compositing process involves combining and fusing the light spot effects generated in the target mesh cell and multiple adjacent mesh cells. An appropriate blending algorithm is used to unify the contributions of multiple light spots into the final pixel rendering result.

[0163] In an optional implementation, the light spot compositing process employs a transparency overlay method, accumulating the light spot transparency of the target mesh cell and each adjacent mesh cell, but it is necessary to prevent the transparency from exceeding the maximum value of 1.0. For example, when the pixel to be rendered is affected by the light spot transparency of the target mesh cell (0.3) and the light spot transparency of two adjacent mesh cells (0.2 and 0.4 respectively), the terminal device will perform appropriate blending operations on these transparency values, possibly using saturation addition or other blending functions to ensure that the final transparency is within a reasonable range.

[0164] In an optional implementation, the compositing process may also consider distance weighting, weighting the contribution of light points within different grid cells according to the distance relationship between each grid cell and the pixel to be rendered. For example, light points in grid cells closer to the pixel to be rendered have higher weights, while the weights of light points in adjacent grid cells farther away are correspondingly reduced. The terminal device achieves a more realistic light point rendering effect through this weighted compositing method.

[0165] In a specific application, when rendering a starry sky scene, the terminal device determines the eight surrounding neighboring grid cells as the influence area for the target grid cell (5,3) where the current pixel is located. For each neighboring grid cell, unique star position offset and brightness parameters are generated using its index, and then corresponding star effects are generated within each grid cell. Finally, through a transparency-weighted compositing method, the multiple star effects from the target grid cell and neighboring grid cells are merged into the final rendering result of that pixel, achieving a natural and continuous distribution of starlight points in the sky.

[0166] In a specific application of this embodiment, when the terminal device processes a particle effect rendering scene, after determining that the pixel to be rendered is located in grid cell (10, 15), the system identifies the eight neighboring grid cells surrounding that grid cell. For each neighboring grid cell, the terminal device uses its unique grid index as a seed to generate the position offset and size parameters of the particles within that grid cell using a hash function and a trigonometric function. Subsequently, the corresponding particle light spot effects are generated in each neighboring grid cell according to the same algorithm. Finally, the particle effects of the target grid cell and all neighboring grid cells are synthesized using a distance-weighted method to generate the final rendered color and transparency of that pixel location.

[0167] In a light spot rendering method provided in one embodiment of this application, determining the adjacent mesh cells of the target mesh cell includes: With the target grid cell as the center, grid cells within a preset range are determined as the adjacent grid cells.

[0168] The method provided in this embodiment makes the determination of adjacent grid cells have a clear spatial range limit, avoiding the waste of computing resources caused by processing distant grid cells without limit. By limiting the range, the continuity of light spot rendering is guaranteed, while the computational complexity is controlled, thus achieving a balance between rendering quality and performance.

[0169] The above plan will be explained in detail below.

[0170] With the target grid cell as the center, grid cells within a preset range are determined as the adjacent grid cells.

[0171] Here, "centering on the target grid cell" means taking the position of the target grid cell as the reference origin, and the preset range is the size of the spatial area set around the target grid cell, which is used to limit the search and selection range of adjacent grid cells.

[0172] In an optional implementation, the preset range can be defined by a distance threshold, setting a circular or square area with the center of the target grid cell as the origin. All grid cells whose center falls within this area are considered adjacent grid cells. For example, when the preset range has a radius of 2 grid cells, the terminal device calculates the Euclidean distance between the center of each candidate grid cell and the center of the target grid cell, and selects all grid cells whose distance is less than or equal to the width of 2 grid cells as adjacent grid cells.

[0173] In an optional implementation, the preset range can also be defined by grid layers, expanding outwards from the target grid cell by a specified number of grid layers to form a regular grid area. For example, when the set range is one layer, the adjacent grid cells include the eight directly adjacent grid cells surrounding the target grid cell; when the set range is two layers, the adjacent grid cells also include the 16 grid cells of the second layer. The terminal device systematically determines the range of adjacent grid cells through this hierarchical expansion method.

[0174] Among them, the grid cell is the basic spatial unit after the rendering area is divided. Each grid cell has independent index coordinates and boundary range. The determination of adjacent grid cells needs to be calculated based on the spatial relationship of these grid cells.

[0175] In one optional implementation, the boundary and size of the grid cell determine the method for determining adjacency. When the grid cell is square, the adjacency between grid cells can be calculated using Manhattan distance or Chebyshev distance. For example, for a target grid cell with index (i,j), the terminal device can determine adjacent grid cells by checking the absolute value of the index difference. When |Δi|+|Δj|≤ a preset threshold, the corresponding grid cell is identified as an adjacent grid cell.

[0176] In an alternative implementation, the adjacency of mesh cells may also be limited by the rendering region boundary. When the target mesh cell is located at the edge of the region, some theoretically adjacent mesh cells may be outside the effective rendering range. For example, when the target mesh cell is located at the left boundary of the rendering region, its theoretically adjacent mesh cells to the left do not actually exist. The terminal device needs to perform boundary checks when determining adjacent mesh cells to exclude mesh cells that are outside the effective range.

[0177] In a specific application, when the terminal device processes the rendering of a dynamic particle system, a preset range is set as a circular area with a radius of 1.5 grid units. When the target grid unit index is (8,12), the terminal device calculates the distance between each surrounding grid unit and the center of the target unit, and determines the grid units with a distance less than or equal to 1.5 grid unit widths as adjacent grid units, including grid units such as (7,11), (7,12), (7,13), (8,11), (8,13), (9,11), (9,12), and (9,13), thereby providing a suitable influence range for subsequent light spot synthesis processing.

[0178] In one specific application of this embodiment, when rendering fireworks explosion effects, the terminal device uses the target grid cell (15,20) as the center point and sets a square area with a preset range of 2 grid cells. The terminal device determines that the area contains 25 grid cells as adjacent grid cells by calculating the difference in grid indices, i.e., a 5×5 grid area from (13,18) to (17,22). These adjacent grid cells provide sufficient space for rendering the fireworks particles, ensuring the integrity of the explosion effect while avoiding unnecessary calculations for excessively distant grid cells.

[0179] In a light spot rendering method provided in one embodiment of this application, after obtaining the world coordinates of the pixel to be rendered, the method includes: Step S81: Obtain the observer's gaze direction relative to the pixel to be rendered; Step S82: Calculate the parallax offset based on the line of sight direction; Step S83: Apply the parallax offset to the local coordinates to generate light spots with depth levels.

[0180] The method provided in this embodiment enables the generation of light spot effects with a three-dimensional sense of depth on a two-dimensional plane by introducing the observer's line of sight and parallax offset calculation, which significantly improves the visual hierarchy and three-dimensionality of the light spot rendering. At the same time, the accurate parallax calculation ensures the realism and accuracy of the depth effect.

[0181] The above plan will be explained in detail below.

[0182] In step S81, the observer's gaze direction relative to the pixel to be rendered is obtained.

[0183] In this context, the observer is the viewpoint subject of the current scene being observed, and its line of sight relative to the pixel to be rendered reflects the spatial directional relationship from the observer's position to the pixel's position.

[0184] In an optional implementation, the observer's gaze direction is determined by calculating the vector difference between the observer's position coordinates and the coordinates of the pixel to be rendered. This direction vector, after normalization, represents the unit direction vector from the observer to the pixel. For example, when the observer is located at the center of the scene (0,0,10) and the pixel to be rendered is located at (5,5,0), the terminal device calculates the gaze direction vector as (0.577,0.577,-0.577), which accurately describes the spatial direction relationship of the observer's view of the pixel.

[0185] In an optional implementation, the observer's gaze direction can also be calculated through camera parameter matrix transformation. By utilizing the camera's position, orientation, and projection parameters, the pixel coordinates in screen space are projected inversely to world space, thereby obtaining the corresponding gaze direction vector. For example, the terminal device converts the screen coordinates (320, 240) into a gaze direction in world space based on the camera's view matrix and projection matrix, ensuring the accuracy and consistency of the gaze direction calculation.

[0186] In step S82, the parallax offset is calculated based on the line of sight direction.

[0187] Among them, the parallax offset is a spatial displacement parameter calculated based on the observer's line of sight, used to simulate the visual difference in the position of an object under different viewing angles.

[0188] In an optional implementation, the parallax offset is calculated by multiplying the gaze direction vector by a preset depth parameter. The depth parameter controls the strength of the parallax effect; a larger depth parameter produces a more pronounced stereoscopic effect. For example, when the gaze direction is (0.6, 0.8, 0) and the depth parameter is 2.0, the terminal device calculates a parallax offset of (1.2, 1.6, 0), which will be used in the subsequent coordinate adjustment process.

[0189] In an optional implementation, the calculation of the parallax offset also considers pixel depth information. The offset intensity is adjusted by the depth value in the depth buffer, so that pixels at different depth levels produce corresponding parallax effects. For example, for a pixel with a depth value of 0.5, the terminal device scales the parallax offset to half of its original value to achieve a more realistic depth effect.

[0190] In step S83, the parallax offset is applied to the local coordinates to generate light spots with depth levels.

[0191] The local coordinate application is a coordinate transformation process that superimposes the calculated parallax offset onto the original local coordinates, thereby achieving three-dimensional adjustment of the light spot position.

[0192] In one optional implementation, the parallax offset is directly vector-added with the local coordinates to obtain the adjusted coordinate position, which reflects the spatial distribution of the light spot after considering the observer's viewpoint. For example, when the original local coordinates are (2.5, 3.0) and the parallax offset is (0.5, 0.2), the terminal device calculates the adjusted local coordinates as (3.0, 3.2), thus achieving parallax adjustment of the light spot position.

[0193] In one optional implementation, depth layering is generated by applying parallax offsets of varying intensities to light spots at different depth levels. Foreground light spots receive larger offsets, while background light spots receive smaller offsets, thus creating a distinct sense of depth visually. For example, the terminal device applies a 100% parallax offset to foreground light spots, a 60% offset to mid-ground light spots, and a 30% offset to background light spots, creating a rich depth layering effect.

[0194] In a specific application, when a user observes the starry sky effect in a virtual reality scene, the terminal device first obtains the viewing direction of the user's head-mounted device, calculates the line-of-sight vector from the user's position to each star pixel, then calculates the corresponding parallax offset based on the preset depth value of the star, and finally applies these offsets to the local coordinates of the star, so that the nearby star points produce a larger displacement as the user's viewing angle changes, and the distant star points produce a smaller displacement, thereby creating a realistic sense of depth in a three-dimensional starry sky.

[0195] In one specific application of this embodiment, when the terminal device renders the magic light effects in the game scene, it obtains the player character's viewing angle, calculates the line of sight from the character's position to the light effect particles, calculates the parallax offset based on the layer setting of the light effect, and applies the offset to the coordinates of the light effect particles, so that the light effect particles in the foreground produce obvious parallax movement, while the light effect particles in the background remain relatively stable, creating a three-dimensional light effect display with distinct layers.

[0196] In a light spot rendering method provided in one embodiment of this application, rendering and outputting the adjusted light spot further includes: Step S91: Obtain the color information of the base rendered image; Step S92: The color information of the light point is mixed with the color information of the base rendering image to obtain the mixed color information; Step S93: Output the mixed color information to the frame buffer.

[0197] The method provided in this embodiment enables the natural fusion of light spots and background scenes by acquiring basic image color information and accurately mixing it with the color of light spots, which significantly improves the realism and visual quality of the rendering effect. At the same time, a reasonable mixing algorithm ensures the smoothness of color transition and the accuracy of the final output.

[0198] The above plan will be explained in detail below.

[0199] In step S91, the color information of the base rendered image is obtained.

[0200] The base rendering image is the scene image content that has been completed before the light spot rendering, which includes color data of various visual elements such as background, objects, and materials.

[0201] In one optional implementation, the color information of the base rendered image is obtained by reading the RGBA value of the corresponding pixel position in the frame buffer. This color information reflects the original scene content at the current pixel position. For example, when the terminal device processes the pixel at screen coordinates (100, 200), it reads the color value of that position from the frame buffer as RGB(120, 80, 200), which represents the color representation of the base scene at that position.

[0202] In an optional implementation, color information acquisition also includes processing the multi-sampling anti-aliasing buffer. By averaging the color values ​​of multiple sampling points, a smoother and more accurate base color information is obtained. For example, the terminal device acquires the color values ​​RGB(100,50,150), RGB(110,60,160), RGB(105,55,155), and RGB(115,65,165) for four sampling points of a pixel, respectively, and calculates the average value to obtain the final base color RGB(107.5,57.5,157.5).

[0203] In step S92, the color information of the light spot is mixed with the color information of the base rendered image to obtain the mixed color information.

[0204] Color mixing is a computational process that combines the color of the light spot with the color of the base image using a specific algorithm, thereby achieving the organic fusion of the two color information.

[0205] In an optional implementation, the color mixing employs an Alpha blending algorithm, which weights the light spot color and the base color based on the light spot's transparency value. Light spots with higher transparency contribute more to the final color. For example, when the light spot color is RGB(255,255,0) and the transparency is 0.6, and the base color is RGB(100,100,100), the terminal device calculates the mixed color as RGB(193,193,60), achieving a natural blending of the yellow light spot with the gray background.

[0206] The weighted average calculation is a mixing method that calculates the values ​​of different color components based on their transparency weights, ensuring smooth color transitions and continuous visual effects.

[0207] In an optional implementation, the weighted average calculation is achieved using the formula "Final Color = Spot Color × Transparency + Base Color × (1 - Transparency)", which ensures the mathematical accuracy and visual plausibility of the color mixing. For example, when a terminal device processes the mixing of a blue spot RGB(0,0,255) with a transparency of 0.3 and a red background RGB(255,0,0), the calculated mixed color is RGB(178.5,0,76.5), resulting in a purplish-red mixed effect.

[0208] In an optional implementation, color mixing also supports multiple mixing modes, including additive mixing, multiplicative mixing, and screen mixing, allowing the selection of an appropriate mixing algorithm based on different visual requirements. For example, for light spots with an luminous effect, the terminal device uses an additive mixing mode to directly superimpose the light spot color onto the base color, producing a brighter luminous effect.

[0209] In step S93, the mixed color information is output to the frame buffer.

[0210] The frame buffer output writes the final calculated color data into the storage area of ​​the display system for subsequent display processing and screen presentation.

[0211] In an optional implementation, color information is output by directly writing it to the corresponding pixel position in the frame buffer, ensuring that the mixed color is accurately displayed in the correct position on the screen. For example, the terminal device writes the calculated mixed color RGB(150,200,100) to the frame buffer at coordinates (320,240), and this color will be presented to the user in the next frame.

[0212] In an optional implementation, the frame buffer output also includes color format conversion and gamma correction processing, converting the linear color space used for internal calculations into the standard color format required by the display device. For example, the terminal device converts linear RGB color values ​​to sRGB format and applies a gamma correction factor of 2.2 to ensure that the final display effect conforms to standard display specifications.

[0213] In a specific application, when a terminal device renders the streetlight halo effect in a night scene, it first obtains the dark blue color information of the night scene background, then performs Alpha blending with the warm orange-yellow light spot color and the background, and generates a blending effect that gradually becomes transparent from the center to the edge according to the halo's transparency gradient. Finally, the blended color information is output to the frame buffer, presenting a soft and natural streetlight halo visual effect on the screen.

[0214] In a specific application of this embodiment, when the terminal device processes an explosion and spark scene in a movie special effects, it obtains the dark red base image color information of the explosion background, mixes the bright yellow-white spark points with the background, achieves natural fusion of the sparks and smoke background through the Alpha blending algorithm, and finally outputs the mixed orange-red color information to the frame buffer to create a realistic and stunning explosion light effect display.

[0215] In a light spot rendering method provided in one embodiment of this application, generating a first random value and a second random value based on the random seed through trigonometric function operations includes: Step S101: Perform a hash operation on the random seed to obtain a hash value; Step S102: Input the hash value into the sine function and the cosine function respectively to obtain the first random value and the second random value.

[0216] The method provided in this embodiment effectively ensures the uniformity and stability of random number generation by combining hash operations and trigonometric functions, thereby improving the naturalness and visual effect of light spot distribution. At the same time, the deterministic operation based on mathematical functions ensures the consistency of results under the same input conditions, thereby improving the stability and predictability of rendering effects.

[0217] The above plan will be explained in detail below.

[0218] In step S101, a hash operation is performed on the random seed to obtain a hash value.

[0219] Hash operation is a data mapping and transformation algorithm that can convert input random seed data into a fixed-length hash value output.

[0220] In an optional implementation, hashing specifically refers to the computational process of mapping input data of arbitrary length to fixed-length values ​​through mathematical transformation functions. Its main function is to achieve uniform data distribution and fast lookup. Specific functions include ensuring a uniform distribution of output results within a numerical range, maintaining a deterministic correspondence between input and output, and providing good avalanche effect characteristics. For example, the terminal device can use a simplified hash algorithm based on bitwise operations to transform the grid index values ​​through XOR operations and bit shift operations to generate uniformly distributed hash values ​​for subsequent random number generation.

[0221] In an optional implementation, the hash value specifically refers to the numerical result obtained after hashing. Its main function is to serve as an input parameter for trigonometric functions to generate pseudo-random values. Specific functions include ensuring the discrete distribution of the values, maintaining the deterministic nature of the calculation results, and providing a suitable range of values ​​for function calculations. For example, a terminal device can obtain a 32-bit integer value by hashing the grid index. This value exhibits good distribution characteristics across the entire integer range, providing a stable input basis for subsequent trigonometric function calculations.

[0222] In a specific application, after receiving the grid index value 12345, the terminal device first performs a hash operation on the index value. By performing an XOR operation on the index value and a preset constant and combining it with a shift transformation, the hash value 987654321 is finally generated. This hash value will be used as the basic input parameter for the next trigonometric function operation.

[0223] In step S102, the hash value is input into the sine function and the cosine function respectively to obtain the first random value and the second random value.

[0224] Among them, the sine function is a basic trigonometric function that can map the input value to a periodic value output between -1 and 1.

[0225] In an optional implementation, the sine function specifically refers to a periodic mathematical function with the input angle value as a variable. Its main function is to convert arbitrary values ​​into standardized periodic output results. Specific functions include achieving standardized mapping of values, providing good distribution uniformity, and maintaining the deterministic characteristics of function operations. For example, the terminal device inputs the hash value as an angle parameter into the sine function, and obtains a first random value in the range of -1 to 1 through the sin(hash_value) operation. This value can be used to determine the horizontal offset of the light spot.

[0226] In an optional implementation, the cosine function specifically refers to a periodic trigonometric function with a 90-degree phase difference from the sine function. Its main function is to generate random numerical outputs that are orthogonal to the sine function. Specific functions include ensuring the independence between the two random values, providing periodic changes in different phases, and maintaining the same numerical range characteristics as the sine function. For example, the terminal device simultaneously inputs the same hash value into the cosine function for cos(hash_value) operation, obtaining a second random value in the range of -1 to 1. This value is statistically independent of the first random value and can be used to determine the vertical offset of the light spot.

[0227] In a spot rendering method provided in one embodiment of this application, calculating the thrust intensity based on the first distance includes: Step S111: Set the thrust attenuation coefficient; Step S112: Calculate the thrust intensity using an inverse proportional function based on the first distance and the thrust attenuation coefficient.

[0228] The method provided in this embodiment enables the accurate simulation of the force decay characteristics in the physical world by introducing a mathematical model of thrust attenuation coefficient and inverse proportional function. This achieves a visual representation that the thrust effect of the light spot naturally weakens with increasing distance, thereby improving the realism and immersion of the interactive effect, while ensuring the mathematical accuracy and computational efficiency of thrust calculation.

[0229] The above plan will be explained in detail below.

[0230] In step S111, the thrust attenuation coefficient is set.

[0231] The thrust attenuation coefficient is a numerical parameter used to adjust the thrust intensity attenuation rate, which can control the degree of attenuation of thrust effect with distance.

[0232] In an optional implementation, the thrust attenuation coefficient is specifically a numerical constant that controls the rate at which thrust intensity decreases with distance. Its main function is to adjust the sensitivity and range of the interactive effect. Specific functions include controlling the effective range of thrust, adjusting the thrust intensity attenuation curve, and balancing the relationship between visual effects and computational performance. For example, the terminal device can set the thrust attenuation coefficient to 0.5. This value ensures a moderate attenuation effect of thrust intensity with increasing distance, guaranteeing a noticeable effect for close-range interaction while avoiding excessive thrust at long distances.

[0233] In an optional implementation, setting the thrust attenuation coefficient specifically refers to the process of determining an appropriate value based on the application scenario requirements. Its main function is to adapt to different interaction needs and visual effect requirements. Specific functions include adjusting the effective range according to the scene size, adjusting the sensitivity according to the type of interactive object, and optimizing computational complexity according to performance requirements. For example, when processing large-scale scenes, the terminal device can set a smaller attenuation coefficient, such as 0.2, to make the thrust effect decay quickly and reduce long-distance computational overhead. When processing detailed interaction scenes, a larger attenuation coefficient, such as 0.8, can be set to make the thrust effect smoother and more natural.

[0234] In a specific application, when the terminal device initializes the light spot rendering system, it sets the thrust attenuation coefficient to 0.6 based on the scale of the current game scene and the interaction requirements. This parameter value will be used as a fixed constant in the subsequent thrust intensity calculation to ensure that the thrust effect of all light spots maintains the same attenuation characteristics.

[0235] In step S112, the thrust intensity is calculated using an inverse proportional function based on the first distance and the thrust attenuation coefficient.

[0236] Among them, the inverse proportional function is a mathematical function type that can realize the numerical mapping of the output result to the input variable inversely proportional to the output result.

[0237] In an optional implementation, the inverse proportional function specifically refers to a calculation function in which the output value and the input value exhibit an inverse mathematical relationship. Its main function is to simulate the physical effect that thrust intensity decreases with increasing distance. Specific functions include ensuring strong thrust at close range, ensuring natural thrust decay at long range, and maintaining the continuity and smoothness of thrust changes. For example, the terminal device uses an inverse proportional function of f(d) = k / d, where d represents the first distance and k represents the thrust decay coefficient. Calculations using this function can yield a thrust intensity distribution effect that conforms to physical intuition.

[0238] In an optional implementation, the thrust strength calculation process specifically refers to the process of substituting the first distance and the thrust attenuation coefficient into an inverse proportional function for numerical calculation. Its main function is to obtain an accurate thrust value under the current distance conditions. Specific functions include ensuring the mathematical accuracy of the calculation results, maintaining the real-time responsiveness of the thrust effect, and providing basic data for subsequent position adjustment calculations. For example, the terminal device substitutes the measured first distance value of 5.0 and the preset thrust attenuation coefficient of 0.6 into the inverse proportional function for calculation. The thrust strength value of 0.12 is obtained through the calculation of 0.6 / 5.0. This value will be used to determine the specific magnitude of the spot position adjustment.

[0239] In a specific application, the terminal device detects that the first distance between the interactive object and the light spot is 3.0 units. Combined with the previously set thrust attenuation coefficient of 0.6, the thrust intensity is calculated as 0.6 / 3.0=0.2 through an inverse proportional function. This thrust intensity value is then used to calculate the position adjustment vector of the light spot, so as to realize the natural movement effect of the light spot under the influence of the interactive object.

[0240] In a light spot rendering method provided in one embodiment of this application, the method includes the following steps before obtaining the position of the interactive object: Step S121: Detect interactive objects in the scene; Step S122: Determine whether the distance between the interactive object and the pixel to be rendered is less than a preset threshold; Step S123: When the distance is less than the preset threshold, execute the step of obtaining the position of the interactive object.

[0241] The method provided in this embodiment avoids redundant processing of position acquisition and distance calculation for all interactive objects by pre-detecting and screening interactive objects in the scene, significantly improving the computational efficiency of light spot rendering. At the same time, it ensures that only objects within the interaction range will affect the light spot, improving the accuracy and real-time performance of the rendering effect.

[0242] The above plan will be explained in detail below.

[0243] In step S121, interactive objects in the scene are detected.

[0244] Scene detection is the process by which a terminal device identifies and locates interactive elements in the current rendering environment.

[0245] In one optional implementation, scene detection involves traversing all object nodes in the scene graph, identifying objects with interactive attributes, and obtaining their spatial coordinate information. For example, the terminal device scans all game characters, props, environmental elements, and other objects in a 3D scene, and filters out interactive objects such as mouse pointers, touch points, and virtual controllers that are marked as interactive.

[0246] In one alternative implementation, scene detection employs a spatial segmentation algorithm to divide the scene into regions, performing object detection only within the currently rendered field of view, thus reducing the detection range. For example, the terminal device uses an octree or BSP tree algorithm to divide the 3D scene into multiple sub-regions, and then performs interactive object detection only within the region inside the camera's view frustum, filtering out irrelevant objects outside the field of view.

[0247] In step S122, it is determined whether the distance between the interactive object and the pixel to be rendered is less than a preset threshold.

[0248] Among them, distance judgment is the process by which the terminal device calculates the spatial distance between the interactive object and the currently processed pixel and compares it with a predefined range of influence.

[0249] In one optional implementation, distance determination is achieved by calculating the Euclidean distance between the position of the interactive object in the world coordinate system and the 3D spatial position corresponding to the pixel to be rendered, and then comparing it with a preset radius of influence. For example, when the mouse pointer is located at screen coordinates (500, 300), the terminal device converts it to world coordinates (10.5, 8.3, 2.1), calculates the distance to the current pixel's world coordinates (10.2, 8.1, 2.0) as 0.36 units, and if the preset threshold is 1.0 unit, then the interactive object is determined to be within the radius of influence.

[0250] In one optional implementation, the distance determination employs a hierarchical distance calculation strategy. First, a rapid two-dimensional planar distance estimation is performed, followed by a precise three-dimensional spatial distance calculation for objects that pass the initial screening. For example, the terminal device first calculates the projected distance between the interactive object and the pixel in the XY plane. When this distance is less than 1.2 times the threshold, a complete three-dimensional distance calculation including the Z-axis is then performed, avoiding unnecessary complex calculations.

[0251] In step S123, when the distance is less than the preset threshold, the step of obtaining the position of the interactive object is executed.

[0252] Among them, conditional execution is the control logic of the terminal device to decide whether to perform subsequent interactive processing based on the distance judgment result.

[0253] In an optional implementation, conditional execution controls the program flow through Boolean judgments. When the distance condition is met, the interactive object is added to the active interaction list, and the location acquisition process is triggered. For example, when the distance between the mouse pointer and the current pixel is detected to be 0.8 units and less than the threshold of 1.0, the terminal device marks the mouse pointer as an active interactive object and performs precise location coordinate acquisition.

[0254] In an optional implementation, conditional execution also includes a priority sorting mechanism. When multiple interactive objects simultaneously meet the distance condition, they are sorted according to their distance or the importance of their object types. For example, when both the mouse pointer and the keyboard focus are detected within the influence range, the terminal device prioritizes the closer interactive object or selects the more influential interaction type according to a preset object priority rule.

[0255] In a specific application, when rendering star particle effects, the terminal device first scans all interactive objects in the scene, including the user's mouse pointer and touch points. Then, it calculates the distance between these interactive objects and the star pixels currently being processed. Only when the distance between the mouse pointer and the star pixels is less than 50 pixels is the precise position coordinates of the mouse pointer obtained for subsequent calculations to adjust the position of the light spots.

[0256] In a light spot rendering method provided in one embodiment of this application, the preset smooth interpolation function includes a smooth step function, and the calculation of pixel transparency using the preset smooth interpolation function includes: Step S131: Normalize the second distance and the size of the light spot to obtain a normalized distance; Step S132: Input the normalized distance into the smooth step function to obtain the pixel transparency.

[0257] The method provided in this embodiment unifies the distance calculation standard for light spots of different sizes through normalization processing, and achieves a smooth transition effect at the edge of the light spot by combining a smooth step function, avoiding the jaggedness caused by hard boundaries, and improving the visual quality of the rendered image and the naturalness of the light spot effect.

[0258] The above plan will be explained in detail below.

[0259] In step S131, the second distance and the size of the light spot are normalized to obtain a normalized distance.

[0260] Normalization is a data processing step in which the terminal device converts distance values ​​of different magnitudes into a uniform relative proportion.

[0261] In an optional implementation, normalization is achieved by dividing the second distance by the spot size, resulting in a value that varies between 0 and 1, facilitating subsequent interpolation function processing. For example, when the second distance between the pixel to be rendered and the center of the spot is 15 pixel units, and the spot size is 30 pixel units, the terminal device calculates the normalized distance as 15 / 30 = 0.5, indicating that the pixel is located at the midpoint of the spot radius.

[0262] In an optional implementation, the normalization process further includes boundary value processing, whereby the normalized distance is limited to 1.0 when the second distance exceeds the spot size, ensuring the validity of the numerical range. For example, when the second distance is 45 pixel units and the spot size is 30 pixel units, the terminal device clamps the calculated result 1.5 to 1.0, indicating that the pixel is completely outside the influence range of the spot.

[0263] In step S132, the normalized distance is input into the smooth step function to obtain the pixel transparency.

[0264] Among them, the smooth step function is a mathematical function used by terminal devices to achieve smooth numerical transitions, which can provide continuous gradient changes within a specified interval.

[0265] In an alternative implementation, the smooth step function employs a cubic Hermite interpolation algorithm, through t The calculation formula for (3-2t) achieves a smooth transition from 0 to 1, where t is the normalized distance.

[0266] In an alternative implementation, the smooth step function can also be implemented using a variant of the smoothstep function, by adjusting the function parameters to control the steepness of the transition interval and the decay characteristics.

[0267] Among them, function parameter adjustment is the process of modifying the configuration of smoothing function characteristics by the terminal device according to the rendering effect requirements.

[0268] In an alternative implementation, function parameter adjustment controls the rate and shape of transparency decay by modifying the power and coefficients of the interpolation function, achieving different visual effects. For example, the terminal device can use t^2 (3-2 To achieve a steeper decay, use sqrt(1-t^2) to achieve a similar circular decay effect.

[0269] In an optional implementation, the function parameter adjustment also includes dynamic parameter control, which adjusts the characteristics of the interpolation function in real time based on the brightness, color, or animation status of the light spot. For example, for brighter light spots, the terminal device can use a gentler decay function to maintain a larger luminous range, while for dimmer light spots, a steeper decay function is used to achieve a more concentrated luminous effect.

[0270] In a specific application, when rendering starlight effects in the night sky, for a starlight point with a radius of 20 pixels, when the current pixel is 12 pixels away from the center of the starlight, the normalized distance is calculated as 12 / 20=0.6. Then, 0.6 is input into the smooth step function smoothstep(0.6) to calculate the transparency value of approximately 0.352. Finally, the pixel displays the starlight color with 35.2% transparency, achieving a natural transition effect from the center of the starlight to the edge.

[0271] This exemplary embodiment also discloses a light spot rendering apparatus. Figure 7 This is a diagram illustrating the composition of a translucent material effect fabrication apparatus according to an exemplary embodiment of this disclosure. Figure 7 As shown, the device includes: The acquisition module is used to obtain the world coordinates of the pixel to be rendered. The determination module is used to divide the rendering area into multiple grid cells based on the world coordinates, and to determine the target grid cell to which the pixel to be rendered belongs and the local coordinates within the target grid cell; The first generation module is used to generate the spot position offset and spot size based on the index of the target grid cell using a pseudo-random function; The second generation module is used to generate a light spot within the target grid cell based on the light spot position offset and the light spot size. The calculation module is used to obtain the position of the interactive object and calculate the first distance and directional relationship between the interactive object and the light spot; An adjustment module is used to adjust the display position of the light spot based on the distance and direction relationship; The rendering module is used to render and output the adjusted light spots.

[0272] Optionally, based on world coordinates, the rendering area is divided into multiple grid cells, including: Extract the horizontal coordinate component from the world coordinate system; The horizontal coordinate components are scaled to obtain scaled coordinates. The scaled coordinates are divided into grids using grid density values, and the grid index is determined by rounding down.

[0273] Optionally, the spot position offset and spot size are generated using a pseudo-random function, including: Use the index of the target grid cell as a random seed; Based on a random seed, a first random value and a second random value are generated through trigonometric function operations; The position offset of the light spot is determined based on the first random value; The spot size is determined based on the second random value.

[0274] Optionally, a light spot is generated within the target grid cell based on the light spot position offset and the light spot size, including: The center position of the light spot is determined based on the center coordinates of the target mesh cell and the offset of the light spot position. Calculate the second distance between the pixel to be rendered and the center of the light spot; Pixel transparency is calculated using a preset smooth interpolation function based on the second distance and the size of the light spot; Light spots are generated based on pixel transparency.

[0275] Optionally, based on the first distance and direction relationship, the display position of the light spot is adjusted, including: Calculate the direction vector from the light spot to the interactive object; Thrust intensity is calculated based on the first distance, where thrust intensity is inversely proportional to distance; Calculate the position adjustment vector based on the direction vector and thrust intensity; The position adjustment vector is applied to the center position of the light spot to obtain the adjusted center position of the light spot.

[0276] Optionally, after dividing the rendering area into multiple mesh units based on world coordinates, the process also includes: Determine the adjacent grid cells of the target grid cell; Generate corresponding spot position offsets and spot sizes for adjacent grid cells; Light spots are generated in adjacent grid cells respectively; The target grid cell and the light spots in the adjacent grid cells are combined.

[0277] Optionally, determining the neighboring grid cells of the target grid cell includes: With the target grid cell as the center, determine the grid cells within a preset range as adjacent grid cells.

[0278] Optionally, after obtaining the world coordinates of the pixel to be rendered, the process also includes: Obtain the viewer's gaze direction relative to the pixel to be rendered; Calculate the disparity offset based on the line-of-sight direction; By applying the parallax offset to the local coordinates, light spots with depth levels are generated.

[0279] Optionally, rendering the adjusted light spot also includes: Obtain the color information of the base rendered image; The color information of the light spot is mixed with the color information of the base rendered image to obtain the mixed color information. The mixed color information is output to the frame buffer.

[0280] Optionally, the trigonometric functions include sine and cosine functions; based on the random seed, generating the first and second random values ​​through trigonometric function operations includes: Perform a hash operation on the random seed to obtain the hash value; Input the hash value into the sine and cosine functions respectively to obtain the first and second random values.

[0281] Optionally, calculating thrust intensity based on distance includes: Set the thrust attenuation coefficient; The thrust intensity is calculated using an inverse proportional function based on the distance and thrust attenuation coefficient.

[0282] Optionally, before obtaining the position of the interactive object, the following steps are also included: Detect interactive objects in the scene; Determine whether the distance between the interactive object and the pixel to be rendered is less than a preset threshold; When the distance is less than a preset threshold, execute the step of obtaining the location of the interactive object.

[0283] Optionally, the preset smooth interpolation function includes a smooth step function, and the pixel transparency is calculated using the preset smooth interpolation function as follows: The second distance is normalized to the spot size to obtain the normalized distance; The normalized distance is input into the smooth step function to obtain the pixel transparency.

[0284] The method provided in this embodiment enables highly efficient dynamic light spot rendering by establishing a gridded light spot generation mechanism combined with interactive position adjustment technology, significantly improving image rendering quality and generation efficiency, while ensuring the randomness and visual coherence of light spot distribution.

[0285] The specific details of each module unit in the above embodiments have been described in detail in the corresponding light spot rendering method. In addition, the light spot rendering device also includes other unit modules corresponding to the display control method, so they will not be described again here.

[0286] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0287] Figure 8 This is a schematic diagram of the structure of a computer-readable storage medium according to an exemplary embodiment of the present disclosure. Figure 8 As shown, a program product 1100 according to an embodiment of the present disclosure is described, on which a computer program is stored, which, when executed by a processor, implements the method steps of the above-described light spot rendering method. The method provided by this embodiment enables highly efficient dynamic light spot rendering by establishing a gridded light spot generation mechanism combined with interactive position adjustment technology, significantly improving image rendering quality and generation efficiency, while ensuring the randomness and visual coherence of the light spot distribution.

[0288] Computer-readable storage media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable storage media may transmit, propagate, or transfer programs for use by or in connection with an instruction execution system, apparatus, or device.

[0289] The program code contained in a computer-readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, radio frequency, or any suitable combination thereof.

[0290] The following is combined with Figure 9 The electronic device 1000 in this exemplary embodiment is described. The electronic device 1000 is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0291] See Figure 9 As shown, the electronic device 1000 is presented in the form of a general-purpose computing device. The components of the electronic device 1000 may include, but are not limited to: at least one processor 1010, at least one memory 1020, a bus 1030 connecting different system components (including processor 1010 and memory 1020), and a display unit 1040.

[0292] The memory 1020 stores program code that can be executed by the processor 1010, enabling the processor 1010 to execute the specific method steps of the aforementioned light spot rendering method by executing the executable instructions. The method provided in this embodiment achieves highly efficient dynamic light spot rendering by establishing a gridded light spot generation mechanism combined with interactive position adjustment technology, significantly improving image rendering quality and generation efficiency while ensuring the randomness and visual coherence of the light spot distribution.

[0293] The electronic device may also include: a power supply component configured to manage the power of the electronic device; a wired or wireless network interface configured to connect the electronic device to a network; and an input / output (I / O) interface. The electronic device can operate on an operating system stored in memory, such as Android, iOS, Windows, Mac OS X, Unix, Linux, FreeBSD, or similar.

[0294] 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 the present invention can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, portable hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, electronic device, or network device, etc.) to execute the method according to the embodiments of the present invention.

[0295] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.

[0296] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. A method for rendering light spots, characterized in that, include: Get the world coordinates of the pixel to be rendered; Based on the world coordinates, the rendering area is divided into multiple grid cells, and the target grid cell to which the pixel to be rendered belongs and its local coordinates within the target grid cell are determined. Based on the index of the target grid cell, the spot position offset and spot size are generated using a pseudo-random function; Based on the spot position offset and spot size, a spot is generated within the target grid cell; Obtain the position of the interactive object, and calculate the first distance and directional relationship between the interactive object and the light spot; Based on the distance and direction relationship, the display position of the light spot is adjusted; Render and output the adjusted light spots.

2. The light spot rendering method according to claim 1, characterized in that, The process of dividing the rendering area into multiple grid units based on the world coordinates includes: Extract the horizontal coordinate component from the world coordinates; The horizontal coordinate components are scaled to obtain scaled coordinates; The scaled coordinates are divided into grids using grid density values, and the grid index is determined by rounding down.

3. The light spot rendering method according to claim 1, characterized in that, The process of generating the spot position offset and spot size using a pseudo-random function includes: Use the index of the target grid cell as a random seed; Based on the random seed, a first random value and a second random value are generated through trigonometric function operations; The position offset of the light spot is determined based on the first random value; The size of the light spot is determined based on the second random value.

4. The light spot rendering method according to claim 1, characterized in that, The step of generating a light spot within the target grid cell based on the light spot position offset and light spot size includes: The center position of the light spot is determined based on the center coordinates of the target grid cell and the offset of the light spot position. Calculate the second distance between the pixel to be rendered and the center position of the light spot; Pixel transparency is calculated using a preset smooth interpolation function based on the second distance and the size of the light spot; The light spot is generated based on the pixel transparency.

5. The light spot rendering method according to claim 1, characterized in that, The step of adjusting the display position of the light spot based on the first distance and direction relationship includes: Calculate the direction vector from the light spot to the interactive object; The thrust intensity is calculated based on the first distance, wherein the thrust intensity is inversely proportional to the distance; Calculate the position adjustment vector based on the direction vector and the thrust intensity; The position adjustment vector is applied to the center position of the light spot to obtain the adjusted center position of the light spot.

6. The light spot rendering method according to claim 1, characterized in that, After dividing the rendering area into multiple grid units based on the world coordinates, the process further includes: Determine the adjacent grid cells of the target grid cell; For each adjacent grid cell, a corresponding spot position offset and spot size are generated. Light spots are generated in the adjacent grid cells respectively; The light spots in the target grid cell and the adjacent grid cells are combined.

7. The light spot rendering method according to claim 6, characterized in that, The process of determining the adjacent grid cells of the target grid cell includes: With the target grid cell as the center, grid cells within a preset range are determined as the adjacent grid cells.

8. The light spot rendering method according to claim 1, characterized in that, After obtaining the world coordinates of the pixel to be rendered, the process also includes: Obtain the observer's gaze direction relative to the pixel to be rendered; Calculate the disparity offset based on the line of sight; The parallax offset is applied to the local coordinates to generate light spots with depth levels.

9. The light spot rendering method according to claim 1, characterized in that, The rendering and output of the adjusted light spots also includes: Obtain the color information of the base rendered image; The color information of the light spot is mixed with the color information of the base rendered image to obtain the mixed color information. The mixed color information is output to the frame buffer.

10. The light spot rendering method according to claim 3, characterized in that, The trigonometric functions include sine and cosine functions; the generation of the first and second random values ​​based on the random seed through trigonometric function operations includes: Perform a hash operation on the random seed to obtain a hash value; The hash value is input into the sine function and the cosine function respectively to obtain the first random value and the second random value.

11. The light spot rendering method according to claim 5, characterized in that, The calculation of thrust intensity based on the distance includes: Set the thrust attenuation coefficient; The thrust intensity is calculated using an inverse proportional function based on the distance and the thrust attenuation coefficient.

12. The light spot rendering method according to claim 1, characterized in that, Before obtaining the location of the interactive object, the method further includes: Detect interactive objects in the scene; Determine whether the distance between the interactive object and the pixel to be rendered is less than a preset threshold; When the distance is less than the preset threshold, the step of obtaining the position of the interactive object is executed.

13. The light spot rendering method according to claim 4, characterized in that, The preset smooth interpolation function includes a smooth step function, and the calculation of pixel transparency using the preset smooth interpolation function includes: The second distance and the size of the light spot are normalized to obtain the normalized distance; The normalized distance is input into the smooth step function to obtain the pixel transparency.

14. A light spot rendering device, characterized in that, include: The acquisition module is used to obtain the world coordinates of the pixel to be rendered. The determination module is used to divide the rendering area into multiple grid cells based on the world coordinates, and to determine the target grid cell to which the pixel to be rendered belongs and the local coordinates within the target grid cell; The first generation module is used to generate the spot position offset and spot size based on the index of the target grid cell using a pseudo-random function; The second generation module is used to generate a light spot within the target grid cell based on the light spot position offset and the light spot size. The calculation module is used to obtain the position of the interactive object and calculate the first distance and directional relationship between the interactive object and the light spot; An adjustment module is used to adjust the display position of the light spot based on the distance and direction relationship; The rendering module is used to render and output the adjusted light spots.

15. A computer-readable storage medium, characterized in that, The device contains a computer program that, when executed by a processor, implements the method of any one of claims 1 to 13.

16. An electronic device, characterized in that, include: Memory, which stores computer programs; A processor that executes the computer program to implement the method of any one of claims 1 to 13.