Method and device for enhancing character display effect in real-time rendering application
By expanding the text grid data and optimizing the stroke rendering channel, the rendering quality and performance issues of text strokes in real-time rendering applications were resolved, achieving a technical solution with high-quality smooth stroke effects and low performance overhead.
Patent Information
- Application Number
- CN202511741217.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-25
- Publication Date
- 2026-02-10
AI Technical Summary
In existing technologies, text outlines suffer from insufficient rendering quality and high performance overhead in real-time rendering applications, especially when generating outline edges with insufficient smoothness and increasing the outline width, which leads to high CPU and GPU resource consumption.
By expanding the text mesh data, increasing the stroke rendering channel, and performing multiple texture samplings in the fragment shader, the rendering process is optimized using unified stroke parameters and vertex effect parameters, reducing storage resource consumption and the number of DrawCalls. At the same time, elliptical circumferential sampling technology is used to improve stroke smoothness.
It achieves high-quality, smooth stroke effects while significantly reducing performance overhead, adapting to different resolution devices and maintaining consistent stroke quality.
Smart Images

Figure CN121505067A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer graphics rendering technology, and in particular to a method and apparatus, computing device and computer-readable storage medium for enhancing text display effects in real-time rendering applications. Background Technology
[0002] In real-time rendering applications such as video games, interactive multimedia software, and user operating systems, the clear presentation of UI elements is fundamental to ensuring a good user experience. Among these, text, as the primary medium for information transmission, is particularly important for its readability and visual appeal. For example, when the color of the text is similar to the background color or texture overlaid on it in terms of brightness or chromaticity, it needs to be distinguished. Furthermore, to match specific visual art styles, special visual effects are often applied to the text, and these functions need to be performed against dynamically changing backgrounds. Current technologies commonly use the method of adding outlines to the text, generating a high-contrast color band around the text outline to achieve these effects.
[0003] However, a widely adopted text outlining method based on mesh offset has the following significant technical drawbacks: First, in terms of rendering quality, this technique simulates the outlining effect by slightly offsetting and repeatedly drawing the text mesh in multiple directions within screen space. The resulting outlining edges often exhibit noticeable jagged, stepped edges, lacking smoothness and precise contour control, thus failing to meet high-quality rendering requirements.
[0004] Secondly, in terms of performance, this solution incurs significant overhead. Each offset drawing constitutes an independent drawing call. When the stroke width increases or a more refined stroke effect is required, the number of drawing calls increases exponentially, significantly increasing the CPU load and GPU pixel fill rate pressure, resulting in high overall resource consumption. Therefore, there is an urgent need for a text stroke technology solution that can generate high-quality, smooth stroke edges while significantly reducing performance overhead. Summary of the Invention
[0005] In view of this, embodiments of this application provide a method and apparatus, computing device and computer-readable storage medium for enhancing text display effects in real-time rendering applications, in order to solve the technical defects existing in the prior art.
[0006] According to a first aspect of the embodiments of this application, a method for enhancing text display effects in a real-time rendering application is provided, comprising:
[0007] The text mesh data is obtained, and the original vertex coordinates and original UV coordinates of the text are expanded to obtain the first vertex data and the first UV coordinates; the offset of the expansion is based on the target width of the stroke.
[0008] Calculate the uniform stroke parameters and write them into a constant buffer;
[0009] Calculate vertex effect parameters based on the target rendering effect, write back the first vertex data and write it into the vertex buffer along with the first UV coordinates;
[0010] Create a stroke rendering channel and a text rendering channel, and complete the configuration of the rendering channels;
[0011] In the stroke rendering pass, the fragment shader obtains the parameters of the buffer and performs multiple texture samplings in a small area around the UV coordinates corresponding to the current pixel to complete the stroke rendering;
[0012] The text is rendered in the text rendering channel.
[0013] According to a second aspect of the embodiments of this application, an apparatus for enhancing text display effects in real-time rendering applications is provided, comprising:
[0014] An expansion unit is used to acquire text mesh data, expand the original vertex coordinates and original UV coordinates of the text to obtain first vertex data and first UV coordinates; the offset of the expansion is based on the target width of the stroke.
[0015] The first calculation unit is used to calculate the uniform stroke parameters and write them into the constant buffer.
[0016] The second calculation unit is used to calculate vertex effect parameters according to the target rendering effect, write back the first vertex data and write it into the vertex buffer together with the first UV coordinates;
[0017] Create a unit to create the stroke rendering channel and the text rendering channel, and complete the configuration of the rendering channels;
[0018] The first rendering unit is used in the stroke rendering channel. The fragment shader obtains the parameters of the buffer and performs multiple texture samplings in a small area around the UV coordinates corresponding to the current pixel to complete the stroke rendering.
[0019] The second rendering unit is used to render text in the text rendering channel.
[0020] According to a third aspect of the present application, a computing device is provided, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor executes the instructions to implement the steps of the method for enhancing text display effects in a real-time rendering application.
[0021] According to a fourth aspect of the present application, a computer-readable storage medium is provided that stores computer instructions, which, when executed by a processor, implement the steps of the method for enhancing text display effects in a real-time rendering application.
[0022] The method provided by the embodiments of this application first expands the text mesh data and adds a stroke rendering channel during rendering, passing additional vertex data to the GPU without generating additional mesh vertices, greatly reducing the storage resources occupied. Moreover, almost all the required stroke and shadow effect parameters are passed through vertex data, allowing all text components to use the same material, which can then be batched by the rendering engine's dynamic batching technology, significantly reducing the number of draw calls. At the same time, when sampling in different directions in the fragment shader, a sampling method on the circumference of an ellipse is adopted, so that the stroke effect can be kept consistent on devices with different resolutions, and by controlling the range of the stroke on the screen and using more fragment sampling times, the stroke effect is made smoother. Attached Figure Description
[0023] Figure 1 This is a structural block diagram of the computing device provided in the embodiments of this application;
[0024] Figure 2 This is a flowchart illustrating a method for enhancing text display effects in real-time rendering applications, as provided in an embodiment of this application.
[0025] Figure 3 This is a schematic diagram of the text outline effect rendered according to the method provided in the embodiments of this application;
[0026] Figure 4 This is a schematic diagram of a device for enhancing text display in real-time rendering applications, provided in an embodiment of this application. Detailed Implementation
[0027] Many specific details are set forth in the following description to provide a full understanding of this application. However, this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this application; therefore, this application is not limited to the specific embodiments disclosed below.
[0028] The terminology used in one or more embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this application. The singular forms “a,” “the,” and “the” used in one or more embodiments of this application and in the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” used in one or more embodiments of this application refers to and includes any or all possible combinations of one or more associated listed items.
[0029] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this application, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this application, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "in response to a determination".
[0030] This application provides a method, apparatus, computing device, and computer-readable storage medium for enhancing text display in real-time rendering applications, which will be described in detail in the following embodiments.
[0031] Figure 1 A structural block diagram of a computing device 100 according to an embodiment of this application is shown. The components of the computing device 100 include, but are not limited to, a memory 110 and a processor 120. The processor 120 is connected to the memory 110 via a bus 130, and a database 150 is used to store data.
[0032] The computing device 100 also includes an access device 140, which enables the computing device 100 to communicate via one or more networks 160. Examples of these networks include a Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 140 may include one or more of any type of wired or wireless network interface (e.g., a Network Interface Card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) interface, a Wi-MAX interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0033] In one embodiment of this application, the aforementioned components of the computing device 100 and Figure 1 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 1The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this application. Those skilled in the art can add or replace other components as needed.
[0034] The computing device 100 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs.
[0035] In the embodiments of this application, Figure 2 A flowchart of a method for enhancing text display in a real-time rendering application, as provided in this application, is shown, including steps 202 to 212.
[0036] Step 202: Obtain text mesh data, expand the original vertex coordinates and original UV coordinates of the text to obtain the first vertex data and the first UV coordinates.
[0037] In this embodiment, the basic geometric mesh data constituting the shape of the text is first obtained from the font engine or UI system. This mesh data includes the following information:
[0038] The original vertex positions of the text: the coordinates of each vertex in three-dimensional space. In UI rendering, these are typically screen space or canvas space coordinates. These positions define the geometry of the mesh.
[0039] The raw UV coordinates of the text: the mapped coordinates of each vertex on the 2D texture, which tells the GPU where to sample color information from the text texture atlas.
[0040] Vertex color: The color information of each vertex, which can be used to achieve effects such as color gradients.
[0041] These vertex data are organized into primitives, most commonly quadrilaterals, which are usually further subdivided into two triangles inside the GPU.
[0042] Furthermore, to allow space for the stroke, the original text's mesh needs to be expanded outwards, with the original text acting as the "solid core" and the stroke as the "halo" surrounding it. This step creates a larger virtual mesh that can cover this "halo." Simultaneously, the UV coordinates also need to be adjusted accordingly, expanding the fragment shader's sampling range on the texture to ensure that subsequent sampling can be correctly mapped onto the texture.
[0043] During vertex expansion, the CPU calculates an offset for each vertex that makes up the text mesh, pushing it outwards. This offset is typically calculated based on the target width of the stroke. For a quadrilateral (the basic unit of the text mesh), this means that its four corners move away from the center of the quadrilateral. This operation is performed on all vertices of the entire text mesh, causing the geometric outline of the entire string to expand outwards. After expansion, the new geometric mesh occupies a larger area on the screen than the original text mesh. This extra area is where the stroke will be drawn.
[0044] During UV coordinate expansion, the CPU expands the UV coordinates of each vertex in sync with vertex position expansion. The UV coordinates of the original text precisely correspond to the region of that character in the texture atlas, while expanding the UV coordinates means extending the range of the original text's UV coordinates outwards, covering a texture region slightly larger than the original character region.
[0045] Step 204: Calculate the uniform stroke parameters and write them into the constant buffer.
[0046] In one feasible implementation, the calculation of the uniform stroke parameter includes a uniform stroke width, which is used to determine the stroke thickness of all text. In this step, the initial stroke width value set in the editor is converted into a precise technical parameter relevant to the current rendering environment. This rendering environment-related parameter includes: screen DPI (pixel density), UI canvas scaling, camera attributes, and viewport size. Through the conversion of these factors, a "corrected width value" that produces a consistent visual effect in the current rendering context is finally obtained, which directly determines the stroke thickness.
[0047] In one feasible implementation, the uniform stroke parameter also includes a uniform stroke color, used to determine the color of all strokes.
[0048] In one feasible implementation, the uniform stroke parameters also include a bounding box of the original UV coordinates, which is a rectangular area obtained based on the minimum and maximum coordinates of the original text in the UV texture space. This bounding box summarizes the entire range of the original text in the UV space and is passed to the GPU for use in the fragment shader.
[0049] Furthermore, the unified stroke parameters are written into the GPU's constant buffer, providing rendering parameters and optimization basis for the GPU's shaders.
[0050] Those skilled in the art should know that the types of unified stroke parameters mentioned above are examples rather than an exhaustive list. Those skilled in the art can add other unified stroke parameters according to actual needs, which will not be elaborated here.
[0051] Step 206: Calculate the vertex effect parameters based on the target effect, write back the first vertex data and write it to the vertex buffer along with the first UV coordinates.
[0052] In the embodiments of this application, in this step, the data structure used to define vertices is dynamically modified or extended according to the rendering needs, and additional, personalized rendering information is attached to each vertex. This information is then packaged into the final vertex buffer and sent to the GPU.
[0053] Specifically, for example, a gradient effect that changes with vertex position cannot be achieved using a single stroke color, but per-vertex data can. For instance, you can assign red to all vertices at the top of the text and blue to all vertices at the bottom. During rendering, the GPU will automatically perform smooth linear interpolation of the colors across the pixels between these vertices, thus producing a perfect gradient effect.
[0054] In one feasible implementation, the added vertex effect parameters, based on the description of the stroke, shadow, or stroke gradient target effect, include:
[0055] Vertex color is a color value containing four components (R, G, B, A). Different vertex colors are used to achieve the following desired effects:
[0056] Stroke gradient: As mentioned above, different colors are set for different vertices, and the GPU automatically interpolates to form a gradient.
[0057] Transparency variation: By modifying the alpha channel of the vertex color, the outline or text can have different transparency at different locations.
[0058] In one feasible implementation, the added vertex effect parameters are achieved through a custom effect parameter vector.
[0059] Specifically, to achieve more complex effects, one or more custom float4 type parameters can be added. For example, a float4 effectParams can contain:
[0060] x (Channel 1): Effect intensity. Controls the density of strokes or shadows, allowing the intensity to vary with vertex position.
[0061] y (Channel 2): Effect type identifier. Use an integer (e.g., 0 for solid color, 1 for gradient, 2 for pattern) to tell the fragment shader which rendering logic to use.
[0062] z (Channel 3): Animation Phase. If you want the stroke to have animation effects such as flowing or blinking, you can store a value here that changes over time.
[0063] w(Channel 4): Reserved or standby. Can be used for future expansions or other specific effects.
[0064] Furthermore, these vertex effect parameters are written back into the vertex data and then into the GPU's vertex cache.
[0065] In a specific example, the initial data structure for each vertex might look like this:
[0066]
[0067] After adding effect parameters, the CPU will define a new, expanded data structure and use it to populate the vertex buffer:
[0068]
[0069]
[0070] When the CPU writes back vertex data, it fills all the fields of the EnhancedVertex structure for each vertex. The vertex buffer that is finally sent to the GPU is an array of EnhancedVertex structures.
[0071] Those skilled in the art should know that the examples of vertex effect parameters mentioned above are merely illustrative. Those skilled in the art can set specific vertex effect parameters according to the target rendering requirements, which will not be elaborated here.
[0072] Adding effect parameters to vertex data is a powerful data orchestration step. By expanding the vertex data structure and repopulating the vertex buffer, it upgrades data that could only achieve global effects to per-vertex data capable of local, variable, and personalized effects. This lays the data foundation for GPUs to leverage their powerful parallel interpolation capabilities to generate high-quality gradients, animations, and other complex visual effects.
[0073] Preferably, in another embodiment of this application, when the target rendering effect also includes complex rendering effects such as multi-layered outlines and shadow outlines, a repeatable, templated data preparation process is created to create unique parameters for each effect. For example, shadows have their own color, offset, and blur; the second layer of outline has its own color and width. Separating them allows for independent and non-interfering control of the visual effect of each layer.
[0074] Specifically, for each complex target rendering effect, multiple processes are initiated based on the user-specified effect list (n strokes, shadows, etc.). Each process follows the standard process of [creating vertices] -> [expanding (offsetting)] -> [adding effect parameters] -> [writing to buffer].
[0075] For example, when performing a secondary stroke, the following steps are implemented:
[0076] Additional vertex data creation: The CPU copies the original text mesh, creating a new mesh copy, StrokeMesh.
[0077] Outward expansion: Expand the position and UV of all vertices of the StrokeMesh according to the needs of secondary outlining.
[0078] Add effect parameters:
[0079] Unified parameters: Pack the secondary stroke color (e.g., red) and the corrected stroke width into a constant buffer.
[0080] Vertex data: If the stroke needs to be gradient (e.g., from red to dark red from top to bottom), the CPU will calculate the color of each vertex on the StrokeMesh and write these color values into the vertex data of the StrokeMesh.
[0081] Write to the buffer: Submit vertex data to the GPU's vertex buffer.
[0082] Other outline rendering effects follow a similar process to the one described above, and will not be repeated here.
[0083] Step 208: Create the stroke rendering channel and the text rendering channel to complete the rendering channel configuration.
[0084] In this step, an outline rendering pass and a text rendering pass are created, and the rendering pass configuration is completed, including:
[0085] Binding Vertex Buffers: The CPU binds the vertex buffers (containing expanded positions, UVs, vertex colors, etc.) prepared in the previous steps for outlining to the rendering pipeline. This tells the vertex shader where to read data for each vertex.
[0086] Bind constant buffer: The CPU also connects constant buffers containing stroke parameters (such as the corrected uniform stroke width, uniform stroke color, original UV bounding box, etc.) to the pipeline.
[0087] Texture binding: The CPU binds a font texture atlas containing all characters to the pipeline. The fragment shader needs to sample the alpha channel from this texture to determine the text outline.
[0088] Step 210: In the stroke rendering channel, the fragment shader obtains the parameters of the buffer and performs texture sampling in a small area around the UV coordinates corresponding to the current pixel to complete the stroke rendering.
[0089] In this step, the fragment shader first obtains parameters from the constant buffer and the vertex shader.
[0090] The global parameters passed through the constant buffer include, but are not limited to:
[0091] The revised uniform stroke width, uniform stroke color, original UV bounding box, and other global settings, such as gamma correction flags and Canvas Group transparency, etc.
[0092] The vertex shader reads individual vertex data from the vertex buffer, including UV coordinates, vertex color, and custom effect parameters, and passes this data to the next stage of the rendering pipeline. This data is then automatically interpolated by the GPU hardware and finally delivered to the fragment shader.
[0093] Furthermore, after acquiring the relevant parameters, the fragment shader begins texture sampling, performing n samples within a small area around the UV coordinates corresponding to the current pixel.
[0094] In one feasible implementation, performing n samplings within a small region surrounding the UV coordinates of the current pixel includes:
[0095] Obtain the UV coordinates of the pixel currently being processed and use them as the center point of an ellipse;
[0096] Uniform sampling is performed on the circumference of the ellipse to obtain n sampling points, where n≥10;
[0097] Specifically, the two radii of the ellipse are determined based on the stroke width and the rate of change of the UV coordinates. An ellipse radius in UV space is dynamically calculated for each pixel, so that after the ellipse is projected in the screen space, the distance from its edge to the center is always equal to the set stroke width.
[0098] Preferably, when calculating the ellipse radius, the ellipse radius is calculated only for the three vertices of a single triangular face, and then the vertex data of the three vertices is written. After interpolation, the ellipse radius value obtained by each pixel of the triangular face in the shader is consistent, and the fragment shader no longer performs complex radius calculations, but directly reads the interpolated, uniform radius value.
[0099] Furthermore, after obtaining n sampling points, the relationship between these sampling points and the original UV coordinate bounding box is used to determine whether to render the currently processed pixel.
[0100] Specifically, in order to improve the edge effect of the stroke, in the n samplings of the ellipse circumference, the sampling points that are not within the original UV coordinate bounding box are discarded. The remaining sampling points are summed by the transparency value and then restricted to the range [0,1] by the smoothstep function to obtain a new transparency value. This new transparency value is used as the transparency value of the final output fragment, resulting in a high-quality stroke with soft edges and no jaggedness.
[0101] Preferably, after adding the remaining sampling points by transparency values and limiting them to the range [0,1] by the smoothstep function to obtain a new transparency value, if the new transparency value is less than or equal to the threshold, the current pixel (fragment) is discarded.
[0102] Prior to this step, the vertex shader transforms the vertex positions that the CPU has already expanded from model space to clip space, completing the projection process from 3D geometry to the 2D screen, which is well known to those skilled in the art and will not be described in detail here.
[0103] Step 212: Render the text in the text rendering channel.
[0104] In this step, the actual text characters are drawn using raw, unexpanded text geometry and textures in the text rendering pass to obtain the final rendering effect, such as... Figure 3 As shown.
[0105] In the above embodiments of this application, to address the problems of traditional mesh-offset-based text outlining schemes consuming large amounts of memory and video memory and exhibiting poor display effects, an additional outlining rendering channel is added during rendering by expanding the text's mesh data. Although this requires inputting additional vertex data, it eliminates the need to generate additional mesh vertices, significantly reducing storage resource consumption. Moreover, almost all required outlining and shadow effect parameters are input through vertex data, allowing all text components to use the same material, which in turn enables dynamic batching by the rendering engine, significantly reducing the number of draw calls. Simultaneously, when sampling in different directions in the fragment shader, sampling is performed on the circumference of an ellipse, ensuring consistent outlining effects across devices with different resolutions. Furthermore, controlling the outlining's range on the screen and using a higher number of fragment samples results in smoother outlining effects.
[0106] Corresponding to the above method embodiments, this application also provides an embodiment of an apparatus for enhancing text display effects in real-time rendering applications, such as... Figure 4 As shown, the device includes:
[0107] An expansion unit is used to acquire text mesh data, expand the original vertex coordinates and original UV coordinates of the text to obtain first vertex data and first UV coordinates; the offset of the expansion is based on the target width of the stroke.
[0108] The first calculation unit is used to calculate the uniform stroke parameters and write them into the constant buffer.
[0109] The second calculation unit is used to calculate vertex effect parameters according to the target rendering effect, write back the first vertex data and write it into the vertex buffer together with the first UV coordinates;
[0110] Create a unit to create the stroke rendering channel and the text rendering channel, and complete the configuration of the rendering channels;
[0111] The first rendering unit is used in the stroke rendering channel. The fragment shader obtains the parameters of the buffer and performs multiple texture samplings in a small area around the UV coordinates corresponding to the current pixel to complete the stroke rendering.
[0112] The second rendering unit is used to render text in the text rendering channel.
[0113] The above is an illustrative scheme of an apparatus for enhancing text display effects in real-time rendering applications according to this embodiment. It should be noted that the technical solution of this apparatus for enhancing text display effects in real-time rendering applications belongs to the same concept as the technical solution of the method for enhancing text display effects in real-time rendering applications described above. Details not described in detail in the technical solution of this apparatus for enhancing text display effects in real-time rendering applications can be found in the description of the technical solution of the method for enhancing text display effects in real-time rendering applications described above.
[0114] One embodiment of this application also provides a computing device, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor executes the instructions to implement the steps of the method for enhancing text display effects in real-time rendering applications.
[0115] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the method for enhancing text display effects in real-time rendering applications described above belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the method for enhancing text display effects in real-time rendering applications described above.
[0116] An embodiment of this application also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the steps of the method for enhancing text display in a real-time rendering application as described above.
[0117] The above is an illustrative embodiment of a computer-readable storage medium. It should be noted that the technical solution of this storage medium belongs to the same concept as the technical solution of the method for enhancing text display effects in real-time rendering applications described above. Details not described in detail in the technical solution of the storage medium can be found in the description of the technical solution of the method for enhancing text display effects in real-time rendering applications described above.
[0118] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0119] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0120] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0121] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0122] The preferred embodiments disclosed above are merely illustrative of this application. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this application. These embodiments are selected and specifically described in this application to better explain the principles and practical applications of this application, thereby enabling those skilled in the art to better understand and utilize this application. This application is limited only by the claims and their full scope and equivalents.
Claims
1. A method for enhancing text display effects in real-time rendering applications, characterized in that, The method includes: The text mesh data is obtained, and the original vertex coordinates and original UV coordinates of the text are expanded to obtain the first vertex data and the first UV coordinates; the offset of the expansion is based on the target width of the stroke. Calculate the uniform stroke parameters and write them into a constant buffer; Calculate vertex effect parameters based on the target rendering effect, write back the first vertex data and write it into the vertex buffer along with the first UV coordinates; Create a stroke rendering channel and a text rendering channel, and complete the configuration of the rendering channels; In the stroke rendering pass, the fragment shader obtains the parameters of the buffer and performs multiple texture samplings in a small area around the UV coordinates corresponding to the current pixel to complete the stroke rendering; The text is rendered in the text rendering channel.
2. The method according to claim 1, wherein, Calculating the uniform stroke parameters and writing them into the constant buffer includes: The calculation includes a uniform stroke width, which is used to determine the stroke thickness of all text, and a uniform stroke color, which is used to determine the color of all strokes.
3. The method according to claim 2, wherein, Calculating the uniform stroke parameters and writing them to the constant buffer also includes: Calculate the bounding box of the original UV coordinates and write it to the GPU's constant buffer.
4. The method according to claim 1, wherein, Calculating vertex effect parameters based on the target rendering effect, and writing back the first vertex data along with the first UV coordinates to the vertex buffer includes: Modify the data structure used to define vertices according to the target rendering effect, add additional rendering information to each vertex, and pack it into the vertex buffer; the target rendering effect includes, but is not limited to: vertex color, stroke gradient, and transparency change.
5. The method according to claim 4, wherein, The method also includes: if the target rendering effect is a complex rendering effect, then start a process for each target rendering effect, and each process follows the process of [creating vertices] -> [expanding and or offsetting] -> [adding effect parameters] -> [writing to buffer]; The complex rendering effects include, but are not limited to: multi-layered outlines and shadow outlines.
6. The method according to claim 1 or 3, wherein, Texture sampling is performed within a small area around the UV coordinates corresponding to the current pixel to complete the rendering of the outline, including: Obtain the UV coordinates corresponding to the currently processed pixel and use it as the center point of an ellipse; perform uniform sampling on the circumference of the ellipse to obtain n sampling points, where n≥10; wherein, determine the two radii of the ellipse based on the stroke width and the rate of change of the UV coordinates of the text network, and dynamically calculate the ellipse radius in UV space for each pixel.
7. The method according to claim 6, wherein, Texture sampling is performed within a small area around the UV coordinates corresponding to the current pixel. The rendering of the outline also includes: In n samplings of the elliptical circumference, sampling points that are not within the original UV coordinate bounding box are discarded. The transparency values of the remaining sampling points are added together and smoothly mapped to the range [0,1] to obtain a new transparency value, which is then used as the transparency value of the current pixel.
8. The method according to claim 7, wherein, The method also includes: After discarding sampling points that are not within the original UV coordinate bounding box, the transparency values of the remaining sampling points are summed and smoothly mapped to the range [0,1] to obtain a new transparency value. If the new transparency value is less than or equal to a preset threshold, the current pixel is discarded.
9. A device for enhancing text display in real-time rendering applications, characterized in that, include: An expansion unit is used to acquire text mesh data, expand the original vertex coordinates and original UV coordinates of the text to obtain first vertex data and first UV coordinates; the offset of the expansion is based on the target width of the stroke. The first calculation unit is used to calculate the uniform stroke parameters and write them into the constant buffer. The second calculation unit is used to calculate vertex effect parameters according to the target rendering effect, write back the first vertex data and write it into the vertex buffer together with the first UV coordinates; Create a unit to create the stroke rendering channel and the text rendering channel, and complete the configuration of the rendering channels; The first rendering unit is used in the stroke rendering channel. The fragment shader obtains the parameters of the buffer and performs multiple texture samplings in a small area around the UV coordinates corresponding to the current pixel to complete the stroke rendering. The second rendering unit is used to render text in the text rendering channel.
10. A computing device, comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, characterized in that, When the processor executes the instructions, it implements the steps of the method according to any one of claims 1-8.
11. A computer-readable storage medium storing computer instructions, characterized in that, When executed by the processor, this instruction implements the steps of the method according to any one of claims 1-8.