|
|
Hello,
While working on PoseRay I have been trying to simplify the conversion
of materials to POV-Ray SDL. One thing is Fresnel effects without using
reflection. Although Fresnel is available through reflections, getting a
smooth effect is very time consuming because of the high AA settings and
blurred reflections needed.
Using the aoi pattern I created the material below to fake a Fresnel
specular. I tried using the actual expression for non-polarized light
but that also controls the reflection amount on the faces facing the
viewer. This limits the control of the specular values. So I created a
simple power ramp that simulates the specular increase with angle of
incidence in radians. The ramp increases the specular level from the
basic facing the viewer to a maximum at the edge. Similarly the
roughness becomes 1.0 at the edge to enhance the effect. The power
parameter controls the spread of the effect from the edge. Lower values
make the effect wider.
You can view a sample scene rendered with and without the effect for
comparison, plus a Poser model using the fake Fresnel with a light dome:
https://sites.google.com/site/poseray/samples
Limitation: I cannot find a way of applying a pigment pattern to a
texture map to simulate a finish map and use the aoi pattern to fake the
Fresnel at the same time. I could use the aoi pattern on the pigment but
that will not respond to light properly since this effect is related to
how the light interacts with the surface. If anyone knows how to do this
please let me know.
Code is below. If someone finds a more elegant way of doing this or has
any tips please let me know. I am implementing this into PoseRay as a
macro or similar for the materials tab.
FlyerX
////
#macro power_ramp2(xv,xa,xb,ya,yb,pw)
//generates a float with a power ramp from (xa,ya) to (xb,yb) with power
pw and argument xv.
//ramp slope is zero at xa
((yb-ya)/pow((xb-xa),pw))*pow((xv-xa),pw)+ya
#end
#declare PR_DIFFUSE=pigment {color srgb <0.99,0.29,0.03> transmit 0/100 }
#declare index=0;
#declare nint=50;
#declare fake_fresnel_power=6; //controls how compressed the edge effect
is, lower value spreads effect
#declare specular_edge_level=1;//controls how strong the edge specular
is (0->1)
#declare specular_level=0.08;//basic specular
#declare specular_roughness=0.005;//basic roughness
material{
texture{uv_mapping
aoi
texture_map{
#while (index<nint)
#declare p=index/((nint-1));
#declare index=index+1;
//avoid going beyong 90deg for angle of incidence (ai)
//ai=0 facing viewer, ai=pi/2 perp to viewer.
#if (p>0.5)
#declare ai=pi*(1-p);//angle of incidence, radians - front faces
#else
#declare ai=pi*(p-0.5)+pi/2;//angle of incidence, radians - back faces
#end
[p
pigment{ PR_DIFFUSE }
finish{phong 0
specular power_ramp2(ai,0,pi/2, specular_level,
specular_edge_level,fake_fresnel_power)
roughness power_ramp2(ai,0,pi/2,
specular_roughness,1,fake_fresnel_power)
ambient 0 conserve_energy}
]
#end
}
}
}
////
Post a reply to this message
|
|