You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//float3 worldNormal: TEXCOORD1; //we don't need normals where we're going
51
+
//LIGHTING_COORDS(3,4) //nor do we need this crap
52
+
float3 planetOrigin: TEXCOORD1; //moved from fragment shader
53
+
//float4 objectVertex: TEXCOORD2;
54
+
};
55
+
56
+
v2f vert(appdata_base v)
57
+
{
58
+
v2f o;
59
+
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
60
+
61
+
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
62
+
63
+
//o.viewDir = normalize(o.worldPos - _WorldSpaceCameraPos); //viewdir calculation moved to fragment shader because of interpolation artifacts (that frankly don't make any sense to me)
64
+
65
+
//o.worldNormal = normalize(mul( unity_ObjectToWorld, float4(v.normal, 0)).xyz); //should be fine
//mie scattering through rings when observed from the back
126
+
float mieG = -0.95; //needs to be negative?
127
+
float mieScattering = PhaseFunctionM(mu, mieG);
128
+
mieScattering *= 0.03; // result too bright for some reason, this fixes it
129
+
130
+
//planet shadow on ring
131
+
//do everything relative to planet position
132
+
float shadow = getEclipseShadow(worldPosRelPlanet * 6000, sunPosRelativeToPlanet, 0, planetRadius, sunRadius * penumbraMultiplier); //*6000 to convert to local space, might be simpler in scaled?
133
+
134
+
//TODO: Fade in some noise here when getting close to the rings
135
+
//make it procedural noise?
136
+
137
+
float4 color = tex2D(_MainTex, float2(texturePosition, 0.25)); //let's say left side = front texture and right side = back texture
138
+
float4 backColor = tex2D(_MainTex, float2(texturePosition, 0.75)); //back color, same as frontColor if only one band is included
139
+
//haven't tested a different back texture yet
140
+
141
+
color.xyz = color.xyz * dotLight + backColor.xyz * mieScattering; //for now alpha is taken from front color only, I'll try to think of something
142
+
color.xyz *= shadow;
143
+
144
+
color = (texturePosition > 1 || texturePosition < 0) ? float4(0, 0, 0, 0) : color; //return transparent pixels if not between inner and outer radiuses
145
+
146
+
//I'm kinda proud of this shader so far, it's short and clean
0 commit comments