Method, device and electronic equipment for rendering an eye ball glint
Patent Information
- Application Number
- CN202211415602.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-11
- Publication Date
- 2026-09-29
- Estimated Expiration
- 2042-11-11
AI Technical Summary
这种方式中,需要使用三维贴图,实现过程较为复杂,对运行设备的性能消耗较高
本发明提供了一种眼球光斑的渲染方法、装置和电子设备,获取虚拟对象的眼球模型,基于眼球模型的眼球朝向,确定三维坐标系;获取射入眼球模型的光照方向,确定光照方向在三维坐标系的指定坐标平面上的投影向量;确定投影向量与三维坐标系的指定坐标轴之间的目标夹角信息;基于目标夹角信息对预设的光斑贴图进行旋转处理,将旋转后的光斑贴图渲染至眼球模型,得到具有眼球光斑效果的眼球模型。该方式中,通过光照方向和眼球朝向,可以确定预设的光斑贴图在不同光照下的旋转角度,通过一次贴图采样即可得到具有光斑效果的眼球模型,使得眼睛的光斑能够随着光照方向的改变而改变,实现过程简单,降低了对运行设备的性能消耗,提高了眼球光斑的渲染效果。
Smart Images

Figure CN115880412B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of portrait processing technology, and in particular to a method, apparatus and electronic device for rendering eyeball light spots. Background Technology
[0002] Iridescent spots are a phenomenon where light refracts through the crystalline structure of the eye, creating bright spots on the iris and making it appear brighter. This phenomenon can be simulated in games to make virtual characters and game visuals more realistic. Some techniques pre-render the effects of different lighting conditions onto different 3D textures, resulting in multiple 3D texture maps. Then, based on the actual lighting information, the corresponding 3D texture map is sampled and overlaid onto the eyeball material. This method requires 3D textures, is complex, and consumes significant device resources. Other techniques directly render the iris-brightening effect of the light spots onto the eyeball texture. However, this method doesn't consider the direction of light, and the eyeball's bright spots don't change with the direction of light, resulting in poor rendering quality. Summary of the Invention
[0003] In view of this, the purpose of the present invention is to provide a method, apparatus and electronic device for rendering eyeball light spots, so as to reduce the performance consumption of the operating equipment and improve the rendering effect of eyeball light spots.
[0004] In a first aspect, embodiments of the present invention provide a method for rendering eyeball light spots. The method includes: acquiring an eyeball model of a virtual object; determining a three-dimensional coordinate system based on the eyeball orientation of the eyeball model; acquiring the illumination direction incident on the eyeball model; determining the projection vector of the illumination direction on a specified coordinate plane of the three-dimensional coordinate system; determining the target angle information between the projection vector and a specified coordinate axis of the three-dimensional coordinate system; rotating a preset light spot texture based on the target angle information; and rendering the rotated light spot texture onto the eyeball model to obtain an eyeball model with eyeball light spot effects.
[0005] Secondly, embodiments of the present invention provide a rendering device for eyeball spot effects. The device includes: a three-dimensional coordinate system determination module, used to acquire an eyeball model of a virtual object and determine a three-dimensional coordinate system based on the eyeball orientation of the eyeball model; a projection vector determination module, used to acquire the illumination direction incident on the eyeball model and determine the projection vector of the illumination direction on a specified coordinate plane of the three-dimensional coordinate system; a target angle information determination module, used to determine the target angle information between the projection vector and a specified coordinate axis of the three-dimensional coordinate system; and a rendering module, used to rotate a preset spot texture based on the target angle information and render the rotated spot texture onto the eyeball model to obtain an eyeball model with eyeball spot effects.
[0006] Thirdly, embodiments of the present invention provide an electronic device, including a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the method for rendering eyeball light spots according to the first aspect of the claim.
[0007] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing computer-executable instructions. When the computer-executable instructions are invoked and executed by a processor, the computer-executable instructions cause the processor to implement the method for rendering eyeball light spots according to the first aspect of the claim.
[0008] The embodiments of the present invention bring the following beneficial effects: This invention provides a method, apparatus, and electronic device for rendering eyeball vignetting. The method involves acquiring an eyeball model of a virtual object, determining a three-dimensional coordinate system based on the eyeball orientation of the model, acquiring the illumination direction incident on the eyeball model, determining the projection vector of the illumination direction onto a specified coordinate plane of the three-dimensional coordinate system, determining the target angle information between the projection vector and a specified coordinate axis of the three-dimensional coordinate system, rotating a preset vignetting texture based on the target angle information, and rendering the rotated vignetting texture onto the eyeball model to obtain an eyeball model with vignetting effects. In this method, the rotation angle of the preset vignetting texture under different lighting conditions can be determined by the illumination direction and eyeball orientation. An eyeball model with vignetting effects can be obtained with a single texture sampling, allowing the vignetting of the eye to change with the illumination direction. This simplifies the process, reduces the performance consumption of the operating device, and improves the rendering effect of the eyeball vignetting.
[0009] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.
[0010] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0011] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0012] Figure 1A schematic diagram of a three-dimensional texture map with multiple light spots provided in an embodiment of the present invention; Figure 2 A schematic diagram of a cartoon two-dimensional eye model provided in an embodiment of the present invention; Figure 3 A flowchart illustrating a method for rendering an eyeball spot, provided as an embodiment of the present invention; Figure 4 A schematic diagram of a three-dimensional coordinate system provided for an embodiment of the present invention; Figure 5 A schematic diagram of a light spot texture and an eyeball model UV provided in an embodiment of the present invention; Figure 6 A schematic diagram of another three-dimensional coordinate system provided in an embodiment of the present invention; Figure 7 A schematic diagram of the illumination direction in a three-dimensional coordinate system provided for an embodiment of the present invention; Figure 8 A schematic diagram in a three-dimensional coordinate system for another illumination direction provided in an embodiment of the present invention; Figure 9 A schematic diagram in a three-dimensional coordinate system for another illumination direction provided in an embodiment of the present invention; Figure 10 A schematic diagram in a three-dimensional coordinate system for another illumination direction provided in an embodiment of the present invention; Figure 11 This is a schematic diagram illustrating the effect of light direction forming a light spot on an eyeball model, provided as an embodiment of the present invention. Figure 12 A schematic diagram illustrating the effect of another lighting direction forming a light spot on an eyeball model, as provided in an embodiment of the present invention; Figure 13 A schematic diagram illustrating the effect of another lighting direction forming a light spot on an eyeball model, as provided in an embodiment of the present invention; Figure 14 A schematic diagram in a three-dimensional coordinate system for another illumination direction provided in an embodiment of the present invention; Figure 15 A schematic diagram in a three-dimensional coordinate system for another illumination direction provided in an embodiment of the present invention; Figure 16 A schematic diagram of the structure of an eyeball light spot rendering device provided in an embodiment of the present invention; Figure 17 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0013] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0014] Ocular flare refers to the phenomenon where light refracts through the lens of the eye, creating a bright spot on the iris. This phenomenon can be simulated in games to make virtual characters and game graphics more realistic, which is one of the goals of realistic games.
[0015] In some related technologies, ray tracing is often used to pre-render the light spot effects produced by different lighting conditions onto different 3D textures, resulting in multiple light spot 3D textures, such as... Figure 1 The diagram shows multiple white light spot textures. Then, based on the actual lighting direction and model information, the target light spot 3D texture to be used is calculated, sampled, and finally superimposed onto the eyeball material to simulate the eyeball light spot. While this method provides a good simulation effect and is more realistic, it requires the use of 3D textures, the format of which is not suitable for all mobile devices, and the sampling process for 3D textures is relatively complex, resulting in high performance consumption on the running device.
[0016] In other related technologies, the effect of the light spot brightening the iris is usually directly applied to a texture map of the eyeball, such as... Figure 2 The example shown is a cartoon 2D eye model. However, this method does not consider the direction of light, and the light spot of the eye does not change with the change of the direction of light. The rendering of the light spot of the eyeball is too simple, resulting in poor rendering effect.
[0017] Based on this, the present invention provides a method, apparatus and electronic device for rendering eyeball spot, which can be applied to terminal devices such as mobile phones, tablets and computers, and especially to devices with the function of rendering eyeball spot for virtual characters.
[0018] To facilitate understanding of this embodiment, a method for rendering an eyeball spot disclosed in this invention will first be described in detail, such as... Figure 3 As shown, the method includes: Step S302: Obtain the eyeball model of the virtual object, and determine the three-dimensional coordinate system based on the eyeball orientation of the eyeball model; The aforementioned eye model refers to the initial eye model without any speckle mapping processing, including the pupil. The aforementioned eye orientation typically refers to the direction vector of the center of the pupil on the surface of the eye model relative to the center of the eye model. The aforementioned three-dimensional coordinate system typically includes an x-axis, a y-axis, and a z-axis, and the origin of the three-dimensional coordinate system can be either the center of the eye model or the center of the pupil on the surface of the eye model.
[0019] In practice, the eye orientation of the eye model—that is, the direction vector of the pupil's center relative to the eye's center—can be defined as a coordinate axis in a three-dimensional coordinate system. For example, the eye orientation can be defined as the z-axis or x-axis. After determining one coordinate axis (e.g., the z-axis), the other two axes can be determined in a specified direction. For instance, based on the eye orientation, the vector perpendicular to the eye orientation (z-axis) can be defined as another coordinate axis (e.g., the x-axis). Now that two axes are determined, the vector perpendicular to the x and z axes can be directly defined as the y-axis, thus obtaining the three-dimensional coordinate system described above.
[0020] For example, such as Figure 4 The diagram showing a 3D coordinate system, with the center of the eyeball model as the origin of the coordinate axis, illustrates this. The eyeball is currently facing left (the eyeball's direction is determined by the perspective of the virtual object). This direction can be defined as the z-axis. The coordinates are then determined based on the z-axis. Figure 4 The x-axis and y-axis are shown.
[0021] Step S304: Obtain the illumination direction of the light entering the eyeball model, and determine the projection vector of the illumination direction on a specified coordinate plane in the three-dimensional coordinate system; The aforementioned lighting direction specifically refers to the direction of parallel light entering the eyeball model. This lighting direction is always within the space in front of the eyeball, for example, as... Figure 4 As shown, the illumination is always within the space along the positive z-axis. The specified coordinate plane typically includes multiple planes; it can be a coordinate plane composed of a coordinate axis determined by the eye's orientation and a coordinate axis perpendicular to the eye's orientation in the right or left direction; or it can be a coordinate plane composed of a coordinate axis perpendicular to the eye's orientation in the right or left direction and a coordinate axis perpendicular to the eye's orientation in the up or down direction. Similarly, the projection vector may also include multiple vectors. For example, as... Figure 4 As shown, the specified coordinate plane can be the xz plane or the xy plane. In actual calculations, the above-mentioned lighting direction is actually a vector with the origin as its endpoint and the lighting direction as its vector direction.
[0022] Specifically, the direction of the parallel light entering the eye model is obtained, for example, it can be represented as a light vector. Then, the projection vector of the light direction on the specified coordinate plane is determined, for example, as shown in the figure. Figure 4 As shown, the coordinate axis determining the eye's orientation is the z-axis, and the coordinate axis perpendicular to the right of the eye's orientation is represented as the x-axis in the three-dimensional coordinate system. This yields the xz plane, and the projection vector of the lighting direction onto this xz plane can be represented as light_xz. Simultaneously, as... Figure 4 As shown, the projection vector of the illumination direction on the xy plane is determined, and this projection vector can be represented as light_xy.
[0023] Step S306: Determine the target angle information between the projection vector and the specified coordinate axis of the three-dimensional coordinate system; The aforementioned specified coordinate axes typically include multiple axes, which can be axes perpendicular to the eye's orientation in the left or right direction, or axes perpendicular to the eye's orientation in the up or down direction. For example... Figure 4 As shown, the specified coordinate axes can be the x-axis and y-axis. The target angle information can be a specific angle or radian information, and it is typically used to indicate the rotation angle of the spot map. In actual calculations, the target angle information is usually expressed as a radian value or a numerical value in the shader calculation.
[0024] For example, the aforementioned projection vector includes a projection vector on the xz plane, from which the angle between the projection vector and the x-axis can be directly calculated. Then, the projection vector also includes a projection vector on the xy plane, from which the angle between the projection vector and the y-axis can be directly calculated. After calculating the angle information, it can be processed according to its magnitude to obtain the aforementioned target angle information.
[0025] Step S308: Rotate the preset spot texture based on the target angle information, and render the rotated spot texture onto the eye model to obtain an eye model with eye spot effect.
[0026] The aforementioned preset light spot texture is drawn based on the center of the pupil of the eye model and the radius of the pupil. Specifically, a light spot shape is drawn at a specified location on the light spot texture. For example, as shown... Figure 5 A schematic diagram of the spot map shown in (a) and Figure 5 The diagram (b) shows a schematic of the UV mapping for the eye model, where the center of the spot map corresponds to the center of the pupil. The distance between the white spot shape in the spot map and the center of the map is... Figure 5 The pupil radius r is shown in (b) in the figure.
[0027] In practice, the preset spot map is rotated based on the target angle information. This rotation can be clockwise or counter-clockwise. Specifically, the angle indicated by the target angle information is rotated to ensure the spot in the spot map adapts to the lighting direction. Finally, the rotated spot map is rendered onto the initial eye model without spot map processing, resulting in an eye model with an eye spot effect.
[0028] The above-described method for rendering eye-like light spots involves: acquiring the eye model of a virtual object; determining a three-dimensional coordinate system based on the eye's orientation; acquiring the illumination direction incident on the eye model; determining the projection vector of the illumination direction onto a specified coordinate plane in the three-dimensional coordinate system; determining the target angle information between the projection vector and a specified coordinate axis of the three-dimensional coordinate system; rotating a preset light spot texture based on the target angle information; and rendering the rotated light spot texture onto the eye model to obtain an eye model with eye-like light spot effects. In this method, the rotation angle of the preset light spot texture under different lighting conditions can be determined by the illumination direction and eye orientation. An eye model with light spot effects can be obtained with a single texture sampling, allowing the eye's light spot to change with the illumination direction. This simple process reduces the performance consumption of the running device and improves the rendering effect of the eye-like light spots.
[0029] According to step S302 above, the step of determining the three-dimensional coordinate system based on the eye orientation of the eye model, one possible implementation is as follows: Step 1: Determine the orientation of the eyeball as the positive direction of the first coordinate axis; where the positive direction of the first coordinate axis is the direction from the center of the eyeball model to the center of the pupil on the surface of the eyeball model. Step 2: Determine multiple vectors perpendicular to the direction of the eyeball, and determine the second and third coordinate axes based on these vectors; wherein, the multiple vectors are perpendicular to each other. Step 3: Determine the three-dimensional coordinate system based on the first coordinate axis, the second coordinate axis, and the third coordinate axis.
[0030] For example, such as Figure 4 As shown, the first coordinate axis (i.e. Figure 4 The positive direction of the z-axis in the model is the center of the eyeball (i.e., Figure 4 The black dot in the image points to the center of the pupil on the surface of the eyeball model (i.e., Figure 4 The direction of the white dots in the image. The starting point of the above vectors can be the center of the eyeball model or the center of the pupil.
[0031] In practical implementation, using the eye's orientation, i.e., the first coordinate axis, as a reference, a first vector perpendicular to the first coordinate axis is first determined. The positive direction of this first vector can be located to the left or right of the first coordinate axis. The target plane formed by this first vector and the first coordinate axis can be a horizontal plane or a non-horizontal plane. Then, a third coordinate axis perpendicular to the target plane is determined. The positive direction of this third coordinate axis can be located above or below the target plane. Finally, the first, second, and third coordinate axes can be directly combined to form a three-dimensional coordinate system.
[0032] For example, based on the orientation of the eyeball, the direction from the center of the eyeball model to the center of the pupil on the surface of the eyeball model is determined as the positive direction of the first coordinate axis, such as... Figure 4 As shown, the positive direction of the z-axis in the three-dimensional coordinate system is determined. Furthermore, starting from the center of the eyeball model as the origin, multiple vectors perpendicular to the eyeball's orientation (z-axis) are determined. Specifically, the vector located to the right of the z-axis can be used as the second coordinate axis, i.e. Figure 4 The x-axis is defined in the xz plane, which is the horizontal plane. The vector perpendicular to the xz plane is then used as the third coordinate axis. Figure 4 The y-axis is used as the coordinate axis, and finally, the three-dimensional coordinate system is determined based on the x-axis, y-axis, and z-axis.
[0033] In this method, the eye orientation is determined as the first coordinate axis, and then a second coordinate axis and a third coordinate axis that are perpendicular to the first coordinate axis and mutually perpendicular to each other are determined based on the eye orientation. The resulting three-dimensional coordinate system can more accurately determine the lighting information, thereby improving the accuracy of the light spot position in the eye model.
[0034] In step 2 above, the step of determining multiple vectors perpendicular to the eye's orientation, and then determining the second and third coordinate axes based on these vectors, can be implemented in the following way: Step 21: Obtain the first intermediate vector located to the left or right of the positive direction of the first coordinate axis from among multiple vectors; obtain the first target vector from the first intermediate vector whose plane with the first coordinate axis is a horizontal plane; Step 22: Obtain the second intermediate vector from among multiple vectors, which is located above or below the positive direction of the first coordinate axis; obtain the second target vector from the second intermediate vector, which forms a vertical plane with the first coordinate axis; the horizontal plane and the vertical plane are perpendicular to each other; Step 23: Determine the second and third coordinate axes based on the first and second target vectors.
[0035] The directions to the left or right of the positive direction of the first coordinate axis are determined from the perspective of the virtual model. In actual implementation, the first intermediate vector located to the left or right of the positive direction of the first coordinate axis is obtained from multiple vectors perpendicular to the eye's orientation. This first intermediate vector and the first coordinate axis can usually form planes in multiple directions. Specifically, a horizontal plane can be found from these planes, and the first intermediate vector corresponding to the horizontal plane can be determined as the first target vector. For example, such as... Figure 4 The x-axis is shown. Among multiple vectors perpendicular to the eye's orientation, the second intermediate vector located above or below the positive direction of the first coordinate axis is obtained. This second intermediate vector and the first coordinate axis typically form planes in multiple directions. Specifically, a vertical plane can be found from these planes, and the second intermediate vector corresponding to this vertical plane can be determined as the second target vector. An example is shown below. Figure 4 The y-axis is shown.
[0036] For example, the above-mentioned three-dimensional coordinate system can also be as follows: Figure 6 The three-dimensional coordinate axes are shown, and the first target vector mentioned above is... Figure 6 In the context of `rightvec`, the second target vector is `upvec`. It can be understood that the horizontal plane and the vertical plane are perpendicular, and the first target vector and the second target vector are perpendicular. Based on the first and second target vectors, the second coordinate axis (e.g., `upvec`) can be determined. Figure 4 (x-axis) and third coordinate axis (e.g.) Figure 4 (y-axis in the diagram).
[0037] Specifically, the first target vector perpendicular to the direction of the eyeball can be set as the right vector `rightvec`, and the second target vector can be set as the vertical vector `upvec`, which are used to calculate the rotation angle of the spot map. This can be represented in code as: `float3rightvec = float3(1.0f,0.0f,0.0f);float3 upvec = float3(0.0f,1.0f,0.0f)`.
[0038] In step 23 above, the step of determining the second and third coordinate axes based on the first and second target vectors can be implemented in one possible way: The direction of the first target vector is defined as the positive direction of the second coordinate axis; the direction of the second target vector is defined as the positive direction of the third coordinate axis; wherein the direction of the first target vector is to the right or left of the eye's direction, and the direction of the second target vector is above or below the eye's direction.
[0039] In actual implementation, the eye orientation is set as the first coordinate axis (e.g., Figure 4The positive direction of the second coordinate axis (e.g., the z-axis) is determined based on the vector direction of the first target vector obtained from the first intermediate vector located to the left or right of the positive direction of the first coordinate axis. Since the vector direction of the first target vector is to the right or left of the direction the eye is facing, the positive direction of the second coordinate axis (e.g., the z-axis) is determined based on the vector direction of the first target vector. Figure 4 The positive direction of the x-axis (in the first coordinate system) is either to the right or left of the direction the eye is facing. Based on the vector direction of the second target vector obtained from the second intermediate vector located above or below the positive direction of the first coordinate axis, the third coordinate axis (e.g., ...) is determined. Figure 4 The positive direction of the y-axis (in the context of the image) is such that, since the direction of the second target vector is above or below the direction the eye is facing, the third coordinate axis (e.g., the positive direction of the y-axis) is also considered. Figure 4 The positive direction of the y-axis (in the image) is above or below the direction the eye is facing.
[0040] Based on step S304 above, the step of determining the projection vector of the illumination direction on a specified coordinate plane in the three-dimensional coordinate system can be implemented in one possible way: Determine the first projection vector of the lighting direction on the first coordinate plane of the three-dimensional coordinate system; the first coordinate plane is composed of the first coordinate axis and the second coordinate axis of the three-dimensional coordinate system; determine the second projection vector of the lighting direction on the second coordinate plane of the three-dimensional coordinate system; the second coordinate plane is composed of the second axis and the third axis of the three-dimensional coordinate system.
[0041] The aforementioned first projection vector typically refers to the projection vector of the lighting direction onto the first coordinate plane of the three-dimensional coordinate system (the plane composed of the first and second coordinate axes of the three-dimensional coordinate system). The aforementioned second projection vector typically refers to the projection vector of the lighting direction onto the second coordinate plane of the three-dimensional coordinate system (the plane composed of the second and third coordinate axes of the three-dimensional coordinate system).
[0042] For example, such as Figure 7 As shown in (a) of the diagram, taking the first coordinate axis of a three-dimensional coordinate system as the z-axis, the second coordinate axis as the x-axis, and the third coordinate axis as the y-axis as an example, the first coordinate plane is the xz-plane formed by the first and second coordinate axes, and the second coordinate plane is the xy-plane formed by the second and third coordinate axes. Based on the direction of illumination, as... Figure 7 The light vector shown in (a) (the lighting direction is from the upper right of the eyeball model) can determine the first projection vector of the lighting direction on the first coordinate plane (xz plane), as follows: Figure 7 The light_xz vector shown in (a) and the second projection vector of the lighting direction on the second coordinate plane (xy plane), as shown in (a). Figure 7 The light_xy vector is shown in (a) of the diagram.
[0043] because Figure 7(a) in the image is a three-dimensional image. This three-dimensional image is then converted into a two-dimensional image, such as... Figure 7 The xz plane shown in (b) and the first projection vector light_xz; as shown in Figure 7 The xy plane shown in (c) and the second projection vector light_xy.
[0044] Specifically, the lighting direction can be set as follows: the first projection vector on the first coordinate plane (xz plane) is light_xz, and the second projection vector on the second coordinate plane (xy plane) is light_xy. This can be represented in code as: float3light_xz = float3(1.x,0.0f,1.z); float3 light_xy = float3(1.x,1.b,0.0f).
[0045] As mentioned above, the projection vector includes a first projection vector and a second projection vector; the specified coordinate axes include a second coordinate axis and a third coordinate axis; according to step S306 above, the step of determining the target angle information between the projection vector and the specified coordinate axes of the three-dimensional coordinate system can be implemented as follows: Calculate the first angle information between the first projection vector and the second coordinate axis, and calculate the second angle information between the second projection vector and the third coordinate axis; update the second angle information based on the first angle information to obtain the target angle information.
[0046] The aforementioned first included angle information typically refers to the angle between the first projection vector and the second coordinate axis, expressed in degrees or radians. The aforementioned second included angle information typically refers to the angle between the second projection vector and the third coordinate axis, expressed in degrees or radians.
[0047] For example, such as Figure 7 As shown, the first angle information (angle_xz) between the first projection vector light_xz and the second coordinate axis (x-axis) is calculated. The second angle information (angle_xy) between the second projection vector light_xy and the third coordinate axis (y-axis) is calculated. Based on the first angle information, the second angle information is updated. The updated second angle information can be the same as the original second angle information, or it can be obtained by performing a sum-difference operation on the original second angle information. The updated second angle information is then determined as the target angle information, i.e., the rotation angle of the light spot map.
[0048] The purpose of calculating the first included angle information is to confirm the direction of light incidence, such as whether the light is coming from the left or right side of the eye. Then, based on the direction of incidence and the size of the second included angle information, the update method of the second included angle information is determined, and the above-mentioned target included angle information can be obtained.
[0049] In this method, the second angle information is updated by calculating the first angle information to obtain the target angle information, which in turn determines the rotation angle of the spot map, making the spot in the rotated spot map more suitable for the current lighting direction, and further improving the spot effect of the eye model.
[0050] One possible implementation of the steps described above for calculating the first angle between the first projection vector and the second coordinate axis, and the second angle between the second projection vector and the third coordinate axis: Calculate the first angle between the first projection vector and the positive direction of the second coordinate axis, and calculate the second angle between the second projection vector and the positive direction of the third coordinate axis.
[0051] For example, such as Figure 7 As shown, the first included angle information angle_xz is the angle between the first projection vector light_xz and the positive direction of the second coordinate axis (x-axis), or the corresponding radian value of the angle. The second included angle information angle_xy is the angle between the second projection vector light_xy and the positive direction of the third coordinate axis (y-axis), or the corresponding radian value of the angle. Specifically, if the angle is 0 degrees, the corresponding radian value is 0; if the angle is 180 degrees, the corresponding radian value is 1; and if the angle is 90 degrees, the corresponding radian value is 0.5.
[0052] The purpose of calculating the first included angle is to confirm the direction of light incidence. For example, if the first included angle is greater than 0.5 (meaning the angle between the first projection vector and the positive x-axis is greater than 90 degrees), it indicates that the light is entering from the left side, towards the eye. The purpose of calculating the second included angle is to determine the rotation angle of the light spot map. The specific determination method is usually related to the establishment of the coordinate system, the magnitude of the first included angle, and the magnitude of the second included angle.
[0053] The first and second included angle information can be obtained using the following code. The first included angle information (angle_xz) between light_xz and rightvec is used to determine the left / right position of the lighting direction relative to the eye's orientation, while light_xy and upvec are used to subsequently control the UV rotation of the light spot map. The specific implementation code is as follows: function AngleBetweenVectors(light_xz, rightvec) out(float3 angle_xz); function AngleBetweenVectors(light_xy, upvec) out(float3 angle_xy).
[0054] The function `AngleBetweenVectors` is used to calculate the angle information between `light_xz` and `rightvec`, and `light_xy` and `upvec` of the input eyeball material. The output value is the radian value corresponding to the angle information (1 radian = 180 degrees). The code is as follows: function AngleBetweenVectors in(float3 vec1, float3 vec2) out(floatangle) { float radios = acos(dot(normalize(vec1),vec2) / length(vec1) / length(vec2)) 57.29578018f 0.005556f; out(angle, radios); }
[0055] One possible implementation of the above steps for updating the second included angle information based on the first included angle information to obtain the target included angle information is as follows: Step A: Determine the left and right positions of the illumination direction relative to the direction of the eyeball based on the first included angle information; Step B: Update the second included angle information based on the left and right positions to obtain the target included angle information.
[0056] Specifically, the left-right position of the illumination direction relative to the eye's orientation can be determined based on the magnitude of the first included angle information. For example, such as... Figure 7 In the coordinate system shown, if the first included angle is less than 90 degrees or less than 0.5, it indicates that the light direction is to the right of the eye's orientation, meaning the light is entering from the right side of the eye's orientation. If the first included angle is greater than 90 degrees or greater than 0.5, it indicates that the light direction is to the left of the eye's orientation, meaning the light is entering from the left side of the eye's orientation. After determining the left and right positions of the light direction relative to the eye's orientation, the second included angle is updated based on these positions, and the updated second included angle is then determined as the target included angle.
[0057] In this method, the left and right positions of the illumination direction relative to the eye's orientation are determined based on the first included angle information, and then the second included angle information is updated to obtain the target included angle information. This improves the accuracy of determining the left and right positions of the illumination direction relative to the eye's orientation and further enhances the light spot effect of the eye model.
[0058] Based on step A above, the step of determining the left and right position of the illumination direction relative to the eye's orientation based on the first included angle information, one possible implementation is as follows: If the positive direction of the second coordinate axis is to the right of the eye's direction and the first included angle information meets the preset conditions, the illumination direction is determined to be to the right of the eye's direction; if the positive direction of the second coordinate axis is to the right of the eye's direction and the first included angle information does not meet the preset conditions, the illumination direction is determined to be to the left of the eye's direction.
[0059] The above-mentioned preset condition is that the first included angle information is less than 90 degrees or less than 0.5.
[0060] For example, such as Figure 7 As shown, the positive direction of the second coordinate axis (x-axis) is to the right of the eye's orientation (positive direction of the z-axis), and the first included angle information angle_xz is less than 90 degrees or less than 0.5, which determines that the illumination direction is to the right of the eye's orientation.
[0061] For example, such as Figure 8 As shown, the positive direction of the second coordinate axis (x-axis) is to the right of the eye's orientation (positive direction of the z-axis), and the first included angle information angle_xz is greater than 90 degrees or greater than 0.5, which determines that the illumination direction is to the left of the eye's orientation.
[0062] Another possible implementation: If the positive direction of the second coordinate axis is to the left of the eye's direction and the first included angle information meets the preset conditions, the illumination direction is determined to be to the left of the eye's direction; if the positive direction of the second coordinate axis is to the left of the eye's direction and the first included angle information does not meet the preset conditions, the illumination direction is determined to be to the right of the eye's direction.
[0063] For example, such as Figure 9 As shown, the positive direction of the second coordinate axis (x-axis) is to the left of the eye's direction (positive direction of the z-axis), and the first included angle information angle_xz is less than 90 degrees or less than 0.5, which determines that the illumination direction is to the left of the eye's direction.
[0064] For example, such as Figure 10 As shown, the positive direction of the second coordinate axis (x-axis) is to the left of the eye's orientation (positive direction of the z-axis), and the first included angle information angle_xz is greater than 90 degrees or greater than 0.5, which determines that the illumination direction is to the right of the eye's orientation.
[0065] In step B above, the step of updating the second included angle information based on the left and right positions to obtain the target included angle information can be implemented in one possible way: (1) If the light direction is to the right of the eye's direction and the positive direction of the third coordinate axis is above the eye's direction, calculate the difference between the first value and the second angle information to obtain the target angle information. The first value mentioned above usually refers to 180 degrees, or 1 radian. For example, such as... Figure 7 As shown, the position of the lighting direction relative to the eye's orientation is to the right of the eye's orientation (the light enters from the upper right corner of the eye's orientation), and the positive direction of the third coordinate axis is above the eye's orientation. For example, as... Figure 7 As shown in (b), if the calculated second included angle information is less than 90 degrees, such as 45 degrees, or a radian value of 0.25, calculate 1-0.25=0.75, or calculate 180°-45°=135°. The target included angle information is obtained as 135 degrees. Then control the spot map to rotate clockwise by 135 degrees.
[0066] For example, such as Figure 11 As shown in (b), the position of the light direction relative to the direction the eye is facing is the position of the light direction to the right of the direction the eye is facing. Figure 11 As shown in (a), the light enters from the direction of the lower right corner of the eye, and the positive direction of the third coordinate axis is above the direction the eye is facing. Figure 11 As shown in (c), the calculated second included angle information angle_xy is 135 degrees, or 0.75 radians. Calculate 1-0.75=0.25, or calculate 180°-135°=45°. Therefore, the target included angle information is 45 degrees. Figure 11 As shown in (a), the spot map is rotated 45 degrees clockwise.
[0067] (2) If the light direction is to the left of the eye's direction and the positive direction of the third coordinate axis is above the eye's direction, calculate the sum of the first value and the second angle information to obtain the target angle information.
[0068] For example, such as Figure 12 As shown in (b), the position of the light direction relative to the direction the eye is facing is the position of the light direction to the left of the direction the eye is facing. Figure 12 As shown in (a) above, the light enters from the direction of the lower left corner of the eye, and the positive direction of the third coordinate axis is above the direction the eye is facing. Figure 12 As shown in (c), the calculated second included angle information is 135 degrees, or 0.75 radians. Calculate 1 + 0.75 = 1.75, or calculate 180° + 135° = 315°. The target included angle information is thus 315 degrees. Figure 12As shown in (a), the spot map is rotated 315 degrees clockwise.
[0069] For example, such as Figure 13 As shown in (b), the position of the light direction relative to the direction the eye is facing is the position of the light direction to the left of the direction the eye is facing. Figure 13 As shown in (a), the light enters from the direction of the upper left corner facing the eye, and the positive direction of the third coordinate axis is above the direction the eye is facing. Figure 13 As shown in (c), the calculated second included angle information is 45 degrees, or 0.25 radians. Calculate 1 + 0.25 = 1.25, or calculate 180° + 45° = 225°. The target included angle information is thus 225 degrees. Figure 13 As shown in (a), the spot map is rotated 225 degrees clockwise.
[0070] Another possible implementation: (1) If the light direction is to the right of the eye's direction and the positive direction of the third coordinate axis is below the eye's direction, then the second included angle information is determined as the target included angle information. For example, such as Figure 14 As shown in (b), the position of the light direction relative to the direction the eye is facing is the position of the light direction to the right of the direction the eye is facing (for example, such as...). Figure 14 As shown in (a) above, the light enters from the direction of the lower right corner of the eye, and the positive direction of the third coordinate axis is below the direction the eye is facing. For example, as... Figure 14 In (c), the second included angle information angle_xy = 45 degrees is obtained at this time, and the second included angle information angle_xy can be directly determined as the target included angle information. Then, the spot map is controlled to rotate clockwise by the angle value of the target included angle information.
[0071] (2) If the position of the illumination direction relative to the direction of the eyeball is the left side of the direction of the eyeball, and the positive direction of the third coordinate axis is below the direction of the eyeball, calculate the difference between the second value and the second included angle information to obtain the target included angle information; wherein, the second value is twice the first value.
[0072] The second value mentioned above usually refers to 360 degrees, or 2 radians. For example, such as... Figure 15 As shown in (b), the position of the light direction relative to the direction the eye is to the left of the direction the eye is facing (for example, such as...). Figure 15 As shown in (a) above, the light enters from the direction of the upper left corner facing the eye, and the positive direction of the third coordinate axis is below the direction the eye is facing. For example, as... Figure 15In step (c), the calculated second included angle information angle_xy = 135 degrees. Calculate the angle value by subtracting the second included angle information angle_xy from 360 degrees, or by subtracting the radian value of the second included angle information angle_xy from 2, to obtain the target included angle information. That is, 360° - 135° = 225°, or 2 - 0.75 = 1.25. Then, control the spot map to rotate clockwise by the angle value of the target included angle information.
[0073] According to step S308 above, the preset spot texture is rotated based on the target angle information, and the rotated spot texture is rendered onto the eye model to obtain an eye model with eye spot effect. One possible implementation is as follows: Using the center of the light spot texture as the rotation center and the target angle information as the rotation angle, the light spot texture is rotated clockwise by this rotation angle to obtain the target light spot texture. The light spot texture includes a light spot shape, which is located at a specified position in the light spot texture. The distance between the specified position and the center of the texture is the same as the radius of the pupil. The target light spot texture is rendered onto the eyeball model to obtain an eyeball model with an eyeball light spot effect.
[0074] The aforementioned target spot map typically refers to a spot map obtained by rotating a spot map that includes the spot shape. For example... Figure 5 As shown, the light spot map includes a light spot shape located at a specified position in the light spot map. The distance between the specified position and the center of the map is the same as the radius of the pupil. The specified position is located below the light spot map.
[0075] In fact, the light spot map is a UV map. The rotated UV map can be passed to a sampling function to sample the light spot map, and then combined with other eye effects to obtain an eye model with an eye spot effect. For example, from the perspective of the eye model, such as... Figure 11 As shown in (a), the lighting direction is located at the lower right corner of the eye model. At this time, the light spot is located at the lower right corner of the eye model, and the lighting effect is located at the upper left corner of the eye model, as shown in (a). Figure 12 As shown in (a), the lighting direction is located at the lower left corner of the eye model. At this time, the light spot is located at the lower left corner of the eye model, and the lighting effect is located at the upper right corner of the eye model, as shown in (a). Figure 13 As shown in (a), the lighting direction is located at the upper left corner of the eye model. At this time, the light spot is located at the upper left corner of the eye model, and the lighting effect is located at the lower right corner of the eye model.
[0076] Further explanation is provided in conjunction with specific code examples: The `CustomRotator` function is a function that rotates the UVs (u, v texture map coordinates) of a spot map. It calculates the rotated UVs by taking the rotation center of the spot map, the rotation angle, and the UVs to be rotated. The code is as follows: function CustomRotator(float2(0.5f,0.5f), rotateangle, uv_Iris) out(float2 uv_rotate); The detailed code for using the CustomRotator function is as follows: function CustomRotator in (float2 RotateCenter,float RotateAngle,float2 uv) out(float2 rotateuv) { float2 _CustomRotatoruv = ((RotateCenter -1.0f) + uv); float RotateAnglecos = cos((RotateAngle) 6.28318548f / 1.0f); float RotateAnglesin = sin((RotateAngle) 6.28318548f / 1.0f); float2 uv_r = (RotateCenter + float2(dot(_CustomRotatoruv,float2(RotateAnglecos,( RotateAnglesin -1.0f))),dot(_CustomRotatoruv, float2(RotateAnglesin, RotateAnglecos)))); out(rotateuv,uv_r); }; Finally, the obtained UVs are passed to the sampling function to sample the texture, and then combined with other effects of the eye model. The code is as follows: lowp float4 limbus = sample(Tex0, uv_rotate); In this method, by rotating the light spot map and then rendering it onto the eye model, the light spot effect of the eyeball under different lighting directions can be obtained, which further improves the realism of the light spot effect.
[0077] For the above method embodiments, see Figure 16 The illustrated device for rendering eyeball light spots includes: The three-dimensional coordinate system determination module 161 is used to obtain the eyeball model of the virtual object and determine the three-dimensional coordinate system based on the eyeball orientation of the eyeball model; The projection vector determination module 162 is used to obtain the illumination direction of the light entering the eyeball model and determine the projection vector of the illumination direction on a specified coordinate plane in the three-dimensional coordinate system. The target angle information determination module 163 is used to determine the target angle information between the projection vector and the specified coordinate axis of the three-dimensional coordinate system; The rendering module 164 is used to rotate the preset spot texture based on the target angle information, and render the rotated spot texture onto the eye model to obtain an eye model with eye spot effect.
[0078] The aforementioned eye-spot rendering device acquires an eye model of a virtual object, determines a three-dimensional coordinate system based on the eye orientation of the eye model, acquires the illumination direction incident on the eye model, determines the projection vector of the illumination direction on a specified coordinate plane of the three-dimensional coordinate system, determines the target angle information between the projection vector and a specified coordinate axis of the three-dimensional coordinate system, rotates a preset spot texture based on the target angle information, and renders the rotated spot texture onto the eye model to obtain an eye model with an eye-spot effect. In this method, the rotation angle of the preset spot texture under different lighting conditions can be determined by the illumination direction and eye orientation. An eye model with a spot effect can be obtained with a single texture sampling, allowing the eye spot to change with the illumination direction. This simple process reduces the performance consumption of the operating equipment and improves the rendering effect of the eye-spot effect.
[0079] The aforementioned three-dimensional coordinate system determination module is further configured to: determine the eyeball orientation as the positive direction of the first coordinate axis; wherein the positive direction of the first coordinate axis is the direction from the center of the eyeball model to the center of the pupil on the surface of the eyeball model; determine multiple vectors perpendicular to the eyeball orientation, and determine the second and third coordinate axes based on the multiple vectors; wherein the multiple vectors are perpendicular to each other; and determine the three-dimensional coordinate system based on the first, second, and third coordinate axes.
[0080] The aforementioned three-dimensional coordinate system determination module is further configured to: obtain a first intermediate vector located to the left or right of the positive direction of the first coordinate axis from among multiple vectors; obtain a first target vector from the first intermediate vector whose plane with the first coordinate axis is a horizontal plane; obtain a second intermediate vector located above or below the positive direction of the first coordinate axis from among multiple vectors; obtain a second target vector from the second intermediate vector whose plane with the first coordinate axis is a vertical plane; the horizontal plane and the vertical plane are perpendicular to each other; and determine the second coordinate axis and the third coordinate axis based on the first target vector and the second target vector.
[0081] The aforementioned three-dimensional coordinate system determination module is further configured to: determine the vector direction of the first target vector as the positive direction of the second coordinate axis; and determine the vector direction of the second target vector as the positive direction of the third coordinate axis; wherein the vector direction of the first target vector is to the right or left of the direction the eyeball is facing, and the vector direction of the second target vector is above or below the direction the eyeball is facing.
[0082] The aforementioned projection vector determination module is further configured to: determine the first projection vector of the illumination direction on the first coordinate plane of the three-dimensional coordinate system; the first coordinate plane is composed of the first coordinate axis and the second coordinate axis of the three-dimensional coordinate system; determine the second projection vector of the illumination direction on the second coordinate plane of the three-dimensional coordinate system; the second coordinate plane is composed of the second coordinate axis and the third coordinate axis of the three-dimensional coordinate system.
[0083] The aforementioned projection vectors include a first projection vector and a second projection vector; the specified coordinate axes include a second coordinate axis and a third coordinate axis; the aforementioned target angle information determination module is further used to: calculate the first angle information between the first projection vector and the second coordinate axis, calculate the second angle information between the second projection vector and the third coordinate axis; update the second angle information according to the first angle information to obtain the target angle information.
[0084] The aforementioned target angle information determination module is also used to: calculate the first angle information between the first projection vector and the positive direction of the second coordinate axis, and calculate the second angle information between the second projection vector and the positive direction of the third coordinate axis.
[0085] The aforementioned target angle information determination module is also used to: determine the left and right positions of the illumination direction relative to the direction of the eyeball based on the first angle information; update the second angle information based on the left and right positions to obtain the target angle information.
[0086] The aforementioned target angle information determination module is further configured to: if the positive direction of the second coordinate axis is to the right of the eye's direction and the first angle information meets the preset conditions, determine that the illumination direction is to the right of the eye's direction; if the positive direction of the second coordinate axis is to the right of the eye's direction and the first angle information does not meet the preset conditions, determine that the illumination direction is to the left of the eye's direction.
[0087] The aforementioned target angle information determination module is further configured to: if the positive direction of the second coordinate axis is to the left of the eyeball's direction and the first angle information meets the preset conditions, determine that the illumination direction is to the left of the eyeball's direction; if the positive direction of the second coordinate axis is to the left of the eyeball's direction and the first angle information does not meet the preset conditions, determine that the illumination direction is to the right of the eyeball's direction.
[0088] The aforementioned target angle information determination module is further configured to: if the illumination direction relative to the left and right position of the eyeball is the right position of the illumination direction relative to the eyeball's direction, and the positive direction of the third coordinate axis is above the eyeball's direction, calculate the difference between the first value and the second angle information to obtain the target angle information; if the illumination direction relative to the left and right position of the eyeball is the left position of the illumination direction relative to the eyeball's direction, and the positive direction of the third coordinate axis is above the eyeball's direction, calculate the sum of the first value and the second angle information to obtain the target angle information.
[0089] The aforementioned target angle information determination module is further configured to: if the illumination direction relative to the left and right position of the eyeball is the right side of the eyeball's direction, and the positive direction of the third coordinate axis is below the eyeball's direction, determine the second angle information as the target angle information; if the illumination direction relative to the left and right position of the eyeball is the left side of the eyeball's direction, and the positive direction of the third coordinate axis is below the eyeball's direction, calculate the difference between the second value and the second angle information to obtain the target angle information; wherein, the second value is twice the first value.
[0090] The rendering module described above is further configured to: rotate the light spot texture clockwise by the center of the light spot texture as the rotation center and the target angle information as the rotation angle, thereby obtaining a target light spot texture; wherein the light spot texture includes a light spot shape, the light spot shape is located at a specified position in the light spot texture, and the distance between the specified position and the center of the texture is the same as the radius of the pupil; and render the target light spot texture onto the eyeball model to obtain an eyeball model with an eyeball light spot effect.
[0091] The eyeball spot rendering device provided in this embodiment of the invention has the same technical features as the eyeball spot rendering method provided in the above embodiment, so it can also solve the same technical problems and achieve the same technical effects.
[0092] This embodiment also provides an electronic device, including a processor and a memory. The memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the resource processing method described above. This electronic device can be a server or a terminal device.
[0093] See Figure 17As shown, the electronic device includes a processor 100 and a memory 101. The memory 101 stores machine-executable instructions that can be executed by the processor 100. The processor 100 executes the machine-executable instructions to implement the above-described method for rendering eyeball light spots. The method includes the following steps: The process involves acquiring a virtual object's eye model, determining a 3D coordinate system based on the eye's orientation, obtaining the light direction incident on the eye model, and determining the projection vector of the light direction onto a specified coordinate plane in the 3D coordinate system. The process also involves determining the target angle information between the projection vector and a specified coordinate axis of the 3D coordinate system, rotating a preset spot texture based on the target angle information, and rendering the rotated spot texture onto the eye model to obtain an eye model with an eye spot effect. This method allows the rotation angle of the preset spot texture under different lighting conditions to be determined by the light direction and eye orientation. An eye model with a spot effect can be obtained with a single texture sampling, enabling the eye's spot to change with the light direction. The process is simple, reduces the performance consumption of the running device, and improves the rendering effect of the eye spot.
[0094] The steps described above for determining a three-dimensional coordinate system based on the eyeball orientation of an eyeball model include: defining the eyeball orientation as the positive direction of a first coordinate axis; wherein the positive direction of the first coordinate axis is the direction from the center of the eyeball model to the center of the pupil on the surface of the eyeball model; determining multiple vectors perpendicular to the eyeball orientation, and determining a second and third coordinate axis based on these multiple vectors; wherein the multiple vectors are mutually perpendicular; and determining a three-dimensional coordinate system based on the first, second, and third coordinate axes. In this method, by defining the eyeball orientation as the first coordinate axis and then determining the second and third coordinate axes, which are perpendicular to the first coordinate axis and mutually perpendicular, the determined three-dimensional coordinate system can more accurately determine illumination information, thereby improving the accuracy of the light spot position in the eyeball model.
[0095] The steps described above for determining multiple vectors perpendicular to the eye's orientation and determining the second and third coordinate axes based on these multiple vectors include: obtaining a first intermediate vector located to the left or right of the positive direction of the first coordinate axis from among the multiple vectors; obtaining a first target vector from the first intermediate vector whose plane with the first coordinate axis is a horizontal plane; obtaining a second intermediate vector located above or below the positive direction of the first coordinate axis from among the multiple vectors; obtaining a second target vector from the second intermediate vector whose plane with the first coordinate axis is a vertical plane; the horizontal plane and the vertical plane are perpendicular to each other; and determining the second and third coordinate axes based on the first and second target vectors.
[0096] The steps described above for determining the second and third coordinate axes based on the first and second target vectors include: determining the vector direction of the first target vector as the positive direction of the second coordinate axis; and determining the vector direction of the second target vector as the positive direction of the third coordinate axis; wherein the vector direction of the first target vector is to the right or left of the direction the eye is facing, and the vector direction of the second target vector is above or below the direction the eye is facing.
[0097] The steps described above for determining the projection vector of the illumination direction on a specified coordinate plane of a three-dimensional coordinate system include: determining the first projection vector of the illumination direction on a first coordinate plane of a three-dimensional coordinate system; the first coordinate plane is composed of the first coordinate axis and the second coordinate axis of the three-dimensional coordinate system; determining the second projection vector of the illumination direction on a second coordinate plane of a three-dimensional coordinate system; the second coordinate plane is composed of the second coordinate axis and the third coordinate axis of the three-dimensional coordinate system.
[0098] The aforementioned projection vectors include a first projection vector and a second projection vector; the specified coordinate axes include a second coordinate axis and a third coordinate axis; the step of determining the target angle information between the projection vectors and the specified coordinate axes of the three-dimensional coordinate system includes: calculating the first angle information between the first projection vector and the second coordinate axis, calculating the second angle information between the second projection vector and the third coordinate axis; updating the second angle information based on the first angle information to obtain the target angle information. In this method, by updating the second angle information using the calculated first angle information to obtain the target angle information, the rotation angle of the spot map can be determined, making the spot in the rotated spot map more suitable for the current lighting direction, further improving the spot effect of the eye model.
[0099] The steps of calculating the first angle information between the first projection vector and the second coordinate axis, and calculating the second angle information between the second projection vector and the third coordinate axis, include: calculating the first angle information between the first projection vector and the positive direction of the second coordinate axis, and calculating the second angle information between the second projection vector and the positive direction of the third coordinate axis.
[0100] The steps described above for updating the second included angle information based on the first included angle information to obtain the target included angle information include: determining the left and right position of the illumination direction relative to the eye's orientation based on the first included angle information; and updating the second included angle information based on the left and right position to obtain the target included angle information. In this method, by determining the left and right position of the illumination direction relative to the eye's orientation based on the first included angle information, and then updating the second included angle information to obtain the target included angle information, the accuracy of determining the left and right position of the illumination direction relative to the eye's orientation is improved, further enhancing the light spot effect of the eye model.
[0101] The above-mentioned step of determining the left and right positions of the illumination direction relative to the eye's orientation based on the first included angle information includes: if the positive direction of the second coordinate axis is to the right of the eye's orientation and the first included angle information meets the preset conditions, the illumination direction is determined to be to the right of the eye's orientation; if the positive direction of the second coordinate axis is to the right of the eye's orientation and the first included angle information does not meet the preset conditions, the illumination direction is determined to be to the left of the eye's orientation.
[0102] The above-mentioned step of determining the left and right position of the illumination direction relative to the direction of the eyeball based on the first included angle information includes: if the positive direction of the second coordinate axis is to the left of the direction of the eyeball and the first included angle information meets the preset conditions, the illumination direction is determined to be to the left of the direction of the eyeball; if the positive direction of the second coordinate axis is to the left of the direction of the eyeball and the first included angle information does not meet the preset conditions, the illumination direction is determined to be to the right of the direction of the eyeball.
[0103] The steps described above for updating the second included angle information based on the left and right positions to obtain the target included angle information include: if the illumination direction relative to the left and right position of the eyeball is the right position of the illumination direction relative to the eyeball's direction, and the positive direction of the third coordinate axis is above the eyeball's direction, calculate the difference between the first value and the second included angle information to obtain the target included angle information; if the illumination direction relative to the left and right position of the eyeball is the left position of the illumination direction relative to the eyeball's direction, and the positive direction of the third coordinate axis is above the eyeball's direction, calculate the sum of the first value and the second included angle information to obtain the target included angle information.
[0104] The steps described above for updating the second included angle information based on the left and right positions to obtain the target included angle information include: if the light direction relative to the left and right position of the eyeball is the light direction to the right of the eyeball, and the positive direction of the third coordinate axis is below the eyeball, the second included angle information is determined as the target included angle information; if the light direction relative to the left and right position of the eyeball is the light direction to the left of the eyeball, and the positive direction of the third coordinate axis is below the eyeball, the difference between the second value and the second included angle information is calculated to obtain the target included angle information; wherein, the second value is twice the first value.
[0105] The steps described above, which involve rotating a preset spot map based on target angle information and rendering the rotated spot map onto an eye model to obtain an eye model with an eyeball spot effect, include: rotating the spot map clockwise around its center as the rotation center and the target angle information as the rotation angle to obtain the target spot map; wherein the spot map includes a spot shape, the spot shape is located at a specified position in the spot map, and the distance between the specified position and the center of the map is the same as the radius of the pupil; and rendering the target spot map onto the eye model to obtain an eye model with an eyeball spot effect. In this method, by rotating the spot map and then rendering it onto the eye model, spot effects can be obtained in different lighting directions, further improving the realism of the spot effect.
[0106] Furthermore, Figure 17 The electronic device shown also includes a bus 102 and a communication interface 103, with the processor 100, the communication interface 103 and the memory 101 connected via the bus 102.
[0107] The memory 101 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 103 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc. The bus 102 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 17 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0108] Processor 100 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 100 or by instructions in software form. Processor 100 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a readily available storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 101, and the processor 100 reads the information from memory 101 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.
[0109] This embodiment also provides a machine-readable storage medium storing machine-executable instructions. When these machine-executable instructions are invoked and executed by a processor, they cause the processor to implement the aforementioned method for rendering eyeball light spots. The method includes the following steps: The process involves acquiring a virtual object's eye model, determining a 3D coordinate system based on the eye's orientation, obtaining the light direction incident on the eye model, and determining the projection vector of the light direction onto a specified coordinate plane in the 3D coordinate system. The process also involves determining the target angle information between the projection vector and a specified coordinate axis of the 3D coordinate system, rotating a preset spot texture based on the target angle information, and rendering the rotated spot texture onto the eye model to obtain an eye model with an eye spot effect. This method allows the rotation angle of the preset spot texture under different lighting conditions to be determined by the light direction and eye orientation. An eye model with a spot effect can be obtained with a single texture sampling, enabling the eye's spot to change with the light direction. The process is simple, reduces the performance consumption of the running device, and improves the rendering effect of the eye spot.
[0110] The steps described above for determining a three-dimensional coordinate system based on the eyeball orientation of an eyeball model include: defining the eyeball orientation as the positive direction of a first coordinate axis; wherein the positive direction of the first coordinate axis is the direction from the center of the eyeball model to the center of the pupil on the surface of the eyeball model; determining multiple vectors perpendicular to the eyeball orientation, and determining a second and third coordinate axis based on these multiple vectors; wherein the multiple vectors are mutually perpendicular; and determining a three-dimensional coordinate system based on the first, second, and third coordinate axes. In this method, by defining the eyeball orientation as the first coordinate axis and then determining the second and third coordinate axes, which are perpendicular to the first coordinate axis and mutually perpendicular, the determined three-dimensional coordinate system can more accurately determine illumination information, thereby improving the accuracy of the light spot position in the eyeball model.
[0111] The steps described above for determining multiple vectors perpendicular to the eye's orientation and determining the second and third coordinate axes based on these multiple vectors include: obtaining a first intermediate vector located to the left or right of the positive direction of the first coordinate axis from among the multiple vectors; obtaining a first target vector from the first intermediate vector whose plane with the first coordinate axis is a horizontal plane; obtaining a second intermediate vector located above or below the positive direction of the first coordinate axis from among the multiple vectors; obtaining a second target vector from the second intermediate vector whose plane with the first coordinate axis is a vertical plane; the horizontal plane and the vertical plane are perpendicular to each other; and determining the second and third coordinate axes based on the first and second target vectors.
[0112] The steps described above for determining the second and third coordinate axes based on the first and second target vectors include: determining the vector direction of the first target vector as the positive direction of the second coordinate axis; and determining the vector direction of the second target vector as the positive direction of the third coordinate axis; wherein the vector direction of the first target vector is to the right or left of the direction the eye is facing, and the vector direction of the second target vector is above or below the direction the eye is facing.
[0113] The steps described above for determining the projection vector of the illumination direction on a specified coordinate plane of a three-dimensional coordinate system include: determining the first projection vector of the illumination direction on a first coordinate plane of a three-dimensional coordinate system; the first coordinate plane is composed of the first coordinate axis and the second coordinate axis of the three-dimensional coordinate system; determining the second projection vector of the illumination direction on a second coordinate plane of a three-dimensional coordinate system; the second coordinate plane is composed of the second coordinate axis and the third coordinate axis of the three-dimensional coordinate system.
[0114] The aforementioned projection vectors include a first projection vector and a second projection vector; the specified coordinate axes include a second coordinate axis and a third coordinate axis; the step of determining the target angle information between the projection vectors and the specified coordinate axes of the three-dimensional coordinate system includes: calculating the first angle information between the first projection vector and the second coordinate axis, calculating the second angle information between the second projection vector and the third coordinate axis; updating the second angle information based on the first angle information to obtain the target angle information. In this method, by updating the second angle information using the calculated first angle information to obtain the target angle information, the rotation angle of the spot map can be determined, making the spot in the rotated spot map more suitable for the current lighting direction, further improving the spot effect of the eye model.
[0115] The steps of calculating the first angle information between the first projection vector and the second coordinate axis, and calculating the second angle information between the second projection vector and the third coordinate axis, include: calculating the first angle information between the first projection vector and the positive direction of the second coordinate axis, and calculating the second angle information between the second projection vector and the positive direction of the third coordinate axis.
[0116] The steps described above for updating the second included angle information based on the first included angle information to obtain the target included angle information include: determining the left and right position of the illumination direction relative to the eye's orientation based on the first included angle information; and updating the second included angle information based on the left and right position to obtain the target included angle information. In this method, by determining the left and right position of the illumination direction relative to the eye's orientation based on the first included angle information, and then updating the second included angle information to obtain the target included angle information, the accuracy of determining the left and right position of the illumination direction relative to the eye's orientation is improved, further enhancing the light spot effect of the eye model.
[0117] The above-mentioned step of determining the left and right positions of the illumination direction relative to the eye's orientation based on the first included angle information includes: if the positive direction of the second coordinate axis is to the right of the eye's orientation and the first included angle information meets the preset conditions, the illumination direction is determined to be to the right of the eye's orientation; if the positive direction of the second coordinate axis is to the right of the eye's orientation and the first included angle information does not meet the preset conditions, the illumination direction is determined to be to the left of the eye's orientation.
[0118] The above-mentioned step of determining the left and right position of the illumination direction relative to the direction of the eyeball based on the first included angle information includes: if the positive direction of the second coordinate axis is to the left of the direction of the eyeball and the first included angle information meets the preset conditions, the illumination direction is determined to be to the left of the direction of the eyeball; if the positive direction of the second coordinate axis is to the left of the direction of the eyeball and the first included angle information does not meet the preset conditions, the illumination direction is determined to be to the right of the direction of the eyeball.
[0119] The steps described above for updating the second included angle information based on the left and right positions to obtain the target included angle information include: if the illumination direction relative to the left and right position of the eyeball is the right position of the illumination direction relative to the eyeball's direction, and the positive direction of the third coordinate axis is above the eyeball's direction, calculate the difference between the first value and the second included angle information to obtain the target included angle information; if the illumination direction relative to the left and right position of the eyeball is the left position of the illumination direction relative to the eyeball's direction, and the positive direction of the third coordinate axis is above the eyeball's direction, calculate the sum of the first value and the second included angle information to obtain the target included angle information.
[0120] The steps described above for updating the second included angle information based on the left and right positions to obtain the target included angle information include: if the light direction relative to the left and right position of the eyeball is the light direction to the right of the eyeball, and the positive direction of the third coordinate axis is below the eyeball, the second included angle information is determined as the target included angle information; if the light direction relative to the left and right position of the eyeball is the light direction to the left of the eyeball, and the positive direction of the third coordinate axis is below the eyeball, the difference between the second value and the second included angle information is calculated to obtain the target included angle information; wherein, the second value is twice the first value.
[0121] The steps described above, which involve rotating a preset spot map based on target angle information and rendering the rotated spot map onto an eye model to obtain an eye model with an eyeball spot effect, include: rotating the spot map clockwise around its center as the rotation center and the target angle information as the rotation angle to obtain the target spot map; wherein the spot map includes a spot shape, the spot shape is located at a specified position in the spot map, and the distance between the specified position and the center of the map is the same as the radius of the pupil; and rendering the target spot map onto the eye model to obtain an eye model with an eyeball spot effect. In this method, by rotating the spot map and then rendering it onto the eye model, spot effects can be obtained in different lighting directions, further improving the realism of the spot effect.
[0122] The computer program product of the eyeball light spot rendering method, apparatus, electronic device and storage medium provided in the embodiments of the present invention includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation, please refer to the method embodiments, which will not be repeated here.
[0123] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0124] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.
[0125] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0126] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0127] Finally, it should be noted that the above embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for rendering eyeball light spots, characterized in that, The method includes: Obtain the eyeball model of the virtual object, and determine the three-dimensional coordinate system based on the eyeball orientation of the eyeball model; Obtain the illumination direction of the light entering the eyeball model, and determine the projection vector of the illumination direction on a specified coordinate plane of the three-dimensional coordinate system; Determine the target angle information between the projection vector and a specified coordinate axis of the three-dimensional coordinate system; Based on the target angle information, the preset spot texture is rotated, and the rotated spot texture is rendered onto the eyeball model to obtain the eyeball model with eyeball spot effect; The projection vector includes a first projection vector and a second projection vector; the specified coordinate axes include a second coordinate axis and a third coordinate axis; The step of determining the target angle information between the projection vector and a specified coordinate axis of the three-dimensional coordinate system includes: Calculate the first angle information between the first projection vector and the second coordinate axis, and calculate the second angle information between the second projection vector and the third coordinate axis; The second angle information is updated based on the first angle information to obtain the target angle information.
2. The method according to claim 1, characterized in that, The step of determining the three-dimensional coordinate system based on the eye orientation of the eye model includes: The orientation of the eyeball is defined as the positive direction of the first coordinate axis; wherein, the positive direction of the first coordinate axis is the direction from the center of the eyeball model to the center of the pupil on the surface of the eyeball model; A plurality of vectors perpendicular to the eye's orientation are determined, and a second coordinate axis and a third coordinate axis are determined based on the plurality of vectors; wherein the plurality of vectors are perpendicular to each other; The three-dimensional coordinate system is determined based on the first coordinate axis, the second coordinate axis, and the third coordinate axis.
3. The method according to claim 2, characterized in that, The step of determining multiple vectors perpendicular to the eye's orientation, and determining a second and third coordinate axis based on the multiple vectors, includes: Obtain the first intermediate vector located to the left or right of the positive direction of the first coordinate axis from the plurality of vectors; obtain the first target vector from the first intermediate vector whose plane with the first coordinate axis is a horizontal plane; Obtain a second intermediate vector located above or below the positive direction of the first coordinate axis from among the plurality of vectors; obtain a second target vector from the second intermediate vector whose plane with the first coordinate axis is a vertical plane; the horizontal plane and the vertical plane are perpendicular to each other; The second coordinate axis and the third coordinate axis are determined based on the first target vector and the second target vector.
4. The method according to claim 3, characterized in that, The step of determining the second coordinate axis and the third coordinate axis based on the first target vector and the second target vector includes: The vector direction of the first target vector is determined as the positive direction of the second coordinate axis; the vector direction of the second target vector is determined as the positive direction of the third coordinate axis; wherein, the vector direction of the first target vector is to the right or left of the direction the eyeball is facing, and the vector direction of the second target vector is above or below the direction the eyeball is facing.
5. The method according to claim 1, characterized in that, The step of determining the projection vector of the illumination direction onto a specified coordinate plane of the three-dimensional coordinate system includes: Determine the first projection vector of the illumination direction onto the first coordinate plane of the three-dimensional coordinate system; the first coordinate plane is composed of the first coordinate axis and the second coordinate axis of the three-dimensional coordinate system; Determine the second projection vector of the illumination direction on the second coordinate plane of the three-dimensional coordinate system; the second coordinate plane is composed of the second coordinate axis and the third coordinate axis of the three-dimensional coordinate system.
6. The method according to claim 1, characterized in that, The steps of calculating the first angle information between the first projection vector and the second coordinate axis, and calculating the second angle information between the second projection vector and the third coordinate axis, include: Calculate the first angle between the first projection vector and the positive direction of the second coordinate axis, and calculate the second angle between the second projection vector and the positive direction of the third coordinate axis.
7. The method according to claim 1, characterized in that, The step of updating the second included angle information based on the first included angle information to obtain the target included angle information includes: The left and right positions of the illumination direction relative to the direction of the eyeball are determined based on the first included angle information; The second included angle information is updated based on the left and right positions to obtain the target included angle information.
8. The method according to claim 7, characterized in that, The step of determining the left-right position of the illumination direction relative to the direction of the eyeball based on the first included angle information includes: If the positive direction of the second coordinate axis is to the right of the direction the eyeball is facing, and the first included angle information meets a preset condition, the position of the illumination direction to the right of the direction the eyeball is facing is determined; the preset condition is that the first included angle information is less than 90 degrees, or less than 0.
5. If the positive direction of the second coordinate axis is to the right of the direction the eyeball is facing, and the first included angle information does not meet the preset conditions, the illumination direction is determined to be to the left of the direction the eyeball is facing.
9. The method according to claim 7, characterized in that, The step of determining the left-right position of the illumination direction relative to the direction of the eyeball based on the first included angle information includes: If the positive direction of the second coordinate axis is to the left of the direction the eyeball is facing, and the first included angle information meets a preset condition, the position of the illumination direction to the left of the direction the eyeball is facing is determined; the preset condition is that the first included angle information is less than 90 degrees, or less than 0.
5. If the positive direction of the second coordinate axis is to the left of the direction the eyeball is facing, and the first included angle information does not meet the preset conditions, the position of the illumination direction is determined to be to the right of the direction the eyeball is facing.
10. The method according to claim 7, characterized in that, The step of updating the second included angle information based on the left and right positions to obtain the target included angle information includes: If the illumination direction is positioned to the right of the eye's orientation relative to the left and right position of the eye's orientation, and the positive direction of the third coordinate axis is above the eye's orientation, calculate the difference between the first value and the second angle information to obtain the target angle information; the first value refers to 180 degrees, or 1 radian value. If the illumination direction is to the left of the eye's orientation relative to the left-right position of the eye's orientation, and the positive direction of the third coordinate axis is above the eye's orientation, calculate the sum of the first value and the second angle information to obtain the target angle information.
11. The method according to claim 10, characterized in that, The step of updating the second included angle information based on the left and right positions to obtain the target included angle information includes: If the position of the illumination direction relative to the eye's orientation is to the right of the eye's orientation, and the positive direction of the third coordinate axis is below the eye's orientation, then the second included angle information is determined as the target included angle information. If the position of the illumination direction relative to the eye's orientation is to the left of the eye's orientation, and the positive direction of the third coordinate axis is below the eye's orientation, calculate the difference between the second value and the second angle information to obtain the target angle information; wherein, the second value is twice the first value.
12. The method according to claim 1, characterized in that, The steps include rotating a preset spot texture based on the target angle information, rendering the rotated spot texture onto the eye model, and obtaining an eye model with an eye spot effect, including: Using the center of the light spot texture as the rotation center and the target angle information as the rotation angle, the light spot texture is controlled to rotate clockwise by the rotation angle to obtain the target light spot texture; wherein, the light spot texture includes a light spot shape, the light spot shape is located at a specified position in the light spot texture, and the distance between the specified position and the center of the texture is the same as the radius of the pupil on the surface of the eyeball model; The target light spot texture is rendered onto the eyeball model to obtain the eyeball model with the eyeball light spot effect.
13. A rendering device for eyeball light spots, characterized in that, The device includes: The three-dimensional coordinate system determination module is used to obtain the eyeball model of the virtual object and determine the three-dimensional coordinate system based on the eyeball orientation of the eyeball model. The projection vector determination module is used to obtain the illumination direction of the light entering the eyeball model and determine the projection vector of the illumination direction on a specified coordinate plane of the three-dimensional coordinate system. The target angle information determination module is used to determine the target angle information between the projection vector and a specified coordinate axis of the three-dimensional coordinate system; The rendering module is used to rotate the preset spot texture based on the target angle information, and render the rotated spot texture onto the eyeball model to obtain the eyeball model with eyeball spot effect; The projection vector includes a first projection vector and a second projection vector; the specified coordinate axes include a second coordinate axis and a third coordinate axis; The target angle information determination module is further configured to: calculate the first angle information between the first projection vector and the second coordinate axis, calculate the second angle information between the second projection vector and the third coordinate axis; update the second angle information according to the first angle information to obtain the target angle information.
14. An electronic device, characterized in that, The method includes a processor and a memory, the memory storing computer-executable instructions that can be executed by the processor, the processor executing the computer-executable instructions to implement the method for rendering eyeball light spots according to any one of claims 1-12.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the eyeball light spot rendering method according to any one of claims 1-12.
Citation Information
Patent Citations
Highlight rendering method and device, medium and electronic equipment
CN114693860A
Virtual character eye rendering method and device, electronic equipment and storage medium
CN114949863A