Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Forum
1 2 Previous Next  
Search
Topic Color & Tone By Wurstinator Date 2010-05-29 12:28

> "The saturation (HSV) is reduced by the tone's gray value."


As RunnerPack said it is converted to HSV, saturation is reduced and then back to RGB.
Anyway, this can be done also without conversion:
class Color
  def grayscale(percent = 1.0)
    average = (self.red + self.green + self.blue) / 3
    r = (average - self.red) * percent
    g = (average - self.green) * percent
    b = (average - self.blue) * percent
    return Color.new(self.red + r, self.green + g, self.blue + b, self.alpha)
  end
end

A small code I have written for RGSS. It should be clear how it works :)

> "The color is "overlayed" ((color.alpha / 255.0) * color.red + (1 - (color.alpha / 255.0)) * pixel.red)"


Standard alpha blending :)

> I can implement 'tones' in TP.


That would be nice but as TP changes the Images themselves and does not only modify the draw method of Gosu it might also come to a problem of performance :|
Topic Color & Tone By Wurstinator Date 2010-05-24 17:09
For some sprites it may fit but a full map has about
20 characters (128 * 192) +
400 tiles (32 * 32)
= over 900000 pixels each frame.

So, I need a method written in C.
Topic Color & Tone By Wurstinator Date 2010-05-17 16:03
Anyway, even with cache, it would be way to slow the first time.
And also, it would fastly use up all available RAM.
Topic Color & Tone By Wurstinator Date 2010-05-15 16:30
@jlnr: Disabling z is not good :(

@BlueScope: Tone != Hue
And of course, tone, color and hue are all features of RGSS. The RMXP without RGSS would have nothing to do with Ruby.

@ AmIMeYet: I already thought about texplay but as you said it should be smoothly used with maps. A map contains maybe 25 sprites. With 60 FPS and normal RMXP-32x48 images that means 25 * 60 * 32 * 48 = 2304000 pixels each second have to be rendered.
Topic Color & Tone By Wurstinator Date 2010-05-14 13:11
Hi :3
I'd like to request another thing ( :D )
Ruby Game Scripting System has a nice feature of so called "colors" and "tones".
Color = Red, Green, Blue, Alpha
Tone = Red, Green, Blue, Gray
They are applied when the image (Sprite) is drawn
I made some examples:
Image without any effects:
http://img140.imageshack.us/img140/2891/nonep.png
Tone (255, 0, 0, 0):
http://img248.imageshack.us/img248/3278/tonem.png
Color (0, 100, 255, 130):
http://img97.imageshack.us/img97/4575/colormd.png
Tone (255, 0, 0, 0) and Color (0, 100, 255, 130):
http://img413.imageshack.us/img413/6145/both.png
Tone (200, 0, 0, 200):
http://img375.imageshack.us/img375/9825/tone.png
Color (0, 50, 0, 255) (with or without Tone, is the same here):
http://img32.imageshack.us/img32/5354/colorou.png

The algorithm is pretty easy. For each pixel the following is done:
R, G and B of the tone are added to R, G and B of the pixel.
The saturation (HSV) is reduced by the tone's gray value.
The color is "overlayed" ((color.alpha / 255.0) * color.red + (1 - (color.alpha / 255.0)) * pixel.red)

Yes... and that's what I'd like to rebuild in gosu :)
Topic Draw on another window By Wurstinator Date 2010-05-14 11:49
Multiplayer? :o

No, I wanted to use one process / thread for things like AI or pathfinding :)
Topic Draw on another window By Wurstinator Date 2010-05-11 20:37
@ erisdiscord: Yes, I heard of FFI but as you said, most gems do not support it.

@ jlnr: I nearly know nothing about C so I cannot tell you why something is threadsafe and something other is not.
The problem is, that the developers of Ruby disabled the possibility to use parallel threads with the GIL. So maybe it wouldn't throw errors your way, but it just can't be done (only if you modify the interpreter).
Topic Draw on another window By Wurstinator Date 2010-05-10 15:07
Sorry, for not answering for some time.
I found out that Ruby 1.9.1 is able to support native threads but it only uses one because of the global interpreter lock because some C functions are not thread-safe.
Sadly, there is no alternative for Windows yet, so I just have to wait for a better threading version of Ruby to be released.
Topic Draw on another window By Wurstinator Date 2010-04-16 18:33
1.9.1
i386-mingw32
Topic Draw on another window By Wurstinator Date 2010-04-15 22:24
I think I am doing something wrong :|
http://img255.imageshack.us/img255/5381/screenxk.png

