Author Topic: How to generate this at runtime?  (Read 8733 times)

0 Members and 1 Guest are viewing this topic.

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
How to generate this at runtime?
« on: January 12, 2008 »
I need the following two images to be generated at runtime... Someone an idea, how i can do it to look like the original (smooth quality)?  Thanks in advance!

http://secretly.de/images/image1.jpg
http://secretly.de/images/image2.jpg

Btw, its still ok, when having just only the last (big) star like object
- 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 stormbringer

  • Time moves by fast, no second chance
  • Amiga 1200
  • ****
  • Posts: 453
  • Karma: 73
    • View Profile
    • www.retro-remakes.net
Re: How to generate this at runtime?
« Reply #1 on: January 12, 2008 »
easy!

draw filled circles (with radial gradient) and play with the aspect ratio for the radius

change

radius = sqrt(x^2+y^2)

into

radius = sqrt(a*x^2+y^2) or
radisu = sqrt(x^2+a*y^2)

a => aspect ratio => different from 1.0 will flatten your circles....

draw a radial gradient circle for the halo, then other circles with extreme aspect ratios for the streaks on the top => you get a star!

use OGL/DX to get real-time performance
We once had a passion
It all seemed so right
So young and so eager
No end in sight
But now we are prisoners
In our own hearts
Nothing seems real
It's all torn apart

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: How to generate this at runtime?
« Reply #2 on: January 18, 2008 »
i'll give you this, copy pasted straight out of my texture generator.. create the "star" using algorithm 5 and the halo using algorithm 0.. simple enough :)

what i managed to get with about 2 minutes of tweaking(i think the last one resembles your original the most):


procedure enviromentmap(algo,x_ofs,y_ofs,x_size,y_size,dest,channel:byte);
var color : longint;
    x1,y1 : byte;
    x2,y2 : single;
begin
 x_size:=(x_size shr 1);
 y_size:=(y_size shr 1);
 for x1:=0 to 255 do
 for y1:=0 to 255 do
  begin
   x2:=(x1-x_ofs)/(x_size);
   y2:=(y1-y_ofs)/(y_size);
    case algo of
     0: color:=round((sqrt(x2*x2  +     y2*y2)) *256);
     1: color:=round(( abs(x2*x2  +     y2*y2)) *256);
     2: color:=round(( sqr(x2*x2  +     y2*y2)) *256);
     3: color:=round(( sqr(x2*x2) + sqr(y2*y2)) *256);
     4: color:=round(( abs(x2)    + abs(y2))    *256);
     5: color:=round(( abs(x2*y2) + abs(x2*y2)) *256);
     6: color:=round(( abs(x2)    + abs(x2))    *128);
     7: color:=round(( abs(y2)    + abs(y2))    *128);
    end;
   if color<000 then color:=000;
   if color>255 then color:=255;
   Texture[dest][channel]^[x1+y1 shl 8]:=(255-color);
  end;
end;



so, what i did on the first 2 was generate a "star" using algorithm 5 with a setting of about 35 width/height, then i created a halo(algorithm 0) with 255/255 width height and multiplied the star by that(to get the fading spikes kinda) and finally i created another halo using algo 0 with around 210 width/height and finally added the star and halo together and inverted it.. boom there ya go :) now take this and optimize it for your own use.. dont forget to credit where credit is due :D

the last 2 are basically the same, except the fact that before i add the star and halo together i copy the star to another layer, blur it a few times and subtract the result from the halo, THEN i add the star.. i did this because looking at the examples you provided, i see a slight shift in the luminance where the halo and star meet, as if there was a bright glow surrounding the star.. might be jpeg artifacts but hey, thats what i saw and this is how i duplicated it :)


edit: and to create the one in your second example, simply generate 2 star thingys instead of one, rotate 1 of them by 45 degrees, add them together before performing any blurs/subtrcts with the halo/whatever and then add the halo to it all.. good to go :)


« Last Edit: January 18, 2008 by mind »
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: How to generate this at runtime?
« Reply #3 on: January 18, 2008 »
Good job!  K+

Jim
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: How to generate this at runtime?
« Reply #4 on: January 18, 2008 »
Nice one Mind
k++;
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: How to generate this at runtime?
« Reply #5 on: January 19, 2008 »
K++ tsan
Challenge Trophies Won:

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: How to generate this at runtime?
« Reply #6 on: January 19, 2008 »
thanks guys.. now i just need a reply from va!n stating that this whas somewhat useful, and i'll be happy :D
Challenge Trophies Won:

Offline relsoft

  • DBF Aficionado
  • ******
  • Posts: 3303
  • Karma: 47
    • View Profile
Re: How to generate this at runtime?
« Reply #7 on: January 19, 2008 »
Holy Mama! That's a pretty kick ass generator mind!
 :clap:
Challenge Trophies Won:

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: How to generate this at runtime?
« Reply #8 on: January 19, 2008 »
Holy Mama! That's a pretty kick ass generator mind!
 :clap:

thanks.. gets the job done.. whenever there is such a job to be done, so to speak :D


seeing as its not really useful to me in any way anymore i might just release the entire project :D but hell, its delphi so have fun understanding it.. :D

i just need to think about it a tad longer.. its a project i invested almost 8 years in..

yeah i know its crazy.. EIGHT YEARS? INTO THAT PIECE OF SHIT? lol..

So, i guess this turned into a kinda story about how i got into the stuff, and how it progressed from there(and why it has taken 8 years and still isnt finished)..

It all started with me beeing bored at work, and just fiddling around with some random stuff(no pun intended) when i realized that i could actually take all of this knowledge i had.. almost every little bit of it, and assemble it into one big pile of texture generation goodness.. and so it began..

my texture generator saw the dawn of day at that boring company, the same day.. in it's full 256 grayscales glory.. it had it all, the works:  XOR texture(my first procedural ever!!), sine plasmas, diamond square "fractal plasmas",  "enviroment maps"(you know, pythagoras, x^x+y^y), a very basic "moonish" thing i came up with myself, which basically was interpolated 2 dimensional noise blurred a few times.. but it looked SO BADASS(at that time, i might add), sine distorts, a basic map distort and a few layer operations like copy, add, subtract etc..

and bear in mind, this was all done, back in like, 1999-2000.. thats loooong ago :D

so as i was messing around with all of this grayscale goodness, i got the brilliant idea of combining 3 of those "layers" so to speak, into ONE IMAGE!!(and the crowd goes wild!!!!)

and thus i marked an important step in the developing of my texture generator.. i was suddenly able to generate fullcolor(24bits) textures, in plain turbo pascal.. thats SIXTEEN BITS PASCAL! no fancy borland schmorland pascal with their dpmi extenders and shit, this was hard, rough, violent 16bit sex.

so after a lot of tweaking(and god knows how i did it) i managed to get it running realtime(with no saving shit to disks etc) with 3 full 256x256x24bit textures.. and for you mathematically impaired, thats (3x3)x65536=589824 bytes.. and thats just the memory i needed for the textures and not the actual code to set the images up, generate shit on them, save them to disk etc.. so that means i had basically 50k to use for that shit(640x1024= ~655460bytes, just about what the old dos could handle in its glory days).. and as i was saying, only god knows how i managed, but he DOES KNOW i managed :P

so i guess, from that point it just progressed.. i found myself spending more and more time infront of the compiler just looking at this, trying to come up with new clever ways of doing shit that noone had ever dreamed of(and im pretty sure i came up with a few if those crazy ideas :P)

i kept adding and adding(no pun intended), and still to this day i make improvements every now and then, not because its needed or wanted, but just because i can and it still gives me joy, toying around with this old lovechild of mine.. i've been crazy about the idea of generating content procedurally and im pretty sure its visible all around these forums in old threads and stuff.. hell i actually tried to procedurally generate a newspaper once.. it was one beast of a project and it was fun, i'd say it kept me occupied for atleast 2 weeks and then i scrapped it because it just wasnt real enough.. figures..

