Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Creating procedural textures in Java  (Read 10041 times)
0 Members and 1 Guest are viewing this topic.
Offline zammbi

JGO Coder


Medals: 4



« Posted 2008-06-17 11:53:58 »

Just wondering if there's any work/tools in the area of creating textures like
http://www.werkkzeug.com
Would be great when I start on a 3d game that I can create textures on the fly to keep downloads small.

Current project - Rename and Sort
Online Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2008-06-17 17:33:25 »

Yes you can.

A texture is just a bunch of bytes.

You must code a few nice algorithms that put values in those bytes.

Heck, you can even make procedural textures in DHTML.


But... don't waste your time on it, because it's darn hard.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Hansdampf

Senior Member


Projects: 3


too offending?


« Reply #2 - Posted 2008-06-17 20:11:35 »

I used to code procedural textures, a youtube video of the result is <a href="http://de.youtube.com/watch?v=NkTIZ1GldgQ">here</a>
But sadly I don't have the source code anymore...

The most important book for me was:
<a href="http://books.google.de/books?id=GWQ_hz2sIMcC&dq=procedural+texturing+and+modeling+a+procedural&pg=PP1&ots=pIV5IrInux&sig=wcIW5elOlVzIwLMi3ZD8o3PUbWQ&hl=de&prev=http://www.google.de/search%3Fhl%3Dde%26client%3Dfirefox-a%26rls%3Dorg.mozilla:de:official%26hs%3DRJh%26q%3Dprocedural%2Btexturing%2Band%2Bmodeling%2Ba%2Bprocedural%26btnG%3DSuche&sa=X&oi=print&ct=title&cad=one-book-with-thumbnail">Texturing & Modeling: A Procedural Approach</a>

You can just google the different chapters and you should find a lot of material and source code.
A slick implementation in Java of Perlin Noise (da mother of all procedural textures) is <a href="http://mrl.nyu.edu/~perlin/noise/">here</a>



lots of sillystupid games: http://www.emaggame.com
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DzzD
« Reply #3 - Posted 2008-06-17 20:26:41 »

a code I share a cupple of monthes ago

http://demo.dzzd.net/PERLINSample/


Offline zammbi

JGO Coder


Medals: 4



« Reply #4 - Posted 2008-06-18 01:00:43 »

Quote
A texture is just a bunch of bytes.
You must code a few nice algorithms that put values in those bytes.
I know what a texture is  Roll Eyes just wanting to know if there was a library of the such.
Thanks Hansdampf and DzzD, that's a start.

Current project - Rename and Sort
Online Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #5 - Posted 2008-06-18 09:33:36 »

I responded like that because you asked whether that could be done in Java, which is kinda obvious.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline zammbi

JGO Coder


Medals: 4



« Reply #6 - Posted 2008-06-18 09:52:49 »

Yea sorry should of made it more clear.
Maybe I will make my own program like werkkzeug(slimmed down version) but written in Java and then create a library to use the textures.
Though really don't know much in this area but I'm a quick learner.
I'll see what I can come up with when I have time. If anyone else finds other useful links that will help, please post here.

Current project - Rename and Sort
Offline zammbi

JGO Coder


Medals: 4



« Reply #7 - Posted 2008-06-19 12:35:07 »

DzzD that link you posted worked wonders. I can create and control perlin textures. I'll be creating a editor, I'll post it when I ever finish it  Smiley

Current project - Rename and Sort
Offline zammbi

JGO Coder


Medals: 4



« Reply #8 - Posted 2008-06-21 16:37:25 »

Ok finally built something slightly useful.
Can't do much currently, but does let you play around with colours, size, octave,etc...
I optimised the code much as possible and used look up tables which it's 100-140% faster then DzzD example iirc. Which should help in the future when creating advance textures.
I have added a few more things like turbulence but haven't done the gui for them yet.
No webstart yet. That will come soon
Download

Current project - Rename and Sort
Offline zammbi

JGO Coder


Medals: 4



« Reply #9 - Posted 2008-06-22 09:13:21 »

One problem I'm having is making it tileable with using the above formulas. Anyone able to help me out there?

Current project - Rename and Sort
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DzzD
« Reply #10 - Posted 2008-06-22 11:34:08 »

you can just flip the generated texture to the right than the first texture an the flipped one to the bottom, no ? but they should be already tilable that's strange

Offline Hansdampf

Senior Member


Projects: 3


too offending?


« Reply #11 - Posted 2008-06-22 12:34:41 »

here we go:
http://www.cs.cmu.edu/~mzucker/code/perlin-noise-math-faq.html

that works with ANY proc. texture which has a "height" value.
For cellular textures you need a "wrapping" space. Hm I hope you understood me. Smiley

lots of sillystupid games: http://www.emaggame.com
Offline zammbi

JGO Coder


Medals: 4



« Reply #12 - Posted 2008-06-22 13:31:26 »

