THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 19/09/2003 at 11:52, xxxxxxxx wrote:
Cinema 4D Version: 8.200
Platform: Windows ;
Language(s) : C++ ;
in my plug-in C4Dfx I want not only to support Cg shaders but also to emulate the standard Cinema 4D material. To this end, I'd like to know how Cinema computes the specular lighting. Somehow there has to be a conversion from the "Width" parameter to a Phong exponent. And so on. Maybe there is a code snippet demonstrating how Cinema's parameters enter the lighting model? This would save me some hours of trial and error.
Thanks in advance.
New alpha release of C4Dfx:
On 19/09/2003 at 12:27, xxxxxxxx wrote:
The source for Illuminance1() is in Illuminance.cpp in the SDK project.
On 19/09/2003 at 13:03, xxxxxxxx wrote:
yes, but Cinema's internal specular lighting is more complex. In particular, the user does not enter the Phong exponent directly ...
On 21/09/2003 at 11:43, xxxxxxxx wrote:
Could somebody tell me at least what the x axis in the diagram on the specular lighting page of the material attributes is supposed to mean?
These are all quite similar. But only quite.
On 23/09/2003 at 23:41, xxxxxxxx wrote:
Really nobody out there who knows?
And didn't even ask about how to emulate the bump mapping ... (For instance: How is the bump map smoothed before computing its gradient? Is the gradient computed by differences between two neighboring texels? Or by interpolating three neighboring texels?)
On 24/09/2003 at 23:27, xxxxxxxx wrote:
I've passed your questions along and am waiting for an answer.
Is that last part a question or a non-question?
On 25/09/2003 at 01:22, xxxxxxxx wrote:
Mikael Sterner wrote:
> Is that last part a question or a non-question?
Well, let's try the specular lighting first
On 28/09/2003 at 04:09, xxxxxxxx wrote:
Here you go:
Real Highlight(Real x, Real w, Real h, Real f, Real b)
w = Pow(w+0.0001,1/3.0);
x = Cos(Abs(x)*pi*0.5);
x = ACos(x);
x = -((-x+w*b*pi05)/(1-w*b+0.0001));
x = FCut(x,0.0,pi05);
Real expo = Exp(4.605170185988091368*f+0.5756462732485115421);
Real fac1 = Exp(-0.45158270528945486478 * expo);
x = 1.0-fac1*Pow(Abs(x)/w,expo);
x = FCut(x,0.0,1.0);
On 28/09/2003 at 11:42, xxxxxxxx wrote:
great. A few "x" too much, but I guess I can get that straight.
On 30/09/2003 at 01:42, xxxxxxxx wrote:
yes, that code works. That is, if you leave out the cubic root of w (first line).
I've put the code snippet into a more concise form:
// Use the angle (not the dot product, but the acos of it)
// between ray to viewer and reflected light ray as input.
// Scale the angle to 0.0 ... 1.0 for 0° ... 90°.
Real Highlight(Real angle, Real width, Real height, Real falloff, Real innerw)
// better (pre-)compute this per material
Real expo = pow(100.0, falloff + 0.125);
Real fact = 1.0/width/(1.0001 - width*innerw);
Real subt = innerw/(1.0001 - width*innerw);
Real twbw = 2.0/width;
// compute only this per ray/object intersection
return pow(1.0 - pow(FCut(angle*fact - subt, 0.0, 1.0), expo), twbw)*height;
Can someone hand this back to the developers at Maxon? Maybe we see a 300% improvement of rendering speed
Thanks again. Could not have found this by reverse engineering. I'll post my other question about bump maps in a new thread.