|
|
Samuel Benge nous apporta ses lumieres en ce 2007/06/20 22:08:
> Kirk Andrews wrote:
>> Some time ago a saw a post in the image binaries titled "ambient
>> occlusion",
>> which is a way of lighting objects such that crevices and corners receive
>> less ambient light. It would incredibly useful if this could be
>> applied to
>> *textures*, allowing a "dirty" or "mossy" texture to be applied only to
>> crevices and corners. I wonder if anyone knows of a way of doing this?
>>
>> -- Kirk
>
> One way is to use MegaPOV's projection pattern: 2.6.3. Projection pattern
>
> To get a full effect, you would need several patterns to specify blurry
> light_sources all around the object. They would be averaged together.
Don't know.
>
> The other option I know of (and it may have been my post you saw), is to
> make a pigment out of the target object and combine jittered versions
> of it into an average pigment's pigment_map. If that makes any sense.
Done!
>
> Both ways will be terribly slow.
>
> ~Sam
The object pattern is used in the patina macro, and yes, it's teribly slow, in
particular if there is some reflection involved.
--
Alain
-------------------------------------------------
A day without sunshine is like, night
Post a reply to this message
|
|
|
|
This macro does some edge detection, but the results are
so so. And it generates a zillion acos warnings. And it's slow.
#include "rand.inc"
#include "transforms.inc"
#include "math.inc"
#macro detect(Obj, N, Size, Angle, EDGE, CREVICE)
#local mn = min_extent(Obj);
#local mx = max_extent(Obj);
#local cntr = (mn+mx)/2;
#local rad = vlength(mx-cntr)+1;
#local S1 = seed(1);
#local THit = array[9];
#local TNorm = array[9];
#local TFrom = array[9];
#local TLen = array[9];
#local c = 0;
#while (c<N)
#local RP = VRand_On_Sphere(S1);
#local RN = -1*RP;
#local TFP = RP*rad+cntr;
#local RNPerp = VPerp_To_Vector(RN);
// the 9 points to trace from
#local TFrom[0] = TFP;
#local tc = 0;
#while (tc<8)
#local TFrom[tc+1] = TFP + vaxis_rotate(Size*RNPerp,RN,tc*45);
#local tc=tc+1;
#end
// the 9 traces
#local tc = 0;
#while (tc<9)
#local Norm = <0,0,0>;
#local THit[tc] = trace(Obj, TFrom[tc], RN, Norm);
#local TNorm[tc] = Norm;
#local tc=tc+1;
#end
// check if any of the 9 traces missed
#local Tmissed = false;
#local tc = 0;
#while (tc<9)
#if (vlength(TNorm[tc])=0)
#local Tmissed = true;
#end
#local tc=tc+1;
#end
#if (Tmissed = false)
// the 4 angles checks
#local A_1 = (VAngleD( THit[1]-THit[0], THit[5]-THit[0]) > Angle);
#local A_2 = (VAngleD( THit[2]-THit[0], THit[6]-THit[0]) > Angle);
#local A_3 = (VAngleD( THit[3]-THit[0], THit[7]-THit[0]) > Angle);
#local A_4 = (VAngleD( THit[4]-THit[0], THit[8]-THit[0]) > Angle);
// the 9 lengths
#local tc = 0;
#while (tc<9)
#local TLen[tc] = vlength(TFrom[tc]-THit[tc]);
#local tc=tc+1;
#end
// the belly button check
#local Innie_1 = ((TLen[1]<TLen[0]) & (TLen[5]<TLen[0]));
#local Innie_2 = ((TLen[2]<TLen[0]) & (TLen[6]<TLen[0]));
#local Innie_3 = ((TLen[3]<TLen[0]) & (TLen[7]<TLen[0]));
#local Innie_4 = ((TLen[4]<TLen[0]) & (TLen[8]<TLen[0]));
#local Outie_1 = ((TLen[1]>TLen[0]) & (TLen[5]>TLen[0]));
#local Outie_2 = ((TLen[2]>TLen[0]) & (TLen[6]>TLen[0]));
#local Outie_3 = ((TLen[3]>TLen[0]) & (TLen[7]>TLen[0]));
#local Outie_4 = ((TLen[4]>TLen[0]) & (TLen[8]>TLen[0]));
// edge detection
#if ( ((A_1)&(Outie_1)) |
((A_2)&(Outie_2)) |
((A_3)&(Outie_3)) |
((A_4)&(Outie_4)) )
#local edge_detected = true;
#else
#local edge_detected = false;
#end
// crevice detection
#if ( ((A_1)&(Innie_1)) |
((A_2)&(Innie_2)) |
((A_3)&(Innie_3)) |
((A_4)&(Innie_4)) )
#local crevice_detected = true;
#else
#local crevice_detected = false;
#end
// do edges
#if (EDGE & edge_detected)
sphere{THit[0],Size}
#end
// do crevices
#if (CREVICE & crevice_detected)
sphere{THit[0],Size}
#end
#end
#local c=c+1;
#end
#end
#macro edge(Obj, N, Size, Angle)
detect(Obj, N, Size, Angle, true, false)
#end
#macro crevice(Obj, N, Size, Angle)
detect(Obj, N, Size, Angle, false, true)
#end
#declare Sample = union {
box {0,1 translate <-0.5,-1.2,0>}
box {0,1 translate <-1.5,-1,0.1>}
box {0,1 translate <0.5,-1,0.1>}
};
object{ Sample
pigment{
object {
union {
edge(Sample, 5000, 0.05, 45)
}
Cyan*0.5
Blue
}
}
}
Post a reply to this message
|
|