Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (769)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (855)
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  
  Problem with PointLight  (Read 1963 times)
0 Members and 1 Guest are viewing this topic.
Offline JoyrexJ9

Senior Newbie




Losing my mind...


« Posted 2004-06-29 20:55:28 »

Hi,

I have been playing about with Xith3D for a couple of days writing a Dungeon Master clone, and I've got a tiny problem with using PointLight.

I have a PointLight at the same location as the View eye, which moves with the player (representing a torch carried by the player). I want this to only illuminate a small "pool" of light arround the player, the problem is that far away walls are still being lit brightly looking very odd. See this screenshot for details -


Any ideas how to prevent this? I've tried adding a BoundingSphere to the light and changing the attenuation but none of this has helped.

BTW - I know the graphics and math theory why this happening but I don't know how to stop it in Xith3D

Any help very much appreciated, cheers
Ben

Ben
----------------------------------------------------
Dungeon Engine - http://cgi.bencoleman.plus.com/tiki/tiki-index.php?page=DungeonEngine
Offline Yuri Vl. Gushchin

Senior Devvie




Speak Java!


« Reply #1 - Posted 2004-06-30 03:29:04 »

Hi,

You should use distance attenuation for your light - this is done exactly for that.

Use PointLight.setAttenuation(Point3f), where x = constant atteniation, y = linear distance, z = quadratic distance attenuation.

The default attenuation is 1, 0, 0, which means it does not depend on distance.

This is strange that attenuation does not work for you. If you feel this is a bug, I request a small (as small as possible) test case and an issue filed in IssueZilla, so I can check if attenuation really works or not.

Yuri

Yuri Vl. Gushchin
JProof Group
Offline JoyrexJ9

Senior Newbie




Losing my mind...


« Reply #2 - Posted 2004-06-30 06:02:02 »

Thanks,

I was simply using the X part (constant attenuation)
I didn't know Y, Z did anything!

I've changed to quadratic distance (Z) and it's looking a lot better, I need to play about with the values and the ambient light to get it looking 100% as I want.

Here's a new screen shot


Thanks a lot!

Ben
----------------------------------------------------
Dungeon Engine - http://cgi.bencoleman.plus.com/tiki/tiki-index.php?page=DungeonEngine
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline hawkwind

Junior Devvie




Java games rock!


« Reply #3 - Posted 2004-07-10 11:57:21 »

The Hawk would REALLY Grin like to see a code exceprt on this.  My Point lights have yet to give this effect...arrrggghh.   Are you using your own bounds, the default bounds, a boundingleaf, and influencingbounds...??  
Offline Yuri Vl. Gushchin

Senior Devvie




Speak Java!


« Reply #4 - Posted 2004-07-11 06:06:16 »

Hawk,

Just try setAttenuation(new Point3f(1f, 1f, 0f)) on your light.

Default value for attenuation is 1, 0, 0, and this means no distance attenuation.

Equation is:

1  
2  
3  
4  
5  
6  
d = distance;
a = attenuation;
i = light intensity;
R = resulting intensity;

R = i*a.x + i*a.y*d + i*a.z*d*d;


Yuri

Yuri Vl. Gushchin
JProof Group
Offline aschwalb

Senior Newbie




Java games rock!


« Reply #5 - Posted 2004-07-11 12:11:55 »

Hello

The light intensity must be grow weaker in the distance,
e.g. for (0.0f<=distance<=1.0f)
R = i*a.x + i*a.y*d + i*a.z*(d*d) is ok, but for
(distance>=1.0f)
R = i*a.x + i*a.y/d + i*a.z/(d*d) is correct.

Also, there is a difference between 'java3d' and 'xith'
in 'setAttenuation(new Point3f(1f, 1f, 0f))'.
In 'java3d' you can set :
setAttenuation(new Point3f(1f, 0f, 0f)) or
setAttenuation(new Point3f(0f, 1f, 0f)) or
setAttenuation(new Point3f(0f, 0f, 1f))
but not 2 values concurrently, how
setAttenuation(new Point3f(1f, 1f, 0f))

A Problem what i have with a PointLight in xith
is. that i can't set it corretly.
Normally, under a pointlight, one half from a sphere must be highlighted and the other not.
(There a no reflections from a side, and the own
shininess from the sphere is very low)
My question is:
" How can i set a pointlight correct, so one half from
a sphere is highlighted and the other not?Huh"

Thanks Adi


Offline Yuri Vl. Gushchin

Senior Devvie




Speak Java!


« Reply #6 - Posted 2004-07-12 07:48:23 »

Hi,

Xith3D sends attenuation to OpenGL as they are, so docs from OpenGL are valid for attenuation factors:

Quote
GL_CONSTANT_ATTENUATION
GL_LINEAR_ATTENUATION
GL_QUADRATIC_ATTENUATION
The params parameter is a single integer or floating-point value that specifies one of the three light attenuation factors. Integer and floating-point values are mapped directly. Only nonnegative values are accepted. If the light is positional, rather than directional, its intensity is attenuated by the reciprocal of the sum of: the constant factor, the linear factor multiplied by the distance between the light and the vertex being lighted, and the quadratic factor multiplied by the square of the same distance. The default attenuation factors are (1,0,0), resulting in no attenuation.

The equation in my previous post is to give an idea of the x, y and z attenuation factor dependencies.

As of PointLight, the statement
Quote
Normally, under a pointlight, one half from a sphere must be highlighted and the other not.

seems to be incorrect.

Both Java3D and Xith3D set cutoff angle of PointLight to 180 deg., resulting in uniform light distribution:

Quote
GL_SPOT_CUTOFF
Effective light intensity is attenuated by the cosine of the angle between the direction of the light and the direction from the light to the vertex being lighted, raised to the power of the spot exponent. Thus, higher spot exponents result in a more focused light source, regardless of the spot cutoff angle (see the following paragraph). The default spot exponent is 0, resulting in uniform light distribution.
The params parameter is a single integer or floating-point value that specifies the maximum spread angle of a light source. Integer and floating-point values are mapped directly. Only values in the range [0,90], and the special value 180, are accepted. If the angle between the direction of the light and the direction from the light to the vertex being lighted is greater than the spot cutoff angle, then the light is completely masked. Otherwise, its intensity is controlled by the spot exponent and the attenuation factors. The default spot cutoff is 180, resulting in uniform light distribution.


You should use SpotLight and set its spread angle to 90 deg. to achieve the effect you want.

Yuri

Yuri Vl. Gushchin
JProof Group
Offline aschwalb

Senior Newbie




Java games rock!


« Reply #7 - Posted 2004-07-15 18:39:11 »

Hello

Thanks for your help.

Normally, a SpotLight is good, but a sun in a solarsystem shines in all directions,
not in a specific one, how a SpotLight does.

If i have no light integrated, all is highlighted.
Normally, my textured planets cannot be seen, without a lightsource.

I only have one lightsource, (sitting in the center, the sun), but the lightsource is sitting on my position, i think.
When i change my lightsource to red, with a simple rotation, i can see that the color from the lightsource
changes from red to white, but i have only that
red color light.
What can it be???

Bye Adi
Offline JoyrexJ9

Senior Newbie




Losing my mind...


« Reply #8 - Posted 2004-07-15 20:32:51 »

Could be a specularity (shiny-ness) problem with (large) white highlights showing over the whole object making them appear white.

Here's some code for a completely non-specular material
1  
2  
3  
4  
5  
6  
        Material matt_basic = new Material();
        matt_basic.setAmbientColor(1f, 1f, 1f);  ;
        matt_basic.setDiffuseColor(1f, 1f, 1f);            
        matt_basic.setShininess(0.00f);
        matt_basic.setSpecularColor(0.00f, 0.00f, 0.00f);
        matt_basic.setLightingEnable(true);

Ben
----------------------------------------------------
Dungeon Engine - http://cgi.bencoleman.plus.com/tiki/tiki-index.php?page=DungeonEngine
Offline aschwalb

Senior Newbie




Java games rock!


« Reply #9 - Posted 2004-07-17 08:15:18 »

Hello

Many thanks for your help.
The 'shininess' was the problem.

Bye Adi
Pages: [1]
  ignore  |  Print  
 
 

 
EgonOlsen (1569 views)
2018-06-10 19:43:48

EgonOlsen (1629 views)
2018-06-10 19:43:44

EgonOlsen (1142 views)
2018-06-10 19:43:20

DesertCoockie (1569 views)
2018-05-13 18:23:11

nelsongames (1173 views)
2018-04-24 18:15:36

nelsongames (1638 views)
2018-04-24 18:14:32

ivj94 (2395 views)
2018-03-24 14:47:39

ivj94 (1604 views)
2018-03-24 14:46:31

ivj94 (2691 views)
2018-03-24 14:43:53

Solater (882 views)
2018-03-17 05:04:08
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
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!