An OpenGL-based real feeling simulation method for fiber scale woven fabric

By employing an OpenGL-based fiber-scale realistic simulation method for woven fabrics, utilizing NURBS curve fitting of yarn paths and PBR material mapping, and combining lighting, shadow processing, and LOD technology, the complexity and real-time performance issues of 3D simulation of woven fabrics are resolved, achieving efficient 3D realistic simulation and real-time interaction.

CN120951611BActive Publication Date: 2026-01-27CHANGSHU INSTITUTE OF TECHNOLOGY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511475522.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-16
Publication Date
2026-01-27
Estimated Expiration
2045-10-16

AI Technical Summary

Technical Problem

Existing technologies struggle to accurately simulate the buckling and interlacing effects of woven fabric fibers in three-dimensional space, and suffer from high computational complexity and poor real-time performance.

Method used

We employ an OpenGL-based fiber-scale woven fabric realistic simulation method, which uses NURBS curve fitting to fit the yarn path, combined with feather effect texture mapping and PBR material mapping, and utilizes lighting and shadow processing, along with LOD technology and GPU acceleration, to achieve efficient rendering and real-time interaction.

Benefits of technology

It achieves highly realistic simulation of woven fabrics in three-dimensional space, improving design efficiency and detail expression, and meeting the needs of real-time interaction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120951611B_ABST
    Figure CN120951611B_ABST
Patent Text Reader

Abstract

The application is a kind of real feeling simulation method of fiber scale woven fabric based on OpenGL.The application relates to the technical field of real feeling simulation of woven fabric, the center line path of yarn is fitted through NURBS curve, the geometric model of yarn is constructed and the fluff effect texture map is added, the interlaced structure is formed based on the simulation of yarn path of NURBS curve; the real yarn image is collected and the texture information is extracted, the PBR material map is generated; the OpenGL graphics library is used for rendering, the stereoscopic sense is enhanced through light and shadow processing, the real-time interactive control and parameter adjustment of the model are realized; the LOD is used for dynamically adjusting the model detail level, and the rendering efficiency is improved in combination with GPU acceleration.The application simulates the bending and interlaced details of yarn through fiber scale modeling, combines the physical rendering and real-time interaction technology, and significantly improves the real feeling, detail expressiveness and design efficiency of the simulation of woven fabric.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of realistic simulation technology for woven fabrics, and is a fiber-scale realistic simulation method for woven fabrics based on OpenGL. Background Technology

[0002] In the textile industry, the design and production of woven fabrics heavily rely on the accurate simulation of their appearance and structure. Traditional woven fabric simulation methods are often limited to a two-dimensional level, making it difficult to accurately reflect the complex interweaving patterns and physical properties of fabrics in three-dimensional space. While some three-dimensional woven fabric simulation methods have emerged with the development of 3D technology, these methods often suffer from high computational complexity, poor real-time performance, and difficulty in accurately simulating yarn buckling and interweaving effects at the fiber scale. Therefore, there is an urgent need to develop a simulation method that can accurately simulate the fiber-scale structure of woven fabrics while also meeting the requirements for real-time interaction. Summary of the Invention

[0003] This invention addresses the problems of existing technologies by disclosing a fiber-scale realistic simulation method for woven fabrics based on OpenGL. By constructing a geometric model of the yarn, combining it with a yarn texture map exhibiting a fuzzy effect, and utilizing a sine curve to simulate the yarn path, this invention achieves efficient rendering of plain weave fabric structures with interwoven warp and weft yarns. This method significantly enhances the realism and detail of woven fabric simulations.

[0004] This invention provides the following technical solutions:

[0005] A fiber-scale realistic simulation method for woven fabrics based on OpenGL, the method comprising the following steps:

[0006] Step 1: Fit the centerline path of the yarn in 3D space using NURBS curves, construct the geometric model of the yarn and add a texture map with a feather effect, and simulate the yarn path based on the NURBS curves to form an interlacing structure;

[0007] Step 2: Acquire real yarn images and extract texture information to generate PBR material maps;

[0008] Step 3: Use the OpenGL graphics library for rendering, enhance the sense of depth through lighting and shadow processing, and realize real-time interactive control and parameter adjustment of the model;

[0009] Step 4: Use LOD to dynamically adjust the model's level of detail, and combine it with GPU acceleration to improve rendering efficiency.

[0010] Preferably, step 1 specifically comprises:

