Author Topic: Looking for texture algorithm.  (Read 8045 times)

0 Members and 1 Guest are viewing this topic.

Offline b0ib0t

  • ZX 81
  • *
  • Posts: 12
  • Karma: 1
    • View Profile
Looking for texture algorithm.
« on: January 30, 2008 »
Here and there I see this generated texture that I find quite nice.  Its to uniform to be randomly generated squares.  My guess is that it must be some type of fractal or something. Alas, I am not sure. Any information on this texture would be greatly appreciated.

Here is a screen-shot of what I am talking of.

Edit:
I've uploaded that screen shot.
« Last Edit: January 30, 2008 by b0ib0t »

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Looking for texture algorithm.
« Reply #1 on: January 30, 2008 »
to generate a texture of any nearly any art you need stuff like this:

GENERATORS (generate seperate image/texture):
- Rect (Flat / Rectancle)
- Pixel (random or perlin noise)
- Clouds
- Circle (EvnMap)
- Cells
- Fractal

FILTERS:
- Distort
- Sine
- Rotozoom

- Brightness
- Invert
- Hue Saturation Intensity
- Color

- Blur
- Normal Map
- Directional Light
- Spot Light
- Blend

- Math ops like Add/Sub/Mul/Div Texture

- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline b0ib0t

  • ZX 81
  • *
  • Posts: 12
  • Karma: 1
    • View Profile
Re: Looking for texture algorithm.
« Reply #2 on: January 30, 2008 »
After a little chat with Rel on Yahoo, I now know the secret!  Its a xor trick, and Rel told me all about it. I made a little "card" if you will to tell him thank you.

http://dbfinteractive.com/index.php?topic=2869.0

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Looking for texture algorithm.
« Reply #3 on: January 30, 2008 »
It's nice of you to thank Rel :) I know he'll appreciate it!

Here's something for you to get your teeth into, it's a good excercise to see if you can figure out why it draws what it does :)

Code: [Select]
' By Shockwave
'--------------------------------------------------------------------------

            OPTION STATIC
            OPTION EXPLICIT
           
'-------------------------------------------------------------------------
' Includes.
'-------------------------------------------------------------------------
            #define PTC_WIN
            #Include Once "tinyptc.bi"

'-------------------------------------------------------------------------
' Open Screen;
'-------------------------------------------------------------------------

        If( ptc_open( "EHHH??!", 256, 256 ) = 0 ) Then
        End -1
        End If   
        Dim Shared As uInteger Buffer( 256 * 256 ):' Screen Buffer.       
'-------------------------------------------------------------------------
' Main Loop;
'-------------------------------------------------------------------------
dim x,y,cc as integer
    DO               
        for y=0 to 255
        cc=Y*256
        for x=0 to 255
            if (x and y) = 1 then
            buffer(cc+x) = &hffffff
            else
            buffer(cc+x) = (x xor y)
            end if
        next
        next   
    ptc_update@buffer(0)   
    LOOP UNTIL INKEY$ = CHR$(27)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline relsoft

  • DBF Aficionado
  • ******
  • Posts: 3303
  • Karma: 47
    • View Profile
Re: Looking for texture algorithm.
« Reply #4 on: January 31, 2008 »
b0ib0t: Don't mind it. If I wasn't able to help you, somebody here surely would.  :cheers:

Shock:  Whoa! SierpinskiXOR, I didn't know you could do sierpinski that way. Nice!
Challenge Trophies Won:

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: Looking for texture algorithm.
« Reply #5 on: January 31, 2008 »
for x = 0 to texture.width
 for y = 0 to texture.height
  {
    plot x XOR y;
  }

done :D
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Looking for texture algorithm.
« Reply #6 on: January 31, 2008 »
'plain old black / white checkerboard pattern

for y = 0 to 256
  for x = 0 to 256
    checker_pattern(x,y) = ((x xor y) and 1)*255
  next
next

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Looking for texture algorithm.
« Reply #7 on: January 31, 2008 »
These are handy routines for stand-in textures, but if you use them in a real demo without a new twist expect to get flamed because the XOR texture is a total cliche.

Jim
Challenge Trophies Won:

Offline p01

  • Atari ST
  • ***
  • Posts: 158
  • Karma: 51
    • View Profile
    • www.p01.org
Re: Looking for texture algorithm.
« Reply #8 on: February 01, 2008 »
relsoft+shockwave: It fits 21 bytes in assembler ;)

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Looking for texture algorithm.
« Reply #9 on: February 01, 2008 »
'plain old black / white checkerboard pattern

for y = 0 to 256
  for x = 0 to 256
    checker_pattern(x,y) = ((x xor y) and 1)*255
  next
next


Its generates a checkerboard with 1x1 black/white boxes... is there a way using this algo to draw any block sized checkerboard like 8x8 32x32 and so on checkerboard boxes on a 256x256 texture? It would be cool, because my version for drawing a ceckerboard (blocks in any size) need more code and is not the best coding solution.
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Looking for texture algorithm.
« Reply #10 on: February 01, 2008 »
I've had a few right now, but it's worth seeing what
checker_pattern(x,y) = ((x xor y) and 3)*255
checker_pattern(x,y) = ((x xor y) and 7)*255
would do
Jim
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: Looking for texture algorithm.
« Reply #11 on: February 01, 2008 »
I would go with the advice to NEVER use that texture. You _will_ get flamed. Even at 256b its risky.
Challenge Trophies Won:

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: Looking for texture algorithm.
« Reply #12 on: February 01, 2008 »
loop thru x
 loop thru y
  check if ((x / size) and 1) xor ((y / size) and 1) = 0 then buffer[x,y] = 0 else buffer[x,y] = 255;

size can be any number but to make the checker tile it has be be a power of 2.. enjoy
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Looking for texture algorithm.
« Reply #13 on: February 01, 2008 »
Good link p01 never seen sierpinski triangle done so small

Va!n the pattern is done on a pixel level but can easily be scaled up by applying it to grid tyles of any size

Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Looking for texture algorithm.
« Reply #14 on: February 01, 2008 »
@mind:
great! thanks for sharing the tip! :-)
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: Looking for texture algorithm.
« Reply #15 on: February 02, 2008 »
@mind:
great! thanks for sharing the tip! :-)
any place, any time :D when there are textures to be made, the superhero Texture-San saves the day :D
Challenge Trophies Won: