More bitmap-producers

ZGE Source Code discussion. Ask questions, present your changes, propose patches etc.

Moderator: Moderators

User avatar
VilleK
Site Admin
Posts: 2199
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

H and W are no longer passed to the function because I declared it to be "inline", so the code of the function is inserted instead of called. This normally makes code larger but in this case where the function was a single line of code and the parameters could be declared "const" it actually resulted in less code than before. So globals would not help in this case. I try to stay away from globals unless it gives great speed or size advantages, because I find the code harder to understand and debug.
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

very cool!
Attached is some tests I'm running,. (looking for a way to do clean fadeing from one texture to another,. for the tube shooter, amoung other things,. .)
One odd thing; look at the 3rd texture,. and move throught the cell point counts 35 to 36 (and others),. and notice the results seem to phase from a smooth image to a pixelated one,. just curious what is happening there,. and if it is intended?
Attachments
q2.zgeproj
some tests,.. .
(3.25 KiB) Downloaded 618 times
iterationGAMES.com
User avatar
VilleK
Site Admin
Posts: 2199
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Some nice textures jph! I guessing the pixel effect is somehow caused by Windows up-scaling the preview bitmap differently depending on content. If you use a higher resolution such as 512x512 to reduce the up-scaling then the effect is not visible so I don't think there is anything wrong in Kattles code.
User avatar
VilleK
Site Admin
Posts: 2199
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Just a interesting link I found:

http://www.adobe.com/cfusion/exchange/i ... ome&exc=26

Adobe Pixel Bender is a technique for writing filters and effects, there are many interesting ones on that site including source that maybe we can take inspiration from. Need Adobe-login for download sources though.
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

