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); }
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); }
/// <summary> /// Constructor to use when a mesh that already exists in Cycles needs to be represented. /// </summary> /// <param name="client"></param> /// <param name="id"></param> /// <param name="shader"></param> internal Mesh(Client client, uint id, Shader shader) { Client = client; Shader = shader; Id = id; }
public virtual Material CheckShaderAndCreateMaterial(Shader s, Material m2Create) { if (!(bool)((Object)s)) { Debug.Log("Missing shader in " + this.ToString()); this.enabled = false; return (Material)null; } else { if (s.isSupported && (bool)((Object)m2Create) && (Object)m2Create.shader == (Object)s) return m2Create; if (!s.isSupported) { this.NotSupported(); Debug.LogError("The shader " + s.ToString() + " on effect " + this.ToString() + " is not supported on this platform!"); return (Material)null; } else { m2Create = new Material(s); m2Create.hideFlags = HideFlags.DontSave; if ((bool)((Object)m2Create)) return m2Create; else return (Material)null; } } }
private void Awake() { shaderino = Shader.Find("Custom/Autofade"); DontDestroyOnLoad(this); m_Instance = this; m_Material = new Material(shaderino); }
/// <summary> /// add the texture to the game object and his child /// </summary> public void AddTexture() { normal = Shader.Find("Diffuse"); transparent = Shader.Find("Transparent/Diffuse"); data = ToolBox.Instance.data; if (fileName != null && data.mtl.ContainsKey(fileName)) { ReadMtl(data.mtl[fileName]); foreach (KeyValuePair<string, string> mat in matNameFile) { if (meshes.ContainsKey(mat.Key)) { Material material; if (matNameColor[mat.Key].a < 1) { material = new Material(transparent); } else { material = new Material(normal); } material.color = matNameColor[mat.Key]; if (data.textures.ContainsKey(mat.Value)) { material.mainTexture = data.textures[mat.Value]; } foreach (GameObject g in meshes[mat.Key]) { g.GetComponent<Renderer>().material = material; } } } } }
/// <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)); }
void Awake() { if (camera==null) { Debug.LogError("SetupForGrassRendering script (at "+gameObject.name+") - can't find camera component !"); return; } if ((useCustomDepthShader) && (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth))) { shad=Shader.Find("GrassRenderDepth"); // our simple depth rendering shader (rely on native z-depth buffer and don't render into color channels) } else { shad=Shader.Find("Hidden/Camera-DepthTexture"); // unity's render depth - probably slower as it renders everything into color buffer } if (!shad) { // we've got no shader ? Make simple one (handles native z-buffer for Opaque RenderType only) Material mat=new Material("Shader \"RenderDepth\" {SubShader { Tags { \"RenderType\"=\"Opaque\"} \n Pass { ColorMask 0 }}}"); shad=mat.shader; } SetupTexture(); GameObject go=new GameObject("GrassDepthCamera"); go.AddComponent(typeof(Camera)); go.transform.parent=transform; myCam=go.camera; SetupParams(); teleportTresholdSqr = teleportTreshold * teleportTreshold; }
void Start() { _velCam = GameObject.FindGameObjectWithTag("VelocityCamera").GetComponent<VelocityCamera>(); _defaultShader = renderer.material.shader; if(_velCam != null) _velCam.AddToRenderList(this); }
public bool AddShaderToProgram(Shader addMe) { if (!addMe.IsLoaded())//sejker nie je nacitany return false; GL.AttachShader(ProgramHandle, addMe.GetShaderHandle()); return true; }
// Use this for initialization void Start () { doorFrameRenderer = doorFrame.GetComponent<MeshRenderer> (); doorRenderer = door.GetComponent<MeshRenderer> (); originalFrameShader = doorFrameRenderer.material.shader; originalDoorShader = doorRenderer.material.shader; }
public Sprite(string textureName, Vector3 pos, Vector3 rot, Vector3 s) { vbo = new VBO(); vao = new VAO(); ebo = new EBO(); texture = TextureManager.GetTextureID(textureName); shader = new Shader(System.IO.File.ReadAllText("Shaders/Sprite/sprite_vert.glsl"), System.IO.File.ReadAllText("Shaders/Sprite/sprite_frag.glsl")); position = pos; rotation = rot; scale = s / 0.5f; float[] vertices = { // Positions // Normals // Texture Coords 0.5f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, // Top Right 0.5f, -0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, // Bottom Right -0.5f, -0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, // Bottom Left -0.5f, 0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f // Top Left }; uint[] indices = { 0, 3, 2, 2, 1, 0 }; vao.Enable(); vbo.BufferData(vertices); ebo.BufferData(indices); vao.Disable(); }
// 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; }
// Use this for initialization void Start() { transShader = Shader.Find ("Transparent/Cutout/Diffuse"); trans = new Color (0, 0, 0, 0); trees = FindObjectsOfType<Tree> (); }
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)); }
protected override void CreateShaderFromFile(string name, string vertShader, string fragShader) { Shader shader = new Shader(); shader.Name = name; //Initialize the OpenGL Program shader.ProgramId = GL.CreateProgram(); int vertShaderId, fragShaderId; LoadShader(vertShader, ShaderType.VertexShader, shader.ProgramId, out vertShaderId); LoadShader(fragShader, ShaderType.FragmentShader, shader.ProgramId, out fragShaderId); //Deincriment the reference count on the shaders so that they //don't exist until the context is destroyed. GL.DeleteShader(vertShaderId); GL.DeleteShader(fragShaderId); GL.BindAttribLocation(shader.ProgramId, (int)ShaderAttributeIds.Position, "vertexPos"); GL.BindAttribLocation(shader.ProgramId, (int)ShaderAttributeIds.Color, "inColor"); GL.BindAttribLocation(shader.ProgramId, (int)ShaderAttributeIds.TexCoord, "vertexUV"); //Link shaders GL.LinkProgram(shader.ProgramId); shader.UniformMVP = GL.GetUniformLocation(shader.ProgramId, "modelview"); shader.UniformColor = GL.GetUniformLocation(shader.ProgramId, "inColor"); if (GL.GetError() != ErrorCode.NoError) Console.WriteLine(GL.GetProgramInfoLog(shader.ProgramId)); _shaders.Add(name, shader); }
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"); }
internal ShaderPassCollection(DeviceContext context, Shader shader, ShaderTechnique technique) { _passes = new ShaderPass[technique.PassCount]; for (int i = 0; i < _passes.Length; i++) _passes[i] = new ShaderPass(context, shader, shader.Effect.GetPass(technique.Handle, i), i); }
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); }
//Mono Methods// void Awake() { //Set the appropriate replacement shader shader = Shader.Find("Aubergine/Replacement/Holographic_v2"); //Set Holographic texture Shader.SetGlobalTexture("_HoloTex", holoTex); }
public override void AddShader(int id, string code, Shader.ShaderTypes type) { ShaderType stype = ShaderType.VertexShader; if (type == Shader.ShaderTypes.Vertex) stype = ShaderType.VertexShader; else if (type == Shader.ShaderTypes.Fragment) stype = ShaderType.FragmentShader; else if (type == Shader.ShaderTypes.Geometry) stype = ShaderType.GeometryShader; else if (type == Shader.ShaderTypes.TessControl) stype = ShaderType.TessControlShader; else if (type == Shader.ShaderTypes.TessEval) stype = ShaderType.TessEvaluationShader; int shader = GL.CreateShader(stype); if (shader == 0) { throw new Exception("Error creating shader.\n\tShader type: " + type + "\n\tCode: " + code); } GL.ShaderSource(shader, code); GL.CompileShader(shader); GL.AttachShader(id, shader); int status = -1; string info = ""; GL.GetShaderInfoLog(shader, out info); GL.GetShader(shader, ShaderParameter.CompileStatus, out status); if (status != 1) { Console.WriteLine("Shader compiler error!\nType: " + type.ToString() + "\nName: " + this.GetType().ToString() + "\n\n"/* + "Source code:\n" + code + "\n\n"*/ + info + "\n" + "Status Code: " + status.ToString()); } }
//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; }
public static void Main() { ClutterRun.Init (); Stage stage = Stage.Default; stage.SetSize(512, 384); Shader shader = new Shader (); shader.FragmentSource = shader_sources[current_shader]; shader.Compile (); stage.Title = "Shader Test"; stage.Color = new Clutter.Color (0x61, 0x64, 0x8c, 0xff); Timeline timeline = new Timeline(360, 60); timeline.Loop = true; stage.AddActor (new Label ("Mono 16", "Press the Hand")); Texture actor = new Texture("redhand.png"); actor.SetShader (shader); actor.Reactive = true; actor.ButtonPressEvent += HandleActorButtonPress; stage.AddActor (actor); actor.SetShaderParam("brightness", 0.4f); actor.SetShaderParam("contrast", -1.9f); actor.SetPosition (0, 20); stage.ShowAll (); timeline.Start (); ClutterRun.Main (); }
public EquipFXUILogicManager() { AssetCacheMgr.GetUIResource("FlowLightShaderWithTwirl.shader", (obj) => { m_shaderFlowLight = (Shader)obj; }); AssetCacheMgr.GetUIResource("PlayerShader.shader", (obj) => { m_playerShader = (Shader)obj; }); foreach (var item in EquipSpecialEffectData.dataMap) { if (item.Value.group == 1) { ++JewelFXNum; } else if (item.Value.group == 2) { ++EquipFXNum; } else if (item.Value.group == 3) { ++StrenthFXNum; } } Mogo.Util.EventDispatcher.AddEventListener<int, int>("EquipFXUIActiveBtnUp", OnActiveBtnUp); Mogo.Util.EventDispatcher.AddEventListener<byte,byte>("ActiveSepciaclEffectsResp", OnActiveFXResp); }
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; } }
public Model(int triangles, VertexArray mesh) : base() { this.mesh = mesh; this.triangles = triangles; this.shader = ShaderLibrary.Get("basic"); }
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; }
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."); } }
public void Init(Shader shader, Texture texture) { if (shader == null) { shader = Shader.Find("submarine/Planes/Normal"); } if (shader == null) { shader = Shader.Find("Unlit/Texture"); } base.Init(shader); Renderer rdr = gameObject.GetComponent<MeshRenderer>(); if (rdr.sharedMaterial != null) { if (texture != null) { rdr.sharedMaterial.mainTexture = texture; ReinitMesh(); } //todo: need default texture //else //{ //} } }
// Use this for initialization void Start() { trans = gameObject.GetComponent<Transform> (); shad = gameObject.GetComponent<Shader> (); rend = gameObject.GetComponent<Renderer> (); source = gameObject.GetComponent<AudioSource> (); }
public static string GetPropertyDescription(Shader s, int propertyIdx) { CheckPropertyIndex(s, propertyIdx); return(GetPropertyDescriptionImpl(s, propertyIdx)); }
extern internal static int GetLOD(Shader s);
[NativeName("GetPropertyDescription")] extern private static string GetPropertyDescriptionImpl([NotNull] Shader s, int propertyIdx);
[NativeName("GetShaderPropertyAttributes")] extern private static string[] GetShaderPropertyAttributesImpl([NotNull] Shader s, int propertyIdx);
[NativeName("IsShaderPropertyNonModifiableTexureProperty")] extern private static bool IsShaderPropertyNonModifiableTexurePropertyImpl([NotNull] Shader s, int propertyIdx);
public static bool IsShaderPropertyHidden(Shader s, int propertyIdx) { CheckPropertyIndex(s, propertyIdx); return(IsShaderPropertyHiddenImpl(s, propertyIdx)); }
[NativeName("IsShaderPropertyHidden")] extern private static bool IsShaderPropertyHiddenImpl([NotNull] Shader s, int propertyIdx);
public static TextureDimension GetTexDim(Shader s, int propertyIdx) { CheckPropertyIndex(s, propertyIdx); return(GetTexDimImpl(s, propertyIdx)); }
[NativeName("GetTexDim")] extern private static TextureDimension GetTexDimImpl([NotNull] Shader s, int propertyIdx);
[NativeName("GetRangeLimits")] extern private static float GetRangeLimitsImpl([NotNull] Shader s, int propertyIdx, int defminmax);
[NativeName("GetPropertyType")] extern private static ShaderPropertyType GetPropertyTypeImpl([NotNull] Shader s, int propertyIdx);
[NativeName("GetPropertyName")] extern private static string GetPropertyNameImpl([NotNull] Shader s, int propertyIdx);
public static string GetPropertyName(Shader s, int propertyIdx) { CheckPropertyIndex(s, propertyIdx); return(GetPropertyNameImpl(s, propertyIdx)); }
public static ShaderPropertyType GetPropertyType(Shader s, int propertyIdx) { CheckPropertyIndex(s, propertyIdx); return(GetPropertyTypeImpl(s, propertyIdx)); }
extern public static void ClearShaderMessages([NotNull] Shader s);
extern public static int GetShaderMessageCount([NotNull] Shader s);
extern public static ShaderMessage[] GetShaderMessages([NotNull] Shader s);
[FreeFunction] extern private static int FindShaderPropertyIndex([NotNull] Shader s, string name);
extern public static int GetPropertyCount([NotNull] Shader s);
extern internal static int GetRenderQueue([NotNull] Shader s);
extern internal static bool HasTangentChannel([NotNull] Shader s);
extern internal static void FetchCachedMessages([NotNull] Shader s);
extern internal static bool HasShadowCasterPass([NotNull] Shader s);
extern internal static bool HasInstancing([NotNull] Shader s);
extern internal static bool HasProceduralInstancing([NotNull] Shader s);
extern internal static bool DoesIgnoreProjector([NotNull] Shader s);
extern static public void ClearCachedData([NotNull] Shader s);
extern internal static int GetTextureSamplerBindingIndex(Shader s, int texturePropertyID);
public static bool IsShaderPropertyNonModifiableTexureProperty(Shader s, int propertyIdx) { CheckPropertyIndex(s, propertyIdx); return(IsShaderPropertyNonModifiableTexurePropertyImpl(s, propertyIdx)); }
extern internal static bool HasShaderSnippets([NotNull] Shader s);