50 % CPU usage (1 of 2 cores) with 3 Threads...
Topic Draw on another window By Wurstinator Date 2010-04-15 19:29
"What you can do to support multiple processors is use Ruby 1.9 with native threads and offload all the calculation into a second thread. All Gosu calls have to be made on the main thread though (i.e. rendering). "

Uhh... what? ^^'
I always thought as Ruby only works only inside the Ruby compiler its threads only use one core?!
Topic TexPlay, drawing and hit-testing for Gosu::Image [from wiki] By Wurstinator Date 2010-04-14 16:33
Well, as your tilemap is written in full ruby it won't be faster as a one I can write. And if I have the chance to write something on my own, I will always do it ;)
Topic Draw on another window By Wurstinator Date 2010-04-14 12:55
Hi :)
I'd like to know if there is a way to get a window by its handel and draw onto it with Gosu::Image#draw.
I am trying to get some multi-core working in Ruby. The first process shall be the main process and calculating everything. It executes a second process when started which shall draw everything on the window.
Is there a way to do this? :)
Topic TexPlay, drawing and hit-testing for Gosu::Image [from wiki] By Wurstinator Date 2010-04-01 15:02
I am trying to create a Tilemap class.
The layers with trees, flowers and such stuff are drawn as seperate Images but the ground layer with (for example) grass or stone should be one single image.
Topic TexPlay, drawing and hit-testing for Gosu::Image [from wiki] By Wurstinator Date 2010-03-16 20:07
Thanks, it works.
And with no_sync I could made it to 54 FPS with 490 splices a frame :)
Topic Post processing effects for Ruby By Wurstinator Date 2010-03-16 17:38
Thanks, it works :)
I think I can do some other filters on my own now... if I can't I'll ask you :p
One last question, is it possible to "shader" just a certain image and not the full screen?
Topic Post processing effects for Ruby By Wurstinator Date 2010-03-14 15:46
uniform sampler2D tex;
uniform float radius;
uniform float width;
uniform float height;

void main(void)
{
  if (radius == 0.0) {
    gl_FragColor = texture2D(tex, gl_TexCoord[0]);
    return;
  }
  float x = gl_TexCoord[0].x;
  float y = gl_TexCoord[0].y;
  vec4 color = vec4(0.0, 0.0, 0.0, 0.0);
  float wradius = radius/width;
  float hradius = radius/height;
  int i = 0;
  for (float n = x-wradius; n < x+wradius; n++) {
    for (float m = y-hradius; m < y+hradius; m++) {
      color += texture2D(tex, vec2(n, m));
      i++;
    }
  }
  gl_FragColor = color / i;
}

I still have an error somewhere :(
Topic Post processing effects for Ruby By Wurstinator Date 2010-03-13 15:01
Okay... I tried a blur filter now but all I get is a screen full in black :/
uniform sampler2D tex;
uniform int radius;

void main(void)
{
  if (radius == 0) {
    gl_FragColor = texture2D(tex, gl_TexCoord[0]);
    return;
  }
  float x = gl_TexCoord[0].x;
  float y = gl_TexCoord[0].y;
  vec4 color = vec4(0.0, 0.0, 0.0, 0.0);
  int i = 0;
  for (int n = int(x)-radius; n < (int(x)+radius); n++) {
    for (int m = int(y)-radius; m < (int(y)+radius); m++) {
      color += texture2D(tex, vec2(n, m));
      i++;
    }
  }
  gl_FragColor = color / i;
}

Where is my mistake?
Topic Post processing effects for Ruby By Wurstinator Date 2010-03-13 10:30
I know the OpenGL example but it is not a tutorial. There is not a single comment explaining OpenGL's functions and the online doc doesn't really help me.
Topic Post processing effects for Ruby By Wurstinator Date 2010-03-12 21:35
So this means "yes"? :)
Is there a tutorial for opengl in gosu or do I have to wait for someone satisfying my wish? :)
Topic Post processing effects for Ruby By Wurstinator Date 2010-03-12 18:24
Hi,
is it possible to create something like Adobe Pixel Bender on the base of this?
For those who don't know: Pixel Bender is a tool for creating image effects in Adobe Flash.
You write a small script with certain parameters and your image will be rendered. For example "Invert RGB":

/*****************************************************************************
*
* Copyright (C) 2008 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE:  All information contained  herein is,  and remains the property of
* Adobe Systems Incorporated and its suppliers, if any.  The intellectual and
* technical  concepts  contained  herein  are  proprietary  to  Adobe Systems
* Incorporated  and  its suppliers  and may  be covered  by U.S.  and Foreign
* Patents, patents in process, and are protected by trade secret or copyright
* law.  Dissemination of this information or reproduction of this material is
* strictly forbidden  unless prior  written permission is obtained from Adobe
* Systems Incorporated.
*
*****************************************************************************/

<languageVersion: 1.0;>

// invertRGB: A simple example to demonstrate how to invert the RGB color
//            space.
kernel invertRGB
<   namespace : "AIF";
    vendor : "Adobe Systems, Inc.";
    version : 2;
    description : "Invert the Red, Green and Blue channels of an image"; >
{
    input image4 src;
    output float4 dst;
   
    // evaluatePixel(): The function of the filter that actually does the
    //                  processing of the image.  This function is called once
    //                  for each pixel of the output image.
    void
    evaluatePixel()
    {
        // Obtain the input pixel color
        float4 inputColor = sampleNearest(src, outCoord());

        // Calculate (1 - channel) for each of the RGB channels
        dst.rgb = float3(1.0, 1.0, 1.0) - inputColor.rgb;
       
        // set the alpha value equal to the alpha of the input
        dst.a = inputColor.a;
    }
}

I'd try to do this on my own but I don't know anything about OpenGL and I don't know a tutorial about it (in Ruby).
Topic TexPlay, drawing and hit-testing for Gosu::Image [from wiki] By Wurstinator Date 2010-03-12 16:14
Thanks =)
Hope the update will be out soon.
Topic TexPlay, drawing and hit-testing for Gosu::Image [from wiki] By Wurstinator Date 2010-03-10 17:48
:alpha_blend isn't mentioned in the blog post ;(
Anyway, it isn't what I want, actually it's quite the opposite :)
This is what I get:
http://img53.imageshack.us/img53/4779/screenx.png
Topic TexPlay, drawing and hit-testing for Gosu::Image [from wiki] By Wurstinator Date 2010-03-10 15:43
But there will be pixels with alpha 1-254 and I cannot just leave them out ;)
Topic TexPlay, drawing and hit-testing for Gosu::Image [from wiki] By Wurstinator Date 2010-03-10 13:14
I think I know what you mean ^^
(anyway, the two pictures:
http://img641.imageshack.us/img641/6500/074bird04.png
http://img30.imageshack.us/img30/352/070goblin04.png)

But I guess a C++ solution would be faster wouldn't it? I have to call the splice method about 300 times each frame :)
Topic TexPlay, drawing and hit-testing for Gosu::Image [from wiki] By Wurstinator Date 2010-03-09 19:45
Hey banister,
I have a problem with TexPlay.
If you use :alpha with the chroma_key parameter of Image#splice, you get for example this:
http://img61.imageshack.us/img61/2865/screenb.png

But I would like to have this:
http://img697.imageshack.us/img697/6500/074bird04.png

You know? :)
Topic Blendings By Wurstinator Date 2010-03-09 19:36
Nice :D
I always wondered what the mode parameter is used for but I didn't found seomthing in the Doc.

Well, I don't know how you do the calculation but shouldn't it be easy now to implement other blendings if you got the formulas?
Topic Blendings By Wurstinator Date 2010-03-09 18:03
Hi, it's me again :>
I'd like to make a request for coming GOSU versions: blendings for images.
You know, the standard calculation of a pixel is just adding RGB values and dividing by the alpha percentage.
But most graphics programs like Photoshop or GIMP have layer blendings like "Mulitplication", "Division", "Addition" etc.
Is there a way to give the Gosu::Images this ability of drawing? You can create much more atmosphere with it :) (important for me because I am developing an RPG and will maybe switch to GOSU)
Topic Audio By Wurstinator Date 2010-01-17 19:29
Weird... now it works :S
Maybe last time my PC was just running slow or something :/
Topic Audio By Wurstinator Date 2010-01-17 11:03
Sorry for annoying you again ^^'
I got a problem with streaming the music. When I try to play a sound file which is some MBs big it doesn't start playing at 0:00 but about 3 seconds later.
Is there a way to fix it?
Topic Audio By Wurstinator Date 2010-01-15 13:24

