View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# lightning the ball (or light + material)

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1/ fir   Members

Posted 07 February 2014 - 11:01 AM

I am doing some very simple raytracing

I want to get some experiments and get knowledge in the fundamentals

the result is not impressive, I noticed it before that simple setting the light

as a cosinus of normal to surface and light direction (I used here) give some

'plastic' looking lightning

there are also big topics:

i would like to define material color (as 3 floats from 0..1)

I would like to define light color (as 3 floats from 0..1)

how to calculate the resulting color (also as 3 floats from 0..1)

how to add more lights lightning the same point?

should i invite some open float (0 to more than 1) as a color value

then map it with some transformation to 0..1 ?

### #2Icebone1000  Members

Posted 07 February 2014 - 12:02 PM

Do you have an light intensity/coefficient factor? you just need to split it in 3, and use it to compute each component.

material: 0.2, 0.5, 0.4

light: 0.3, 0.4, 0.2

difuseStrenght: hitPoint.normal.Dot( llightDirection );

finalColor  = material * light * difuseStrenght; (all component affected)

Since its all multiplication, will not overflow beyond 1.0f.

Although you can have more than one light, in that case you need to sum all "finalColor"s..

Also, the ambient light is always sum:

finalColor += ambient;

Then you need to clamp to 1 (if > 1.0f, = 1.0f)

At least thats how I do it.

You can have coefficients saying how much the material is affected by the light type.

Like: finalColor =  materialColor * light * difuseStrength * materialDifuseCoefficient

So you can have a materialDifuseCoefficient and a materialAmbientCoefficient (and a specular..), both affecting the unique material color, or split in two colors already(a difuse and an ambient (and specular), but this is less intuitive).

### #3/ fir   Members

Posted 07 February 2014 - 03:01 PM

Do you have an light intensity/coefficient factor? you just need to split it in 3, and use it to compute each component.

material: 0.2, 0.5, 0.4

light: 0.3, 0.4, 0.2

difuseStrenght: hitPoint.normal.Dot( llightDirection );

finalColor  = material * light * difuseStrenght; (all component affected)

Since its all multiplication, will not overflow beyond 1.0f.

Although you can have more than one light, in that case you need to sum all "finalColor"s..

Also, the ambient light is always sum:

finalColor += ambient;

Then you need to clamp to 1 (if > 1.0f, = 1.0f)

At least thats how I do it.

You can have coefficients saying how much the material is affected by the light type.

Like: finalColor =  materialColor * light * difuseStrength * materialDifuseCoefficient

So you can have a materialDifuseCoefficient and a materialAmbientCoefficient (and a specular..), both affecting the unique material color, or split in two colors already(a difuse and an ambient (and specular), but this is less intuitive).

I think those are simple formulas and not looking to much good,

also are inclomplete for example

1) shouldnt the ambient light be multiplied by object color?

2) what when values of light adds and are over 1.0

this all loks like plastic, especially if i add ambient light the shaded

part hen i was doing test looked especially bad (lit part also imo

wasnt looking to much good)

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.