-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for drawing large arrays of objects
Fixes #2
- Loading branch information
Showing
5 changed files
with
789 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,370 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<WorkflowBuilder Version="2.6.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:gl="clr-namespace:Bonsai.Shaders;assembly=Bonsai.Shaders" | ||
xmlns:bv="clr-namespace:BonVision;assembly=BonVision" | ||
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" | ||
xmlns:p1="clr-namespace:OpenTK;assembly=OpenTK" | ||
xmlns="https://bonsai-rx.org/2018/workflow"> | ||
<Description>Draws multiple model instances using per-instance 4x3 transform matrix data array.</Description> | ||
<Workflow> | ||
<Nodes> | ||
<Expression xsi:type="WorkflowInput"> | ||
<Name>Source1</Name> | ||
</Expression> | ||
<Expression xsi:type="MemberSelector"> | ||
<Selector>ViewMatrix</Selector> | ||
</Expression> | ||
<Expression xsi:type="ExternalizedMapping"> | ||
<Property Name="MeshName" /> | ||
</Expression> | ||
<Expression xsi:type="ExternalizedMapping"> | ||
<Property Name="X" DisplayName="TranslationX" /> | ||
<Property Name="Y" DisplayName="TranslationY" /> | ||
<Property Name="Z" DisplayName="TranslationZ" /> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:Translate"> | ||
<gl:Order>Prepend</gl:Order> | ||
<gl:X>0</gl:X> | ||
<gl:Y>0</gl:Y> | ||
<gl:Z>0</gl:Z> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="ExternalizedMapping"> | ||
<Property Name="X" DisplayName="ScaleX" /> | ||
<Property Name="Y" DisplayName="ScaleY" /> | ||
<Property Name="Z" DisplayName="ScaleZ" /> | ||
</Expression> | ||
<Expression xsi:type="ExternalizedMapping"> | ||
<Property Name="Ambient" Description="The amount and color of the ambient light reflected by the material.
" Category="Model Material" /> | ||
<Property Name="Diffuse" Description="The amount and color of the diffuse light reflected by the material.
" Category="Model Material" /> | ||
<Property Name="Specular" Description="The amount and color of the specular light reflected by the material.
" Category="Model Material" /> | ||
<Property Name="SpecularExponent" Description="The exponent used to compute the specular response of the material." Category="Model Material" /> | ||
</Expression> | ||
<Expression xsi:type="ExternalizedMapping"> | ||
<Property Name="Value" DisplayName="RotationZ" Description="The rotation about the z-axis." /> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="bv:AngleProperty"> | ||
<bv:Value>0</bv:Value> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="PropertyMapping"> | ||
<PropertyMappings> | ||
<Property Name="Angle" /> | ||
</PropertyMappings> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:RotateZ"> | ||
<gl:Order>Prepend</gl:Order> | ||
<gl:Angle>0</gl:Angle> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="ExternalizedMapping"> | ||
<Property Name="Value" DisplayName="RotationY" Description="The rotation about the y-axis." /> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="bv:AngleProperty"> | ||
<bv:Value>0</bv:Value> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="PropertyMapping"> | ||
<PropertyMappings> | ||
<Property Name="Angle" /> | ||
</PropertyMappings> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:RotateY"> | ||
<gl:Order>Prepend</gl:Order> | ||
<gl:Angle>0</gl:Angle> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="ExternalizedMapping"> | ||
<Property Name="Value" DisplayName="RotationX" Description="The rotation about the x-axis." /> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="bv:AngleProperty"> | ||
<bv:Value>0</bv:Value> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="PropertyMapping"> | ||
<PropertyMappings> | ||
<Property Name="Angle" /> | ||
</PropertyMappings> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:RotateX"> | ||
<gl:Order>Prepend</gl:Order> | ||
<gl:Angle>0</gl:Angle> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:Scale"> | ||
<gl:Order>Prepend</gl:Order> | ||
<gl:X>1</gl:X> | ||
<gl:Y>1</gl:Y> | ||
<gl:Z>1</gl:Z> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:UpdateUniform"> | ||
<gl:UniformName>modelview</gl:UniformName> | ||
<gl:ShaderName>ModelArray</gl:ShaderName> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:NormalMatrix" /> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:UpdateUniform"> | ||
<gl:UniformName>normalMatrix</gl:UniformName> | ||
<gl:ShaderName>ModelArray</gl:ShaderName> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="MemberSelector"> | ||
<Selector>ProjectionMatrix</Selector> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:UpdateUniform"> | ||
<gl:UniformName>projection</gl:UniformName> | ||
<gl:ShaderName>ModelArray</gl:ShaderName> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="MemberSelector"> | ||
<Selector>Light</Selector> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:UpdateUniform"> | ||
<gl:UniformName>light</gl:UniformName> | ||
<gl:ShaderName>ModelArray</gl:ShaderName> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="rx:Zip" /> | ||
</Expression> | ||
<Expression xsi:type="GroupWorkflow"> | ||
<Name>UpdateMaterial</Name> | ||
<Workflow> | ||
<Nodes> | ||
<Expression xsi:type="WorkflowInput"> | ||
<Name>Source1</Name> | ||
</Expression> | ||
<Expression xsi:type="ExternalizedMapping"> | ||
<Property Name="Value" DisplayName="Ambient" /> | ||
</Expression> | ||
<Expression xsi:type="PropertySource" TypeArguments="gl:CreateLookAt,p1:Vector3"> | ||
<MemberName>Eye</MemberName> | ||
<Value> | ||
<X>0.2</X> | ||
<Y>0.2</Y> | ||
<Z>0.2</Z> | ||
</Value> | ||
</Expression> | ||
<Expression xsi:type="InputMapping"> | ||
<PropertyMappings> | ||
<Property Name="X" Selector="X" /> | ||
<Property Name="Y" Selector="Y" /> | ||
<Property Name="Z" Selector="Z" /> | ||
</PropertyMappings> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:CreateVector4"> | ||
<gl:X>0.2</gl:X> | ||
<gl:Y>0.2</gl:Y> | ||
<gl:Z>0.2</gl:Z> | ||
<gl:W>1</gl:W> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:UpdateUniform"> | ||
<gl:UniformName>colorAmbient</gl:UniformName> | ||
<gl:ShaderName>ModelArray</gl:ShaderName> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="ExternalizedMapping"> | ||
<Property Name="Value" DisplayName="Diffuse" /> | ||
</Expression> | ||
<Expression xsi:type="PropertySource" TypeArguments="gl:CreateLookAt,p1:Vector3"> | ||
<MemberName>Eye</MemberName> | ||
<Value> | ||
<X>0.8</X> | ||
<Y>0.8</Y> | ||
<Z>0.8</Z> | ||
</Value> | ||
</Expression> | ||
<Expression xsi:type="InputMapping"> | ||
<PropertyMappings> | ||
<Property Name="X" Selector="X" /> | ||
<Property Name="Y" Selector="Y" /> | ||
<Property Name="Z" Selector="Z" /> | ||
</PropertyMappings> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:CreateVector4"> | ||
<gl:X>0.8</gl:X> | ||
<gl:Y>0.8</gl:Y> | ||
<gl:Z>0.8</gl:Z> | ||
<gl:W>1</gl:W> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:UpdateUniform"> | ||
<gl:UniformName>colorDiffuse</gl:UniformName> | ||
<gl:ShaderName>ModelArray</gl:ShaderName> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="ExternalizedMapping"> | ||
<Property Name="Value" DisplayName="Specular" /> | ||
</Expression> | ||
<Expression xsi:type="PropertySource" TypeArguments="gl:CreateLookAt,p1:Vector3"> | ||
<MemberName>Eye</MemberName> | ||
<Value> | ||
<X>0.8</X> | ||
<Y>0.8</Y> | ||
<Z>0.8</Z> | ||
</Value> | ||
</Expression> | ||
<Expression xsi:type="InputMapping"> | ||
<PropertyMappings> | ||
<Property Name="X" Selector="X" /> | ||
<Property Name="Y" Selector="Y" /> | ||
<Property Name="Z" Selector="Z" /> | ||
</PropertyMappings> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:CreateVector4"> | ||
<gl:X>0.8</gl:X> | ||
<gl:Y>0.8</gl:Y> | ||
<gl:Z>0.8</gl:Z> | ||
<gl:W>1</gl:W> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:UpdateUniform"> | ||
<gl:UniformName>colorSpecular</gl:UniformName> | ||
<gl:ShaderName>ModelArray</gl:ShaderName> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="ExternalizedMapping"> | ||
<Property Name="Value" DisplayName="SpecularExponent" /> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="FloatProperty"> | ||
<Value>10</Value> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:UpdateUniform"> | ||
<gl:UniformName>shininess</gl:UniformName> | ||
<gl:ShaderName>ModelArray</gl:ShaderName> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="WorkflowOutput" /> | ||
</Nodes> | ||
<Edges> | ||
<Edge From="0" To="2" Label="Source1" /> | ||
<Edge From="1" To="2" Label="Source2" /> | ||
<Edge From="2" To="3" Label="Source1" /> | ||
<Edge From="3" To="4" Label="Source1" /> | ||
<Edge From="4" To="5" Label="Source1" /> | ||
<Edge From="5" To="7" Label="Source1" /> | ||
<Edge From="6" To="7" Label="Source2" /> | ||
<Edge From="7" To="8" Label="Source1" /> | ||
<Edge From="8" To="9" Label="Source1" /> | ||
<Edge From="9" To="10" Label="Source1" /> | ||
<Edge From="10" To="12" Label="Source1" /> | ||
<Edge From="11" To="12" Label="Source2" /> | ||
<Edge From="12" To="13" Label="Source1" /> | ||
<Edge From="13" To="14" Label="Source1" /> | ||
<Edge From="14" To="15" Label="Source1" /> | ||
<Edge From="15" To="17" Label="Source1" /> | ||
<Edge From="16" To="17" Label="Source2" /> | ||
<Edge From="17" To="18" Label="Source1" /> | ||
<Edge From="18" To="19" Label="Source1" /> | ||
</Edges> | ||
</Workflow> | ||
</Expression> | ||
<Expression xsi:type="WorkflowInput"> | ||
<Name>Source2</Name> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="rx:WithLatestFrom" /> | ||
</Expression> | ||
<Expression xsi:type="MemberSelector"> | ||
<Selector>Item2</Selector> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:DrawMeshInstanced"> | ||
<gl:ShaderName>ModelArray</gl:ShaderName> | ||
<gl:MeshName>Plane</gl:MeshName> | ||
<gl:Usage>DynamicDraw</gl:Usage> | ||
<gl:InstanceAttributes> | ||
<gl:InstanceAttributeMapping> | ||
<gl:Size>3</gl:Size> | ||
<gl:Normalized>false</gl:Normalized> | ||
<gl:Type>Float</gl:Type> | ||
<gl:Divisor>1</gl:Divisor> | ||
</gl:InstanceAttributeMapping> | ||
<gl:InstanceAttributeMapping> | ||
<gl:Size>3</gl:Size> | ||
<gl:Normalized>false</gl:Normalized> | ||
<gl:Type>Float</gl:Type> | ||
<gl:Divisor>1</gl:Divisor> | ||
</gl:InstanceAttributeMapping> | ||
<gl:InstanceAttributeMapping> | ||
<gl:Size>3</gl:Size> | ||
<gl:Normalized>false</gl:Normalized> | ||
<gl:Type>Float</gl:Type> | ||
<gl:Divisor>1</gl:Divisor> | ||
</gl:InstanceAttributeMapping> | ||
<gl:InstanceAttributeMapping> | ||
<gl:Size>3</gl:Size> | ||
<gl:Normalized>false</gl:Normalized> | ||
<gl:Type>Float</gl:Type> | ||
<gl:Divisor>1</gl:Divisor> | ||
</gl:InstanceAttributeMapping> | ||
</gl:InstanceAttributes> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="WorkflowOutput" /> | ||
</Nodes> | ||
<Edges> | ||
<Edge From="0" To="1" Label="Source1" /> | ||
<Edge From="0" To="23" Label="Source1" /> | ||
<Edge From="0" To="25" Label="Source1" /> | ||
<Edge From="1" To="4" Label="Source1" /> | ||
<Edge From="2" To="32" Label="Source2" /> | ||
<Edge From="3" To="4" Label="Source2" /> | ||
<Edge From="4" To="10" Label="Source1" /> | ||
<Edge From="5" To="19" Label="Source2" /> | ||
<Edge From="6" To="28" Label="Source2" /> | ||
<Edge From="7" To="8" Label="Source1" /> | ||
<Edge From="8" To="9" Label="Source1" /> | ||
<Edge From="9" To="10" Label="Source2" /> | ||
<Edge From="10" To="14" Label="Source1" /> | ||
<Edge From="11" To="12" Label="Source1" /> | ||
<Edge From="12" To="13" Label="Source1" /> | ||
<Edge From="13" To="14" Label="Source2" /> | ||
<Edge From="14" To="18" Label="Source1" /> | ||
<Edge From="15" To="16" Label="Source1" /> | ||
<Edge From="16" To="17" Label="Source1" /> | ||
<Edge From="17" To="18" Label="Source2" /> | ||
<Edge From="18" To="19" Label="Source1" /> | ||
<Edge From="19" To="20" Label="Source1" /> | ||
<Edge From="20" To="21" Label="Source1" /> | ||
<Edge From="21" To="22" Label="Source1" /> | ||
<Edge From="22" To="27" Label="Source1" /> | ||
<Edge From="23" To="24" Label="Source1" /> | ||
<Edge From="24" To="27" Label="Source2" /> | ||
<Edge From="25" To="26" Label="Source1" /> | ||
<Edge From="26" To="27" Label="Source3" /> | ||
<Edge From="27" To="28" Label="Source1" /> | ||
<Edge From="28" To="30" Label="Source1" /> | ||
<Edge From="29" To="30" Label="Source2" /> | ||
<Edge From="30" To="31" Label="Source1" /> | ||
<Edge From="31" To="32" Label="Source1" /> | ||
<Edge From="32" To="33" Label="Source1" /> | ||
</Edges> | ||
</Workflow> | ||
</WorkflowBuilder> |
Oops, something went wrong.