> my point is it's perfectly possible (as far as I'm aware) to write a game in C++ with Gosu. In fact, from the looks of things in the repository, Objective-C might be an option as well.


Of course my post only makes sense when talking about a game in Ruby ;)

> Are you sure? It should be...


testsampleinstance.rb:18:in update': undefined method volume' for #<Gosu::Samp
leInstance:0xe7f980> (NoMethodError)

I still have 0.7.15 so you may have changed it already?

> Why? What does it mean if you reduce the volume of the sample? Will it be more quiet if you play it afterwards? What about instances that are already playing? One library I worked with (ClanLib) applies the same to images, which have
> rotation and scaling properties. It's the direct opposite of what I want Gosu to be :)


Never mind. I had an idea how I can do it on my own :)

> If there was no commercial project driving Gosu, the library and this board wouldn't be here.


Okay... never saw one ^^
Topic Audio By Wurstinator Date 2010-01-14 22:26
It may be written in C++ but most of the code (if you develop a full game) will be written in Ruby and the actual Ruby is not the perfect language for games.
Topic Audio By Wurstinator Date 2010-01-14 22:00

> No, it's exactly correct and the point of SampleInstance that these are not attributes of Sample :)


Oh yes, I tried .volume -= 0.01 last time but the attribute is not readable.
So my new idea for SampleInstance is:
- make the attributes readable
- give Gosu::Sample the same attributes

> I don't mind FMOD, but if there is one top feature request for Gosu, it might be a sound library that is completely free, as in "sell your game and don't even worry". So if I should ever mess around with the Windows port of Gosu/Audio, I should > look for something that is easier in that regard …


I don't think a lot of people would care about a game done in Gosu. You shouldn't take this as an insult but I think for the commercial games languages like C++ are better. So I think you should just concentrate on finishing it and not on problems with law people may have later on.
Topic Audio By Wurstinator Date 2010-01-12 20:23

> The bigger difference is that there is only one song playing at any time, and that is actually because it fits both (initially) used APIs a lot: FMOD and SDL_mixer. For tracked music files (IT, S3M, …) or streamed music files, they just don't offer > the functionality needed to make them work like a Sample. :(


So the APIs you use miss support for such features? Aren't there other good free sound APIs around the net? :)

> Which mistake? :)


It says:
Attributes
Name  Read/write?
pan   RW
speed   RW
volume   RW
at SampleInstance but I think these should be at Sample ;)

> Since sound works completely differently on all three platforms, please always mention on which platform it behaves like that :)


On Windows (XP, SP 3).

> Yes ;)


Dann sind wir ja schon 2 :)

> My internal To Do list for audio looks like this:
> • get rid of the "Window" or "Audio&" arguments in all constructors (works except on Windows)
> • get rid of FMOD on Windows, because its licensing is complicated enough that you actually have to think about it
> • make streamed music files work on OS X again (the Ostnati Bastion game needs this to work on OS X :/)
> • find a way to implement "speed" on Linux, which probably means leaving SDL_mixer alone for good
>
> After that all works, I agree that a single class Gosu::Sound would be awesome, but I think it will take a few years to that point ;)


Maybe this will help you?
http://www.rpg-studio.de/scriptdb/script_files/181/FmodExAudio.html
It is a code written in RGSS (used in RPG-Maker) which uses Fmod (should be clear through the name :)
It provides functions like fading while playing.

Also, maybe you'd like to take a look at BASS:
http://www.un4seen.com/
Topic Audio By Wurstinator Date 2010-01-12 14:25
Hi :)
I would like to suggest a better way to handel sound output of Gosu.
There are some features which, I think, should be improved if it is possible.
First, there are two classes (Gosu::Song, Gosu::Sample) for playing sound files and the only difference between them is, the way the data is loaded. Apart from that, Gosu::Sample has a lot more features.
Things which could be better:
- only one class, with a parameter which defines kind of loading data
- beside volume and speed it also would be nice to have pitch
- still being able to play as many sounds/musics as you want to

