本文整理汇总了C#中ShadingState.initCausticSamples方法的典型用法代码示例。如果您正苦于以下问题:C# ShadingState.initCausticSamples方法的具体用法?C# ShadingState.initCausticSamples怎么用?C# ShadingState.initCausticSamples使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadingState
的用法示例。
在下文中一共展示了ShadingState.initCausticSamples方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getRadiance
public Color getRadiance(ShadingState state)
{
// don't use these - gather lights for sphere of directions
// gather lights
state.initLightSamples();
state.initCausticSamples();
Vector3 v = state.getRay().getDirection();
v.negate();
Vector3 h = new Vector3();
Vector3 t = state.getBasis().transform(new Vector3(0, 1, 0));
Color diff = Color.black();
Color spec = Color.black();
foreach (LightSample ls in state)
{
Vector3 l = ls.getShadowRay().getDirection();
float dotTL = Vector3.dot(t, l);
float sinTL = (float)Math.Sqrt(1 - dotTL * dotTL);
// float dotVL = Vector3.dot(v, l);
diff.madd(sinTL, ls.getDiffuseRadiance());
Vector3.add(v, l, h);
h.normalize();
float dotTH = Vector3.dot(t, h);
float sinTH = (float)Math.Sqrt(1 - dotTH * dotTH);
float s = (float)Math.Pow(sinTH, 10.0f);
spec.madd(s, ls.getSpecularRadiance());
}
Color c = Color.add(diff, spec, new Color());
// transparency
return Color.blend(c, state.traceTransparency(), state.getV(), new Color());
}
示例2: GetRadiance
public Color GetRadiance(ShadingState state)
{
// make sure we are on the right side of the material
state.faceforward();
// direct lighting
state.initLightSamples();
state.initCausticSamples();
Color d = getDiffuse(state);
Color lr = state.diffuse(d);
if (!state.includeSpecular)
return lr;
if (glossyness == 0)
{
float cos = state.getCosND();
float dn = 2 * cos;
Vector3 refDir = new Vector3();
refDir.x = (dn * state.getNormal().x) + state.getRay().getDirection().x;
refDir.y = (dn * state.getNormal().y) + state.getRay().getDirection().y;
refDir.z = (dn * state.getNormal().z) + state.getRay().getDirection().z;
Ray refRay = new Ray(state.getPoint(), refDir);
// compute Fresnel term
cos = 1 - cos;
float cos2 = cos * cos;
float cos5 = cos2 * cos2 * cos;
Color spec = getSpecular(state);
Color ret = Color.white();
ret.sub(spec);
ret.mul(cos5);
ret.add(spec);
return lr.add(ret.mul(state.traceReflection(refRay, 0)));
}
else
return lr.add(state.specularPhong(getSpecular(state), 2 / glossyness, numSamples));
}
示例3: getRadiance
public Color getRadiance(ShadingState state)
{
// make sure we are on the right side of the material
state.faceforward();
// setup lighting
state.initLightSamples();
state.initCausticSamples();
return state.diffuse(getDiffuse(state));
}
示例4: getRadiance
public Color getRadiance(ShadingState state)
{
state.faceforward();
state.initCausticSamples();
// integrate a diffuse function
Color lr = Color.black();
foreach (LightSample sample in state)
lr.madd(sample.dot(state.getNormal()), sample.getDiffuseRadiance());
return lr.mul(1.0f / (float)Math.PI);
}
示例5: getRadiance
public Color getRadiance(ShadingState state)
{
// make sure we are on the right side of the material
state.faceforward();
// setup lighting
state.initLightSamples();
state.initCausticSamples();
// execute shader
return state.diffuse(getDiffuse(state)).add(state.specularPhong(spec, power, numRays));
}
示例6: getRadiance
public Color getRadiance(ShadingState state)
{
// make sure we are on the right side of the material
state.faceforward();
OrthoNormalBasis onb = state.getBasis();
// direct lighting and caustics
state.initLightSamples();
state.initCausticSamples();
Color lr = Color.black();
// compute specular contribution
if (state.includeSpecular)
{
Vector3 inv = state.getRay().getDirection().negate(new Vector3());
foreach (LightSample sample in state)
{
float cosNL = sample.dot(state.getNormal());
float fr = brdf(inv, sample.getShadowRay().getDirection(), onb);
lr.madd(cosNL * fr, sample.getSpecularRadiance());
}
// indirect lighting - specular
if (numRays > 0)
{
int n = state.getDepth() == 0 ? numRays : 1;
for (int i = 0; i < n; i++)
{
// specular indirect lighting
double r1 = state.getRandom(i, 0, n);
double r2 = state.getRandom(i, 1, n);
float alphaRatio = alphaY / alphaX;
float phi = 0;
if (r1 < 0.25)
{
double val = 4 * r1;
phi = (float)Math.Atan(alphaRatio * Math.Tan(Math.PI / 2 * val));
}
else if (r1 < 0.5)
{
double val = 1 - 4 * (0.5 - r1);
phi = (float)Math.Atan(alphaRatio * Math.Tan(Math.PI / 2 * val));
phi = (float)Math.PI - phi;
}
else if (r1 < 0.75)
{
double val = 4 * (r1 - 0.5);
phi = (float)Math.Atan(alphaRatio * Math.Tan(Math.PI / 2 * val));
phi += (float)Math.PI;
}
else
{
double val = 1 - 4 * (1 - r1);
phi = (float)Math.Atan(alphaRatio * Math.Tan(Math.PI / 2 * val));
phi = 2 * (float)Math.PI - phi;
}
float cosPhi = (float)Math.Cos(phi);
float sinPhi = (float)Math.Sin(phi);
float denom = (cosPhi * cosPhi) / (alphaX * alphaX) + (sinPhi * sinPhi) / (alphaY * alphaY);
float theta = (float)Math.Atan(Math.Sqrt(-Math.Log(1 - r2) / denom));
float sinTheta = (float)Math.Sin(theta);
float cosTheta = (float)Math.Cos(theta);
Vector3 h = new Vector3();
h.x = sinTheta * cosPhi;
h.y = sinTheta * sinPhi;
h.z = cosTheta;
onb.transform(h);
Vector3 o = new Vector3();
float ih = Vector3.dot(h, inv);
o.x = 2 * ih * h.x - inv.x;
o.y = 2 * ih * h.y - inv.y;
o.z = 2 * ih * h.z - inv.z;
float no = onb.untransformZ(o);
float ni = onb.untransformZ(inv);
float w = ih * cosTheta * cosTheta * cosTheta * (float)Math.Sqrt(Math.Abs(no / ni));
Ray r = new Ray(state.getPoint(), o);
lr.madd(w / n, state.traceGlossy(r, i));
}
}
lr.mul(rhoS);
}
// add diffuse contribution
lr.add(state.diffuse(getDiffuse(state)));
return lr;
}