Forum Discussion
kronnect
10 years agoExplorer
Weird problem with fog image effect
Hi guys,
I have a strange issue regarding Oculus DK2 and a full-screen post image effect.
This is how it looks on a PC with the Debug Mode enabled (no device attached but OVR is running in debug mode) on and htiting play into the editor. It plays ok:
And this is what happens in another PC with the device (wrong!):
Note that the image effect runs fine on Windows and Mac. It just get distorted when Virtual Reality checkbox is enabled and during playmode.
This is the vertex shader:
_ClipToWorld is set from the C# script as:
Note the line above:
farPlaneClip *= float4(1,-1,1,1);
I had to introduce this to make the fog effect work on my PC with the debug mode on. But it still doesn't work on the PC with Oculus DK2.
So, right now I'm a little lost since it works then I enable Debug but it doesn't otherwise on the other PC?
Anyone has faced a similar problem with Oculus / Virtual Reality enabled? Is this a bug?
Also I'd love to read some details about how does Virtual Reality check affect projections in Unity since at this moment I'm rather lost.
thank you very much in advance!
I have a strange issue regarding Oculus DK2 and a full-screen post image effect.
This is how it looks on a PC with the Debug Mode enabled (no device attached but OVR is running in debug mode) on and htiting play into the editor. It plays ok:
And this is what happens in another PC with the device (wrong!):
Note that the image effect runs fine on Windows and Mac. It just get distorted when Virtual Reality checkbox is enabled and during playmode.
This is the vertex shader:
float4x4 _ClipToWorld;
struct appdata {
float4 vertex : POSITION;
half2 texcoord : TEXCOORD0;
};
struct v2f {
float4 pos : POSITION;
float2 uv: TEXCOORD0;
float2 depthUV : TEXCOORD1;
float3 cameraToFarPlane : TEXCOORD2;
};
v2f vert(appdata v) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.depthUV = MultiplyUV(UNITY_MATRIX_TEXTURE0, v.texcoord);
o.uv = o.depthUV;
#if UNITY_UV_STARTS_AT_TOP
if (_MainTex_TexelSize.y < 0) {
// Depth texture is inverted WRT the main texture
o.depthUV.y = 1 - o.depthUV.y;
}
#endif
// Clip space X and Y coords
float2 clipXY = o.pos.xy / o.pos.w;
// Position of the far plane in clip space
float4 farPlaneClip = float4(clipXY, 1, 1);
// Homogeneous world position on the far plane
[B] farPlaneClip *= float4(1,-1,1,1);[/B]
float4 farPlaneWorld4 = mul(_ClipToWorld , farPlaneClip);
// World position on the far plane
float3 farPlaneWorld = farPlaneWorld4.xyz / farPlaneWorld4.w;
// Vector from the camera to the far plane
o.cameraToFarPlane = farPlaneWorld - _WorldSpaceCameraPos;
return o;
}
_ClipToWorld is set from the C# script as:
material.SetMatrix ("_ClipToWorld", Camera.main.cameraToWorldMatrix * Camera.main.projectionMatrix.inverse);Note the line above:
farPlaneClip *= float4(1,-1,1,1);
I had to introduce this to make the fog effect work on my PC with the debug mode on. But it still doesn't work on the PC with Oculus DK2.
So, right now I'm a little lost since it works then I enable Debug but it doesn't otherwise on the other PC?
Anyone has faced a similar problem with Oculus / Virtual Reality enabled? Is this a bug?
Also I'd love to read some details about how does Virtual Reality check affect projections in Unity since at this moment I'm rather lost.
thank you very much in advance!
5 Replies
Replies have been turned off for this discussion
- cyberealityGrand ChampionThis has been a bug for a while. I first saw it with Global Fog. I would guess your effect works similar.
Can you let me know what version of Unity you are using and which SDK? - kronnectExplorerIssue occurs with Unity 5.3.0b5 on Windows 10 with Oculus 0.8.
However it works ok on 5.2.2p3 with same SDK so I guess it's either a regression bug or something new??
Unity has been informed of this as well. - hoestereyProtegeI have the same issue. Using unity 5.1.3p1 with SDK 0.7. All image effects don't show up in standalone build, but are fine in the editor.
- vrdavebOculus StaffUnity recently fixed an issue with several built-in depth-buffer-based effects (such as reflections) where the view matrix was flipped on the Y axis to deal with the texture coordinate conventions of different drivers. That was fixed in 5.2.1p3 and it may have affected fog.
- pommakExplorerWe also seem to suffer from the same problem.
We have quite many effects in the game that need inverse MVP matrix in the shader (both post process, and traditional materials). It seems that the matrix is incorrect, producing incorrect effects.
Basically the result of this function is incorrect: (cam.projectionMatrix * cam.worldToCameraMatrix).inverse
Is there any workaround or is there a fix coming up soon?
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 1 year ago
- 8 months ago
- 2 years ago