I also like the idea that pausing, resuming and stoping is done using a Gosu::SampleInstance. A mistake in the Documentation (http://www.libgosu.org/rdoc/classes/Gosu/SampleInstance.html) gave me a good idea.
If the parameters pan, volume and speed (and maybe pitch :) are possible to be used with a SampleInstance you could do for example a fading effect in the background music.

Last, I'd like a variable which defines, if the sounds are still playing if the window isn't selected because at the moment it stops which may be good for some games/scenes but not for others :)

I never dealt with audio playing yet so I don't know if even any of these suggestions is possible to include but I think it would be a could step for Gosu =)

PS: jlnr, are you german? =o
Topic DevIL imaging library now works with Gosu By Wurstinator Date 2009-12-22 16:17
Oh, yes sorry.
I totally forgot that.
Topic DevIL imaging library now works with Gosu By Wurstinator Date 2009-12-21 20:12
Hi again,
I have a problem with DevIL ^^'
When I call gem install devil I get the error:

gem install devil
Building native extensions.  This could take a while...
ERROR:  Error installing devil:
        ERROR: Failed to build gem native extension.

D:/Programme/Ruby/bin/ruby.exe extconf.rb
checking for main() in -lDevIL... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=D:/Programme/Ruby/bin/ruby
        --with-DevILlib
        --without-DevILlib

Gem files will remain installed in D:/Programme/Ruby/lib/ruby/gems/1.9.1/gems/de
vil-0.1.9.1 for inspection.
Results logged to D:/Programme/Ruby/lib/ruby/gems/1.9.1/gems/devil-0.1.9.1/ext/d
evil/gem_make.out
Topic Compiled Chipmunk files By Wurstinator Date 2009-12-12 10:43
No, I am using XP 32 bit.
Chipmunk is the only gem that makes problems yet. All others worked fine :/
Topic Compiled Chipmunk files By Wurstinator Date 2009-12-11 16:46
With a gem it always tells me, that
Ruby/lib/ruby/gems/1.9.1/gems/chipmunk-4.1.0/lib/chipmunk.so
is missing.
Topic Problems with gems By Wurstinator Date 2009-12-11 16:45
Thanks again :)
Topic Compiled Chipmunk files By Wurstinator Date 2009-12-10 20:53
Could you please reupload the chipmunk.so? The forum change destroyed all attachments I think.
Topic Problems with gems By Wurstinator Date 2009-12-08 16:42
Seems like the newest posts have been deleted...
I forgot the command to install a windows version
(gem install gosu --mswin32 or something like that)
could you write it down again? :)
Topic Problems with gems By Wurstinator Date 2009-12-04 05:36
No, I get the error when I try to update the gems (gem update)
Topic Problems with gems By Wurstinator Date 2009-12-03 21:59
WIth 1.8 I get 'failed to build gem native extension'
Topic Problems with gems By Wurstinator Date 2009-12-03 17:55
'everything' means the directory and the environment variables right?
It is the same...
Topic Problems with gems By Wurstinator Date 2009-12-02 21:00
I installed 1.9.1 now alone but when I called gem update I got this error:
http://img687.imageshack.us/img687/1390/screenjo.png

and the same when I try to install a gem...
somehow I made my PC hate Ruby :/
Topic Problems with gems By Wurstinator Date 2009-12-01 17:59
I reinstalled ruby but it still doesn't work.
How did you did it?
Because there is no one click installer for 1.9.1 I installed 1.8 and copied the 1.9.1 files into the Rubydirecotry.
Topic Ocra Path isn't found By Wurstinator Date 2009-11-30 19:45
Wooho, I did it now ^.^
My code is:
Dir.chdir(File.dirname(__FILE__))

thank you two
(well, until I'll get another problem with ocra x)
Topic Problems with gems By Wurstinator Date 2009-11-30 19:31
Windows XP SP3
Ruby 1.9.1

DevIL.rb:12:in '<top (required)>': uninitialized constant Devil (NameError)
Topic Ocra Path isn't found By Wurstinator Date 2009-11-30 17:15
ippa:

> My solution has always been using full paths in my
> games... File.join(ROOT, "gfx", "player.png") bla
> bla


I think you mean __FILE__ not ROOT.
With this it works now ... nearly :)
My images and sounds are included but not fmod.dll :/

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill