Skip to content

Commit

Permalink
update create window article
Browse files Browse the repository at this point in the history
  • Loading branch information
banchan86 committed Jul 1, 2024
1 parent cb4a3b1 commit 83c9204
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 10 deletions.
17 changes: 15 additions & 2 deletions docs/articles/create-window.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Create Window
## Under Construction - to add more details
# CreateWindow
:::workflow
![Create Window](../workflows/create-window.bonsai)
:::

The `CreateWindow` operator creates an OpenGL window where all the stimuli will be rendered and contains many properties for adjusting the visual environment.

- The `ClearColor` property specifies the background color of the visual environment.
- The `DisplayDevice` property controls which monitor the window will be displayed on (for instance if you have multiple monitors).
- The `TargetRenderFrequency` property controls how fast the stimuli are rendered (by default 60fps).
- The `TargetUpdateFrequency` property by default is set to the same as the `TargetRenderFrequency` but can actually be set higher (for instance 120fps) (useful if you have a high refresh rate monitor but cannot render at the higher `TargetRenderFrequency`).
- The `WindowBorder`property can be used to hide the window border or make it resizable (for instance, if you want the window to span multiple displays)
- The `WindowState` property controls how the the window will be displayed (for instance, you can make it full-screen)


## Video Walkthrough
<div style="max-width: 500px">
<iframe width=100% height="282" src="https://www.youtube.com/embed/gHn9YVvM55I" title="BonVision quick tips: Using CreateWindow" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
Expand Down
13 changes: 6 additions & 7 deletions docs/articles/define-display.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@ Each `ViewWindow` must be accompanied by a `DrawViewport` operator. Additional d


## DrawViewport

The `DrawViewport` operator draws the `ViewWindow` to a display and provides additional options for positioning the `ViewWindow` on a display.

This example workflow illustrates how we can combine the `ViewWindow` and `DrawViewport` operators to flexibly position different views (for instance, when we have two monitors side by side).
A single checkboard is drawn in the visual environment and two `ViewWindows` are positioned side by side (by adjusting the `X-axis` variable in the `Translation` property). Then we draw
the two views to two displays.
A single checkboard is drawn in the visual environment and two `ViewWindows` are positioned side by side (by adjusting the `X-axis` variable in the `Translation` property). Then we draw the two views to two displays.


:::workflow
Expand All @@ -36,19 +34,20 @@ the two views to two displays.


## Post-processing Operators (optional)
Bonvision comes with post-processing operators to correct for various distortions in the final display of the image. These operators would be placed between the `ViewWindow` and `DrawViewport` operator.
Bonvision comes with post-processing operators to correct for various distortions in the final display of the image (for instance, when using a projector in conjunction with a mirror/lens or projecting on non-uniform surfaces). These operators would be placed between the `ViewWindow` and `DrawViewport` operator.

### PerspectiveMapping and MeshMapping
Using a projector in conjunction with a mirror/lens or projecting on non uniform surfaces can cause distortions in the image, such that pixels across the display surface might not have the same physical dimensions. In this case, one would have to use these operators to warp the images to display them correctly.

### PerspectiveMapping
The `PerspectiveMapping` operator can be used to correct distortions when projecting displays on the walls of an rectangular arena. One would specify 4 `ViewWindows`, one for each wall, and then specify a `PerspectiveMapping` for each view window to transform the view before attaching a `DrawViewport` operator.

An example implementation can be found at https://groups.google.com/g/bonsai-users/c/WV7V57vlSAk/m/XjQPqCJkCAAJ.


### MeshMapping
The `MeshMapping` operator is best used to correct distortions when projecting displays on a demispherical dome. As the process is more complicated, check out the [mesh mapping calibration](./mesh-mapping-calibration.md) article for more information how to measure and calibrate this operator.

## GammaCorrection

### GammaCorrection
The `GammaCorrection` operator applies simple intensity mapping of the three colors, to make sure the stimuli are linear. It uses a simple LUT (Look-up-table), for Red, Green and Blue. Check out the [gamma calibration](./gamma-calibration.md) article for more information on how to measure and calibrate this operator.

## Other nodes to document (under construction)
Expand Down
1 change: 0 additions & 1 deletion docs/articles/stimuli-alternative.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Alternative Stimuli Creation
## Under Construction
## Dynamic Textures
In addition to loading premade textures and videos, `BonVision` can display dynamic textures generated online or from other sources.

Expand Down
48 changes: 48 additions & 0 deletions docs/workflows/create-window.bonsai
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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="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>
</Nodes>
<Edges />
</Workflow>
</WorkflowBuilder>

0 comments on commit 83c9204

Please sign in to comment.