Method and device for drawing light and shadow
By creating a drawing plane on the target model and directly determining the mapping information to generate light and shadow information, the problem of low light and shadow drawing efficiency in the existing technology is solved, and efficient light and shadow drawing without the need for external software is achieved.
Patent Information
- Application Number
- CN202210689282.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-17
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2042-06-17
AI Technical Summary
Existing light and shadow rendering methods rely on external software, making it difficult to accurately control the position and shape of complex light and shadow, resulting in low light and shadow rendering efficiency.
By creating a drawing plane on the target model, the mapping information is directly determined on the plane to generate light and shadow information, realizing light and shadow drawing without the help of external software.
It improves the efficiency of light and shadow drawing, enriches the light and shadow effects, has a wide range of applications, and does not require repeated debugging.
Smart Images

Figure CN114972615B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of games, and in particular to a method and device for drawing light and shadow. Background Art
[0002] In the creation of User Experience (UE) videos, it is often necessary to render atmospheric light and shadow to shape the picture layering, convey the design emotion, enhance the overall effect of the picture, and make the picture more vivid and specific, especially the light and shadow expression in close-up scenes and on the faces and bodies of characters.
[0003] However, existing light and shadow rendering methods rely on external software for drawing, and it is difficult to accurately control the position and shape of complex light and shadow. Therefore, continuous debugging is required when drawing complex light and shadow, resulting in low light and shadow drawing efficiency. Summary of the Invention
[0004] In view of the above problems, a method and apparatus for rendering light and shadow is proposed to overcome or at least partially solve the above problems, including:
[0005] A method for drawing light and shadow, the method comprising:
[0006] In response to the light and shadow creation operation, creating a target model and a target drawing plane for generating light and shadow information;
[0007] In response to a drawing operation on the target model, determining mapping information corresponding to the drawing operation in the target drawing plane;
[0008] Target light and shadow information of the target model is generated according to the mapping information.
[0009] Optionally, the target model is a three-dimensional target model, and the step of determining, in response to a drawing operation on the target model, mapping information corresponding to the drawing operation in the target drawing plane includes:
[0010] In response to a drawing operation on the target model, determining first position information corresponding to the drawing operation in the target model;
[0011] Taking the first position information as a starting position, emitting a first ray in a preset lighting direction, and determining a first intersection point between the ray and the target drawing plane;
[0012] Determine mapping information corresponding to the drawing operation in the target drawing plane according to the first intersection point.
[0013] Optionally, in response to a drawing operation on the target model, the step of determining first position information corresponding to the drawing operation includes:
[0014] Obtaining a two-dimensional UV plane image according to the three-dimensional target model;
[0015] In response to a drawing operation on the three-dimensional object model, determining second position information of the drawing operation in the UV plane image;
[0016] Performing scene capture on the UV plane image to obtain a target rendered image;
[0017] In the target rendered image, the second position information is converted into the first position information.
[0018] Optionally, the step of determining, according to the first intersection point, mapping information corresponding to the drawing operation in the target drawing plane includes:
[0019] The coordinates of the first intersection point are converted according to the coordinate system of the target drawing plane to obtain mapping information.
[0020] Optionally, in response to a drawing operation on the three-dimensional object model, the step of determining second position information of the drawing operation in the UV plane image includes:
[0021] Acquiring cursor position information when performing a drawing operation on the three-dimensional target model;
[0022] Determine second position information corresponding to the cursor position information in the UV plane image.
[0023] Optionally, the step of determining second position information corresponding to the cursor position information in the UV plane image includes:
[0024] determining a second intersection point between a second ray emitted from the cursor position information and the three-dimensional object model;
[0025] Determine second position information corresponding to the second intersection point in the UV plane image.
[0026] Optionally, the step of converting the second position information into the first position information in the target rendered image includes:
[0027] Determining a UV value corresponding to the second position information in the target rendered image;
[0028] The world coordinate information of the second intersection point is subtracted from the UV value, and the result is rotated according to the direction of the second ray to obtain the first position information.
[0029] A light and shadow rendering device, comprising:
[0030] A creation module, configured to create a target model and a target drawing plane for generating light and shadow information in response to the light and shadow creation operation;
[0031] A texture acquisition module, configured to respond to a drawing operation on the target model and determine texture information corresponding to the drawing operation in the target drawing plane;
[0032] A light and shadow generation module is used to generate target light and shadow information of the target model according to the mapping information.
[0033] An electronic device comprises a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the light and shadow drawing method as described in any one of the above items.
[0034] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the light and shadow drawing method described above.
[0035] The embodiments of the present invention have the following advantages:
[0036] In an embodiment of the present invention, by responding to the light and shadow creation operation, a target model and a target drawing plane for generating light and shadow information are created, and then responding to the drawing operation for the target model, the mapping information corresponding to the drawing operation in the target drawing plane is determined, so that the target light and shadow information of the target model is generated according to the mapping information, thereby realizing light and shadow drawing directly on the target model without the aid of external software, having a wide range of applications, enriching the light and shadow effects, and improving the light and shadow drawing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for use in the description of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0038] Figure 1 This is a flowchart of a light and shadow rendering method provided by one embodiment of the present invention;
[0039] Figure 2 is a flowchart of another light and shadow rendering method provided by one embodiment of the present invention;
[0040] Figure 3a This is a flowchart of a method for drawing light and shadow provided by one embodiment of the present invention;
[0041] Figure 3bThis is a schematic diagram of creating a drawing plane provided by an embodiment of the present invention;
[0042] Figure 3c is a schematic diagram of creating a target model provided by an embodiment of the present invention;
[0043] Figure 4a This is a flowchart of another method for drawing light and shadow provided by one embodiment of the present invention;
[0044] Figure 4b This is a target drawing plane schematic diagram provided by an embodiment of the present invention;
[0045] Figure 5a This is a flowchart of the steps of another method for drawing light and shadow provided by one embodiment of the present invention;
[0046] Figure 5b This is a schematic diagram of a cursor drawing light and shadow provided by an embodiment of the present invention;
[0047] Figure 6 3 is a schematic structural diagram of a light and shadow drawing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0048] To make the above-mentioned objects, features, and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments described are only a portion of the embodiments of the present invention, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are also within the scope of protection of the present invention.
[0049] When creating images or videos, appropriate lighting and shadow effects can create a special atmosphere. Currently, there are two main solutions for rendering lighting and shadows:
[0050] Solution 1: Designers achieve light and shadow effects by placing a mesh between the object and the sunlight to form a light and shadow shield, such as Figure 1 As shown; Option 2: Draw a black and white mask map in external software and import it into UE, such as Figure 2 shown.
[0051] In actual application, when rendering light and shadow for the model, you can use the following method: Figure 1 The rendering method shown generates light and shadow on the character model by placing a mesh between the directional light and the UE built-in mesh to form a light and shadow block. Its light and shadow effect is limited by the mesh, so it can only form a simple light and shadow effect. In addition, it is difficult to intuitively judge the light spot effect after the light passes through the mesh by adjusting the shape of the mesh hole. It is necessary to rely on external software for continuous adjustment, which leads to low efficiency in light and shadow production.
[0052] In practical applications, you can also use Figure 2 The rendering method shown in the figure uses external software to draw a map, which is then applied to the character model. Although complex light and shadow effects can be drawn, it is difficult to control the position and shape of the light and shadow, and continuous debugging is required, resulting in low light and shadow efficiency.
[0053] In an embodiment of the present invention, a drawing plane is created in front of the created target model. Without the aid of external drawing software, the drawing of the target model is directly reflected on the drawing plane to obtain a plane map, and then light and shadow information is generated through the map, so that intuitive light and shadow drawing can be achieved on the target model. Simple light and shadow can be drawn, as well as complex light and shadow, and the application range is wide. Therefore, the light and shadow drawing method of the embodiment of the present invention can be applied to enrich the light and shadow drawing effect. At the same time, without the aid of external software, the designer can intuitively see the light and shadow effect without the need for repeated debugging, thereby improving the light and shadow drawing efficiency.
[0054] Reference Figure 3a , shows a flowchart of a light and shadow drawing method provided by an embodiment of the present invention, which may specifically include the following steps:
[0055] Step 301, in response to the light and shadow creation operation, creating a target model and a target drawing plane for drawing light and shadow information of the target model;
[0056] In one example, the target model may be a character model, an environment model, etc. to which light and shadow information is to be added, wherein the character model may include a model of a character image in a game scene, specifically, the character image may be a person, animal, plant, or other character; the environment model may include a model in a game scene used to represent the environment in which the character is located, specifically, the environment model may include a building model, a natural landscape model, etc.
[0057] In natural environments, lighting can create different light and shadow effects on different objects, resulting in different visual experiences. In the gaming field, to realistically simulate real-world scenes or create a specific visual atmosphere, you can render light and shadow on the created models.
[0058] In practical applications, when creating a target model, a target drawing plane for drawing light and shadow information of the target model can be created in the same environment.
[0059] In one example, the relative position of the target drawing plane and the target model in the environment can be adjusted according to the light and shadow effects that the user needs to achieve. For example, when the user needs to draw light and shadow on the front of the target model, the target drawing plane can be created on the front of the target model; when the user needs to draw light and shadow on the side of the target model, the target drawing plane can be created on the side of the target model.
[0060] like Figures 3b-3c As shown in the figure, they are schematic diagrams of creating a drawing plane and a target model. Figure 3b On the left, create a blueprint named BP_Canvas, place a plane (Canvas), directional light (DirectionalLight), and arrow (Arrow, consistent with the direction of directional light) in the blueprint. Figure 3b In the scene layout diagram shown on the right, the plane, directional light, and arrow combination are placed in front of the character model to be rendered with light and shadow. In this blueprint, it is used to draw the light and shadow mask on the plane (Canvas).
[0061] like Figure 3c As shown, create a blueprint named BP_paintMesh and place the model SkeletalMesh and SceneCaptureComponent2D to be painted in it. The left side is the 3D model, and the right side is the UV image of the model after unfolding.
[0062] This blueprint is used to convert the point in the absolute world coordinate system (the position where the ray emitted from the drawing plane hits the character) into the position on the character's UV, so that painting can be performed on the character.
[0063] Step 302: In response to a drawing operation on the target model, determine the mapping information corresponding to the drawing operation in the target drawing plane;
[0064] After creating the target model and target drawing plane, you can draw the desired light and shadow effects on the target model. Through drawing operations, you can map it to the target drawing plane to obtain the mapping information corresponding to the drawing operation in the target drawing plane.
[0065] In one example, the light and shadow drawing operation can be generated through a mouse operation, a keyboard operation, a touch screen operation or other input devices.
[0066] Step 303: Generate target light and shadow information of the target model according to the mapping information.
[0067] After the mapping information is generated, light and shadow rendering can be performed based on the mapping information to generate target light and shadow information of the target model.
[0068] In one example, the target drawing plane's material blending mode can be changed to Masked to generate the target light and shadow information for the target model. In actual applications, by directly drawing light and shadow on the target model as required and obtaining the mapping information on the drawing plane through reverse mapping, when the plane is changed to Masked, it is equivalent to using the drawing plane as a light blocker. The drawing plane is perforated according to the mapping information. When light from the preset lighting direction shines through the corresponding aperture on the drawing plane and shines on the target model, the light and shadow effect drawn by the user can be formed.
[0069] In another example, the attribute feature channel1 can be added to the target model, and the Lighting channel of DirectionalLight can be modified to channel1, so that the target light and shadow information only acts on the target model and is invalid for other models in the environment (i.e., no light and shadow is generated).
[0070] When users need to achieve complex light and shadow effects, they can directly draw on the target model according to their own needs, so that they can accurately control the position and shape of the light and shadow effects to be achieved. Then, the drawn light and shadow effects are mapped to obtain the corresponding mapping information on the drawing plane, and then the target light and shadow information can be generated through the mapping information, thereby achieving precise control of the position and shape of the generated light and shadow, and improving the efficiency of light and shadow drawing.
[0071] In an embodiment of the present invention, by responding to the light and shadow creation operation, a target model and a target drawing plane for generating light and shadow information are created, and then responding to the drawing operation for the target model, the mapping information corresponding to the drawing operation in the target drawing plane is determined, so that the target light and shadow information of the target model is generated according to the mapping information, thereby realizing light and shadow drawing directly on the target model without the aid of external software, having a wide range of applications, enriching the light and shadow effects, and improving the light and shadow drawing efficiency.
[0072] Reference Figure 4a , shows a flowchart of another light and shadow drawing method provided by an embodiment of the present invention, which may specifically include the following steps:
[0073] Step 401, in response to the light and shadow creation operation, creating a target model and a target drawing plane for generating light and shadow information;
[0074] Step 402: In response to a drawing operation on the target model, determine first position information corresponding to the drawing operation in the target model;
[0075] After creating the target model and the target drawing plane, light and shadow drawing can be performed on the target model to determine the first position information corresponding to the drawing operation in the target model. The first position information is the position information transmitted to the brush when the drawing operation is performed on the target model, so that the brush follows the drawing operation of the target user and draws on the target model.
[0076] For example, taking the mouse drawing operation as an example, when the target user uses the mouse to draw light and shadow on the target model, the first position information of the brush corresponding to the mouse operation can be determined, and the first position information can be transmitted to the brush, so that the effect of the brush following the mouse to draw on the target model can be achieved.
[0077] Step 403: Using the first position information as a starting position, emitting a first ray in a preset illumination direction, and determining a first intersection point between the ray and the target drawing plane;
[0078] The first position information may correspond to the position information corresponding to the target light and shadow effect that the user expects to obtain on the target model. Furthermore, after determining the first position information, the first position information may be used as a starting point to emit a first ray along a preset lighting direction, and reversely simulate sunlight from a certain angle (i.e., the preset lighting direction) to determine the first intersection point of the first ray and the target drawing plane, wherein the first intersection point is a point on the target drawing plane, and the first intersection point can be projected onto the first position information on the target model along the preset lighting direction.
[0079] Step 404: Determine the mapping information corresponding to the drawing operation in the target drawing plane according to the first intersection point.
[0080] After obtaining the first intersection point, position information on the target drawing plane may be determined based on the intersection point. The position information on the target drawing plane is the mapping information corresponding to the drawing operation on the target drawing plane.
[0081] By inferring the mapping on the target drawing plane from the light and shadow effects that the user needs, the light and shadow mapping information with accurate position and shape can be obtained, eliminating the need for repeated debugging and improving the efficiency of light and shadow drawing.
[0082] In an embodiment of the present invention, step 404 specifically includes: converting the coordinates of the first intersection point according to the coordinate system of the target drawing plane to obtain mapping information.
[0083] In actual applications, the coordinate system of the target model and the coordinate system of the target drawing plane may be different. When a ray is emitted from the target model to the plane, the position information of the intersection point obtained is the position information calculated based on the target model. Therefore, the position information of the intersection point needs to be converted into the position information in the coordinate system of the target drawing model, that is, a coordinate system conversion is performed.
[0084] like Figure 4b As shown, it is a schematic diagram of a coordinate transformation in the target drawing plane.
[0085] In UE, you can use getWorldLocation and getWorldScale to get the plane's location (i.e., the P0 position in the figure, i.e., the position of the target drawing plane in the world coordinate system where the target model is located, i.e., the position of the plane center point in the world coordinate system) and the scale value scale. The default size of the plane is 100*100.
[0086] Pu0=location
[0087] Pu1=Pu0-50*scale (P1 is a corner point of the plane)
[0088] Pu2 = Draw Location u (i.e., P2 is the first intersection point, the intersection position coordinates in the world coordinate system of the target model)
[0089] Lu2=Draw Location u-Pu1
[0090] UV X=Lu2 / (100*scale)
[0091] Similarly, UV Y, UV X, and UV Y can be calculated, which are the coordinate point information of point P2 on the target drawing plane after the coordinate system conversion.
[0092] Step 405: Generate target light and shadow information of the target model according to the mapping information.
[0093] In an embodiment of the present invention, the first position information of the target model is obtained by performing a drawing operation on the target model, and the first position information forms a ray to determine the mapping information corresponding to the intersection point on the target drawing plane. According to the mapping information, the light and shadow information expected by the user can be generated quickly and accurately, thereby improving the light and shadow drawing efficiency.
[0094] Reference Figure 5a , shows a flowchart of another light and shadow drawing method provided by an embodiment of the present invention, which may specifically include the following steps:
[0095] Step 501: In response to the light and shadow creation operation, create a target model and a target drawing plane for generating light and shadow information; wherein the target model is a three-dimensional target model;
[0096] Step 502: obtaining a two-dimensional UV plane image based on the three-dimensional target model;
[0097] After building a 3D object model, you can unfold it to obtain a 2D UV plane image. Specifically, each 3D coordinate point in the 3D object model can be stretched along the UV direction (i.e., the direction of the plane formed by the X-axis and Y-axis), and the Z-axis value is subtracted after stretching to obtain a 2D UV plane image.
[0098] Step 503: In response to a drawing operation on the target model, determine second position information of the drawing operation in the UV plane image;
[0099] When a drawing operation is performed on the target model, the drawing operation may correspond to determining the second position information in the UV plane image.
[0100] In this embodiment of the present invention, step 503 may include the following sub-steps:
[0101] Sub-step 5031, obtaining cursor position information when performing a drawing operation on the target model;
[0102] Sub-step 5032: Determine the second position information corresponding to the cursor position information in the UV plane image.
[0103] In one embodiment of the present invention, the sub-step 5032 may include:
[0104] Step S511, determining a second intersection point between a second ray emitted from the cursor position information and the target model;
[0105] Step S512: Determine second position information corresponding to the second intersection point in the UV plane image.
[0106] like Figure 5b As shown, you can create a Character blueprint class named FirstPersonCharacter and place a camera in this blueprint class. This blueprint mainly controls the player's operation behavior at runtime. When you click Run, the screen will be switched to the FirstPersonCamera perspective. Create a widget as the mouse shape. The mouse shape is also the brush shape for drawing light and shadow, and its size can be set. In addition, you can also get the raycast from the mouse hitting the object in this blueprint. Figure 3cThe world coordinate position of BP_paintMesh in (i.e. the second intersection point) and the world coordinate position of the target drawing plane (i.e. the first intersection point).
[0107] In the FirstPersonCharacter blueprint, the mouse position information is obtained and the end position is set along a preset direction to form a second ray. The position in the world coordinate space where the BP_paintMesh is hit (i.e., the second position information) can be obtained and assigned to the paint function's position (i.e., the second position information of the second intersection point) and Normal (i.e., the direction of the second ray).
[0108] Step 504: performing scene capture on the UV plane image to obtain a target rendered image;
[0109] Step 505: Convert the second position information into first position information in the target rendered image.
[0110] After determining the target rendering image, the second position information in the UV plane image can be converted into the first position information in the target rendering image. The first position information can be transmitted to the brush, thereby enabling the brush to perform light and shadow drawing on the target model as the mouse is operated.
[0111] In one embodiment of the present invention, step 505 specifically includes: determining a UV value corresponding to the second position information in the target rendered image; subtracting the world coordinate information of the second intersection point from the UV value, and rotating according to the direction of the second ray to obtain the first position information.
[0112] In practical applications, each coordinate point in the target rendered image is determined, so that the UV value corresponding to the second position information can be obtained. The coordinate point is subtracted from the world coordinate information of the second intersection point, and a vector rotation is performed according to the direction of the second ray to obtain the first position information.
[0113] Since the UV plane is stretched and offset during the unfolding process, when the cursor draws on the target model, multiple second position information indicating the same cursor drawing operation will appear on the unfolded UV plane. The rendered target rendering image corresponds to the brush pattern. By processing the points on the target rendering image, the brush operation corresponding to the cursor drawing operation can be obtained.
[0114] Step 506: Using the first position information as a starting position, emitting a first ray in a preset illumination direction, and determining a first intersection point between the ray and the target drawing plane;
[0115] Step 507: Determine the mapping information corresponding to the drawing operation in the target drawing plane according to the first intersection point.
[0116] Step 508: Generate target light and shadow information of the target model according to the mapping information.
[0117] In an embodiment of the present invention, the first position information of the target model is obtained by performing a drawing operation on the target model, and the first position information forms a ray to determine the mapping information corresponding to the intersection point on the target drawing plane. According to the mapping information, the light and shadow information expected by the user can be generated quickly and accurately, thereby improving the light and shadow drawing efficiency.
[0118] It should be noted that for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0119] Reference Figure 6 , which shows a schematic structural diagram of a light and shadow drawing device provided by an embodiment of the present invention, which may specifically include the following modules:
[0120] A creation module 601 is configured to create a target model and a target drawing plane for generating light and shadow information in response to the light and shadow creation operation;
[0121] A texture acquisition module 602 is configured to respond to a drawing operation on the target model and determine texture information corresponding to the drawing operation in the target drawing plane;
[0122] The light and shadow generation module 603 is used to generate target light and shadow information of the target model according to the mapping information.
[0123] In one embodiment of the present invention, the texture acquisition module 602 may include:
[0124] a first position determination submodule, configured to respond to a drawing operation on the target model and determine first position information corresponding to the drawing operation in the target model;
[0125] A first intersection point determination submodule is configured to use the first position information as a starting position, emit a first ray in a preset illumination direction, and determine a first intersection point between the ray and the target drawing plane;
[0126] The mapping determination submodule is configured to determine mapping information corresponding to the drawing operation in the target drawing plane according to the first intersection point.
[0127] In one embodiment of the present invention, the first location information determination submodule may include:
[0128] A UV plane determining unit, configured to obtain a two-dimensional UV plane image based on the three-dimensional target model;
[0129] a second position information determining unit, configured to determine, in response to a drawing operation on the three-dimensional object model, second position information of the drawing operation in the UV plane image;
[0130] A scene capture unit, configured to perform scene capture on the UV plane image to obtain a target rendered image;
[0131] The first position information determining unit is configured to convert the second position information into first position information in the target rendered image.
[0132] In one embodiment of the present invention, when the mapping determination submodule is used to determine the mapping information corresponding to the drawing operation in the target drawing plane according to the first intersection point, it is specifically used to:
[0133] The coordinates of the first intersection point are converted according to the coordinate system of the target drawing plane to obtain mapping information.
[0134] In one embodiment of the present invention, the second location information determining unit may include:
[0135] a cursor position information determining subunit, which obtains cursor position information when performing a drawing operation on the three-dimensional target model;
[0136] The second position information determining subunit determines second position information corresponding to the cursor position information in the UV plane image.
[0137] In one embodiment of the present invention, when the second position information determining subunit is used to determine the second position information corresponding to the cursor position information in the UV plane image, it is specifically used to:
[0138] Determine a second intersection point between a second ray emitted from the cursor position information and the three-dimensional target model; and determine second position information corresponding to the second intersection point in the UV plane image.
[0139] In one embodiment of the present invention, the first location information determining unit may include:
[0140] A third position determination subunit is configured to determine a UV value corresponding to the second position information in the target rendered image;
[0141] The first position information determining subunit is configured to subtract the world coordinate information of the second intersection point from the UV value and rotate according to the direction of the second ray to obtain the first position information.
[0142] In an embodiment of the present invention, by responding to the light and shadow creation operation, a target model and a target drawing plane for generating light and shadow information are created, and then responding to the drawing operation for the target model, the mapping information corresponding to the drawing operation in the target drawing plane is determined, so that the target light and shadow information of the target model is generated according to the mapping information, thereby realizing light and shadow drawing directly on the target model without the aid of external software, having a wide range of applications, enriching the light and shadow effects, and improving the light and shadow drawing efficiency.
[0143] An embodiment of the present invention further provides an electronic device, which may include a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the steps of the above light and shadow drawing method are implemented.
[0144] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above light and shadow drawing method are implemented.
[0145] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0146] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0147] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, apparatus, or computer program products. Thus, embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0148] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the process in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0149] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0150] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0151] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0152] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0153] The above is a detailed introduction to the provided method and device for drawing light and shadow. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core ideas. At the same time, for those skilled in the art, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A method for drawing light and shadow, characterized in that: The method comprises: In response to the light and shadow creation operation, a target model and a target drawing plane for generating light and shadow information are created; the target model is a three-dimensional target model; Obtaining a two-dimensional UV plane image according to the three-dimensional target model; In response to a drawing operation on the three-dimensional object model, determining second position information of the drawing operation in the UV plane image; Performing scene capture on the UV plane image to obtain a target rendered image; In the target rendered image, converting the second position information into the first position information; Taking the first position information as a starting position, emitting a first ray in a preset lighting direction, and determining a first intersection point between the ray and the target drawing plane; Determining mapping information corresponding to the drawing operation in the target drawing plane according to the first intersection point; Target light and shadow information of the target model is generated according to the mapping information.
2. The method according to claim 1, characterized in that The step of determining the mapping information corresponding to the drawing operation in the target drawing plane according to the first intersection point includes: The coordinates of the first intersection point are converted according to the coordinate system of the target drawing plane to obtain mapping information.
3. The method according to claim 1, characterized in that The step of determining second position information of the drawing operation in the UV plane image in response to the drawing operation on the three-dimensional object model includes: Acquiring cursor position information when performing a drawing operation on the three-dimensional target model; Determine second position information corresponding to the cursor position information in the UV plane image.
4. The method according to claim 3, characterized in that The step of determining second position information corresponding to the cursor position information in the UV plane image includes: determining a second intersection point between a second ray emitted from the cursor position information and the three-dimensional object model; Determine second position information corresponding to the second intersection point in the UV plane image.
5. The method according to claim 4, characterized in that The step of converting the second position information into the first position information in the target rendered image includes: Determining a UV value corresponding to the second position information in the target rendered image; The world coordinate information of the second intersection point is subtracted from the UV value, and the result is rotated according to the direction of the second ray to obtain the first position information.
6. A light and shadow rendering device, characterized in that: The device comprises: A creation module, configured to create a target model and a target drawing plane for generating light and shadow information in response to the light and shadow creation operation; the target model is a three-dimensional target model; A UV plane determining unit, configured to obtain a two-dimensional UV plane image based on the three-dimensional target model; a second position information determining unit, configured to determine, in response to a drawing operation on the three-dimensional object model, second position information of the drawing operation in the UV plane image; A scene capture unit, configured to perform scene capture on the UV plane image to obtain a target rendered image; a first position information determining unit, configured to convert the second position information into first position information in the target rendered image; A first intersection point determination submodule is configured to use the first position information as a starting position, emit a first ray in a preset illumination direction, and determine a first intersection point between the ray and the target drawing plane; a mapping determination submodule, configured to determine mapping information corresponding to the drawing operation in the target drawing plane according to the first intersection point; A light and shadow generation module is used to generate target light and shadow information of the target model according to the mapping information.
7. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein when the computer program is executed by the processor, the method for rendering light and shadow according to any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the light and shadow drawing method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Method and apparatus for projective texture mapping rendered from arbitrarily positioned and oriented light source
US5805782A