Silberwelten Forum

Normale Version: GIMP - How to make a seamless Texture
Sie sehen gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
Creating a seamless Texture


Seamless textures are the basis of almost every work for the simulator; they are used to texturize large areas and allow the texture of an object to be scaled arbitrarily. We encounter endless textures on the simulator floor (24bit only!), on prims, or mesh.

The following tutorial will enable you to generate Seamless textures from your own photos.
To do this you need Gimp, which is available for free. (Download at www.gimp.org)
If you wish, you can receive the document from me as a Word file, as well as the pattern used as a JPEG. Talk to me inworld.

Use cases:

Seamless textures are used to repeatedly display similar structures over larger areas. The most commonly used application in the simulator are the terrain (sim floor) textures.
But large structures whose area would be too roughly displayed with the maximum resolution of 1024x1024 of a single texture also require Seamless textures, just like fabric patterns for clothing.

In general, in many applications a non-seamless texture looks better and more realistic. The eye usually recognizes the repetition as synthetic when one becomes aware of it.
Therefore, its use should be carefully considered.

High demands are placed on an seamless texture. The reason for this lies in the later application area. This is based on a top view of the surface normal. There must be no noticeable grid patterns, periodic disturbances, uneven distance impressions, uneven sharpness impressions, etc. over the entire surface area of the repetitions.

This requires the use of suitable templates and appropriate post-processing.
However, an Seamless texture works best when it is created fully synthetically. I will address this later.


Image template and recording:

Images for Seamless textures usually have to be created specifically for this purpose.
This is the only way to fulfill the countless requirements as well as possible.

Here's how this can be accomplished when recording:

- Color: The motif must have uniform patterns or have very gentle structures. It is important to avoid color gradients such as those that occur with uneven lighting.

- Absence of striking disturbances: striking patterns whose repetition stands out should be avoided if possible or retouched during processing by covering them with more neutral areas.
Avoid irregularities in repeating structures, as these become regularities when repeated.

- Brightness: For macro/close-up shots, the lighting should be placed in a ring.
Shadow falls should be avoided. The edge areas of lenses that affect the edges of the image also have a different brightness. It is therefore advisable to only use the center of the image if the original has sufficient resolution.

- Scaling: The scaling used is decisive for the sharpness of the texture. Since the high camera resolution is a multiple of the necessary texture resolution, it must be scaled down. Inevitably, information is left out. The higher the scaling factor, the more information is lost. According to Nyquist/Shannon, undersampling occurs and thus visible gross interference. An example is fine black/white lines lying next to each other, which become blotchy or blurred to gray depending on how they are processed. The only solution here is to cut out a central area of the template so that you don't have to scale too much.

- Sharpness: Uniform sharpness is necessary because the entire repeated surface must be equally sharp later in use. Uniform sharpness requires photography normal to the surface!
In addition, the objects photographed must be the same distance from the camera.
Here too, the selection of the photo center described under scaling is an advantage: only the sharp center area of the camera lens is used.

- Projection from the perspective of the surface normals: (i.e. everything is the same distance away, and the camera is aligned with the template without any misalignment)
First of all, this eliminates the trapezoidal distortion that would otherwise be necessary in post-processing in order to recreate parallel structures. This has a direct effect on the texture sharpness as interpolations are no longer necessary.


Prepare the image 

The following description refers to the free Gimp (2.8.14) and for which there are Normal Map plugins that we will use later. (Download at www.gimp.org).
As a working template we use the image IMG_2779, which has a resolution of 5184x3456. As a practice exercise, we will only make it an endless texture in the X direction. 
However, I will point out at the appropriate point how an X/Y seamless texture is created. First, the image is prepared to create a suitable, distortion-free section. 

The following approach has proven successful: 

1. Dewarp image:

Work steps: Click on the rulers at the upper edges of the workspace and pull out 2 horizontal guide lines. These are placed on the gray granite base in such a way that the lines only partially touch the gray granite strips. We will later expand/expand the area between these lines until the path fills the entire area between the lines. Do the same with 2 vertical lines pulled out from the left ruler. It's not about the image section to be used, but rather about finding vertical structures in the image that you can use for orientation.

[attachment=2393]

