Guest User

Untitled

a guest
Apr 28th, 2013
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. // Combines two images into one warped Side-by-Side image
  2.  
  3. sampler2D TexMap0;
  4. sampler2D TexMap1;
  5.  
  6. float2 LensCenter;
  7. float2 LensShift;
  8. float2 ScreenCenter;
  9. float2 Scale;
  10. float2 ScaleIn;
  11. float4 HmdWarpParam;
  12.  
  13. float2 HmdWarp(float2 in01)
  14. {
  15. float2 theta = (in01 - LensCenter) * ScaleIn;
  16. float rSq= theta.x * theta.x + theta.y * theta.y;
  17. float2 theta1 = theta * (HmdWarpParam.x + HmdWarpParam.y * rSq +
  18. HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);
  19. return LensCenter + Scale * theta1;
  20. }
  21.  
  22. float4 SBSRift(float2 Tex : TEXCOORD0) : COLOR
  23. {
  24. float2 newPos = Tex;
  25. float2 tc;
  26. float4 tColor;
  27. float2 theta;
  28.  
  29. if(newPos.x < 0.5f) {
  30. tc = HmdWarp(newPos);
  31.  
  32. tc.x = (tc.x - (LensCenter.x+LensShift.x -0.25f)) * 2.0f; //offset for ipd
  33.  
  34. tColor = tex2D(TexMap0,tc);
  35. } else {
  36. newPos.x = (1.0f - newPos.x); // mirror
  37. tc = HmdWarp(newPos);
  38.  
  39. tc.x = (tc.x - (LensCenter.x+LensShift.x -0.25f)) * 2.0f; //offset for ipd
  40.  
  41. tc.x = 1.0f -tc.x; // unmirror
  42. tColor = tex2D(TexMap1,tc);
  43. }
  44.  
  45. tc.x = tc.x / 2.0f;
  46.  
  47. if (any(clamp(tc, ScreenCenter-float2(0.25,0.5), ScreenCenter+float2(0.25, 0.5)) - tc)){
  48. return 0;
  49. // tColor[0] = 1.0f;
  50. // tColor[1] = 1.0f;
  51. // tColor[2] = 1.0f;
  52. }
  53.  
  54. return tColor;
  55. }
  56.  
  57. technique ViewShader
  58. {
  59. pass P0
  60. {
  61. VertexShader = null;
  62. PixelShader = compile ps_2_0 SBSRift();
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment