CN-121982185-A - Map generation method, apparatus, device, storage medium, and program product
Abstract
The present disclosure relates to the technical field of computer graphics, and provides a method, a device, an apparatus, a storage medium and a program product for generating a map, wherein the method for generating a map includes firstly obtaining a texture image of a target two-dimensional object, and extracting brightness information of each pixel; the method comprises the steps of obtaining bone animation data of a target two-dimensional object, determining a vertex normal vector transformed in real time along with bone motion, calculating theoretical illumination intensity of each pixel in a preset virtual light source direction based on the vertex normal vector, determining depth information of each pixel by utilizing difference between extracted brightness information and calculated theoretical illumination intensity, and finally generating a normal map for illumination rendering according to the depth information. The method and the device can generate the normal map adapting to the dynamic deformation of the bone animation, and solve the problems that the manufacturing cost is high and the static map cannot be matched with the dynamic gesture in the related technology.
Inventors
- HUANG TAO
- XU TIANSHU
Assignees
- 广州博冠信息科技有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20251215
Claims (12)
- 1. A method of map generation, the method comprising: acquiring a texture image of a target two-dimensional object, and extracting brightness information of each pixel in the texture image; determining vertex normal vectors transformed with bone motion based on bone animation data driving the target two-dimensional object; Determining illumination intensity of each pixel in the texture image in a preset virtual light source direction based on the vertex normal vector; determining depth information of each pixel in the texture image according to the brightness information and the illumination intensity; And generating a normal map for illumination rendering according to the depth information.
- 2. The method of claim 1, wherein the extracting luminance information of each pixel in the texture image comprises: sampling the texture image to obtain color channel components of each pixel; And carrying out weighted summation on the color channel components according to a preset weighting coefficient to obtain brightness information of each pixel.
- 3. The method of claim 1, wherein determining vertex normal vectors transformed with bone motion based on bone animation data driving the target two-dimensional object comprises: acquiring an initial vertex normal vector of the target two-dimensional object; Acquiring a skeleton transformation matrix and vertex weights in the skeleton animation data; And carrying out weighted transformation on the initial vertex normals according to the vertex weights and the skeleton transformation matrix to obtain vertex normals vectors transformed along with the skeleton movement.
- 4. A method according to claim 3, wherein the initial vertex normal vector is perpendicular to a screen projection plane in which the target two-dimensional object lies.
- 5. The method of claim 1, wherein determining the illumination intensity of each pixel in the texture image in a preset virtual light source direction based on the vertex normal vector comprises: the direction vector of the preset virtual light source direction is obtained, wherein the preset virtual light source direction is a target direction relative to a texture coordinate system; And calculating the dot product of the vertex normal vector and the direction vector, and limiting the dot product result within a preset range to obtain the illumination intensity.
- 6. The method of claim 1, wherein determining depth information for each pixel in the texture image based on the luminance information and the illumination intensity comprises: multiplying the difference value between the brightness information and the illumination intensity by a preset depth scaling parameter to obtain a depth offset; And obtaining a basic depth value of each pixel in the texture image, and overlapping the depth offset to the basic depth value to obtain the depth information of each pixel.
- 7. The method of claim 1, wherein prior to the step of generating a normal map for illumination rendering from the depth information, further comprising: and smoothing the depth map corresponding to the depth information.
- 8. The method of claim 1, wherein generating a normal map for illumination rendering from the depth information comprises: determining a depth gradient value of each pixel according to the depth information; and constructing a normal vector according to the depth gradient value, and carrying out normalization processing and color space mapping on the normal vector to generate the normal map.
- 9. A map generation apparatus, the apparatus comprising: The brightness extraction module is used for acquiring a texture image of the target two-dimensional object and extracting brightness information of each pixel in the texture image; The normal determining module is used for determining vertex normal vectors transformed with bone motion based on bone animation data for driving the target two-dimensional object; The illumination determining module is used for determining illumination intensity of each pixel in the texture image in a preset virtual light source direction based on the vertex normal vector; the depth determining module is used for determining the depth information of each pixel in the texture image according to the brightness information and the illumination intensity; and the generating module is used for generating a normal map for illumination rendering according to the depth information.
- 10. An electronic device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory having stored therein computer instructions, the processor executing the computer instructions to perform the map generation method of any of claims 1 to 8.
- 11. A computer-readable storage medium having stored thereon computer instructions for causing a computer to perform the map generation method of any one of claims 1 to 8.
- 12. A computer program product comprising computer instructions for causing a computer to perform the map generation method of any one of claims 1 to 8.
Description
Map generation method, apparatus, device, storage medium, and program product Technical Field The present disclosure relates to the field of computer graphics technology, and in particular, to a method, an apparatus, a device, a storage medium, and a program product for generating a map. Background In 2D (two-dimensional) game development, in order for a 2D image to exhibit a real-time illumination effect with a sense of volume, it is generally necessary to simulate the concave-convex details of the object surface using a normal line map. The existing normal map acquisition mode mainly depends on manual drawing by an artist or estimation generation from a static picture by using an artificial intelligent model. However, the manual drawing of the normal map is complicated in manufacturing process, high in time and labor cost, and difficult to ensure consistency of drawing standards of different art personnel, the geometric information of the conventional depth map or normal map generated based on the static picture is usually fixed, when a 2D character is subjected to dynamic deformation such as limb bending, rotation and the like under the driving of skeleton animation, the static normal data cannot be transformed in line with the physical rule, so that high light and shadow of illumination cannot accurately follow the character action, the illumination rendering effect is unnatural, and the high-quality rendering requirement of a dynamic scene is difficult to meet. Therefore, a map generation method is needed to solve the problem that the static normal map in the related art cannot adapt to the dynamic deformation of the bone animation. Disclosure of Invention The disclosure provides a method, a device, equipment, a storage medium and a program product for generating a map, which are used for solving the problem that a static normal map in the related art cannot adapt to dynamic deformation of a bone animation. In a first aspect, the present disclosure provides a method for generating a map, the method comprising: Acquiring a texture image of a target two-dimensional object, and extracting brightness information of each pixel in the texture image; Determining vertex normal vectors transformed with bone motion based on bone animation data of the driving target two-dimensional object; determining illumination intensity of each pixel in the texture image in a preset virtual light source direction based on the vertex normal vector; determining depth information of each pixel in the texture image according to the brightness information and the illumination intensity; from the depth information, a normal map for illumination rendering is generated. According to the map generation method, the brightness information of the texture image is obtained, the vertex normal vector transformed along with the motion is determined by combining the bone animation data of the driving target two-dimensional object, the illumination intensity under the virtual light source is calculated, and finally the depth information is determined by utilizing the relation between the brightness information and the illumination intensity, so that the normal map is generated. The method has the advantage that depth and normal information with dynamic adaptability can be generated by combining static texture brightness with dynamic bone normal. Because the derivation of the depth information depends on the vertex normals transformed along with the bone motion, the generated normals map can accurately follow the bone motion of the role in real time to generate deformation conforming to the physical rule, thereby not only eliminating the cost of manual manufacturing, but also solving the problem that the illumination effect of the traditional static normals map in dynamic bone animation is unnatural. In an alternative embodiment, extracting brightness information of each pixel in the texture image includes: Sampling the texture image to obtain color channel components of each pixel; And carrying out weighted summation on the color channel components according to a preset weighting coefficient to obtain brightness information of each pixel. The present disclosure also obtains luminance information by sampling the texture image and weighting and summing the color channel components using a preset weighting coefficient. Compared with simple average value calculation, the weighted summation can more accurately extract the brightness distribution conforming to visual perception, so that the depth fluctuation deduced based on brightness is more natural and real. In an alternative embodiment, determining vertex normal vectors transformed with bone motion based on bone animation data of a driving target two-dimensional object includes: acquiring an initial vertex normal vector of a target two-dimensional object; Acquiring a skeleton transformation matrix and vertex weights in skeleton animation data; And carrying out weighted transformation on the init