Using trapezoid correction, adjust the entire image in the original resolution to the auxiliary lines
(Tool - Transformation - Perspective) or use the 4th symbol on the bottom left in the image above.

Now click on an intersection point of the grid lines (e.g. bottom right)
A white grid is placed over the image. This represents the coordinates of the original before the change.
Click on the intersection points several times with the mouse and move the image while keeping the mouse pointer pressed.

Repeat this action until the image structures run parallel to the auxiliary lines.
With Transformation the selection is ended and the setting is applied.
If you like the result, now is a good time to save the project. Otherwise, go back to Go using “Edit – Undo: Perspective”.

2. Crop image:

Now crop the image to the desired area

The existing auxiliary lines in the Y direction serve as a snap point for the marking tool (Tools – Selection Tools – Rectangular Selection)

We choose the X cutting lines according to the image content. We try to place these on one of the vertical split joints so that the finished texture is separated at the joints. We leave out the area on the far right because the stones appear wetter. We also crop links.

[attachment=2392]

(Image – Crop to Selection)

Now the image content remains within the white marking. The image size has shrunk to 2553x1518 for me. Which roughly amounts to a 5:3 texture. Saving now makes sense.


Creating the Endless (Seamless) Texture

First, the image is now shifted by half the X size. (For X/Y endless, move texture by half in both directions)

I use the same tool that is used for X/Y.
(Plane - Transformation - Offset)

Now go to “Offset by (X/2),(Y/2). Now my default is X: 1776, Y:759. (The value may vary for you). 
This would be correct if we wanted to make the texture endless in X and Y. For us, X/2 is enough, which is why I enter 0 in the Y field.

It is important that the edge behavior is set to “fold”. This is an endless mode that reinserts pixels that fall out at the other edge.
Now carry out the transformation with the offsets.

[attachment=2394]

The result isn't all that bad. Editing now requires the vertical cutting line in the center of the image. The gray curbs show severe disruption due to incorrect joints.

We intentionally stay in the native image resolution until the editing is finished! In this way we avoid annoying losses because the errors move at the pixel level and are later mixed and blended with “healthy” pixels when scaling. This way we get the best possible sharpness of the texture.

Now it is helpful to mark the cutting line with an auxiliary line so that you can easily find it again later at the best possible magnification. I intentionally place the guide line slightly next to it to keep a clear view of the cut.

Now enlarge the work area by zooming in. For me (view - magnification - 50 percent) was the right setting. The 100% setting is ideal for a large monitor, as every pixel is then shown unadulterated.

I'm now starting with the joints of the gray granite stones. To do this, I select another fugue that I want to copy. I decide to use the 2nd joint to the left of the cut for the bottom edge.

Now I select the copy stamp (Tools – Painting Tools – Clone).

Now move the mouse pointer over the desired template and check the size of the copy stamp. The copy stamp can be adjusted via Window – Dockable Dialogs – Tool Settings. The default value of 20 pixels is too small in this case. 30 pixels seems appropriate for the joint width.

Now move the cursor to the copy origin, hold down the control key and click on the position with the left mouse button.

Move to the target point and copy the joint and the adjacent edges while holding down the left mouse button.

Proceed in the same way with the other edge and the split at the middle joint. Replace the entire split in the middle joint. When you release the mouse button, the original cursor jumps back to the starting position of the copy template. This allows you to create larger, identical target areas than the template.

Tip: It's not a good idea to always copy from the same place, you'll see that later.

If stones need to be repaired, various whole stones can be taken from other places. This template is very uncritical of that. If you choose the cutting line correctly, all you need to do is replace the split in the joint. However, major changes are usually necessary. Then larger areas should be copied irregularly over the cutting lines.

It is not advisable to set the opacity below 100%. This results in blurring through the mixture.

When the work is finished satisfactorily, the retransformation takes place at the original image position. (Plane - Transformation - Offset) “Offset by (X/2),(Y/2) with folds. And in our case set Y to 0 again.

Now it's time to save, the texture is now finished.

If you plan to keep a texture archive in the best possible quality, you should archive the resulting Gimp .xcf file. Another approach would be to save in common formats, and at twice the resolution as currently required.

At this point a normal map would be created. Which I will discuss separately.


Prepare texture for export

The present .xcf file is not suitable for use in the current simulator.

