Code Monkey home page Code Monkey logo

scotomasimulator's Introduction

Scotoma Simulator

This repo contains the shader and script needed to simulate two macular degenration scotomas (one for each eye) rendered as post render effects. Implementing them as post render effects allows the scotomas to be rendered after everything is rendered and appear as if they are in or very close to the user's eye. This code was developed as part of a larger project that investigates VR based intervention for macular degeration.

Ths shader and the attached script allow us to have granular control of the scotomas' behaviour including their size, feathering effect (so their edges appear soft and natural), movement and color. The behaviour of the scotomas can be manipulated separately for each eye, or if you chose so, together for both eyes. Together, the above features allow you to customize the scotomas for each user, or even manipulate the behaviour of scotomas in the middle of an experiment. Moreover, you can add custom behaviours without the need to do big changes, for instance, showing scotomas only when they overlap can be implemented by manipulating the effect size in a single if block that checks the position of the two eyes.

Installation

To use the ScotomaSimulator, just download it and copy the assets folder to your projects assets folder. Then, add the ScotomaSimulator.cs script to your main camera. Done!

Usage

Most of the scotomas behaviours can be manipulated from the GUI without writting too much code.

The scotoma size controls the size of your scotoma (separate for each eye). The size controls the radius of the circular scotoma and is expressed as a fraction of the field of view.

The feather settings allows the scotomas to have feathered edges (linear change in opacity of the edges), instead of having hard edges. This allows them to look more natural. The feather size is also expressed as a fraction of the fild of view. The feather is added both to the inside and outside of the circular scotoma, for example: a feather size of 0.1 and scotoma size of 0.4 would give a scotoma that has a size of 0.5, where the outer region of size 0.2 comprises of the feathered edges.

The scotoma color can be changed by changing the scotoma color settings. You can also create a Cubemap and attach it to the Skybox settings if you want the scotoma to change color based on the background. For the scotoma color settings to work, the Skybox setting must be blank.

To allow the scotomas to move with the user's eyes, all you need to do is to just modify the following lines of code in the Update method of the ScotomaSimulator class.

//Eye positions in normalized screen coordinates. You need to update these values from your eye tracker.
_leftEyePosition = new Vector2(0.5f,0.5f);
_rightEyePosition = new Vector2(0.5f,0.5f);

These two lines should be updated using the normalized eye coordinates from PupilLabs (or any other eye tracker).

scotomasimulator's People

Contributors

isayasmatter avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.