Hi guys: I was thinking about getting a full-featured and tileable perlin noise bitmap component, just to get back programming with a simple task.
This actually requires understanding of how perlin noise implemented in ZGE works... Ville, can I ask your sources from that hell of an algorithm you used? Basic is http://mrl.nyu.edu/~perlin/noise/ but you changed a lot of stuff and made the whole a bit terrible to understand.
If it was necessary, could I comment your code and go with a reimplementation of noise "from scratch"? (It's just those lines of code, nothing more).
Mainly, I'm wondering how much are we still looking for extreme code shrinking, because this noise I see in the code *might* have some parts that are repeated a lot and we might skip some of them. But before saying this, I have to either understand the code or wipe it ;)
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
User avatar
VilleK
Site Admin
Posts: 2199
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Yup, the noise algorithm could use improvements. I chose the version that I found was both quick and small (no big constant table), page 24 in this paper by Ken Perlin:

http://www.cs.umbc.edu/~olano/s2002c36/ch02.pdf
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

maybe you could cite your paper in your source next time :P
Once I understood at least what every subfunction was supposed to do, it was kind of easy to get this (BTW: not still really sure about this gonna tile in 3D but I see no reason for it not to work). I wasted a good two days trying to figure this out before! :oops:
Tileable noise texture module coming soon. Post your requests here guys :D
Attachments
IT'S ALIVEEEEE!
IT'S ALIVEEEEE!
tileable.gif (158.12 KiB) Viewed 17201 times
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Hi Kattle, glad to see you here. Im curious what you are saying about tileable in 3d?

There are a few bitmap ideas I have had,. one simple component that is missing is a BitmapShift; with TranslateX,Y settings. It would be cool to have a Wrap setting so parts moved off one edge would wrap around or not. This could be added to the BitmapZoomRotate or be seperate.

Another (far fetched?) one, a much larger project,. is to figure some form of lightmapping to bake lightmaps based on geometry and light locations/settings,.. this would generate lightmaps on bitmaps and the material uv assignments,. . I was messing around with this little freeware app that does this,.

http://cartographyshop.thegamecreators.com/

and thought it would be better to do the processing at run time, for a 64k game anyway,. just a thought.

also anyone have an app to convert .map or .x to .3ds? that way I could use that app to do some small levels and try them in ZGE. Perhaps the editor could have an import .x or .map function like the import .3ds one? just more thoughts on geting 3d lit levels with baked lighting,. . i know it is sorta retro but I like the long shadows and creepyness of this stuff,. .

cheers!
Attachments
like so,. .
like so,. .
lighting_test_6.jpg (3.51 KiB) Viewed 17193 times
jph_room2_lm.zip
.x lm file is plain text,. could be parsed and construct the level in ZGE?
(8.51 KiB) Downloaded 577 times
iterationGAMES.com
User avatar
Kjell
Posts: 1790
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

@jph

TextureX / Y + TextureWrapMode aren't able to do what you want? They are much faster then Bitmap operations can ever be as well.

Lightmaps aren't exactly retro ( Bayonetta / Metal Gear Solid 4 etc ). The benefit of pre-rendering them is that you can go all out on Caustics / GI etc. ( which take minutes to render ) without there being any loading time. But you could already generate them in real-time if you'd really want to, simply use a shader that produces your lightmaps and render everything to FBO's .. it's a bad idea though ( even Unreal Engine bakes them ) :wink:

And ".x" files are the DirectX 3D file format, so that might not be the most appropriate format to bring to ZGE ( although it does support bones / skin / animations unlike 3ds ). Anyway, Blender should be able to do the job ( import x + export 3ds ).

K
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

jph_wacheski wrote:Hi Kattle, glad to see you here. Im curious what you are saying about tileable in 3d?
Not sure if the perlin noise will tile in 3D. This is usefull for example if you need to set some texture repeating over time (very unlikely, but you might still use this in real time at low resolutions, the algorithm is blazing fast), and most of all, if we are even going to make it tile in 3D (for implicit meshes or whatever).
jph_wacheski wrote: There are a few bitmap ideas I have had,. one simple component that is missing is a BitmapShift; with TranslateX,Y settings. It would be cool to have a Wrap setting so parts moved off one edge would wrap around or not. This could be added to the BitmapZoomRotate or be seperate.
I have decided not to include this component some time ago, when I programmed the distort component, since a distortion component used with a flat color will just make your bitmap shift as you desire. Let's say that actually, you might want to use wrapping but adding this is not this easy (without duplicating the code) since some code cannot be changed because it's used by the convolution component.
The convolution component itself might be used if you needed more precise translations (I must say it won't be so fast).
However, I might create a BitmapExpression to create a quickly-usable bitmap for using the distortion component as a shifter. I might even come up with some ideas for a "non-wrapping" option. This bitmap might be added to the Z library.
Ville: one question: would it be difficult to add as a variable to be used inside a BitmapExpression "this.height and this.width" or something similar?
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
User avatar
VilleK
Site Admin
Posts: 2199
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

kattle87 wrote:Ville: one question: would it be difficult to add as a variable to be used inside a BitmapExpression "this.height and this.width" or something similar?
That would be quite easy to fix if you can prove a good example on when it is needed, as any features of ZGE require :)

Regarding the noise function I saved links to a couple of articles, don't know if they are useful to you:

http://iquilezles.org/www/articles/more ... enoise.htm
http://webstaff.itn.liu.se/~stegu/simpl ... xnoise.pdf
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

VilleK wrote: That would be quite easy to fix if you can prove a good example on when it is needed, as any features of ZGE require :)
A BitmapExpression might want to know how many pixels are in an image for behaving in a size-independant way.
And I will tell you more: you can already access the main bitmap height with for example Bitmap1.Height. I think implementing "CurrentBitmap" could be more or less coherent with CurrentModel. If this is tricky, we can easily avoid this, but if this was easy, it could be something nice to use I think
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
User avatar
Kjell
Posts: 1790
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:roll:

This isn't easy enough?

Code: Select all

int W = 16<<Bitmap.Width;
int H = 16<<Bitmap.Height;
K
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

Kjell wrote::roll:

This isn't easy enough?

Code: Select all

int W = 16<<Bitmap.Width;
int H = 16<<Bitmap.Height;
K
Why should I not be able to just use CurrentBitmap? I mean, suppose that i copy and paste several time the component, or need to rename it. This is just more elegant. Sure it is not really needed, but you know...
If this requires little efforts, it could be useful if we were going to add some complicated BitmapExpressions in the library
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

I guess you noticed I'm late with the component...
The fact is that we are not using Perlin Noise, we are using Simplex Noise, which is faster (expecially in 3D), better, with a smaller footprint, and cannot be made to tile.
I was actually able to tile it but results were worse than I was expecting.
There are some limitations and artifacts that made that tiling noise almost not usefull at all. Now I'm playing a little and found a way to make the texture tile... We might loose a bit quality, but the artifacts are really less visible than before. Give me one or two days to fix some stuff and clean the code, and I will send the patch to Ville.
I know this is offtopic, but what should I try to work on after this?
Implicit meshes or mesh subdivision might be something I was thinking about. Suggestions are however welcome
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
Post Reply