I tried doing what was written on the site, but still wasn't tilable.
Quote
Ftileable(x, y) = (
       F(x, y) * (w - x) * (h - y) +
       F(x - w, y) * (x) * (h - y) +
       F(x - w, y - h) * (x) * (y) +
       F(x, y - h) * (w - x) * (y)
) / (wh)
I'm meant replace this code with this in sNoise right?


Quote
you can just flip the generated texture to the right than the first texture an the flipped one to the bottom, no ? but they should be already tilable that's strange
I was thinking something like this but I don't think it would look as great.
It can look tilable when zoomed out, but horrible zoomed in as you can see in my program.

Current project - Rename and Sort
Offline Bonbon-Chan

JGO Coder


Medals: 12



« Reply #13 - Posted 2008-06-24 12:46:48 »

I'm not really interrested by Procedural Texture by them self but...  Tongue It make me want to try to make an editor  Grin

So there is a try out (source code).

Basicly, it work like in 3D Studio Max ( "+" button to add a "filter", ">>" to go the "filter" ) and i add a tree (click on filter to go to it)
Offline DzzD
« Reply #14 - Posted 2008-06-24 13:03:50 »

Quote
I'm meant replace this code with this in sNoise right?
I hadn't enought time to look to the tile problem yet, I will do that soon. one hyper-logical point is that if texture is not tilable it is because one of the function is not, so just have to found wich one.

Offline zammbi

JGO Coder


Medals: 4



« Reply #15 - Posted 2008-06-24 13:20:28 »

Ok thanks because my math is a little rusty.  Undecided
Chan looking good. That's something I'm planning too. I'm going to make mine a really good editor, but haven't got the time atm. My first step to my 3d game I'm designing Smiley

Current project - Rename and Sort
Offline Bonbon-Chan

JGO Coder


Medals: 12



« Reply #16 - Posted 2008-06-26 09:46:36 »



I manage to create "seamless perlin noise". The problem come from the noise(x,y) method. For each octave pass, the noise method must be "titleable".

I have update the jnlp and the source code, if you want to see how i do it (net/bonbonchan/bptest/filter/filter2d/JPerlin)
Offline DzzD
« Reply #17 - Posted 2008-06-26 09:59:49 »

cool, that's a nice result

Offline zammbi

JGO Coder


Medals: 4



« Reply #18 - Posted 2008-06-26 11:05:13 »

Nice work there bonbon, I'll sure check out your how you did it tilable.

Current project - Rename and Sort
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #19 - Posted 2008-06-26 13:47:28 »

Looks good, BonBon-Chan!

What about extracting a self contained class from it (something like 'TiledPerlin' without the GUI stuff, without the net.bonbonchan.** dependencies, just a class generating an array of doubles with 2d perlin noise) and adding it to shared code? Smiley
I bet it would be very useful for many (me included).

Offline kevglass

JGO Kernel


Medals: 164
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #20 - Posted 2008-06-26 13:59:57 »

Seconded here! Great work and I could really do with that noise generator without the extra dependencies Smiley

Kev

Offline zammbi

JGO Coder


Medals: 4



« Reply #21 - Posted 2008-06-26 14:45:45 »

I was going to do that, but If bonbon want's to keep doing her project and have a library that can be used in another program then there isn't much point for me to work on mine.
Are you going to keep working on yours bonbon?
It would save me a lot of time to start on my new game if you did.
Though no reason why I couldn't help you on yours.

Current project - Rename and Sort
Online cylab

JGO Ninja


Medals: 49



« Reply #22 - Posted 2008-06-26 14:46:45 »

This also looks intresting: http://www.codeproject.com/KB/graphics/quilting.aspx. It's C#, but should be portable. And could someone PLEASE implement appearance-space texture synthesis: http://research.microsoft.com/projects/AppTexSyn/  Cool

Mathias - I Know What [you] Did Last Summer!
Offline bienator

Senior Member




OutOfCoffeeException


« Reply #23 - Posted 2008-06-26 16:29:42 »

This also looks intresting: http://www.codeproject.com/KB/graphics/quilting.aspx. It's C#, but should be portable. And could someone PLEASE implement appearance-space texture synthesis: http://research.microsoft.com/projects/AppTexSyn/  Cool
interesting, but almost everything I've read from Hugues Hoppe was patented  persecutioncomplex

Offline Bonbon-Chan

JGO Coder


Medals: 12



« Reply #24 - Posted 2008-06-27 12:16:28 »

There is my planing  Grin :
1) adding a load/save in my editor (in work)
2) adding some more few filters (to verify that I didn't miss something)
3) creating a lib (should not be that difficult, it should be only copy and past)
4) rework the editor to deal with my own lib  Roll Eyes
5) add filters as needed

I don't known if I will go to the end but I want at least to do all the skeleton for the lib/editor. I each step I will give the source code so if for some reason I don't continue, someone else will be able to.
Offline zammbi

JGO Coder


Medals: 4



