Lighting Effects in Inkscape
Hi,
It's been a long time since I started using Inkscape. During the last two weeks, I got frustrated that lighting effects weren't implemented in Inkscape. I took advantage of Niko Kiirala great filter framework to write a first simple implementation of these lighting effects.
Almost everything is implemented now. (kernelUnitsLength support is still missing but I plan to get it done soon).
I write this email to the list to signal a discreprancy I noticed while implementing feSpecularLighting. In fact the svg feSpecularLighting specification, and test examples, do not follow Phong lighting model. In the SVG specs, the specular lighting is computed by taking ks * N.H^speExp In every Phong lighting model I found by googling it is computed as ks * R.E^speExp where ks is the specular constant speExp is the specular exponent N is the surface normal vector L is the light vector, unit vector from the surface point to the light E is the eye vector, unit vector from the surface to the viewer R is the reflected light vector, unit vector from the surface point indicating the reflection direction. H is the normalized vector colinear to L+E/2
writing things down we have N.H = cos (alpha) for some alpha and R.E = cos(2*alpha).
The formula using R.E seems much more natural since the viewer sees reflection if R is "close" to E, ie R.E is close to 1. For the time being the N.H is implemented in Inkscape (standard compliance above all).
However, can anybody explain the formula using N.H? Does anybody know why svg specularLighting uses N.H instead of R.E?
Cheers, Jean-Rene
Jean-René Reinhard wrote:
... However, can anybody explain the formula using N.H? Does anybody know why svg specularLighting uses N.H instead of R.E?
See: http://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_shading_model
Basically it's an optimization, although apparently it can actually give more realistic results (although that probably depends on the effect you're trying to achieve).
participants (2)
-
Jasper van de Gronde
-
Jean-René Reinhard