forked from bonvision/BonVision
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reorganize map stimuli and display env article for clarity
- Loading branch information
Showing
6 changed files
with
152 additions
and
39 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
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
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 |
---|---|---|
@@ -1,43 +1,24 @@ | ||
# Map Stimuli | ||
|
||
## Under Construction | ||
## Sphere Mapping | ||
|
||
## A. Sphere Mapping | ||
> [!NOTE] | ||
> This is best for creating 2D stimuli. | ||
> [!NOTE] | ||
> Needs a Display object: preferably a ViewingWindow | ||
When rendering 3D environments, in the case of 3D stimuli, `BonVision` applies by default a cubemap rendering approach and no additional transformation/operators are necessary. | ||
|
||
[The details of the implementation of Sphere mapping](https://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/UV_Map_Basics) | ||
|
||
In this case, stimuli are always rendered onto the inside of a sphere. This allows easy eye-centric definitions of stimuli in visual angle units. The displays are then windows that observe these rendered stimuli. We use Spherical coordinates to define all stimulus parameters in this case. | ||
However, in the case of 2D stimuli, we use `SphereMapping` to render them onto the inside of a 3D sphere to display them in a 3D space. | ||
More info can be found in the [Display Environments](display-environment-basics.md) | ||
|
||
![SphericalCoord](~/images/DisplayLogic/SphericalCoord_resized.png){width=500} | ||
|
||
## B. Cube Mapping | ||
> [!NOTE] | ||
> This is best for creating 3D stimuli, for Virtual or Augmented Reality Systems. | ||
> [!NOTE] | ||
> Needs a Display object: preferably a PerspectiveViewingWindow | ||
[The details of Cube Mapping are explained here:](https://en.wikipedia.org/wiki/Cube_mapping) | ||
|
||
In this case all the stimuli are created in eye-centric physical coordinates (centimeters for example) and rendered onto a unit Cube. The displays (Perspective cameras) are then windows into these rendered images. | ||
*probably easiest with a whiteboard drawing here* | ||
This workflow below draws a checkboard which is mapped to a sphere using `SphereMapping`. | ||
|
||
### For Virtual Reality (VR) | ||
VR can be easily defined as a situation where the eye, and the screens (windows) are fixed positions, while the all the objects (or VR environment) moves across the eye. | ||
:::workflow | ||
![Sphere Mapping](../workflows/overview-map-stimuli-define-display.bonsai) | ||
::: | ||
|
||
![VR](~/images/DisplayLogic/VRcartoon.png){width=500} | ||
|
||
Example rendering to be added here | ||
|
||
### For Augmented Reality (AR) | ||
|
||
This is a scenario where, generally, the screens remain in a fixed position and the animal can move around. Since we have an eye-centric coordinate frame, the objects and the screen move around to generate an AR. | ||
|
||
![AR](~/images/DisplayLogic/ARcartoon.jpg){width=500} | ||
> [!NOTE] | ||
> `SphereMapping` requires a `ViewWindow`. | ||
Example rendering to be added here | ||
> [!NOTE] | ||
> When drawing stimuli, `SphereMapping` requires a `PublishSubject` and `SubscribeSubject` pair (see the [multiple stimuli](stimuli-multiple.md) for instructions on how to use `Subjects` and this [link](https://github.com/orgs/bonsai-rx/discussions/1835) for an explanation of the reasons). | ||
|
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,111 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<WorkflowBuilder Version="2.8.2" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:gl="clr-namespace:Bonsai.Shaders;assembly=Bonsai.Shaders" | ||
xmlns:res="clr-namespace:Bonsai.Resources;assembly=Bonsai.System" | ||
xmlns:rx="clr-namespace:Bonsai.Reactive;assembly=Bonsai.Core" | ||
xmlns="https://bonsai-rx.org/2018/workflow"> | ||
<Workflow> | ||
<Nodes> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:CreateWindow"> | ||
<gl:Width>640</gl:Width> | ||
<gl:Height>480</gl:Height> | ||
<gl:VSync>On</gl:VSync> | ||
<gl:SwapSync>false</gl:SwapSync> | ||
<gl:ClearColor>Black</gl:ClearColor> | ||
<gl:ClearMask>DepthBufferBit ColorBufferBit</gl:ClearMask> | ||
<gl:CursorVisible>true</gl:CursorVisible> | ||
<gl:Location xsi:nil="true" /> | ||
<gl:WindowBorder>Resizable</gl:WindowBorder> | ||
<gl:WindowState>Normal</gl:WindowState> | ||
<gl:DisplayDevice>Primary</gl:DisplayDevice> | ||
<gl:TargetRenderFrequency>60</gl:TargetRenderFrequency> | ||
<gl:TargetUpdateFrequency xsi:nil="true" /> | ||
<gl:RenderState /> | ||
<gl:GraphicsMode> | ||
<gl:ColorFormat> | ||
<gl:Red>8</gl:Red> | ||
<gl:Green>8</gl:Green> | ||
<gl:Blue>8</gl:Blue> | ||
<gl:Alpha>8</gl:Alpha> | ||
</gl:ColorFormat> | ||
<gl:Depth>16</gl:Depth> | ||
<gl:Stencil>0</gl:Stencil> | ||
<gl:Samples>0</gl:Samples> | ||
<gl:AccumulatorFormat> | ||
<gl:Red>0</gl:Red> | ||
<gl:Green>0</gl:Green> | ||
<gl:Blue>0</gl:Blue> | ||
<gl:Alpha>0</gl:Alpha> | ||
</gl:AccumulatorFormat> | ||
<gl:Buffers>2</gl:Buffers> | ||
<gl:Stereo>false</gl:Stereo> | ||
</gl:GraphicsMode> | ||
</Combinator> | ||
</Expression> | ||
<Expression xsi:type="IncludeWorkflow" Path="BonVision:Primitives.BonVisionResources.bonsai" /> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="res:LoadResources" /> | ||
</Expression> | ||
<Expression xsi:type="Combinator"> | ||
<Combinator xsi:type="gl:RenderFrame" /> | ||
</Expression> | ||
<Expression xsi:type="IncludeWorkflow" Path="BonVision:Environment.OrthographicView.bonsai"> | ||
<Left>-180</Left> | ||
<Right>180</Right> | ||
<Bottom>-90</Bottom> | ||
<Top>90</Top> | ||
</Expression> | ||
<Expression xsi:type="rx:PublishSubject"> | ||
<Name>Draw</Name> | ||
</Expression> | ||
<Expression xsi:type="IncludeWorkflow" Path="BonVision:Environment.SphereMapping.bonsai"> | ||
<ClearColor>Gray</ClearColor> | ||
<Width xsi:nil="true" /> | ||
<Height xsi:nil="true" /> | ||
<RotationZ>0</RotationZ> | ||
<RotationY>0</RotationY> | ||
<RotationX>0</RotationX> | ||
<FaceSize xsi:nil="true" /> | ||
</Expression> | ||
<Expression xsi:type="IncludeWorkflow" Path="BonVision:Environment.ViewWindow.bonsai"> | ||
<Width>20</Width> | ||
<Height>15</Height> | ||
<Rotation> | ||
<X>0</X> | ||
<Y>0</Y> | ||
<Z>0</Z> | ||
</Rotation> | ||
<Translation> | ||
<X>0</X> | ||
<Y>0</Y> | ||
<Z>-10</Z> | ||
</Translation> | ||
</Expression> | ||
<Expression xsi:type="SubscribeSubject"> | ||
<Name>Draw</Name> | ||
</Expression> | ||
<Expression xsi:type="IncludeWorkflow" Path="BonVision:Primitives.DrawCheckerboard.bonsai"> | ||
<ExtentX>90</ExtentX> | ||
<ExtentY>90</ExtentY> | ||
<LocationX>0</LocationX> | ||
<LocationY>0</LocationY> | ||
<Layer>0</Layer> | ||
<Angle>0</Angle> | ||
<NumberColumns>5</NumberColumns> | ||
<NumberRows>5</NumberRows> | ||
<Phase>0</Phase> | ||
</Expression> | ||
</Nodes> | ||
<Edges> | ||
<Edge From="0" To="1" Label="Source1" /> | ||
<Edge From="1" To="2" Label="Source1" /> | ||
<Edge From="3" To="4" Label="Source1" /> | ||
<Edge From="4" To="5" Label="Source1" /> | ||
<Edge From="5" To="6" Label="Source1" /> | ||
<Edge From="6" To="7" Label="Source1" /> | ||
<Edge From="8" To="9" Label="Source1" /> | ||
</Edges> | ||
</Workflow> | ||
</WorkflowBuilder> |