so anyways, on to what actually happened after all that dos goodness.. so i went to celebrate xmas with my family who happens to live like, 500 kilometres from where i live.. and i always keep my machine on at home so i can access important stuff.. you know, like... mp3's and.. movies.. and maybe some occasional pr0n.. BUUUUUT ANYWAYS.. yeah you get it.. :P so i had access to all my code and during the middledays(somewhere between xmas and new years) i somehow got this crazy idea into my head that i JUST HAD TO install borland delphi..

said and done. i found the RAD mostly intriguing.. it was so simple, so powerful and effective, yet so delicate.. and i guess it goes without saying..... unlimited amounts of memory, a FRICKIN AWESOME "rapid application developer" and access to my sourcecode at home.. god this was like a sweet slice of heaven.. i sat at that computer, during the most sacred of weekends and just kept tapping away at those keys.. writing new shit(and most of all, implementing around 100(ONE HUNDRED!!!) trackbars into my code, to handle the different generators, filters, younameitwatchamacallit, and all of that kinda stuff.. damn, it was like beeing at work again.. and it sucked, so i kinda stopped there.. only after posting screenshots and a very buggy beta of the interface, here on these forums ofcourse.. and ofcourse people had mixed feelings about it.. as with all software really.. but the important thing i had to keep in mind at all time was "i want to find this simple yet very sophisticated, and at the same time very entertaining" and thats what helped me through all the development phases really.. people would go like "but i want to work on all layrs at the same time!!" i say fuck that shit.. separate layers equals WAY more control.. (in the end though, i realized that some things like blurs, distorts etc work better if you just perform them on an actual image(and not to mention that its faster) than if you do it on 3 separate layers..

and well.. i wont say that im not actively working on my texture generator, that would be a blatant lie :P i mean i still get ideas and come up with ways of improving, and i add them all in there..

in the end, it has grown from beeing a dream of a viable 64k texture generator ,into something much much more complex, not something i work on because i think its gonna be the latest breakthrough, but something i constantly improve and toy around with, simply because it gives me pleasure in a twisted kind of way.. and a great example of this is, just relaxing after a couple of beers and reading some forums.. i stumble upon this thread and it's like "how do i generate these at runtime".. and BOOM! not only do i start thinking about how i can do it procedurally but i also start imagining how i would use my own tools to do it, and 5 minutes later i sit there, with 4 different images, all bearing alot of resemblence to the images posted by the original author, and im able to say "i did this using these simple steps, its great and you should really try it, you gonna have to trust me on this one", explaining it in detail, every step of the way. and that brings me great joy.. i can just sit back after those 5 minutes and think about all the poor bastards who are trying to duplicate that, on paper, in code, in their favourite art package etc.. when all it took me was a lousy five minutes(not counting the 8 years in development, but hey! thats another story, right? :P)

so in the end, it evolved from a "wannabe 64k intro texture generator" into what i actually like to call it, a personal studio of art.. most people would find it tedious to work with, but i love it and i wouldnt want it any other way(i mean, if i did, would it look like this? no, i didnt think so :P) wich is why to this day i still keep adding stuff to it :)

wow, this turned into quite a read.. and damn it was quite a write too.. :)

anyways, i hope you enjoyed reading it.. and i wish you many sweet nightmares reading my sources.. (those will follow in a few days, i just need to actually let go of it... 8 years of work.. let... it... go....)
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: How to generate this at runtime?
« Reply #9 on: January 19, 2008 »
T-san,

I did enjoy reading that and I have to say, your code is always a learning experience. I'm amazed how you knock up those texture tools (the mini ones, not the 8 year one :-). Frankly your posts are one of the major reasons I enjoy this forum, I only wish you were here more often. If you do release your tool, I know I'll be digging through the code endlessly.

