Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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  
  Material colour vs texture colour vs lights  (Read 1405 times)
0 Members and 1 Guest are viewing this topic.
Offline Breakfast

Senior Duke




for great justice!


« Posted 2003-09-06 21:13:42 »

My scene has a behaviour attached that changes the light levels to create a day/night type effect. It works fine during the day phase but although I am sure that none of my objects have any emissive colour to them and the ambient and directional lights are both set to be (0, 0, 0) the objects are still drawing very clearly.

As far as I can tell, this is to do with the Material ambient colour and how it relates to the blend colour of the texture, but no matter what I change them to, I seem to get the scene drawn as though unlit when there isn't a light source on it (by which I mean, as though there were no lights in the scene and it was just drawing the textures neatly, not a dark scene, which is what I want!) and responding to the brightness increasing. Or, I set both to black and I get a completely black object that doesn't respond to any change in light level.

What settings do I need to use if I want the brightness to increase and decrease so the object is dark when unlit and light when lit?
Offline kevglass

JGO Kernel


Medals: 186
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2003-09-07 05:45:35 »

I think its more likely to be the emissive colour you want to play with.

Kev

Offline Breakfast

Senior Duke




for great justice!


« Reply #2 - Posted 2003-09-07 13:24:58 »

But the emissive colour is set to black on the material anyways.

The code that creates it is like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
Appearance aper = new Appearance();

Color3f Black = new Color3f(0f, 0f, 0f);
Color3f White = new Color3f(0.5f, 0.5f, 0.5f);
javax.media.j3d.Material Mser = new javax.media.j3d.Material(White, Black, Black, Black, 0.05f);
aper.setMaterial(Mser);
TextureLoader Texget=new TextureLoader(new java.net.URL(ourFile), null);
Texture2D ourTex=(Texture2D) Texget.getTexture();
TextureAttributes texatt=new TextureAttributes(TextureAttributes.BLEND, new Transform3D(), new Color4f(0.5f, 0.5f, 0.5f, 0.5f), TextureAttributes.NICEST);
aper.setTextureAttributes(texatt);
aper.setTexture(ourTex);
this.setAppearance(aper);

By changing the Color4f and the Ambient colour I am getting a general colour change but losing the ability to respond to lighting. It actually looks as though I have another ambient light lying about somewhere, but I can't find one, so I'm guessing it must be something in this appearance handling.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #3 - Posted 2003-09-07 13:37:17 »

Quote

As far as I can tell, this is to do with the Material ambient colour and how it relates to the blend colour of the texture, but no matter what I change them to, I seem to get the scene drawn as though unlit when there isn't a light source on it


A wild shot in the dark, but have you set your texture blend mode correctly? To mix your object colour (from surface colour and light colour) with your texture colour you need the mode set to 'MODULATE' (although i forget where this constant is defined Embarrassed ).

Although shouldn't you be messing with diffuse colours, not emissive or ambient to get the lighting to affect the objects?

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

Senior Duke




for great justice!


« Reply #4 - Posted 2003-09-07 19:26:47 »

You're completely right about the diffuse and specular colours, in theory at least, but I am finding that using those two just comes out black. Maybe my lights aren't strong enough.

I'm also finding that changing the colour of my AmbientLight doesn't seem to do much. The directional light you can see because it changes, but no matter how I try to call setColor on the ambientLight it doesn't seem to change, and when I tried to do a getColor I got a NullPointerException- could it be something about the AmbientLight?

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #5 - Posted 2003-09-08 05:51:23 »

Quote
You're completely right about the diffuse and specular colours, in theory at least, but I am finding that using those two just comes out black. Maybe my lights aren't strong enough.


You have set a sufficiantly huge bounds for the light, havn't you...?

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

Senior Duke




for great justice!


« Reply #6 - Posted 2003-09-08 09:28:26 »

Yes  - I am currently only doing this on one part of the scene until I get the appearance settings correct, and the rest of it is reacting normally to the lights (except that when unlit it just looks normal)

This is so annoying - I just know I'm missing something simple.
Offline Ifadolai

Junior Duke




Java forever!!


« Reply #7 - Posted 2003-09-08 10:55:56 »

OK, here is how to do it:

1) Make sure you have high white diffusecolor, something like 0.8 or 0.9 values.

2) You MUST use TextureAttributes.MODULATE

4) The ambient should be white(in most cases) and about half strength or lower.


PS. Remember to use DirectionalLight for the sun and moon, not pointlight.


The above will work, I does for me.

Regards
Nikolai

Nikolai V. Christensen, Computer Engineer,
Simulation and Training department
IFAD, Forskerparken 10A, DK-5230 Odense M
Denmark, EU
Phone: +45 63 15 71 31  Fax: +45 65 93 29 99
Offline Breakfast

Senior Duke




for great justice!


« Reply #8 - Posted 2003-09-08 12:01:56 »

What about the texture blend colour in the TextureAttributes- any recommended settings for that?

Still keeps coming out black. The only one I've found that works at all at the moment is using the BLEND - everything else is just drawing black.
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.

Longarmx (41 views)
2014-10-17 03:59:02

Norakomi (33 views)
2014-10-16 15:22:06

Norakomi (26 views)
2014-10-16 15:20:20

lcass (30 views)
2014-10-15 16:18:58

TehJavaDev (59 views)
2014-10-14 00:39:48

TehJavaDev (60 views)
2014-10-14 00:35:47

TehJavaDev (50 views)
2014-10-14 00:32:37

BurntPizza (66 views)
2014-10-11 23:24:42

BurntPizza (38 views)
2014-10-11 23:10:45

BurntPizza (80 views)
2014-10-11 22:30:10
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!