Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion scatterer/Effects/SunFlare/SunFlare.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void start()

public void updateProperties()
{
sunViewPortPos = Scatterer.Instance.scaledSpaceCamera.WorldToViewportPoint (sourceScaledTransform.position);
sunViewPortPos = Scatterer.Instance.scaledSpaceCamera.WorldToViewportPoint (sourceScaledTransform.position, Camera.current.stereoActiveEye);
hitStatus=false;

if (sunViewPortPos.z > 0)
Expand Down Expand Up @@ -225,6 +225,11 @@ public void updateProperties()
hitStatus=false;
}

// For whatever reason, calling SetVector on the material doesn't work for the right eye in VR
// but calling Shader.SetGlobalVector does (note OnPreRender is called for each eye)
// However this will probably break situations where more than one star has an active lens flare
// so I don't want to enable that by default.
// Shader.SetGlobalVector(ShaderProperties.sunViewPortPos_PROPERTY, sunViewPortPos);
sunglareMaterial.SetVector (ShaderProperties.sunViewPortPos_PROPERTY, sunViewPortPos);

if (!(HighLogic.LoadedScene == GameScenes.TRACKSTATION))
Expand Down
2 changes: 1 addition & 1 deletion scatterer/Effects/SunFlare/SunflareCameraHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void OnPreRender()

public void OnPostRender()
{
if(flare)
if(flare && Camera.current.stereoActiveEye != Camera.MonoOrStereoscopicEye.Left)
{
flare.ClearExtinction ();
flare.sunglareMaterial.SetFloat(ShaderProperties.renderOnCurrentCamera_PROPERTY,0.0f);
Expand Down