Taj
 
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: How to generate this at runtime?
« Reply #10 on: January 19, 2008 »
@mind:
first a hello and very big thanks for your help and showcase images... really amazing and simple on the other side! Sorry for the delay but i had a small converting problem (bug) while converting the source... finally i manged to fix it and so i want to contribute this forum with a PB version of your code! K++ for your great help!! 
:goodpost:

Code: [Select]
; --------------------------------------------------------------
;
; Image Generation (EnvMap, Star)  at runtime
;
; Converted by: Thorsten Will aka Mr.Vain/Secretly!
; Thanks a lot to "mind" for the original source! *thumbs up*
;
; --------------------------------------------------------------


Procedure EnviromentMap( algo, x_ofs, y_ofs, x_size, y_size)
    Protected Color.l, x1.l, y1.l, x2.f, y2.f

    x_size = x_size >> 1
    y_size = y_size >> 1
 
    For y1 = 0 To 255
        For x1 = 0 To 255
           
            x2.f = ( x1 - x_ofs ) / x_size
            y2.f = ( y1 - y_ofs ) / y_size         
               
            Select algo
                Case 0 : Color = Round( ( Sqr( x2 * x2   +      y2 * y2 ) ) * 256 , 1 ) 
                Case 1 : Color = Round( ( Abs( x2 * x2   +      y2 * y2 ) ) * 256 , 1 )
                Case 2 : Color = Round( ( Sqr( x2 * x2   +      y2 * y2 ) ) * 256 , 1 )
                Case 3 : Color = Round( ( Sqr( x2 * x2 ) + Sqr( y2 * y2 ) ) * 256 , 1 )
                Case 4 : Color = Round( ( Abs( x2      ) + Abs( y2      ) ) * 256 , 1 )
                Case 5 : Color = Round( ( Abs( x2 * y2 ) + Abs( x2 * y2 ) ) * 256 , 1 )
                Case 6 : Color = Round( ( Abs( x2      ) + Abs( x2      ) ) * 128 , 1 )
                Case 7 : Color = Round( ( Abs( y2      ) + Abs( y2      ) ) * 128 , 1 )
            EndSelect;
                       
            If Color <   0 : Color =   0 : EndIf
            If Color > 255 : Color = 255 : EndIf

            Plot( x1, y1, RGB(255-Color, 255-Color, 255-Color) )   

        Next
    Next
                   
EndProcedure

« Last Edit: January 19, 2008 by va!n »
- 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 Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: How to generate this at runtime?
« Reply #11 on: January 21, 2008 »
Mind, it was a pleasure to read your post and to get a glimpse of what it is that drives you on.

Fascinating stuff, and you know what, I missed reading your posts too when you dissapeared.

I remember a time (after the mathcomp) where you and RDC were making all sorts of wonderful stuff and Rick went off on his Chladni fetish. I was amazed how many different variations on Chladni he programmed.

Rick doesn't seem to be around here at all nowadays... People come and go I guess, but this forum is only ever going to be as interesting as the posts on it and your reply above was a Karmic post if I ever saw one so have some more good Karma for your collection and next time we run the math comp you can enter it and hopefully win it.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: How to generate this at runtime?
« Reply #12 on: January 21, 2008 »
im still around :) i just dont code as much anymore and thus i dont really post alot of interesting stuff either :)

glad people enjoy reading what i enjoyed writing :)
Challenge Trophies Won:

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: How to generate this at runtime?
« Reply #13 on: July 10, 2009 »
"Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic"

whoa... just dug this thread up.. nice read it is.. reminds me i should get some work in on my texture generator.. clean the code up a bit so i can finally release it to you guys.. but oh im so slack.. but hey, atleast i posted a little tutorial on texture generation.. (old one from another forum, just copy/pasted, but still :))
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: How to generate this at runtime?
« Reply #14 on: July 10, 2009 »
This has now been added to the tutorial list and appears in the random list on the front page.

Thanks for posting it mate, it is really appreciated.
Shockwave ^ Codigos
Challenge Trophies Won: