• Advertisement
Sign in to follow this  

lightning the ball (or light + material)

This topic is 1446 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am doing some very simple raytracing 

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

 

[attachment=19828:ball.jpg]

 

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 ?

 

 

 

 

Share this post


Link to post
Share on other sites
Advertisement

 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).

Share this post


Link to post
Share on other sites

 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)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement