本文整理汇总了C#中Shader类的典型用法代码示例。如果您正苦于以下问题:C# Shader类的具体用法?C# Shader怎么用?C# Shader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Shader类属于命名空间,在下文中一共展示了Shader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Awake
private void Awake()
{
shaderino = Shader.Find("Custom/Autofade");
DontDestroyOnLoad(this);
m_Instance = this;
m_Material = new Material(shaderino);
}
示例2: Start
void Start()
{
_velCam = GameObject.FindGameObjectWithTag("VelocityCamera").GetComponent<VelocityCamera>();
_defaultShader = renderer.material.shader;
if(_velCam != null)
_velCam.AddToRenderList(this);
}
示例3: Mesh
/// <summary>
/// Create a new mesh for the given client using shader as the default shader
/// </summary>
/// <param name="client"></param>
/// <param name="shader"></param>
public Mesh(Client client, Shader shader)
{
Client = client;
Shader = shader;
Id = CSycles.scene_add_mesh(Client.Id, Client.Scene.Id, Client.Scene.GetShaderSceneId(shader));
}
示例4: CheckShaderAndCreateMaterial
// Unity StandardAssets.ImageEffect
protected Material CheckShaderAndCreateMaterial(Shader s, Material m2Create)
{
if (!s)
{
Debug.Log("Missing shader in " + ToString());
enabled = false;
return null;
}
if (s.isSupported && m2Create && m2Create.shader == s)
return m2Create;
/*
if (!s.isSupported)
{
NotSupported();
Debug.Log("The shader " + s.ToString() + " on effect " + ToString() + " is not supported on this platform!");
return null;
}
*/
m2Create = new Material(s);
// createdMaterials.Add(m2Create);
m2Create.hideFlags = HideFlags.DontSave;
return m2Create;
}
示例5: ParticleSimulator
public ParticleSimulator()
{
rand = new Random();
randomTextures = new Texture2D[3];
int randSize = 64;
float[] randData = new float[randSize * randSize];
for (int i = 0; i < randomTextures.Length; i++)
{
randomTextures[i] = new Texture2D(GFX.Device, randSize, randSize, 1, TextureUsage.None, SurfaceFormat.Single);
for (int j = 0; j < randData.Length; j++)
{
randData[j] = (float)(rand.NextDouble() * 2.0 - 1.0);
}
randomTextures[i].SetData<float>(randData);
}
updatePhysicsShader = new Shader();
updatePhysicsShader.VSTarget = 2;
updatePhysicsShader.PSTarget = 3;
updatePhysicsShader.CompileFromFiles("Shaders/Simulation/ParticlePhysicsP.hlsl", "Shaders/Simulation/ParticlesV.hlsl");
updateColorShader = new Shader();
updateColorShader.VSTarget = 2;
updateColorShader.PSTarget = 3;
updateColorShader.CompileFromFiles("Shaders/Simulation/ParticleColorsP.hlsl", "Shaders/Simulation/ParticlesV.hlsl");
updateSizeShader = new Shader();
updateSizeShader.VSTarget = 2;
updateSizeShader.PSTarget = 3;
updateSizeShader.CompileFromFiles("Shaders/Simulation/ParticleSizeP.hlsl", "Shaders/Simulation/ParticlesV.hlsl");
}
示例6: onFlightStart
protected override void onFlightStart()
{
ping = gameObject.AddComponent<AudioSource>();
WWW www = new WWW("file://" + KSPUtil.ApplicationRootPath.Replace("\\", "/") + "Parts/mumech_MuonDetector/ping.wav");
if ((ping != null) && (www != null))
{
ping.clip = www.GetAudioClip(false);
ping.volume = 0;
ping.Stop();
}
disk = transform.Find("model/disk");
if (disk != null)
{
MIN_PING_DIST = 150000;
MIN_PING_TIME = 0.2;
MAX_PING_TIME = 15;
led = transform.Find("model/led");
originalLensShader = led.renderer.material.shader;
pingLight = led.gameObject.AddComponent<Light>();
pingLight.type = LightType.Point;
pingLight.renderMode = LightRenderMode.ForcePixel;
pingLight.shadows = LightShadows.None;
pingLight.range = 1;
pingLight.enabled = false;
}
RenderingManager.AddToPostDrawQueue(3, new Callback(drawGUI));
}
示例7: UpdateColors
public void UpdateColors(Color[] colors)
{
Color newLowColor = colors[0];
Color newMediumColor = colors[1];
Color newHighColor = colors[2];
if (m_Materials == null || m_Materials.Length == 0 ||
m_Materials[0].GetColor("_TintColor") != newLowColor ||
m_Materials[1].GetColor("_TintColor") != newMediumColor ||
m_Materials[2].GetColor("_TintColor") != newHighColor)
{
m_Shader = Shader.Find("Heatmaps/Particles/AlphaBlend");
m_Materials = new Material[3];
m_Materials[0] = new Material(m_Shader);
m_Materials[0].SetColor("_TintColor", newLowColor);
m_Materials[1] = new Material(m_Shader);
m_Materials[1].SetColor("_TintColor", newMediumColor);
m_Materials[2] = new Material(m_Shader);
m_Materials[2].SetColor("_TintColor", newHighColor);
m_RenderState = k_UpdateMaterials;
}
}
示例8: Model
public Model(int triangles, VertexArray mesh)
: base()
{
this.mesh = mesh;
this.triangles = triangles;
this.shader = ShaderLibrary.Get("basic");
}
示例9: Initialize
public static void Initialize(){
OutlineEnemy = Resources.Load<Material>("Materials/OutlineEnemy");
OutlineEnemyLock = Resources.Load<Material>("Materials/OutlineEnemyLock");
OutlineAlly = Resources.Load<Material>("Materials/OutlineAlly");
OutlineTarget = Resources.Load<Material>("Materials/OutlineTarget");
OutlineShader = OutlineTarget.shader;
}
示例10: Start
public override void Start()
{
base.Start(); // Make sure to call this first
mShader = Shader.Find("Transparent/Diffuse");
mLargeItemSlotTransform = new Vector3(1.782f, .1f, -0.151f);
mLargeItemSlotScale = new Vector3(0.4f, 1f, 0.6f);
mSmallItemSlotTransform = new Vector3(-3.35f, .1f, 2.20f);
mSmallItemSlotScale = new Vector3(0.20f, 1f, 0.35f);
if (Inventory.Instance == null)
{
BuildOk = false;
//Debug.LogError("Inventory is null from UIInventoryDisplay()");
}
else
{
BuildOk = SetupPlanes();
}
if (BuildOk == false )
{
Debug.LogError("UIInventoryDisplay not set up properly.");
}
}
示例11: Start
// Use this for initialization
void Start()
{
trans = gameObject.GetComponent<Transform> ();
shad = gameObject.GetComponent<Shader> ();
rend = gameObject.GetComponent<Renderer> ();
source = gameObject.GetComponent<AudioSource> ();
}
示例12: setupMatrices
protected override void setupMatrices(ref ViewInfo curView, ref Shader shader, ref Mesh curMesh)
{
base.setupMatrices(ref curView, ref shader, ref curMesh);
shader.insertUniform(Shader.Uniform.rotation_matrix2, ref orientation2);
shader.insertUniform(Shader.Uniform.model_matrix2, ref modelMatrix2);
}
示例13: OnLoad
protected override void OnLoad(EventArgs e)
{
ColladaXML daeReader = new ColladaXML("collada_schema_1_4.xsd");
Console.WriteLine("Parsing File...");
daeReader.Parse(Paths.ModelPath + "face.dae");
mesh = daeReader.Mesh.Elements[2];
mesh.CreateGPUBuffers();
GL.ClearColor(Color4.Wheat);
GL.Enable(EnableCap.CullFace);
GL.Enable(EnableCap.DepthTest);
GL.DepthFunc(DepthFunction.Lequal);
GL.CullFace(CullFaceMode.Back);
shader = new Shader("hello-gl.v.glsl", "hello-gl.f.glsl");
GL.GenBuffers(1, out buf);
GL.BindBuffer(BufferTarget.ArrayBuffer, buf);
GL.BufferData(BufferTarget.ArrayBuffer, new IntPtr(mesh.VertexBuffer.Length * sizeof(float)), mesh.VertexBuffer, BufferUsageHint.StaticDraw);
GL.GenBuffers(2, out buf2);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, buf2);
GL.BufferData(BufferTarget.ElementArrayBuffer, new IntPtr(mesh.IndexBuffer.Length * sizeof(ushort)), mesh.IndexBuffer, BufferUsageHint.StaticDraw);
CreateShaders();
mouseX = X + (Width / 2);
mouseY = Y + (Height / 2);
CursorVisible = false;
OpenTK.Input.Mouse.SetPosition((double)mouseX, (double)mouseY);
lastState = OpenTK.Input.Mouse.GetState();
CursorVisible = false;
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
base.OnLoad (e);
}
示例14: TerrainGenerator
public TerrainGenerator()
{
histogramShader = new Shader();
histogramShader.CompileFromFiles("Shaders/Procedural/Histogram2D.hlsl", "Shaders/PostProcess/GenericV.hlsl");
interpolateShader = new Shader();
interpolateShader.CompileFromFiles("Shaders/Procedural/Interpolate2D.hlsl", "Shaders/Procedural/GenericTransformV.hlsl");
peakShader = new Shader();
peakShader.CompileFromFiles("Shaders/Procedural/PeakP.hlsl", "Shaders/Procedural/GenericTransformV.hlsl");
gradientShader = new Shader();
gradientShader.CompileFromFiles("Shaders/Procedural/Gradient2DP.hlsl", "Shaders/PostProcess/GenericV.hlsl");
terraceShader = new Shader();
terraceShader.CompileFromFiles("Shaders/Procedural/TerraceP.hlsl", "Shaders/PostProcess/GenericV.hlsl");
basicShader = new Shader();
basicShader.CompileFromFiles("Shaders/PostProcess/GenericP.hlsl", "Shaders/PostProcess/GenericV.hlsl");
varianceShader = new Shader();
varianceShader.CompileFromFiles("Shaders/Procedural/Variance2DP.hlsl", "Shaders/PostProcess/GenericV.hlsl");
whiteTexture = new Texture2D(GFX.Device, 1, 1, 1, TextureUsage.None, SurfaceFormat.Color);
Color[] whiteData = new Color[1] { Color.White };
whiteTexture.SetData<Color>(whiteData);
}
示例15: Create
//TODO: NEED REFINE SHOW & HIDE, FADEOUT-IN
public static Plane Create(string name, Shader shader, Texture texture)
{
GameObject planeObject = new GameObject(name);
Plane retPlane = planeObject.AddComponent<Plane>();
retPlane.Init(shader, texture);
return retPlane;
}