GithubHelp home page GithubHelp logo

unity-eac-shader's People

Contributors

ywwynm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

unity-eac-shader's Issues

Some flips needed on some faces

Hello, thanks for the shader, it saved me a lot of time.

I had some troubles (half the cubemap needed flip) when I downloaded in 2K (with 4K Video Downloader) that video:
https://www.youtube.com/watch?v=YAABA-Ri0YI&t=219s

in unity 2019.3.a3 it's now perfect (still the line problem on some edges, but I'll work on it soon)

modified shader here (lines 60/62/65/73/74):

  1. Shader "Custom/EAC-sphere"
  2. {
  3. Properties
  4. {
  5.  _MainTex ("Texture", 2D) = "white" {}
    
  6. }
  7. SubShader
  8. {
  9.  // No culling or depth
    
  10. 	Cull Front ZWrite Off ZTest Always // Cull front will flip normals
    
  11. 	Pass
    
  12. 	{
    
  13. 		CGPROGRAM
    
  14. 		#pragma vertex vert
    
  15. 		#pragma fragment frag
    
  16. 		#include "UnityCG.cginc"
    
  17. 		struct appdata
    
  18. 		{
    
  19. 	float4 vertex : POSITION;
    
  20. 	float3 normal : NORMAL;
    
  21. 		};
    
  22. 		struct v2f
    
  23. 		{
    
  24. 	float4 vertex : SV_POSITION;
    
  25. 			float3 coord : TEXCOORD0;
    
  26. 		};
    
  27. 		v2f vert (appdata v)
    
  28. 		{
    
  29. 			v2f o;
    
  30. 			o.vertex = UnityObjectToClipPos(v.vertex);
    
  31. 			o.coord = v.normal;
    
  32. 			return o;
    
  33. 		}
    
  34. 		sampler2D _MainTex;
    
  35. 		float4 frag (v2f i) : SV_Target {
    
  36. 			float pi = UNITY_PI;
    
  37. 			float3 xyz = normalize(i.coord);
    
  38. 			float x = xyz.x, y = xyz.y, z = xyz.z;
    
  39. 			float u = 0, v = 0;
    
  40. 			float scale; // sphere coordinates to cube coordinates according to similar-triangle
    
  41. 			if (abs(x) >= abs(y) && abs(x) >= abs(z)) {
    
  42. 				scale = 1.0 / abs(x); // let's assume that radius of sphere is 1, which means u is 6.0 and v is 4.0
    
  43. 				if (x >= 0) { // right
    
  44. 					u = 5.0 - 4.0 * atan(z * scale) / pi;
    
  45. 					v = 3.0 + 4.0 * atan(y * scale) / pi;
    
  46. 				} else { // left
    
  47. 					u = 1.0 + 4.0 * atan(z * scale) / pi;
    
  48. 					v = 3.0 + 4.0 * atan(y * scale) / pi;
    
  49. 				}
    
  50. 			} else if (abs(y) >= abs(x) && abs(y) >= abs(z)) {
    
  51. 				scale = 1.0 / abs(y);
    
  52. 				if (y < 0) { // top                                                                         // < instead of >=
    
  53. 					u = 5.0 + 4.0 * atan(z * scale) / pi;
    
  54. 					v = 1.0 - 4.0 * atan(x * scale) / pi;                                       // - instead of +
    
  55. 				} else { // down
    
  56. 					u = 1.0 - 4.0 * atan(z * scale) / pi;
    
  57. 					v = 1.0 - 4.0 * atan(x * scale) / pi;                                       // - instead of +
    
  58. 				}
    
  59. 			} else if (abs(z) >= abs(x) && abs(z) >= abs(y)) {
    
  60. 				scale = 1.0 / abs(z);
    
  61. 				if (z >= 0) { // front
    
  62. 					u = 3.0 + 4.0 * atan(x * scale) / pi;
    
  63. 					v = 3.0 + 4.0 * atan(y * scale) / pi;
    
  64. 				} else { // end
    
  65. 					u = 3.0 - 4.0 * atan(y * scale) / pi;                                       // - instead of +
    
  66. 					v = 1.0 - 4.0 * atan(x * scale) / pi;                                       // - instead of +
    
  67. 				}
    
  68. 			}
    
  69. 			return tex2D(_MainTex, float2(u / 6.0, 1.0 - v / 4.0));
    
  70. 		}
    
  71. 		ENDCG
    
  72. 	}
    
  73. }
    
  74. }

lines on edges

Hello. I have some problems. When I use this shader on sphere, video play fine, but I see some edges like a cube edges. Then I "play" with scale variable (0.99) on u and v and some edges disappear (I dont see them) but not all.

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.