public void BindShadowMap(BindableContainer a_bindableContainer) { if (m_shadowBuffer != null) { int mapCount = m_light.MapCount; for (int i = 0; i < mapCount; ++i) { GL.ActiveTexture(TextureUnit.Texture0 + a_bindableContainer.Textures); GL.BindTexture(TextureTarget.Texture2D, m_shadowMap[i]); GL.Uniform1(16 + i, a_bindableContainer.Textures++); Matrix4 view = m_light.GetView(i); Matrix4 proj = m_light.GetProjection(i); Matrix4 viewProj = view * proj; GL.UniformMatrix4(32 + i, false, ref viewProj); GL.Uniform1(48 + i, m_splits[i + 1]); } } #if DEBUG_INFO Pipeline.GLError("Directional Light: Bind Shadow Map: "); #endif }
public void Bind(BindableContainer a_container, Binding a_binding) { if (a_binding.Handle != -1) { GL.Uniform1(a_binding.Handle, m_value); } }
public void RemoveAtbindableObjects(BindableContainer refer, int index) { // List<Binding> bindableObjects = new List<Binding> (refer.bindableObjects); var children = refer.children; children.RemoveAt(index); // bindableObjects.RemoveAt (index); // refer.bindableObjects = bindableObjects.ToArray (); }
void LightingPass(MultiRenderTexture a_renderTexture) { GL.Disable(EnableCap.DepthTest); // GL.Disable(EnableCap.Blend); GL.Enable(EnableCap.Blend); // GL.BlendFunc(BlendingFactor.One, BlendingFactor.One); foreach (Light light in Light.LightList) { if (light.Draw) { UniformBufferObject ubo = m_graphics.LightBufferObject; Material material = light.BindLightDrawing(); ubo.UpdateData(light.GetLightData()); BindCamera(); BindTransform(light.Transform.ToMatrix(), light.Transform.RotationMatrix); BindableContainer cont = BindMaterial(material); GL.ActiveTexture(TextureUnit.Texture0 + cont.Textures); GL.BindTexture(TextureTarget.Texture2D, ((OpenTKTexture)a_renderTexture.RenderTextures[0].InternalObject).Handle); GL.Uniform1(0, cont.Textures++); GL.ActiveTexture(TextureUnit.Texture0 + cont.Textures); GL.BindTexture(TextureTarget.Texture2D, ((OpenTKTexture)a_renderTexture.RenderTextures[1].InternalObject).Handle); GL.Uniform1(1, cont.Textures++); GL.ActiveTexture(TextureUnit.Texture0 + cont.Textures); GL.BindTexture(TextureTarget.Texture2D, ((OpenTKTexture)a_renderTexture.RenderTextures[2].InternalObject).Handle); GL.Uniform1(2, cont.Textures++); GL.ActiveTexture(TextureUnit.Texture0 + cont.Textures); GL.BindTexture(TextureTarget.Texture2D, ((OpenTKTexture)m_renderTarget.DepthBuffer.InternalObject).Handle); GL.Uniform1(3, cont.Textures++); ubo.UpdateBuffer(); GL.BindBufferBase(BufferRangeTarget.UniformBuffer, Material.LightUBOIndex, ((OpenTKUniformBufferObject)ubo.InternalObject).Handle); light.BindShadowMap(cont); GL.DrawArrays(PrimitiveType.TriangleStrip, 0, 4); #if DEBUG_INFO Pipeline.GLError("Graphics: Lighting: "); #endif } } GL.Disable(EnableCap.Blend); GL.Enable(EnableCap.DepthTest); }
protected void OnItemRender(object obj1, object obj2, int index) { BindableContainer item = (BindableContainer)obj2; if (item != null) { item.forceContextChanged = true; item.context = items[index]; } }
public void AddbindableObjects(BindableContainer refer, UnityEngine.Component obj) { if (refer.children == null) //需要新增加 { List <Binding> bindings = new List <Binding>(); refer.children = new List <BindableObject>(); // bindings.ToArray (); } var children = refer.children; BindableObject bindable = null; if (obj is BindableObject) { bindable = obj as BindableObject; } else { if (bindable == null) { Component[] allcomps = obj.GetComponents <Component>(); //默认绑定最后一个组件 Component target = null; int index = 0; int tpId = -1; foreach (var comp in allcomps) { if (comp is BindableObject) { bindable = (BindableObject)comp; break; } else if ((index = BinderCheckTypes.IndexOf(comp.GetType())) >= 0) { target = comp; tpId = index; } } if (bindable == null) { Type createBinderType = typeof(Hugula.Databinding.BindableObject); if (tpId >= 0) { createBinderType = BinderCreateTypes[tpId]; } bindable = (BindableObject)obj.gameObject.AddComponent(createBinderType); } } } if (children.IndexOf(bindable) < 0) { refer.AddChild(bindable); } }
protected void OnItemRender(object obj1, object obj2, int index) { BindableContainer item = (BindableContainer)obj2; if (item != null) { item.SetParent(this); //设置上下文关系利用source表达式 parent.context把事件绑定到父级context item.forceContextChanged = true; item.context = items[index]; } }
BindableContainer BindMaterial(Material a_material) { BindableContainer cont = new BindableContainer(); foreach (Binding bind in a_material.Bindings) { bind.Target.Bind(cont, bind); } return(cont); }
public void Bind(BindableContainer a_container, Binding a_binding) { OpenTKProgram program = (OpenTKProgram)a_binding.Program.InternalObject; int handle = program.Handle; GL.UniformBlockBinding(handle, a_binding.Handle, Material.EndUBOIndex + a_container.UniformBufferObjects); GL.BindBufferBase(BufferRangeTarget.UniformBuffer, Material.EndUBOIndex + a_container.UniformBufferObjects++, m_handle); #if DEBUG_INFO Pipeline.GLError("Graphics: Binding Material UBO: "); #endif }
private void InitIoC() { IKernel kernel = new StandardKernel(); Resolver = new DependencyResolver(kernel); InitCoreDependencies(kernel); IBinableContainder binableContainder = new BindableContainer(kernel); BaseDependencyBinder.BindBaseDependencies(binableContainder); kernel.Bind<CompositionContainer>().ToConstant(CreateCompositionContainer()); kernel.Bind<IExtensionsLoader>().To<ExtensionsLoader>().InSingletonScope(); }
public void AddbindableObjects(BindableContainer refer, UnityEngine.Component obj) { if (refer.children == null) //需要新增加 { List <Binding> bindings = new List <Binding>(); refer.children = new List <BindableObject>(); // bindings.ToArray (); } var children = refer.children; BindableObject bindable = null; if (obj is BindableObject) { bindable = obj as BindableObject; } else { if (bindable == null) { Component[] allcomps = obj.GetComponents <Component>(); //默认绑定最后一个组件 Component target = null; Type addType = typeof(Hugula.Databinding.BindableObject); Type findType; foreach (var comp in allcomps) { if (comp is BindableObject) { bindable = (BindableObject)comp; break; } else if ((findType = BindalbeObjectUtilty.FindBinderType(comp.GetType())) != null) { target = comp; addType = findType; } } if (bindable == null) { bindable = (BindableObject)obj.gameObject.AddComponent(addType); } } } if (bindable != null && children.IndexOf(bindable) < 0) { refer.AddChild(bindable); } }
void SetBindingProperties(BindableContainer refer, int i) { BindingPropertiesStyle.fontStyle = FontStyle.Italic; BindingPropertiesStyle.fontSize = 10; BindingPropertiesStyle.alignment = TextAnchor.UpperLeft; // BindingPropertiesStyle. var binding = GetbindableObjects(refer, i); if (binding != null) { // BindableExpression.Expression (binding, i); // EditorGUILayout.LabelField (new GUIContent ("expression:"), BindingPropertiesStyle,GUILayout.Width(55)); // EditorGUILayout.EndHorizontal (); } }
// public void RemoveAtbindableObjects(BindableContainer refer, int index) // { // var children = refer.children; // children.RemoveAt(index); // } public void AddHierarchyChildren(Transform transform, BindableContainer container, bool checkChildren = false) { var children = transform.GetComponents <BindableObject>(); var oldChildren = container.children; if (oldChildren == null) { oldChildren = new List <BindableObject>(); container.children = oldChildren; } bool needDeep = true; bool isSelf = false; foreach (var child in children) { isSelf = System.Object.Equals(child, container); if (oldChildren.IndexOf(child) == -1 && !isSelf) { container.AddChild(child); } if (!isSelf && (child is BindableContainer || child is LoopScrollRectBinder || child is LoopVerticalScrollRectBinder || child is CollectionViewBinder)) //如果遇到容器不需要遍历 { needDeep = false; } } if (needDeep) { for (int i = 0; i < transform.childCount; i++) { AddHierarchyChildren(transform.GetChild(i), container); } } }
public void AddHierarchyChildren(Transform transform, BindableContainer container, bool checkChildren = false) { var children = transform.GetComponents <BindableObject>(); var oldChildren = container.children; if (oldChildren == null) { oldChildren = new List <BindableObject>(); container.children = oldChildren; } bool needDeep = true; foreach (var child in children) { if (oldChildren.IndexOf(child) == -1 && !System.Object.Equals(child, container)) { container.AddChild(child); } if (child is BindableContainer && !checkChildren) //如果遇到容器不需要遍历 { needDeep = false; } } if (needDeep) { for (int i = 0; i < transform.childCount; i++) { AddHierarchyChildren(transform.GetChild(i), container); } } }
public void AddbindableObjects(BindableContainer refer, UnityEngine.Component obj) { if (refer.children == null) //需要新增加 { List <Binding> bindings = new List <Binding> (); // if (refer.bindableObjects != null) bindings.AddRange (refer.bindableObjects); // if (i == -1) i = bindings.Count; // while (bindings.Count <= i) // bindings.Add (new Binding () { expression = @"{}" }); refer.children = new List <BindableObject> (); // bindings.ToArray (); // Debug.Log (bindings.Count); } var children = refer.children; BindableObject bindable = null; if (obj is BindableObject) { bindable = obj as BindableObject; // bindable.target = obj; } else { // BindableObject bindable = obj.<BindableObject> (); if (bindable == null) { Component[] allcomps = obj.GetComponents <Component> (); //默认绑定最后一个组件 Component target = null; int index = 0; int tpId = -1; foreach (var comp in allcomps) { if (comp is BindableObject) { bindable = (BindableObject)comp; break; } else if ((index = BinderCheckTypes.IndexOf(comp.GetType())) >= 0) { target = comp; tpId = index; } } if (bindable == null) { Type createBinderType = typeof(Hugula.Databinding.Binder.UIBehaviourBinder); if (tpId >= 0) { createBinderType = BinderCreateTypes[tpId]; } bindable = (BindableObject)obj.gameObject.AddComponent(createBinderType); bindable.target = target; } } } bindable.targetName = obj.name; // bindable.binderType = GetBinderType (bindable.target.GetType ()); if (children.IndexOf(bindable) < 0) { refer.AddChild(bindable); } // Binding binditem = bindableObjects[i]; // binditem.target = obj; // if (obj) { // binditem.binderType = GetBinderType (obj.GetType ()); // binditem.targetName = obj.name.Trim (); // } }
void SetBindingProperties(BindableContainer refer, int i) { BindingPropertiesStyle.fontStyle = FontStyle.Italic; BindingPropertiesStyle.fontSize = 10; BindingPropertiesStyle.alignment = TextAnchor.UpperLeft; }
void DeferredPass(Vector3 a_cameraPosition, Vector3 a_cameraForward, Frustum a_cameraFrutrum, Camera a_camera, e_TransparencyMode a_transparencyMode) { foreach (DrawingContainer draw in m_drawingObjects) { Material material = draw.Material; if ((material.Transparency & a_transparencyMode) == 0) { continue; } Program program = material.Program; int progHandle = ((OpenTKProgram)program.InternalObject).Handle; GL.UseProgram(progHandle); if (program.DepthTest) { GL.Enable(EnableCap.DepthTest); } else { GL.Disable(EnableCap.DepthTest); } switch (program.CullingMode) { case e_CullingMode.None: { GL.Disable(EnableCap.CullFace); break; } case e_CullingMode.Front: { GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Front); break; } case e_CullingMode.Back: { GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); break; } case e_CullingMode.FrontAndBack: { GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.FrontAndBack); break; } } BindableContainer cont = BindMaterial(material); BindCamera(); BindTime(); if ((a_transparencyMode & e_TransparencyMode.Transparent) != 0) { GL.ActiveTexture(TextureUnit.Texture0 + cont.Textures); GL.BindTexture(TextureTarget.Texture2D, ((OpenTKTexture)m_renderTarget.DepthBuffer.InternalObject).Handle); GL.Uniform1(19, cont.Textures++); } foreach (DrawingContainer.RenderingContainer rend in draw.Renderers) { Renderer renderer = rend.Renderer; if (renderer.Visible) { Transform transform = renderer.Transform; if (transform != null) { lock (transform.GameObject) { Vector3 translation = transform.Translation; Vector3 scale = transform.Scale; float max = (float)Math.Max(scale.X, Math.Max(scale.Y, scale.Z)); float radius = renderer.Radius; float finalRadius = radius * max; if (radius != -1 && !a_cameraFrutrum.CompareSphere(translation, finalRadius)) { continue; } if (!transform.Static) { BindTransform(transform.ToMatrix(), transform.RotationMatrix); } else { int ubo = rend.TransformBuffer; BindTransform(transform, ref ubo); rend.TransformBuffer = ubo; } } } renderer.Draw(a_camera); #if DEBUG_INFO Pipeline.GLError("Graphics: Drawing: "); #endif } } } }
public void Bind(BindableContainer a_container, Binding a_binding) { GL.ActiveTexture(TextureUnit.Texture0 + a_container.Textures); GL.BindTexture(TextureTarget.TextureCubeMap, Handle); GL.Uniform1(a_binding.Handle, a_container.Textures++); }
public override void BindShadowMap(BindableContainer a_bindableContainer) { m_internalObject.BindShadowMap(a_bindableContainer); }
public void Bind(BindableContainer a_container, Binding a_binding) { UpdateBuffer(); m_internalObject.Bind(a_container, a_binding); }
public void Bind(BindableContainer a_container, Binding a_binding) { m_internalObject.Bind(a_container.Textures++, a_binding.Handle); }
public void RemoveAtbindableObjects(BindableContainer refer, int index) { var children = refer.children; children.RemoveAt(index); }
public Binding GetbindableObjects(BindableContainer refer, int index) { // if (index >= 0 && index < refer.bindableObjects.Length) // return refer.bindableObjects[index]; return(null); }
public void Bind(BindableContainer a_container, Binding a_binding) { }
public abstract void BindShadowMap(BindableContainer a_bindableContainer);