The current simulator can import .png, .tga and .jpg files, which are converted to the internal jpeg2000 format.
24bit textures are required for simulator floor textures.

32 bit textures can also be used to texturize prims, mesh, etc.
The maximum format to import is 1024x1024 pixels.

The .PNG and .TGA file formats can save transparency information and forward it to the simulator, and work largely without loss of quality.

The .TGA file is the only format that can save and import surface roughness in the form of a BumpMap.

.Jpg is the worst option because its data reduction visibly affects the image.
The format doesn't show any other strengths, apart from its high distribution. The low amount of data consumption when transmitting on the Internet is no longer an argument these days.


Conclusion:

The PNG 32bit format offers the best basis for archiving and importing and is preferred.


Export texture:

with Image – Image Scaling – open the resolution window.
As long as the concatenation symbol to the right of width and height is activated, the X and Y sizes are changed synchronously. So break the chain.

This usually doesn't work for textures because certain preferred sizes are desired for the simulator. The fact that the Y and Y resolution is adjusted disproportionately is not significant in the simulator, as the scaling depends on the size of the textured area and the set repetition rate.

Because of the more powerful handling of the graphics card, the preferred sizes are powers of 2 as edge lengths.
Table of preferred sizes: 1024 / 768 / 512 / 384 / 256 / 192 / 128 / 96 / 64 / 32

The choice of texture size should be based on the size of the visible area and the normal viewing distance. This prevents textures from appearing pixelated to the viewer.

Best to try it out on construction projects. If you can't see the difference between high-resolution and normal textures, the smaller one can be used.

We now create a high resolution (width 1024, height 512)
and a normal texture (width 768, height 384), and save both as PNG.

Please do not save the project afterwards, otherwise the high-resolution archive will be destroyed.

Optimization question: How much do textures need to be minimized and what is allowed?
Well, that actually just depends on the user's graphics cards. These have a graphics memory that is used together for graphics calculations and textures. Windows computers can also use parts of the RAM for textures.

Computers that only have integrated Intel CPU graphics do not have their own graphics RAM at all. They are intended for office use. In order to achieve reasonable graphical results with the simulator, office computers cannot be taken into account.

As a sensible guideline, 4 gigabytes of graphics memory should currently be required (update 2021). At least 512 Mbytes of this are available for textures.


Deduplication therefore plays a greater role in optimization. This means that for all surfaces / objects of a sim with the same texturing - only the texture with the same UUID is used.
The simulator does not see the content of the texture, but only its UUID.
It also makes no sense to use the same texture sometimes in high resolution and sometimes smaller. It is more efficient to use the same high-resolution texture everywhere.


Create and export terrain texture:

Terrain textures are a special form of endless textures.

They must have 24bit color depth. It is advantageous to import the TGA into the simulator because you can then provide a bump map (roughness information) to the terrain.

Terrain (Sim ground) textures differ from normal textures in the following ways:

1. You can't freely scale them in the sim. Therefore, it is a trial and error story to determine the correct resolution of the image content. Example: Visibility of grass blades.

2. The effect of texture pixelation depends even more than usual on the texture resolution. Therefore, be sure to use the maximum resolution of 1024x1024! Since these 4 textures can be seen everywhere and contribute significantly to the impression of the sim, it is wrong to want to save memory here!

3. The number of repetitions of the texture is very visible, especially when zoomed out. Therefore, special attention must be paid to the uniformity of the image content, otherwise regular, highly disruptive, checkerboard-like patterns will arise.

4. Terrain textures are sometimes stretched badly on large gradients. Therefore, the motif in combination with the terrain structure is crucial for success. Image content with low contrast has proven to be effective. These effects are less noticeable.

5. The nature of the texturing of the simulator floor does not allow the use of materials or separate normal maps. However, since the TGA format is used, you can trick the simulator and still provide height structure information. To do this, use the “Filter – Map – Bump MAP” command in Gimp. Before trying it out, please save the project and copy the working layer. Then only work with one copy at a time.

Background: The effects that can be created with the filter function cannot be planned and are dependent on templates! So try several settings, export them and see the effect in the simulator. Also view it very closely zoomed in, as some bump maps severely destroy the image with block artifacts.


Have fun

Tron


for Kitty