Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How to display a texture in brighter (white)  (Read 3931 times)
0 Members and 1 Guest are viewing this topic.
Offline Aramaz

Junior Devvie




Java Games Rock!


« Posted 2006-01-17 10:27:17 »

How can I change the color of a sprite (texture) to become brighter than it is? I know I can set color but it doesn't get brighter...

I want to make the sprite flash to white and then back to normal again. Do I have to use lightning and stuff or is there an easier way. (It's a 2d game using lwjgl)

Play XSW: www.xsw.se
Offline hvor2

Junior Devvie




Beyond mind, there is an awareness...


« Reply #1 - Posted 2006-01-17 10:38:12 »

Yes, lightning is one option, with high specularity. But it is position dependant, so maybe it is not the best solution.
You can blend your texture with white (GL_ONE), I think that will work.

Offline princec

« JGO Spiffy Duke »


Medals: 422
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #2 - Posted 2006-01-17 10:39:03 »

1  
2  
3  
4  
5  
6  
7  
8  
      if (GLContext.getCapabilities().GL_EXT_secondary_color) {
         GL11.glEnable(EXTSecondaryColor.GL_COLOR_SUM_EXT);
         EXTSecondaryColor.glSecondaryColor3ubEXT((byte)255, (byte)255, (byte)255);
      }        
      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
      GL11.glEnable(GL11.GL_TEXTURE_2D);
      GL11.glEnable(GL11.GL_BLEND);
      GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

Works even when GL_EXT_secondary_color is not present but doesn't look nearly as good.
If anyone finds a better way than this that doesn't require exotic hardware please let me know!

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Aramaz

Junior Devvie




Java Games Rock!


« Reply #3 - Posted 2006-01-18 05:58:04 »

1  
2  
3  
4  
      if (GLContext.getCapabilities().GL_EXT_secondary_color) {
         GL11.glEnable(EXTSecondaryColor.GL_COLOR_SUM_EXT);
         EXTSecondaryColor.glSecondaryColor3ubEXT((byte)255, (byte)255, (byte)255);
      }        


Good stuff, that is exactly what I need. Is  this ability common in graphics card or are there many cards that doesn't support it?

Without this capability it basically just blends it to white? What I want to do is to make it flash (growing linearly from original color to white then back again)... so if this GL_EXT_secondary_color does not exist, how wold I do it then? (or should I just count on this existing on most cards)

Play XSW: www.xsw.se
Offline princec

« JGO Spiffy Duke »


Medals: 422
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #4 - Posted 2006-01-18 10:56:49 »

I've not actually come across a machine without this extension yet. But the fallback is simply to use additive blending instead of alpha blending when rendering the sprite which makes it a lot brighter if there's any background image there already but otherwise has no effect on black backgrounds.

Cas Smiley

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #5 - Posted 2006-01-18 12:19:36 »

Yes, lightning is one option, with high specularity.

Ooo, now theres a nice idea. For sprites you should easily be able to fudge the normals so they're pointing straight at the camera, then the specular colour would just be added on top. So even cards without the secondary extension would be able to blend towards a colour rather than just white.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline princec

« JGO Spiffy Duke »


Medals: 422
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #6 - Posted 2006-01-18 12:21:12 »

Hmm.. I believe that extension is part of the way the separate specular colour is calculated. Without it the specular light component is simply blended with the diffuse component giving, er, remarkably unspecular highlights. But this is also the reason why it is present on every card I've ever seen.

Cas Smiley

Offline DzzD
« Reply #7 - Posted 2006-01-18 12:30:58 »

Depending on what you want to do, you may convert your texture RGB to HSL increase luminosity(L) and convert it back to RGB


Bruno

Offline DzzD
« Reply #8 - Posted 2006-01-18 12:33:30 »

Ps:

You can also keep in memory the two texture not bright and bright and map the brighter one onto the initial texture, alpha used for the brighter texture will determine the luminosity.

Bruno

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #9 - Posted 2006-01-18 12:36:38 »

I might be reading the specs wrong, but I thought the EXT_separate_specular_color extension introduced a second colour for use with specular lighting, and EXT_secondary_color came later to allow it to be used even if lighting was disabled. Unfortunately I can't see when the specular lighting calculation was actually fixed to be additive.

I suppose anything with proper additive specular behaviour is probably also going to have the secondary colour extension, making a specular hack slightly pointless.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Aramaz

Junior Devvie




Java Games Rock!


« Reply #10 - Posted 2006-01-18 17:49:18 »

I've not actually come across a machine without this extension yet. But the fallback is simply to use additive blending instead of alpha blending when rendering the sprite which makes it a lot brighter if there's any background image there already but otherwise has no effect on black backgrounds.

Sounds good that most cards have it... I think I'll just use the extension and don't worry about those without... they can live without the flash... Smiley

It's just to get a little more visual feedback when someone gets hit, so it's not crucial to the game itself.

Thanx for all the suggestions.

Play XSW: www.xsw.se
Offline DzzD
« Reply #11 - Posted 2006-01-18 18:09:09 »

To better explain what  I was meaning by using two texture have a look to the first demo there http://research.microsoft.com/~hoppe/ named "Continuous flash" download it and execute use the right scrollbar to determine luminosity.

Bruno

Offline Aramaz

Junior Devvie




Java Games Rock!


« Reply #12 - Posted 2006-01-18 23:49:52 »

Yes, I understood the 2 texture thing... but I don't want to keep 2 copies in memory... Wink

Anyways, now I implemented the flash thing, works beautifully, thanx for the help.

Play XSW: www.xsw.se
Offline princec

« JGO Spiffy Duke »


Medals: 422
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #13 - Posted 2006-01-19 11:04:11 »

That flash code was developed for Alien Flux and I still use it in all my games to this day Smiley

Cas Smiley

Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #14 - Posted 2006-01-19 11:21:19 »

what i do is just use a brighten the texture in  a paint program(like the gimp). so when i draw it i use something like glColor3f(0.5f, 0.5f, 0.5f);
to draw it in its normal color.

When i need it to flash i just change the color to glColor3f(1.0f, 1.0f, 1.0f);.
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #15 - Posted 2006-01-19 15:36:25 »

But then you lose half the range (contrast).

弾幕 ☆ @mahonnaiseblog
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #16 - Posted 2006-01-19 16:41:09 »

hmm, maybe so, but doesn't look to bad to my untrained eye.
maybe increasing the contrast might help compensate for some of the loss?
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #17 - Posted 2006-01-19 17:47:37 »

Then you'd get banding (as you've reduced your effective colour range by half).

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Pages: [1]
  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.

toopeicgaming1999 (57 views)
2014-11-26 15:22:04

toopeicgaming1999 (50 views)
2014-11-26 15:20:36

toopeicgaming1999 (10 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (27 views)
2014-11-25 11:26:43

Gibbo3771 (24 views)
2014-11-24 19:59:16

trollwarrior1 (37 views)
2014-11-22 12:13:56

xFryIx (75 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!