[0011] Step 1.1: Perform yarn modeling. In 3D space, the centerline path of the yarn is fitted using a NURBS curve. The NURBS curve is defined by control points, weights, and node vectors. Given a set of control points... P i , i =0,1,..., n The corresponding weight w i and node vector U=[ u 0, u 1,..., u m NURBS curves Represented as:

[0012]

[0013] In the formula, N i,p ( u ) is the first i indivual p The NURBS basis functions are derived from the node vectors. U The recursive definition is that n is the total number of control points minus 1, and m is the value of the last node in the node vector;

[0014] The cross-sectional shape of the yarn can be modeled using circles, ellipses, or other shapes depending on the actual situation;

[0015] Step 1.2: Model the interwoven structure:

[0016] Based on the weave structure of the woven fabric, including plain weave, twill weave, or satin weave, determine the interlacing method and sequence of the warp and weft yarns, and construct the overall three-dimensional model of the woven fabric by calculating the spatial coordinates of the warp and weft yarns at the interlacing point.

[0017] Calculation of interlacing point coordinates:

[0018] The buckling shape of the warp and weft yarns at the interlacing point has been described by NURBS curves, and the spatial coordinates of the interlacing point ( x , y , z This is obtained by solving for the intersection of the warp and weft NURBS curves at that point;

[0019] Organizational structure definition:

[0020] Plain weave, where warp and weft yarns interweave alternately in a "one warp, one weft" pattern, its interweaving matrix is ​​represented as follows:

[0021]

[0022] Where 1 indicates that the warp yarn is on top and the weft yarn is on the bottom; 0 indicates that the weft yarn is on top and the warp yarn is on the bottom.

[0023] Twill and satin weaves are modeled after plain weave as needed; Step 1.3: Add fiber details:

[0024] Add fiber details to the yarn model, including fiber orientation, density, and degree of twist;

[0025] Fiber alignment direction:

[0026] The fiber orientation is defined by the fiber tilt angle within the yarn cross-section. i To achieve the tilt angle i Randomly generated, or distributed according to a certain pattern;

[0027] Fiber density:

[0028] Fiber density is achieved by distributing fibers uniformly or non-uniformly within the cross-section of the yarn. The Poisson disk sampling method is used to ensure that the distribution of fibers within the cross-section is neither too dense nor too sparse.

[0029] Fiber twisting:

[0030] The degree of fiber twist is achieved by spiraling the yarn centerline path, and the specific transformation formula is as follows:

[0031]

[0032] in, oh Twist rate, which controls the degree of fiber twisting. , , This represents the coordinate values ​​in the new coordinate system after the spiral transformation.

[0033] Preferably, step 2 specifically comprises:

[0034] Step 2.1: Acquire images of real yarn, extract texture information of the yarn, including color, roughness, and gloss, and preprocess the acquired yarn images to obtain clear texture features;

[0035] The following methods are used to remove noise from an image: Gaussian filtering or median filtering.

[0036]

[0037] in, I ( i ,j) represents the original image in ( x , y The pixel value at () I '( x , y () represents the filtered pixel value. S For filtering window, s The standard deviation of the Gaussian function;

[0038] The image is converted into a binary image using a thresholding method, and a threshold is set. T , to remove pixels with values ​​greater than T Set to 1, less than or equal to T Set it to 0;

[0039] Step 2.2: Based on the collected yarn texture information, generate PBR material maps, including color maps, roughness maps, and normal maps. The maps will be used in the subsequent rendering process to enhance the realism of the woven fabric.

[0040] Preferably, color mapping: color information is extracted from the acquired yarn image to generate a color map;

[0041] Roughness mapping: By analyzing the texture details of the yarn image, the roughness of the yarn surface is estimated and a roughness map is generated. The roughness value is obtained by calculating the variance or standard deviation of the pixel values ​​in the image.

[0042] Normal mapping: By calculating the gradient information of pixels in the yarn image, the normal direction of the yarn surface is estimated, and a normal map is generated.

[0043] Preferably, step 3 specifically comprises:

[0044] The constructed model is imported into the OpenGL environment and rendered using OpenGL graphics functions. By setting lighting, shadows, reflections and other effects, the three-dimensionality and realism of the woven fabric are enhanced.

[0045] Lighting model: Lighting calculations are performed using either the Phong lighting model or the Blinn-Phong lighting model. The Phong lighting model is expressed by the following formula:

[0046]

[0047] in, I For the final light intensity, I a For ambient light intensity, I d The intensity of diffuse reflected light. I s This represents the intensity of light reflected from the specular surface. The specific calculation formula is:

[0048]

[0049]

[0050] in, k d andk s These are the diffuse reflection coefficient and the specular reflection coefficient, respectively. I l For light source intensity, The surface normal vector, L Let be the direction vector of the light source. R The reflection direction vector, V To observe the direction vector, The specular reflectance index;

[0051] Shadow processing: Shadows are generated using shadow mapping, and a depth map is generated by rendering the scene from the light source's perspective. During normal rendering, the depth of a fragment is compared with the depth value of the corresponding position in the depth map to determine whether the fragment is in shadow.

[0052] By leveraging OpenGL's interactive features, users can perform real-time operations and adjustments on the woven fabric model. The interactive control is implemented by capturing user input events through OpenGL's event handling mechanism and converting them into transformation operations on the woven fabric model. The transformation operations are then applied to the vertex coordinates of the woven fabric model using a matrix transformation method.

[0053] Preferably, the level of detail of the model is dynamically adjusted according to the distance between the woven fabric model and the observer. When the model gets closer to the observer, it switches to a model with a high level of detail to ensure rendering quality.

[0054] Preferably, step 4 specifically comprises:

[0055] Step 4.1: Generate the LOD model. During the rendering process, select the appropriate level of detail based on the distance between the model and the viewer, and perform distance calculation and LOD switching.

[0056] Calculate the distance between the center point of the model and the observer. d And according to the preset distance threshold d 1, d 2,..., d n in d 1< d 2<...< d n, The appropriate level of detail to use is determined, and the specific switching strategy is as follows: When d < d When 1, the model with the highest level of detail is used; when d i ≤ d < d i When +1, the first... i A model at a detailed level; when d ≥ dn At that time, the model with the lowest level of detail is used;

[0057] Step 4.2: Utilize the parallel computing capabilities of the graphics processing unit to accelerate the rendering process of the woven fabric model. By writing shader programs, the rendering tasks are distributed to multiple cores of the GPU for parallel execution, thereby significantly improving the rendering speed. Shader programming: Use GLSL to write vertex shaders and fragment shaders to implement the transformation, lighting calculation, and texture mapping functions of the woven fabric model. The shader programs are executed in parallel on the GPU, thereby accelerating the rendering process.

[0058] Step 4.3: Parallel computing optimization. Improve the parallel computing efficiency of the GPU by optimizing the computation process and data access mode of the shader program, including reducing the number of global memory accesses and utilizing high-speed memory such as shared memory and registers.

[0059] A fiber-scale realistic simulation system for woven fabrics based on OpenGL, the system comprising:

[0060] The model building module fits the centerline path of the yarn in three-dimensional space using NURBS curves, constructs the geometric model of the yarn, adds a texture map with a feather effect, and simulates the yarn path based on the NURBS curves to form an interlacing structure.

[0061] The information acquisition module acquires real yarn images and extracts texture information to generate PBR material texture maps;

[0062] The rendering module uses the OpenGL graphics library for rendering, and enhances the sense of three-dimensionality through lighting and shadow processing, enabling real-time interactive control and parameter adjustment of the model;

[0063] The acceleration module uses LOD (Level of Detail) to dynamically adjust the model's level of detail, and combines GPU acceleration to improve rendering efficiency.

[0064] A computer-readable storage medium having a computer program stored thereon, which is executed by a processor to implement a fiber-scale realistic simulation method for woven fabrics based on OpenGL.

[0065] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement a fiber-scale realistic simulation method for woven fabrics based on OpenGL.

[0066] The present invention has the following beneficial effects:

[0067] This invention models woven fabrics at the fiber scale, accurately simulating details such as yarn crimping, interlacing, fiber arrangement, and twisting. Combined with PBR material mapping and realistic lighting models, it achieves highly realistic simulation of woven fabrics in three-dimensional space, providing a more accurate visual reference for product design, display, and evaluation in the textile industry.

[0068] This invention utilizes OpenGL's interactive features, allowing users to perform real-time operations such as rotation, translation, and scaling on woven fabric models. Users can also modify fabric parameters in real time and observe the impact of different parameters on the fabric's appearance. This real-time interactivity significantly improves design efficiency, enabling designers to quickly iterate and optimize design solutions.

[0069] This invention employs LOD technology and GPU acceleration technology to dynamically adjust the model's level of detail based on the distance between the model and the observer, and utilizes the parallel computing power of the GPU to accelerate the rendering process. While ensuring rendering quality, it significantly improves rendering speed and meets the needs of real-time interaction.

[0070] The technical solution of this invention is applicable to various types of woven fabrics, including common weave structures such as plain weave, twill weave, and satin weave, as well as novel woven fabrics with complex interlacing patterns. Furthermore, this method can be integrated with other textile-related software and systems, exhibiting good scalability and versatility. Attached Figure Description

[0071] 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.

[0072] Figure 1 The image shown is a simulation rendering of the plain weave woven fabric of the present invention.

[0073] Figure 2 The image shown is a simulation rendering of the twill woven fabric of the present invention.

[0074] Figure 3 The flowchart shown is a flowchart of the fiber-scale realistic simulation method for woven fabrics based on OpenGL according to the present invention. Detailed Implementation

[0075] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. 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.

[0076] The present invention will be described in detail below with reference to specific embodiments. Specific Implementation Example 1:

[0078] according to Figure 1 to Figure 3 As shown, the specific optimized technical solution adopted by the present invention to solve the above-mentioned technical problems is: The present invention relates to a fiber-scale woven fabric realistic simulation method based on OpenGL.

[0079] This invention provides a method for realistic simulation of fiber-scale woven fabrics based on OpenGL, the method comprising the following steps:

[0080] Step 1: Fit the centerline path of the yarn in 3D space using NURBS curves, construct the geometric model of the yarn and add a texture map with a feather effect, and simulate the yarn path based on the NURBS curves to form an interlacing structure;

[0081] Step 1 specifically involves:

[0082] Step 1.1: Perform yarn modeling. In 3D space, the centerline path of the yarn is fitted using a NURBS curve. The NURBS curve is defined by control points, weights, and node vectors. Given a set of control points... P i , i =0,1,..., n The corresponding weight w i and node vector U=[ u 0, u 1,..., u m NURBS curves Represented as:

[0083]

[0084] In the formula, N i,p ( u ) is the first i indivual p The NURBS basis functions are derived from the node vectors. U Recursive definition;

[0085] The cross-sectional shape of the yarn can be modeled using circles, ellipses, or other shapes depending on the actual situation;

[0086] Step 1.2: Model the interwoven structure:

[0087] Based on the weave structure of the woven fabric, including plain weave, twill weave, or satin weave, determine the interlacing method and sequence of the warp and weft yarns, and construct the overall three-dimensional model of the woven fabric by calculating the spatial coordinates of the warp and weft yarns at the interlacing point.

[0088] Calculation of interlacing point coordinates:

[0089] The buckling shape of the warp and weft yarns at the interlacing point has been described by NURBS curves, and the spatial coordinates of the interlacing point ( x , y , z This is obtained by solving for the intersection of the warp and weft NURBS curves at that point;

[0090] Organizational structure definition:

[0091] Plain weave, where warp and weft yarns interweave alternately in a "one warp, one weft" pattern, its interweaving matrix is ​​represented as follows:

[0092]

[0093] Where 1 indicates that the warp yarn is on top and the weft yarn is on the bottom; 0 indicates that the weft yarn is on top and the warp yarn is on the bottom.

[0094] Twill and satin weaves are modeled after plain weave as needed; Step 1.3: Add fiber details:

[0095] Add fiber details to the yarn model, including fiber orientation, density, and degree of twist;

[0096] Fiber alignment direction:

[0097] The fiber orientation is defined by the fiber tilt angle within the yarn cross-section. i To achieve the tilt angle i Randomly generated, or distributed according to a certain pattern;

[0098] Fiber density:

[0099] Fiber density is achieved by distributing fibers uniformly or non-uniformly within the cross-section of the yarn. The Poisson disk sampling method is used to ensure that the distribution of fibers within the cross-section is neither too dense nor too sparse.

[0100] Fiber twisting:

[0101] The degree of fiber twist is achieved by spiraling the yarn centerline path, and the specific transformation formula is as follows:

[0102]

[0103] in, oh Twist rate controls the degree of fiber twisting.

[0104] Step 2: Acquire real yarn images and extract texture information to generate PBR material maps;

[0105] Step 2 specifically involves:

[0106] Step 2.1: Acquire images of real yarn, extract texture information of the yarn, including color, roughness, and gloss, and preprocess the acquired yarn images to obtain clear texture features;

[0107] The following methods are used to remove noise from an image: Gaussian filtering or median filtering.

[0108]

[0109] in, I ( i ,j) represents the original image in ( x , y The pixel value at () I '( x , y () represents the filtered pixel value. S For filtering window, s The standard deviation of the Gaussian function;

[0110] The image is converted into a binary image using a thresholding method, and a threshold is set. T , to remove pixels with values ​​greater than T Set to 1, less than or equal to T Set it to 0;

[0111] Step 2.2: Based on the collected yarn texture information, generate PBR material maps, including color maps, roughness maps, and normal maps. The maps will be used in the subsequent rendering process to enhance the realism of the woven fabric.

[0112] Color mapping: Extract color information from the acquired yarn image to generate a color map;

[0113] Roughness mapping: By analyzing the texture details of the yarn image, the roughness of the yarn surface is estimated and a roughness map is generated. The roughness value is obtained by calculating the variance or standard deviation of the pixel values ​​in the image.

[0114] Normal mapping: By calculating the gradient information of pixels in the yarn image, the normal direction of the yarn surface is estimated, and a normal map is generated.

[0115] Step 3: Use the OpenGL graphics library for rendering, enhance the sense of depth through lighting and shadow processing, and realize real-time interactive control and parameter adjustment of the model;

[0116] Step 3 specifically involves:

[0117] The constructed model is imported into the OpenGL environment and rendered using OpenGL graphics functions. By setting lighting, shadows, reflections and other effects, the three-dimensionality and realism of the woven fabric are enhanced.

[0118] Lighting model: Lighting calculations are performed using either the Phong lighting model or the Blinn-Phong lighting model. The Phong lighting model is expressed by the following formula:

[0119]

[0120] in, I For the final light intensity, I a For ambient light intensity, I d The intensity of diffuse reflected light. I s This represents the intensity of light reflected from the specular surface. The specific calculation formula is:

[0121]

[0122]

[0123] in, k d and k s These are the diffuse reflection coefficient and the specular reflection coefficient, respectively. I l For light source intensity, The surface normal vector, L Let be the direction vector of the light source. R The reflection direction vector, V To observe the direction vector, The specular reflectance index;

[0124] Shadow processing: Shadows are generated using shadow mapping, and a depth map is generated by rendering the scene from the light source's perspective. During normal rendering, the depth of a fragment is compared with the depth value of the corresponding position in the depth map to determine whether the fragment is in shadow.

[0125] By leveraging OpenGL's interactive features, users can perform real-time operations and adjustments on the woven fabric model. The interactive control is implemented by capturing user input events through OpenGL's event handling mechanism and converting them into transformation operations on the woven fabric model. The transformation operations are then applied to the vertex coordinates of the woven fabric model using a matrix transformation method.

[0126] Step 4: Use LOD to dynamically adjust the model's level of detail, and combine it with GPU acceleration to improve rendering efficiency.

[0127] The model's level of detail is dynamically adjusted based on the distance between the woven fabric model and the observer. When the model gets closer to the observer, it switches to a model with a high level of detail to ensure rendering quality.

[0128] Step 4 specifically involves:

[0129] Step 4.1: Generate the LOD model. During the rendering process, select the appropriate level of detail based on the distance between the model and the viewer, and perform distance calculation and LOD switching.

[0130] Calculate the distance between the center point of the model and the observer. d And according to the preset distance threshold d 1, d 2,..., d n in d 1< d 2<...< d n, The appropriate level of detail to use is determined, and the specific switching strategy is as follows: When d < d When 1, the model with the highest level of detail is used; when d i ≤ d < d i When +1, the first... i A model at a detailed level; when d ≥ d n At that time, the model with the lowest level of detail is used;

[0131] Step 4.2: Utilize the parallel computing capabilities of the graphics processing unit to accelerate the rendering process of the woven fabric model. By writing shader programs, the rendering tasks are distributed to multiple cores of the GPU for parallel execution, thereby significantly improving the rendering speed. Shader programming: Use GLSL to write vertex shaders and fragment shaders to implement the transformation, lighting calculation, and texture mapping functions of the woven fabric model. The shader programs are executed in parallel on the GPU, thereby accelerating the rendering process.

[0132] Step 4.3: Parallel computing optimization. Improve the parallel computing efficiency of the GPU by optimizing the computation process and data access mode of the shader program, including reducing the number of global memory accesses and utilizing shared memory and register high-speed memory.

[0133] This invention provides a fiber-scale realistic simulation method for woven fabrics based on OpenGL, comprising the following steps: fitting the centerline path of the yarn using NURBS curves in three-dimensional space, constructing a geometric model of the yarn and adding a texture map with a feathering effect, and simulating the yarn path to form an interlacing structure using NURBS curves; acquiring real yarn images and extracting texture information to generate PBR material maps; performing efficient rendering using the OpenGL graphics library, enhancing the three-dimensionality through lighting and shadow processing, and enabling real-time interactive control and parameter adjustment of the model by the user; dynamically adjusting the model's detail levels using LOD technology, and improving rendering efficiency by combining GPU acceleration. This method simulates yarn buckling and interlacing details through fiber-scale modeling, and, combined with physically based rendering and real-time interactive technology, significantly improves the realism, detail expression, and design efficiency of woven fabric simulation. It is applicable to various woven fabric structures such as plain weave, twill weave, and satin weave, providing strong technical support for product design, display, and evaluation in the textile industry.

[0134] This invention provides a fiber-scale realistic simulation system for woven fabrics based on OpenGL, the system comprising:

[0135] The model building module fits the centerline path of the yarn in three-dimensional space using NURBS curves, constructs the geometric model of the yarn, adds a texture map with a feather effect, and simulates the yarn path based on the NURBS curves to form an interlacing structure.

[0136] The information acquisition module acquires real yarn images and extracts texture information to generate PBR material texture maps;

[0137] The rendering module uses the OpenGL graphics library for rendering, and enhances the sense of three-dimensionality through lighting and shadow processing, enabling real-time interactive control and parameter adjustment of the model;

[0138] The acceleration module uses LOD (Level of Detail) to dynamically adjust the model's level of detail, and combines GPU acceleration to improve rendering efficiency.

[0139] The present invention provides a computer-readable storage medium having a computer program stored thereon, which is executed by a processor to implement a fiber-scale realistic simulation method for woven fabrics based on OpenGL.

[0140] The present invention provides a computer device, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement a fiber-scale realistic simulation method for woven fabrics based on OpenGL. Specific Implementation Example 2:

[0142] The purpose of this invention is to provide a realistic simulation method for fiber-scale woven fabrics based on OpenGL. By constructing a geometric model of the yarn, combining it with a yarn texture map that creates a fuzzy effect, and using a sine curve to simulate the yarn path, this method achieves efficient rendering of plain weave fabric structures with interwoven warp and weft yarns. This method can significantly improve the realism and detail of woven fabric simulations.

[0143] The technical solution of this invention:

[0144] 1. Construction of fiber-scale woven fabric model:

[0145] 1.1 Yarn Modeling:

[0146] In three-dimensional space, the centerline path of the yarn is fitted using a NURBS (Non-Uniform Rational B-Spline) curve. NURBS curves have local controllability and continuity, and can accurately describe the buckling morphology of the yarn in woven fabrics.

[0147] NURBS curve definition:

[0148] NURBS curves are defined by control points, weights, and node vectors. Given a set of control points... P i ( i =0,1,..., n ), corresponding weight w i and node vector U=[ u 0, u 1,..., u m The mathematical expression for the NURBS curve is:

[0149]

[0150] In the formula, N i,p ( u ) is the first i indivual p The NURBS basis functions are derived from the node vectors. U Recursive definition.

[0151] Yarn cross-section modeling:

[0152] The cross-sectional shape of the yarn can be modeled using circles, ellipses, or other complex shapes, depending on the actual situation.

[0153] 1.2 Modeling of interwoven structures:

[0154] Based on the weave structure of the woven fabric (such as plain weave, twill weave, satin weave, etc.), the interlacing method and sequence of the warp and weft yarns are determined. By calculating the spatial coordinates of the warp and weft yarns at the interlacing points, a three-dimensional model of the woven fabric is constructed.

[0155] Calculation of interlacing point coordinates:

[0156] Assuming the buckling pattern of the warp and weft yarns at the interlacing point has been described by NURBS curves, the spatial coordinates of the interlacing point ( x , y , z This can be obtained by solving for the intersection of the warp and weft NURBS curves at that point.

[0157] Organizational structure definition:

[0158] Taking plain weave as an example, the warp and weft yarns interweave alternately in a "one warp, one weft" pattern. Its interweaving matrix can be represented as:

[0159]

[0160] In this configuration, 1 indicates the warp yarn is on top and the weft yarn is on the bottom; 0 indicates the weft yarn is on top and the warp yarn is on the bottom. 1.3 Fiber Details Added:

[0161] Further fiber details, such as fiber orientation, density, and twist, are added to the yarn model to more realistically reflect the microstructure of the woven fabric.

[0162] Fiber alignment direction:

[0163] The fiber orientation can be defined by the fiber tilt angle within the yarn cross-section. i To achieve this. Tilt angle i It can be generated randomly, or it can be distributed according to a certain pattern.

[0164] Fiber density:

[0165] Fiber density can be achieved by distributing fibers uniformly or non-uniformly within the cross-section of the yarn. In practice, methods such as Poisson disk sampling can be used to ensure that the fiber distribution within the cross-section is neither too dense nor too sparse.

[0166] Fiber twisting:

[0167] The degree of fiber twist can be achieved by spiraling the yarn centerline path. The specific transformation formula is as follows:

[0168]

[0169] in, oh Twist rate controls the degree of fiber twisting.

[0170] 2. Texture and Material Processing:

[0171] 2.1 Yarn texture acquisition:

[0172] Images of real yarn are acquired, and texture information, including color, roughness, and gloss, is extracted. The acquired yarn images are then preprocessed, including denoising, binarization, and edge detection, to obtain clearer texture features.

[0173] Image denoising:

[0174] Noise in images can be removed using methods such as Gaussian filtering or median filtering. The mathematical expression for Gaussian filtering is:

[0175]

[0176] in, I ( i ,j) represents the original image in ( x , y The pixel value at () I '( x , y () represents the filtered pixel value. S For filtering window, s is the standard deviation of the Gaussian function.

[0177] Binarization:

[0178] A thresholding method is used to convert the image into a binary image. A threshold is set. T , to remove pixels with values ​​greater than T Set to 1, less than or equal to T The value is set to 0. The binarized image can more clearly highlight the main body of the yarn and the details of the hair.

[0179] 2.2 PBR Material Map Generation:

[0180] Based on the collected yarn texture information, PBR (Physically Based Rendering) material maps are generated, including color maps, roughness maps, and normal maps. These maps will be used in subsequent rendering processes to enhance the realism of woven fabrics.

[0181] Color mapping: Color information is extracted directly from the collected yarn image to generate a color map.

[0182] Roughness mapping: By analyzing the texture details of the yarn image, the roughness of the yarn surface is estimated, and a roughness map is generated. The roughness value can be obtained by calculating the variance or standard deviation of the pixel values ​​in the image.

[0183] Normal map:

[0184] By calculating the gradient information of pixels in the yarn image, the normal direction of the yarn surface is estimated, and a normal map is generated. The normal map can enhance the three-dimensionality of the yarn surface.

[0185] 3. OpenGL Rendering and Interaction:

[0186] 3.1 Model Import and Rendering:

[0187] The constructed fiber-scale woven fabric model is imported into the OpenGL environment and rendered using OpenGL graphics functions. By setting lighting, shadows, reflections, and other effects, the three-dimensionality and realism of the woven fabric are enhanced.

[0188] Lighting model:

[0189] Illumination calculations are performed using either the Phong illumination model or the Blinn-Phong illumination model. Taking the Phong illumination model as an example, its mathematical expression is:

[0190]

[0191] in, I For the final light intensity, I a For ambient light intensity, I d The intensity of diffuse reflected light. I s This represents the intensity of light reflected from the specular surface. The specific calculation formula is:

[0192]

[0193]

[0194] in, k d and k s These are the diffuse reflection coefficient and the specular reflection coefficient, respectively. I l For light source intensity, The surface normal vector, L Let be the direction vector of the light source. R The reflection direction vector, V To observe the direction vector, The specular reflection index.

[0195] Shadow processing:

[0196] Shadows are generated using shadow mapping technology. The specific steps include: rendering the scene from the light source's perspective to generate a depth map; during normal rendering, comparing the fragment's depth with the depth value of the corresponding position in the depth map to determine whether the fragment is in shadow.

[0197] 3.2 Real-time interactive control:

[0198] Leveraging OpenGL's interactive features, users can manipulate and adjust woven fabric models in real time. Users can rotate, translate, and scale the fabric using input devices such as a mouse and keyboard to observe its details from different angles. Simultaneously, users can modify fabric parameters (such as yarn density and weave pattern) in real time to observe the impact of different parameters on the fabric's appearance.

[0199] Interactive control implementation:

[0200] User input events (such as mouse movement and key presses) are captured using OpenGL's event handling mechanism and converted into transformation operations (such as rotation, translation, and scaling) on ​​the woven fabric model. In practice, matrix transformations can be used to apply the transformation operations to the vertex coordinates of the woven fabric model.

[0201] 4. Optimization and acceleration:

[0202] 4.1 LOD (Level of Detail):

[0203] The model's level of detail is dynamically adjusted based on its distance from the observer. When the model is far from the observer, a model with a low level of detail is used for rendering to improve rendering efficiency; when the model is close to the observer, a model with a high level of detail is used to ensure rendering quality.

[0204] LOD model generation:

[0205] Multiple woven fabric models with varying levels of detail are pre-generated, each with a different level of complexity (e.g., number of polygons). During rendering, the appropriate level of detail is selected based on the distance between the model and the viewer.

[0206] Distance calculation and LOD switching:

[0207] Calculate the distance between the center point of the model and the observer. d And according to the preset distance threshold d 1, d 2,..., d n (in d 1< d 2<...< d nDetermine the appropriate level of detail to use. The specific switching strategy is: when... d < d When 1, the model with the highest level of detail is used; when d i ≤ d < d i When +1, the first... i A model at a detailed level; when d ≥ d n At that time, the model with the lowest level of detail is used.

[0208] 4.2 GPU Acceleration:

[0209] Leveraging the parallel computing capabilities of graphics processing units (GPUs), the rendering process of woven fabric models is accelerated. By writing efficient shader programs, rendering tasks are distributed across multiple GPU cores for parallel execution, thereby significantly improving rendering speed.

[0210] Shader programming:

[0211] Using GLSL (OpenGL Shading Language), vertex shaders, fragment shaders, and other components are written to implement functions such as transformation, lighting calculation, and texture mapping for woven fabric models. Shader programs can be executed in parallel on the GPU, thereby accelerating the rendering process.

[0212] Parallel computing optimization:

[0213] Improve GPU parallel computing efficiency by optimizing the computation flow and data access patterns of shader programs. For example, reduce the number of global memory accesses and utilize high-speed memory such as shared memory and registers. Specific Implementation Example 3:

[0215] Example: Simulation of plain weave woven fabric:

[0216] Model building:

[0217] Yarn modeling: Select a yarn with a circular cross-section and set the yarn radius. r =0.1mm. The centerline path of the yarn was fitted using NURBS curves. Based on the interlacing characteristics of the plain weave, the buckling shape of the warp and weft yarns at the interlacing point was determined. At the interlacing point, the root of the buckling height of the warp and weft yarns was set to... h =0.2mm.

[0218] Interlacing Structure Modeling: Based on the interlacing matrix of the plain weave, the interlacing sequence of the warp and weft yarns is determined. By calculating the spatial coordinates of the warp and weft yarns at the interlacing points, a 3D model of the overall plain weave fabric is constructed. Assuming the warp density of the fabric is 50 yarns / cm and the weft density is 40 yarns / cm, and the model size is 10cm × 10cm, then the number of warp yarns is 500 and the number of weft yarns is 400.

[0219] Adding fiber details: Add fiber details to the yarn model and set the fiber tilt angle. i Randomly distributed between -15° and 15°, with a fiber density of 100 fibers per square millimeter and a twist rate of [missing information]. oh =0.1.

[0220] Texture and material processing:

[0221] Yarn texture acquisition: Images of real cotton yarn are acquired using a high-resolution camera. The acquired images are then denoised using a Gaussian filter. s =1. Then perform binarization and set a threshold. T =128.

[0222] PBR material texture generation: Extract color information from the denoised and binarized image to generate a color texture; generate a roughness texture by calculating the variance of pixel values ​​in the image; generate a normal texture by calculating the gradient information of pixels.

[0223] OpenGL rendering and interaction:

[0224] Model Import and Rendering: Import the constructed plain weave fabric model into the OpenGL environment, perform lighting calculations using the Phong lighting model, and set the ambient light intensity. I a =0.2, diffuse reflectance coefficient k d =0.7, specular reflection coefficient k s =0.3, specular reflection index n =50, light source intensity I l =1.0. Shadows are generated using shadow mapping technology.

[0225] Real-time interactive control: User mouse and keyboard input is captured through OpenGL's event handling mechanism to enable model rotation, translation, and scaling. A parameter adjustment interface is also provided, allowing users to modify parameters such as yarn density and interlacing method in real time and observe changes in the model.

[0226] Optimization and acceleration:

[0227] LOD technology: Pre-generate plain weave fabric models with three levels of detail: high detail (100,000 polygons), medium detail (50,000 polygons), and low detail (10,000 polygons). Set a distance threshold. d 1 = 5 cm d 2 = 10 cm. LOD switching is performed based on the distance between the model's center point and the observer.

[0228] GPU acceleration: Vertex and fragment shaders are written using GLSL to implement model transformations, lighting calculations, and texture mapping. The computation flow of the shader program is optimized to reduce the number of global memory accesses and improve the parallel computing efficiency of the GPU. Specific Implementation Example 4:

[0230] Example: Simulation of twill woven fabric:

[0231] Model building:

[0232] Yarn modeling: Again, select yarn with a circular cross-section, radius... r =0.1mm. The centerline path of the yarn is fitted using NURBS curves. Based on the interlacing characteristics of the twill weave, the buckling shape of the warp and weft yarns at the interlacing point is determined. For example, if the twill weave has a slant angle of 45°, the buckling height at the interlacing point is... h =0.2mm.

[0233] Interlacing structure modeling: Taking a 2 / 1 twill weave as an example, its interlacing matrix is:

[0234]

[0235] A three-dimensional model of the plain weave fabric is constructed by calculating the spatial coordinates of the warp and weft yarns at the interlacing points. Assuming the warp density of the fabric is 80 yarns / cm and the weft density is 60 yarns / cm, and the model size is 10cm×10cm, then the number of warp yarns is 800 and the number of weft yarns is 600.

[0236] Adding fiber details: Add fiber details to the yarn model and set the fiber tilt angle. i Randomly distributed between -15° and 15°, with a fiber density of 200 fibers per square millimeter and a twist rate of [missing information]. oh =0.2.

[0237] Texture and material processing:

[0238] Yarn texture acquisition: Images of real polyester yarn were acquired and denoised using median filtering with a 3×3 filter window. Binarization was then performed, with a threshold set. T =150.

[0239] PBR material texture generation: Extract color information from the image to generate a color texture; generate a roughness texture by calculating the standard deviation of pixel values; generate a normal texture by calculating the gradient information of pixels.

[0240] OpenGL rendering and interaction:

[0241] Model import and rendering: Lighting calculations are performed using the Blinn-Phong lighting model, and the ambient light intensity is set. I a =0.1, diffuse reflectance coefficient k d =0.8, specular reflection coefficient k s =0.2, specular reflection index n =30, light source intensity I l =1.2. Shadows are generated using shadow mapping techniques.

[0242] Real-time interactive control: The interactive operation of the model is realized through the event handling mechanism of OpenGL, and a parameter adjustment interface is provided. Users can modify parameters such as interlacing matrix and yarn density and observe the changes in the model.

[0243] Optimization and acceleration:

[0244] LOD technology: Pre-generate twill woven fabric models with three levels of detail: high detail (90,000 polygons), medium detail (45,000 polygons), and low detail (9,000 polygons). Set a distance threshold. d 1 = 6cm d 2 = 12cm. LOD switching is performed based on the distance between the model's center point and the observer.

[0245] GPU acceleration: Using GLSL to write shader programs optimizes the computation process, improves the parallel computing efficiency of the GPU, and accelerates the rendering process of the model.

[0246] The above description is merely a preferred embodiment of a fiber-scale woven fabric realistic simulation method based on OpenGL. The scope of protection for this OpenGL-based fiber-scale woven fabric realistic simulation method is not limited to the above embodiments; all technical solutions falling within this conceptual framework are within the protection scope of this invention. It should be noted that for those skilled in the art, any improvements and variations made without departing from the principles of this invention should also be considered within the protection scope of this invention.

Claims

1. A fiber-scale realistic simulation method for woven fabrics based on OpenGL, characterized by: The method includes the following steps: Step 1: Fit the centerline path of the yarn in 3D space using NURBS curves, construct the geometric model of the yarn and add a texture map with a feather effect, and simulate the yarn path based on the NURBS curves to form an interlacing structure; Step 1 specifically involves: Step 1.1: Perform yarn modeling. In 3D space, the centerline path of the yarn is fitted using a NURBS curve. The NURBS curve is defined by control points, weights, and node vectors. Given a set of control points... P i , i =0,1,..., n The corresponding weight w i and node vector U=[ u 0, u 1,..., u m NURBS curves Represented as: In the formula, N i,p ( u ) is the first i indivual p NURBS basis functions, derived from node vectors U The recursive definition is as follows: i is the index of the control point, n is the total number of control points minus 1, and m is the value of the last node in the node vector. The cross-sectional shape of the yarn can be modeled using circles, ellipses, or other shapes depending on the actual situation; Step 1.2: Model the interwoven structure: Based on the weave structure of the woven fabric, including plain weave, twill weave, or satin weave, determine the interlacing method and sequence of the warp and weft yarns, and construct the overall three-dimensional model of the woven fabric by calculating the spatial coordinates of the warp and weft yarns at the interlacing point. Calculation of interlacing point coordinates: The buckling shape of the warp and weft yarns at the interlacing point has been described by NURBS curves, and the spatial coordinates of the interlacing point ( x , y , z This is obtained by solving for the intersection of the warp and weft NURBS curves at that point; Organizational structure definition: Plain weave, where warp and weft yarns interweave alternately in a "one warp, one weft" pattern, its interweaving matrix is ​​represented as follows: Where 1 indicates that the warp yarn is on top and the weft yarn is on the bottom; 0 indicates that the weft yarn is on top and the warp yarn is on the bottom. Twill and satin weaves are modeled as needed, referencing plain weave. Step 1.3: Adding fiber details: Add fiber details to the yarn model, including fiber orientation, density, and degree of twist; Fiber alignment direction: The fiber orientation is defined by the fiber tilt angle within the yarn cross-section. θ To achieve the tilt angle θ Randomly generated; Fiber density: Fiber density is achieved by distributing fibers uniformly or non-uniformly within the cross-section of the yarn. The Poisson disk sampling method is used to ensure that the distribution of fibers within the cross-section is neither too dense nor too sparse. Fiber twisting: The degree of fiber twist is achieved by spiraling the yarn centerline path, and the specific transformation formula is as follows: in, ω Twist rate, which controls the degree of fiber twisting. , , This represents the coordinate values ​​in the new coordinate system after the spiral transformation; Step 2: Acquire real yarn images and extract texture information to generate PBR material maps; Step 3: Use the OpenGL graphics library for rendering, enhance the sense of depth through lighting and shadow processing, and realize real-time interactive control and parameter adjustment of the model; Step 4: Use LOD to dynamically adjust the model's level of detail, and combine it with GPU acceleration to improve rendering efficiency.

2. The method according to claim 1, characterized in that: Step 2 specifically involves: Step 2.1: Acquire images of real yarn, extract texture information of the yarn, including color, roughness, and gloss, and preprocess the acquired yarn images to obtain clear texture features; The following methods are used to remove noise from an image: Gaussian filtering or median filtering. in, I ( i ,j) represents the original image in ( x , y The pixel value at () I '( x , y () represents the filtered pixel value. S For filtering window, σ The standard deviation of the Gaussian function; The image is converted into a binary image using a thresholding method, and a threshold is set. T , to select pixels in the image with values ​​greater than T Set to 1, less than or equal to T Set it to 0; Step 2.2: Based on the collected yarn texture information, generate PBR material maps, including color maps, roughness maps, and normal maps. The maps will be used in the subsequent rendering process to enhance the realism of the woven fabric.

3. The method according to claim 2, characterized in that: Color mapping: Extract color information from the acquired yarn image to generate a color map; Roughness mapping: By analyzing the texture details of the yarn image, the roughness of the yarn surface is estimated and a roughness map is generated. The roughness value is obtained by calculating the variance or standard deviation of the pixel values ​​in the image. Normal mapping: By calculating the gradient information of pixels in the yarn image, the normal direction of the yarn surface is estimated, and a normal map is generated.

4. The method according to claim 3, characterized in that: Step 3 specifically involves: The constructed model is imported into the OpenGL environment and rendered using OpenGL graphics functions. By setting lighting, shadows, reflections and other effects, the three-dimensionality and realism of the woven fabric are enhanced. Lighting model: Lighting calculations are performed using either the Phong lighting model or the Blinn-Phong lighting model. The Phong lighting model is expressed by the following formula: in, I For the final light intensity, For ambient light intensity, I d The intensity of diffuse reflected light. I s The specific formula for calculating the intensity of specularly reflected light is as follows: in, k d and k s These are the diffuse reflection coefficient and the specular reflection coefficient, respectively. I l Light source intensity, The surface normal vector, L Let be the direction vector of the light source. R The reflection direction vector, V To observe the direction vector, The specular reflectance index; Shadow processing: Shadows are generated using shadow mapping, and a depth map is generated by rendering the scene from the light source's perspective. During normal rendering, the depth of a fragment is compared with the depth value of the corresponding position in the depth map to determine whether the fragment is in shadow. By leveraging OpenGL's interactive features, users can perform real-time operations and adjustments on the woven fabric model. The interactive control is implemented by capturing user input events through OpenGL's event handling mechanism and converting them into transformation operations on the woven fabric model. The transformation operations are then applied to the vertex coordinates of the woven fabric model using a matrix transformation method.

5. The method according to claim 4, characterized in that: The model's level of detail is dynamically adjusted based on the distance between the woven fabric model and the observer. When the model gets closer to the observer, it switches to a model with a high level of detail to ensure rendering quality.

6. The method according to claim 5, characterized in that: Step 4 specifically involves: Step 4.1: Generate the LOD model. During the rendering process, select the appropriate level of detail based on the distance between the model and the viewer, and perform distance calculation and LOD switching. Calculate the distance between the center point of the model and the observer. d And according to the preset distance threshold d 1, d 2,..., d n in d 1< d 2<...< d n, The appropriate level of detail to use is determined, and the specific switching strategy is as follows: When d < d When 1, the model with the highest level of detail is used; when d i ≤ d < d i When +1, the first... i A model at a detailed level; when d ≥ d n At that time, the model with the lowest level of detail is used; Step 4.2: Utilize the parallel computing capabilities of the graphics processor to accelerate the rendering process of the woven fabric model. By writing shader programs, the rendering tasks are distributed to multiple cores of the GPU for parallel execution, thereby significantly improving the rendering speed. Shader programming: Use GLSL to write vertex shaders and fragment shaders to implement the transformation, lighting calculation, and texture mapping functions of the woven fabric model. The shader programs are executed in parallel on the GPU, thereby accelerating the rendering process. Step 4.3: Parallel computing optimization. Improve the parallel computing efficiency of the GPU by optimizing the computation process and data access mode of the shader program, including reducing the number of global memory accesses and utilizing high-speed memory such as shared memory and registers.

7. A fiber-scale woven fabric realistic simulation system based on OpenGL, the system operating based on the fiber-scale woven fabric realistic simulation method based on OpenGL as claimed in claim 1, characterized in that: The system includes: The model building module fits the centerline path of the yarn in three-dimensional space using NURBS curves, constructs the geometric model of the yarn, adds a texture map with a feather effect, and simulates the yarn path based on the NURBS curves to form an interlacing structure. The information acquisition module acquires real yarn images and extracts texture information to generate PBR material texture maps; The rendering module uses the OpenGL graphics library for rendering, and enhances the sense of three-dimensionality through lighting and shadow processing, enabling real-time interactive control and parameter adjustment of the model; The acceleration module uses LOD (Level of Detail) to dynamically adjust the model's level of detail, and combines GPU acceleration to improve rendering efficiency.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, The program is executed by the processor to implement the method as described in any one of claims 1-6.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, it implements the method of any one of claims 1-6.

Citation Information

Patent Citations

  • Knitted fabric simulation based on data and model combined driving

    CN117371250A

  • Space-dyed yarn knitted fabric simulation method based on color and texture separation

    CN120874410A