Results 1 to 7 of 7

Thread: Drawing with a hue change?

  1. #1

    Talking Drawing with a hue change?

    I was wondering if there is a way to draw a zglPTexture with a modified hue. I'm writing a game with this (excellent!) library and I would like to add colour dye to armour or make variations of monsters with different colours.

    Thank you in advance

  2. #2
    I guess you'd have to do that yourself. One thing you could do is reserve one colour like purple (255,0,255) and replace it with other colours for all your different monsters. But you'd need to change hue if you want to change your whole monster to another color.

    Convert RGB to HSV:
    http://delphi.about.com/od/adptips2006/qt/RgbToHsb.htm
    Convert from HSV to RGB:
    http://www.delphipages.com/forum/sho...d.php?t=133111
    More info:
    http://www.efg2.com/Lab/Graphics/Colors/HSV.htm

    So just write a function that takes one pixel as input, converts to HSV, changes hue, then back to RGB. Call it for every pixel and you're done.

    One cool variation would be to use a mask. That'd give you control over which area's of the picture must be changed and which will have the same color.

    Good luck!
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  3. #3
    If there is a solution via standard OpenGL pipeline, I would implement it in ZenGL, but there is a problem with that. One solution, which can do things like this is color matrix, but latest drivers for new hardware are not support them(here the demo with grayscale effect in realtime, but seems it works only on my ArchLinux with Radeon HD 4650 and Radeon HD 5850 ). Another way - pixel shaders, but for now ZenGL doesn't provide functionality for them. So, the only possible way for now is using different textures. You can modify them in any graphical editor and save for later using, or modify pixels during loading the texture via tex_LoadFromFile. For this - add to flags TEX_CUSTOM_EFFECT and register your own postprocess procedure via zgl_Reg and constant TEX_CURRENT_EFFECT:
    Code:
    procedure myHUE( var pData : Pointer; Width, Height : Word );
    where pData - pointer to pixels in RGBA, which you must modify.

    Quote Originally Posted by NickS
    or make variations of monsters with different colours
    One more solution - color mix(function fx2d_SetColor, see demo05), but it's not so good as changing hue.
    Last edited by Andru; 13-02-2011 at 09:36 AM.

  4. #4
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    I think the important bit here Andru is the
    ArchLinux
    bit. I will be the first person to admit that there is a world of difference between OpenGl on windows and almost any linux 'distro' (call them that for simplicity and not anger mobs of users). Perhaps as linux is solely dependant on OpenGl for graphics? I dont know - but I believe it may not just be the card at fault.

    A thought to keep in mind.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  5. #5
    I think the important bit here Andru is the
    Maybe, but there are such OpenGL extensions as GL_ARB_imaging and GL_SGI_color_matrix(this was in OpenGL 1.2), which were dropped under Windows for many videocards and drivers... and I hate developers for that >_<
    Last edited by Andru; 13-02-2011 at 10:37 AM.

  6. #6
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Ah yes, the infamous ARGB format (I had some nice battle with that one but won in the end) and I must say that ever since Prometheus went Gl, I am so glad I am not on windows Its no surprise you see a majority of OpenGl code written on mac or linux. Thats no minority windows developers - get with the program. Excuse the pun.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  7. #7
    Thank you a bunch once again =) I used the code from demo05 for now for colour changing, will implement the more complicated way using hue in the future.

    Thanks so much!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Comodo SSL