ioxu / microscratches-generator

A texture generator for controlling the rotation of anisotropic reflection in shading models for 3d renderers.
MIT License
4 stars 0 forks source link

implement tiling #4

Open ioxu opened 1 year ago

ioxu commented 1 year ago

ideas

  1. Layers should tile, probably always.
  2. Post fragment effect, copying/repeating borders?
  3. Copies of generated geometry?

findings:

Tiling and symmetry should probably be built into each texture_scene itself, implicit in their generate functions.

ioxu commented 1 year ago

Texture Tiling Experiment One: Copies of Generated Geometry

In test_lines.gd lines are generated by a method that returns a PoolVector2Array. I made a utility function that returns a new PoolVector2Array offset by a Vector2. To complete symmetry of a single square, 8 additional offsets were generated for line point positions. 8 additional pooled arrays were copied for colour and width arrays. For test_lines.gd, default parameters, do_tiling off: 177 ms do_tiling on: 341 ms (192%)

ioxu commented 1 year ago
            lines.append(line)
            if do_tiling:
                lines.append( Util.copyOffset_PoolVector2Array( line, Vector2( idim , 0.0 )  ) )
                lines.append( Util.copyOffset_PoolVector2Array( line, Vector2( -idim , 0.0 )  ) )
                lines.append( Util.copyOffset_PoolVector2Array( line, Vector2( idim , idim )  ) )
                lines.append( Util.copyOffset_PoolVector2Array( line, Vector2( -idim , idim )  ) )
                lines.append( Util.copyOffset_PoolVector2Array( line, Vector2( idim , -idim )  ) )
                lines.append( Util.copyOffset_PoolVector2Array( line, Vector2( -idim , -idim )  ) )
                lines.append( Util.copyOffset_PoolVector2Array( line, Vector2( 0.0 , idim )  ) )
                lines.append( Util.copyOffset_PoolVector2Array( line, Vector2( 0.0 , -idim )  ) )

            var vc : PoolColorArray
            if Global.vector_direction == "tangent":
                vc = vcolours_simple(line, 0.0)
            else:
                vc = vcolours_simple(line)
            lines_colours.append( vc )
            if do_tiling:
                lines_colours.append( vc )
                lines_colours.append( vc )
                lines_colours.append( vc )
                lines_colours.append( vc )
                lines_colours.append( vc )
                lines_colours.append( vc )
                lines_colours.append( vc )
                lines_colours.append( vc )

            var vw = Util.randf_range(thickness_max, thickness_min)
            lines_widths.append( vw )
            if do_tiling:
                lines_widths.append( vw )
                lines_widths.append( vw )
                lines_widths.append( vw )
                lines_widths.append( vw )
                lines_widths.append( vw )
                lines_widths.append( vw )
                lines_widths.append( vw )
                lines_widths.append( vw )