本文整理汇总了C#中ShadingState.getPrimitiveID方法的典型用法代码示例。如果您正苦于以下问题:C# ShadingState.getPrimitiveID方法的具体用法?C# ShadingState.getPrimitiveID怎么用?C# ShadingState.getPrimitiveID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadingState
的用法示例。
在下文中一共展示了ShadingState.getPrimitiveID方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: prepareShadingState
public void prepareShadingState(ShadingState state)
{
state.init();
state.getRay().getPoint(state.getPoint());
Point3 localPoint = state.transformWorldToObject(state.getPoint());
localPoint.x -= particles[3 * state.getPrimitiveID() + 0];
localPoint.y -= particles[3 * state.getPrimitiveID() + 1];
localPoint.z -= particles[3 * state.getPrimitiveID() + 2];
state.getNormal().set(localPoint.x, localPoint.y, localPoint.z);
state.getNormal().normalize();
state.setShader(state.getInstance().getShader(0));
state.setModifier(state.getInstance().getModifier(0));
// into object space
Vector3 worldNormal = state.transformNormalObjectToWorld(state.getNormal());
state.getNormal().set(worldNormal);
state.getNormal().normalize();
state.getGeoNormal().set(state.getNormal());
state.setBasis(OrthoNormalBasis.makeFromW(state.getNormal()));
}
示例2: prepareShadingState
public void prepareShadingState(ShadingState state)
{
state.init();
state.getRay().getPoint(state.getPoint());
int n = state.getPrimitiveID();
switch (n)
{
case 0:
state.getNormal().set(new Vector3(1, 0, 0));
break;
case 1:
state.getNormal().set(new Vector3(-1, 0, 0));
break;
case 2:
state.getNormal().set(new Vector3(0, 1, 0));
break;
case 3:
state.getNormal().set(new Vector3(0, -1, 0));
break;
case 4:
state.getNormal().set(new Vector3(0, 0, 1));
break;
case 5:
state.getNormal().set(new Vector3(0, 0, -1));
break;
default:
state.getNormal().set(new Vector3(0, 0, 0));
break;
}
state.getGeoNormal().set(state.getNormal());
state.setBasis(OrthoNormalBasis.makeFromW(state.getNormal()));
state.setShader(state.getInstance().getShader(0));
state.setModifier(state.getInstance().getModifier(0));
}
示例3: getRadiance
public Color getRadiance(ShadingState state)
{
Vector3 n = state.getNormal();
float f = n == null ? 1.0f : Math.Abs(state.getRay().dot(n));
return BORDERS[state.getPrimitiveID() % BORDERS.Length].copy().mul(f);
}
示例4: ScatterPhoton
public void ScatterPhoton(ShadingState state, Color power)
{
int side = state.getPrimitiveID();
Color kd = null;
switch (side)
{
case 0:
kd = left;
break;
case 1:
kd = right;
break;
case 3:
kd = back;
break;
case 4:
kd = bottom;
break;
case 5:
float lx = state.getPoint().x;
float ly = state.getPoint().y;
if (lx >= lxmin && lx < lxmax && ly >= lymin && ly < lymax && state.getRay().dz > 0)
return;
kd = top;
break;
default:
Debug.Assert(false);
break;
}
// make sure we are on the right side of the material
if (Vector3.dot(state.getNormal(), state.getRay().getDirection()) > 0)
{
state.getNormal().negate();
state.getGeoNormal().negate();
}
state.storePhoton(state.getRay().getDirection(), power, kd);
double avg = kd.getAverage();
double rnd = state.getRandom(0, 0, 1);
if (rnd < avg)
{
// photon is scattered
power.mul(kd).mul(1 / (float)avg);
OrthoNormalBasis onb = OrthoNormalBasis.makeFromW(state.getNormal());
double u = 2 * Math.PI * rnd / avg;
double v = state.getRandom(0, 1, 1);
float s = (float)Math.Sqrt(v);
float s1 = (float)Math.Sqrt(1.0 - v);
Vector3 w = new Vector3((float)Math.Cos(u) * s, (float)Math.Sin(u) * s, s1);
w = onb.transform(w, new Vector3());
state.traceDiffusePhoton(new Ray(state.getPoint(), w), power);
}
}
示例5: GetRadiance
public Color GetRadiance(ShadingState state)
{
int side = state.getPrimitiveID();
Color kd = null;
switch (side)
{
case 0:
kd = left;
break;
case 1:
kd = right;
break;
case 3:
kd = back;
break;
case 4:
kd = bottom;
break;
case 5:
float lx = state.getPoint().x;
float ly = state.getPoint().y;
if (lx >= lxmin && lx < lxmax && ly >= lymin && ly < lymax && state.getRay().dz > 0)
return state.includeLights ? radiance : Color.BLACK;
kd = top;
break;
default:
Debug.Assert(false);
break;
}
// make sure we are on the right side of the material
state.faceforward();
// setup lighting
state.initLightSamples();
state.initCausticSamples();
return state.diffuse(kd);
}
示例6: prepareShadingState
public void prepareShadingState(ShadingState state)
{
state.init();
Instance parent = state.getInstance();
int primID = state.getPrimitiveID();
float u = state.getU();
float v = state.getV();
float w = 1 - u - v;
// state.getRay().getPoint(state.getPoint());
int tri = 3 * primID;
int index0 = triangleMesh.triangles[tri + 0];
int index1 = triangleMesh.triangles[tri + 1];
int index2 = triangleMesh.triangles[tri + 2];
Point3 v0p = triangleMesh.getPoint(index0);
Point3 v1p = triangleMesh.getPoint(index1);
Point3 v2p = triangleMesh.getPoint(index2);
// get object space point from barycentric coordinates
state.getPoint().x = w * v0p.x + u * v1p.x + v * v2p.x;
state.getPoint().y = w * v0p.y + u * v1p.y + v * v2p.y;
state.getPoint().z = w * v0p.z + u * v1p.z + v * v2p.z;
// move into world space
state.getPoint().set(parent.transformObjectToWorld(state.getPoint()));
Vector3 ng = Point3.normal(v0p, v1p, v2p);
if (parent != null)
ng = parent.transformNormalObjectToWorld(ng);
ng.normalize();
state.getGeoNormal().set(ng);
switch (triangleMesh.normals.interp)
{
case ParameterList.InterpolationType.NONE:
case ParameterList.InterpolationType.FACE:
{
state.getNormal().set(ng);
break;
}
case ParameterList.InterpolationType.VERTEX:
{
int i30 = 3 * index0;
int i31 = 3 * index1;
int i32 = 3 * index2;
float[] normals = triangleMesh.normals.data;
state.getNormal().x = w * normals[i30 + 0] + u * normals[i31 + 0] + v * normals[i32 + 0];
state.getNormal().y = w * normals[i30 + 1] + u * normals[i31 + 1] + v * normals[i32 + 1];
state.getNormal().z = w * normals[i30 + 2] + u * normals[i31 + 2] + v * normals[i32 + 2];
if (parent != null)
state.getNormal().set(parent.transformNormalObjectToWorld(state.getNormal()));
state.getNormal().normalize();
break;
}
case ParameterList.InterpolationType.FACEVARYING:
{
int idx = 3 * tri;
float[] normals = triangleMesh.normals.data;
state.getNormal().x = w * normals[idx + 0] + u * normals[idx + 3] + v * normals[idx + 6];
state.getNormal().y = w * normals[idx + 1] + u * normals[idx + 4] + v * normals[idx + 7];
state.getNormal().z = w * normals[idx + 2] + u * normals[idx + 5] + v * normals[idx + 8];
if (parent != null)
state.getNormal().set(parent.transformNormalObjectToWorld(state.getNormal()));
state.getNormal().normalize();
break;
}
}
float uv00 = 0, uv01 = 0, uv10 = 0, uv11 = 0, uv20 = 0, uv21 = 0;
switch (triangleMesh.uvs.interp)
{
case ParameterList.InterpolationType.NONE:
case ParameterList.InterpolationType.FACE:
{
state.getUV().x = 0;
state.getUV().y = 0;
break;
}
case ParameterList.InterpolationType.VERTEX:
{
int i20 = 2 * index0;
int i21 = 2 * index1;
int i22 = 2 * index2;
float[] uvs = triangleMesh.uvs.data;
uv00 = uvs[i20 + 0];
uv01 = uvs[i20 + 1];
uv10 = uvs[i21 + 0];
uv11 = uvs[i21 + 1];
uv20 = uvs[i22 + 0];
uv21 = uvs[i22 + 1];
break;
}
case ParameterList.InterpolationType.FACEVARYING:
{
int idx = tri << 1;
float[] uvs = triangleMesh.uvs.data;
uv00 = uvs[idx + 0];
uv01 = uvs[idx + 1];
uv10 = uvs[idx + 2];
uv11 = uvs[idx + 3];
uv20 = uvs[idx + 4];
uv21 = uvs[idx + 5];
break;
}
//.........这里部分代码省略.........
示例7: prepareShadingState
public void prepareShadingState(ShadingState state)
{
state.init();
Instance i = state.getInstance();
state.getRay().getPoint(state.getPoint());
Ray r = state.getRay();
IShader s = i.getShader(0);
state.setShader(s != null ? s : this);
int primID = state.getPrimitiveID();
int hair = primID / numSegments;
int line = primID % numSegments;
int vRoot = hair * 3 * (numSegments + 1);
int v0 = vRoot + line * 3;
// tangent vector
Vector3 v = getTangent(line, v0, state.getV());
v = i.transformVectorObjectToWorld(v);
state.setBasis(OrthoNormalBasis.makeFromWV(v, new Vector3(-r.dx, -r.dy, -r.dz)));
state.getBasis().swapVW();
// normal
state.getNormal().set(0, 0, 1);
state.getBasis().transform(state.getNormal());
state.getGeoNormal().set(state.getNormal());
state.getUV().set(0, (line + state.getV()) / numSegments);
}
示例8: prepareShadingState
public void prepareShadingState(ShadingState state)
{
state.init();
state.getRay().getPoint(state.getPoint());
Instance parent = state.getInstance();
float u = state.getU();
float v = state.getV();
float[] bu = bernstein(u);
float[] bdu = bernsteinDeriv(u);
float[] bv = bernstein(v);
float[] bdv = bernsteinDeriv(v);
getPatchPoint(u, v, patches[state.getPrimitiveID()], bu, bv, bdu, bdv, new Point3(), state.getNormal());
state.getNormal().set(parent.transformNormalObjectToWorld(state.getNormal()));
state.getNormal().normalize();
state.getGeoNormal().set(state.getNormal());
state.getUV().set(u, v);
state.setShader(parent.getShader(0));
state.setModifier(parent.getModifier(0));
// FIXME: use actual derivatives to create basis
state.setBasis(OrthoNormalBasis.makeFromW(state.getNormal()));
}