« Reply #25 - Posted 2008-06-27 12:59:49 »

Ok great then I'll stop working on mine then.
The loading and saving is what I need. I'm thinking in making all my textures in it so I can send the data on the fly then the client will create a image out of it.

Not sure if this will help but here's what I did for turbulence formula.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
public static float turbulence(final float x,final float y,final float persistence,final int octave, final boolean smooth)
   {
      if(octave <1){
         return 0;
      }
      float result = Math.abs(Noise.iNoise(x,y, smooth));
      float amplitude=1;
      int frequence=1;

      for(int n=1;n<octave;n++)
      {
         frequence<<=1;
         amplitude*=persistence;
         result+=Math.abs(Noise.iNoise(x*frequence,y*frequence, smooth))*amplitude;
      }
      return result;
   }

The smooth boolean just switches the use of lInterpoleLin to lInterpoleCos.

To speed up many areas I used look up tables like so:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
if(setX >= 0 && setY >= 0 && setX < Noise.arraySize && setY < Noise.arraySize){
   if(Noise.noiseValues[setX][setY] != 0.0){
      return Noise.noiseValues[setX][setY];
   }
}
        //<code>

if(setX > 0 && setY > 0 && setX < Noise.arraySize && setY < Noise.arraySize){
       Noise.noiseValues[setX][setY] = value;
}


Current project - Rename and Sort
Offline Bonbon-Chan

JGO Coder


Medals: 12



« Reply #26 - Posted 2008-06-28 08:45:15 »

Update : Save & Load (it was more dificult than expected  persecutioncomplex... I should sleep more  Tongue)

There is an example of file

For Perlin and it variation, I should study it a little more... there is something fishy  Huh

I have another problem : When you draw a color with alpha on another color, the code is :
1  
    color = color_origine * (1-alpha_dest) + color_dest * alpha_dest


But when you draw a color with alpha on another color WITH ALPHA ?

Offline zammbi

JGO Coder


Medals: 4



« Reply #27 - Posted 2008-06-28 09:50:22 »

Not sure if you have notice but the apply button seems hide sometimes which you need to make the window larger to see it.
How do you remove filters or you haven't got that option yet?
Great that you got the saving and loading working. Was it still hard with serializable or you did the saving manually?

Current project - Rename and Sort
Offline Bonbon-Chan

JGO Coder


Medals: 12



« Reply #28 - Posted 2008-07-03 08:54:45 »

Update : Version Alpha 0.2 out
- lib creation
- editor modified to use the lib
- some optimization (Perlin noise cut by half  Shocked)

Editor (Editor source) Lib (Lib source)

To use, the lib :
- create an TextureLibrary
- load a file with TextureLibrary.load()
- get an ArrayList of texture with TextureLibrary.getTextures()
- create a texture with Texture.create2DTexture()

Note : color can be change on the fly. TextureLibrary.getColors() return an ArrayList of used color

Problem&Solution :

1) How to mix 2 colors with alpha :
With a simple calculation, i got :

New alpha : a = a1+a2-a1*a2
New color : c = (c1*a1*(1-a2)+c2*a2) / a

OK !

2) Problem with perlin noise :

What is the difference between :
   c(x,y) = sum( iNoise(x,y,octave) * frequence^octave  )
and
   c(x,y) = sum( Abs(iNoise(x,y,octave))* frequence^octave  )
?

Since my random number are [0,1], there is no difference. Even so, if i use [-0.5,0.5] number, the result will be the same with a shift of 0.5. Did I misunderstand something ?

What's next ?
All people interrested in this project should play around with the editor/lib :
- to see if some more option are need in the actual filters
- to see bugs in the editor (I know there is some works to do with the GUI)
- to see need function in the editor (by the way, unused filter are remove when saving)
- to see need filters
Offline zammbi

JGO Coder


Medals: 4



« Reply #29 - Posted 2008-07-08 05:30:58 »

The editor is looking great, though I'm not great at creating tiles it seems hehe.

Can anyone create some good looking wood/grass textures?
I will surely use your library in my game once I'm to that stage.

Quote
What is the difference between :
   c(x,y) = sum( iNoise(x,y,octave) * frequence^octave  )
and
   c(x,y) = sum( Abs(iNoise(x,y,octave))* frequence^octave  )
?
My editor was using the random number between -1 to 1, but yours should be fine if you did -.5 to .5, it should still show the same turbulence effect.

Current project - Rename and Sort
Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (21 views)
2014-09-19 03:14:18

Dwinin (35 views)
2014-09-12 09:08:26

Norakomi (62 views)
2014-09-10 13:57:51

TehJavaDev (87 views)
2014-09-10 06:39:09

Tekkerue (42 views)
2014-09-09 02:24:56

mitcheeb (65 views)
2014-09-08 06:06:29

BurntPizza (47 views)
2014-09-07 01:13:42

Longarmx (35 views)
2014-09-07 01:12:14

Longarmx (40 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!