本文整理汇总了C#中Effect.EndPass方法的典型用法代码示例。如果您正苦于以下问题:C# Effect.EndPass方法的具体用法?C# Effect.EndPass怎么用?C# Effect.EndPass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Effect
的用法示例。
在下文中一共展示了Effect.EndPass方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: render
/// <summary>
/// Render de quad con shader.
/// Setear previamente todos los parámetros de shader y technique correspondiente.
/// Limpiar la pantalla segun sea necesario
/// </summary>
public void render(Effect effect)
{
Device d3dDevice = GuiController.Instance.D3dDevice;
d3dDevice.VertexFormat = CustomVertex.PositionTextured.Format;
d3dDevice.SetStreamSource(0, screenQuadVB, 0);
effect.Begin(0);
effect.BeginPass(0);
d3dDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
effect.EndPass();
effect.End();
}
示例2: executeRender
public void executeRender(Effect effect)
{
Device device = GuiController.Instance.D3dDevice;
GuiController.Instance.Shaders.setShaderMatrixIdentity(effect);
//Render terrain
effect.SetValue("texDiffuseMap", terrainTexture);
device.VertexFormat = CustomVertex.PositionTextured.Format;
device.SetStreamSource(0, vbTerrain, 0);
int numPasses = effect.Begin(0);
for (int n = 0; n < numPasses; n++)
{
effect.BeginPass(n);
device.DrawPrimitives(PrimitiveType.TriangleList, 0, totalVertices / 3);
effect.EndPass();
}
effect.End();
}
示例3: render
public void render(Effect effect)
{
Device device = GuiController.Instance.D3dDevice;
GuiController.Instance.Shaders.setShaderMatrixIdentity(effect);
device.VertexFormat = CustomVertex.PositionTextured.Format;
device.SetStreamSource(0, vb, 0);
// primero dibujo los objetos opacos:
// piso de la ruta
effect.SetValue("texDiffuseMap", textura_piso);
device.RenderState.AlphaBlendEnable = false;
int numPasses = effect.Begin(0);
for (int n = 0; n < numPasses; n++)
{
effect.BeginPass(n);
device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2 * (cant_ptos_ruta - 1));
effect.EndPass();
}
effect.End();
// vegetacion
if (pos_en_ruta != -1)
{
float[] K = new float[10];
for (int i = 0; i < cant_arboles; ++i)
{
K[i] = 1;
arbol[i].Effect = effect;
arbol[i].Technique = "DefaultTechnique";
}
int[] P = new int[10];
P[0] = 11;
P[1] = 7;
P[2] = 13;
P[3] = 5;
float dr = ancho_ruta / 2;
for (int i = 0; i < cant_ptos_ruta; ++i)
{
Vector3 dir = pt_ruta[i + 1] - pt_ruta[i];
dir.Normalize();
Vector3 n = Vector3.Cross(dir, new Vector3(0, 1, 0));
Vector3 p0 = pt_ruta[i] - n * dr;
Vector3 p1 = pt_ruta[i] + n * dr;
for (int j = 0; j < cant_arboles; ++j)
{
if (i % P[j] == 0)
{
Vector3 pos = pt_ruta[i] - n * 300 * K[j];
pos.Y = 0;
arbol[j].Position = pos;
arbol[j].render();
K[j] *= -1;
}
}
}
}
// Ahora los objetos transparentes (el guarda rail, y los carteles)
// guarda rail
device.RenderState.AlphaBlendEnable = true;
GuiController.Instance.Shaders.setShaderMatrixIdentity(effect);
device.VertexFormat = CustomVertex.PositionTextured.Format;
device.SetStreamSource(0, vb, 0);
effect.SetValue("texDiffuseMap", textura_guardrail);
numPasses = effect.Begin(0);
for (int n = 0; n < numPasses; n++)
{
effect.BeginPass(n);
device.DrawPrimitives(PrimitiveType.TriangleStrip, 2 * cant_ptos_ruta, 2 * (cant_ptos_ruta - 1));
device.DrawPrimitives(PrimitiveType.TriangleStrip, 4 * cant_ptos_ruta, 2 * (cant_ptos_ruta - 1));
effect.EndPass();
}
effect.End();
// carteles
effect.SetValue("texDiffuseMap", textura_cartel);
numPasses = effect.Begin(0);
for (int n = 0; n < numPasses; n++)
{
effect.BeginPass(n);
for (int i = 0; i < cant_carteles; ++i)
device.DrawPrimitives(PrimitiveType.TriangleStrip, pos_carteles + 4 * i, 2);
effect.EndPass();
}
effect.End();
}
示例4: RenderXMeshesWithInstancing
//.........这里部分代码省略.........
foreach (SlimDX.Direct3D9.Mesh mesh in meshes.Keys)
{
device.Indices = meshes[mesh].IndexBuffer;
foreach (Texture texture in meshes[mesh].Textures.Keys)
{
bool first = true;
int numberOfInstancedDraws = 0;
DataStream ds = null;
foreach (Common.Tuple<Graphics.Content.Model9, Entity, string> renderObject in meshes[mesh].Textures[texture].RenderObjects)
{
Entity entity = renderObject.Second;
if (entity.ActiveInMain == Frame)
{
if (first)
{
MetaModel metaModel = GetLatestMetaModel(entity, renderObject.Third);
//if (Settings.PriorityRelation[metaModel.Visible] + Settings.TerrainQualityPriorityRelation[Settings.TerrainQuality] < 3)
// break;
effect.SetTexture(EHTexture, texture);
ds = optimizedVB[k % optimizedVB.Length].Lock(0, meshes[mesh].Textures[texture].RenderObjects.Count * (Vector4.SizeInBytes * 4), LockFlags.None);
if (renderObject.First.SpecularTexture != null)
effect.SetTexture(EHSpecularMap, renderObject.First.SpecularTexture);
UpdateEffectWithMetaModel(effect, metaModel, false);
effect.CommitChanges();
first = false;
}
Matrix worldMatrix;
//Matrix normalMatrix;
if (renderObject.First.SkinnedMesh != null)
{
Matrix[] storedMatrices =
GetLatestMetaModel(renderObject.Second, renderObject.Third).StoredFrameMatrices[mesh][0];
worldMatrix = storedMatrices[0];
//normalMatrix = storedMatrices.Second[0];
}
else
{
MetaModel metaModel = GetLatestMetaModel(entity, renderObject.Third);
worldMatrix = metaModel.GetWorldMatrix(Scene.Camera, renderObject.Second);
//normalMatrix = Matrix.Transpose(Matrix.Invert(worldMatrix));
}
ds.Write(worldMatrix);
//ThreeTimesThreeMatrix matrix;
//matrix.M11 = normalMatrix.M11;
//matrix.M12 = normalMatrix.M12;
//matrix.M13 = normalMatrix.M13;
//matrix.M21 = normalMatrix.M21;
//matrix.M22 = normalMatrix.M22;
//matrix.M23 = normalMatrix.M23;
//matrix.M31 = normalMatrix.M31;
//matrix.M32 = normalMatrix.M32;
//matrix.M33 = normalMatrix.M33;
//ds.Write(matrix);
numberOfInstancedDraws++;
}
}
#if RENDERER_STATISTICS
if (maxNumberOfInstancedDrawCalls < numberOfInstancedDraws)
maxNumberOfInstancedDrawCalls = numberOfInstancedDraws;
if (minNumberOfInstancedDrawCalls > numberOfInstancedDraws)
minNumberOfInstancedDrawCalls = numberOfInstancedDraws;
#endif
if (numberOfInstancedDraws == 0)
continue;
optimizedVB[k % optimizedVB.Length].Unlock();
DrawInstancedIndexedPrimitives(device, mesh, meshes[mesh].VertexBuffer, optimizedVB[k % optimizedVB.Length], instancedVertexElements,
numberOfInstancedDraws);
k++;
}
}
effect.EndPass();
effect.End();
device.SetStreamSourceFrequency(0, 1, StreamSource.IndexedData);
device.SetStreamSourceFrequency(1, 0, StreamSource.InstanceData);
device.SetStreamSource(0, null, 0, 0);
device.SetStreamSource(1, null, 0, 0);
device.ResetStreamSourceFrequency(0);
}
示例5: RenderXMeshes
private void RenderXMeshes(Dictionary<SlimDX.Direct3D9.Mesh, RenderMesh> meshes, Effect effect, Matrix viewProjection, string technique)
{
effect.Technique = technique;
effect.Begin(fx);
effect.BeginPass(0);
foreach (SlimDX.Direct3D9.Mesh mesh in meshes.Keys)
{
foreach (Texture texture in meshes[mesh].Textures.Keys)
{
effect.SetTexture(EHTexture, texture);
if (meshes[mesh].Textures[texture].RenderObjects[0].First.SpecularTexture != null)
effect.SetTexture(EHSpecularMap, meshes[mesh].Textures[texture].RenderObjects[0].First.SpecularTexture);
foreach (Common.Tuple<Graphics.Content.Model9, Entity, string> renderObject in meshes[mesh].Textures[texture].RenderObjects)
{
if (renderObject.Second.ActiveInMain == Frame)
{
Matrix worldMatrix;
MetaModel metaModel = GetLatestMetaModel(renderObject.Second, renderObject.Third);
if (renderObject.First.SkinnedMesh != null)
{
worldMatrix = metaModel.StoredFrameMatrices[mesh][0][0];
}
else
{
worldMatrix = metaModel.GetWorldMatrix(Scene.Camera, renderObject.Second);
worldMatrix = Matrix.Identity;
}
UpdateEffectWithMetaModel(effect, metaModel, false);
effect.SetValue(EHShadowWorldViewProjection, worldMatrix * ShadowMapCamera);
effect.SetValue(EHWorldViewProjectionMatrix, worldMatrix * viewProjection);
effect.SetValue(EHWorldMatrix, worldMatrix);
effect.CommitChanges();
mesh.DrawSubset(0);
}
}
}
}
effect.EndPass();
effect.End();
}
示例6: RenderSkinnedMeshes
private void RenderSkinnedMeshes(Dictionary<SkinnedMesh, RenderSkinnedMesh> skinnedMeshes, Effect effect, bool withShadows, bool hasSkinning, Matrix viewProjection, string technique)
{
effect.Technique = technique;
effect.Begin(fx);
effect.BeginPass(0);
foreach (SkinnedMesh skinnedMesh in skinnedMeshes.Keys)
{
foreach (Texture texture in skinnedMeshes[skinnedMesh].Textures.Keys)
{
bool first = true;
effect.SetTexture(EHTexture, texture);
foreach (Common.Tuple<Model9, Entity, string> renderObject in skinnedMeshes[skinnedMesh].Textures[texture].RenderObjects)
{
Entity entity = renderObject.Second;
MetaModel metaModel = GetLatestMetaModel(renderObject.Second, renderObject.Third);
//if (Settings.TerrainQualityPriorityRelation[Settings.TerrainQuality] + Settings.PriorityRelation[metaModel.Visible] < 3)
// continue;
if (first)
{
//if (Settings.TerrainQualityPriorityRelation[Settings.TerrainQuality] + Settings.PriorityRelation[metaModel.Visible] < 3)
// break;
if (skinnedMeshes[skinnedMesh].Textures[texture].RenderObjects[0].First.SpecularTexture != null && !withShadows)
effect.SetTexture(EHSpecularMap, skinnedMeshes[skinnedMesh].Textures[texture].RenderObjects[0].First.SpecularTexture);
first = false;
}
if ((!withShadows && (entity.ActiveInMain == Frame)) || (withShadows && (entity.ActiveInShadowMap == Frame) && (Settings.PriorityRelation[metaModel.CastShadows] + Settings.ShadowQualityPriorityRelation[Settings.ShadowQuality] > 3)))
{
UpdateEffectWithMetaModel(effect, metaModel, withShadows);
foreach (var SM in skinnedMesh.MeshContainers)
RenderSkinnedMesh(SM, withShadows, effect, hasSkinning, viewProjection, metaModel.StoredFrameMatrices);
}
}
}
}
effect.EndPass();
effect.End();
}