1
\$\begingroup\$

Hello there Firends ,

I'm developing a Virtual Reality game in Unity. As in every VR game , i have 2 cameras for stereo rendering. I want to show the same object in each camera having different color/contrast ratio> The effect is similar to the one shown in this image :

this

the grid in the center here is the same in each side but each camera is seeing it differently.i.e. its grey in the left and black in right (you will notice the black grid if you look closely)

here is another example : this
(source: wired.co.uk)

How do i get this effect ? Any suggestions ?

\$\endgroup\$
  • \$\begingroup\$ From what I can see, it has nothing to do with camera contrast. The checkerboard is the same on the two images, only the cube is rendered with a darker color. \$\endgroup\$ – Alexandre Desbiens Jun 16 '15 at 14:21
1
\$\begingroup\$

As an alternative solution:

camera.SetReplacementShader();

Manual and API reference.

You'd have to create a custom shader for the one side, but it would be pretty easy to get the default shader being used for the left (there's a download for the default shaders here) and modifying it so that the color/brightness/lighting is altered so that it has the effect you desire.

Replacement shaders operate on the camera level, so the entire scene is rendered a second time (as is normal) but with the override shader being used in place of the object's default shader (with some simple rules involving shader tags). Your shader will probably need two subshaders, one with a tag that renders objects in the original manner, the other that renders them darker. It'll take a little tweaking and experimentation on your part, but it's not hard. material.SetOverrideTag() may come in handy.

I use it to achieve a wall-hack effect in a game I'm working on. The two cameras are placed at the same point (as I'm not dealing with VR) with the second camera (the one that has the replacement shader set) rendering second and on top of the previous camera.

Wall hack view

My replacement shader only renders the edges of the model meshes, rather than faces, but if you set yours to use a different lighting model and darken the result, you'll achieve the effect you desire. Both screenshots were achieved during a single program execution by manipulating the object inspector to swap override tags (this may come in handy if you wish to have a control that allows the user to turn the diplopia effect on and off).

\$\endgroup\$
0
\$\begingroup\$

You could duplicate object that you want do render with different colours/brightness and place them in seperate layers. Then you set each of the cameras to ignore one of the layers (layer culling).

But why would you want that? The brain will have problems making sense of such wierd images presented to the eyes - this will almost certainly end in disorientation/headaches/nause for many users. What do you want to achieve - maybe it can be achieved in a less immersion-breaking manner?

\$\endgroup\$
  • 3
    \$\begingroup\$ He's doing some kind of therapy game for people with eye disorders... \$\endgroup\$ – mklingen Apr 17 '15 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.