本文整理汇总了C#中Effect.SetTexture方法的典型用法代码示例。如果您正苦于以下问题:C# Effect.SetTexture方法的具体用法?C# Effect.SetTexture怎么用?C# Effect.SetTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Effect
的用法示例。
在下文中一共展示了Effect.SetTexture方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadShaderTextures
private static shader LoadShaderTextures(Effect effect)
{
try { effect.SetTexture("thisframe", thisFrame); } catch { } //throws an exception if this parameter doesn't exist :(
try { effect.SetTexture("lastpass", lastPass); } catch { }
try { effect.SetTexture("lastshader", lastShader); } catch { }
try { effect.SetTexture("depthframe", depthFrame); } catch { }
try { effect.SetValue("rcpres", new Vector4(1.0f/1024.0f, 1.0f/1024.0f, 0, 1)); } catch { }
try { effect.SetValue("HDR", new Vector4(0.5f, 0.5f, 0.5f, 0.5f)); } catch { }
int count=1;
while(true) {
string texpath;
try { texpath=effect.GetString("texname"+count.ToString()); } catch { break; }
if(texpath!=null) {
try {
Texture tex=Texture.FromFile(DXMain.device, Statics.runDir + "\\data files\\textures\\"+texpath);
effect.SetTexture("tex"+count.ToString(), tex);
} catch { }
} else break;
count++;
}
shader s = new shader();
try {
s.ehTime = effect.GetParameter(null, "time");
} catch {
s.ehTime = null;
}
try {
s.ehHDR = effect.GetParameter(null, "HDR");
} catch {
s.ehHDR = null;
}
s.effect=effect;
return s;
}
示例2: LoadShaderTextures
private static shader LoadShaderTextures(Effect effect) {
try { effect.SetTexture("lastpass", lastPass); } catch { } //throws an exception if this parameter doesn't exist :(
try { effect.SetTexture("lastshader", lastShader); } catch { }
try { effect.SetTexture("depthframe", depthFrame); } catch { }
try { effect.SetValue("rcpres", new Vector4(1f/frameWidth, 1f/frameHeight, 0, 1)); } catch { }
try { effect.SetValue("fov", 85f); } catch { }
try { effect.SetValue("fogstart", 819.2f); } catch { }
try { effect.SetValue("fogrange", 65536.0f); } catch { }
try { effect.SetValue("waterlevel", 0f); } catch { }
try { effect.SetValue("HDR", new Vector4(0.25f, 0.25f, 0.25f, 02.5f)); } catch { }
try { effect.SetValue("eyepos", new Vector3(0f, 0f, 128f)); } catch { }
try { effect.SetValue("eyevec", new Vector3(1f, 0f, 0f)); } catch { }
int count=1;
while(true) {
string texpath;
try { texpath=effect.GetString("texname"+count.ToString()); } catch { break; }
if(texpath!=null) {
try {
Texture tex=Texture.FromFile(DXMain.device, Statics.runDir + "\\data files\\textures\\"+texpath);
effect.SetTexture("tex"+count.ToString(), tex);
} catch { }
} else break;
count++;
}
shader s = new shader();
try {
s.ehTime = effect.GetParameter(null, "time");
} catch {
s.ehTime = null;
}
try {
s.ehHDR = effect.GetParameter(null, "HDR");
} catch {
s.ehHDR = null;
}
s.effect=effect;
return s;
}
示例3: 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();
}
示例4: RenderXMeshesWithInstancing
private void RenderXMeshesWithInstancing(Dictionary<SlimDX.Direct3D9.Mesh, RenderMesh> meshes, Device device, Effect effect, string technique)
{
effect.Technique = technique;
effect.Begin(fx);
effect.BeginPass(0);
int k = 0;
device.VertexFormat = VertexFormat.None;
device.VertexDeclaration = vd;
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++;
//.........这里部分代码省略.........
示例5: 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();
}