Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated version.

- Added some color adjustments made by : Antitheory !!
- adjusted the skydome script and sun, put them all in one
  • Loading branch information...
commit ff838981dbf9c9cf84ee649ecc69098451d27a81 1 parent d00ecc0
@Pixelstudio authored
View
BIN  Assets/New Terrain.asset
Binary file not shown
View
2  Assets/New Terrain.asset.meta
@@ -1,2 +0,0 @@
-fileFormatVersion: 1
-guid: b702ade43aad7234d812ceebc8c5c3bd
View
BIN  Assets/Skydome/Skydome.cs
Binary file not shown
View
282 Assets/Skydome/Sun.cs
@@ -5,141 +5,151 @@
public class Sun : MonoBehaviour
{
public GameObject skydome;
- Skydome skydomeScript;
+ skydomeScript2 skydomeScript;
public Vector3 m_vDirection;
- public Vector3 m_vColor;
- Vector3 sunDirection = new Vector3 ();
- Vector3 sunDirection2 = new Vector3 ();
- float SolarAzimuth;
- float solarAltitude;
- Vector3 sunPosition;
- public float domeRadius;
- public float m_fTheta;
- public float m_fPhi;
-
- float LATITUDE_RADIANS;
- float STD_MERIDIAN;
-
- // Use this for initialization
- void Start ()
- {
- skydomeScript = skydome.GetComponent (typeof(Skydome)) as Skydome;
- }
-
- void OnEnable ()
- {
- skydomeScript = skydome.GetComponent (typeof(Skydome)) as Skydome;
- }
-
- void Update ()
- {
- skydomeScript.LATITUDE = Mathf.Clamp (skydomeScript.LATITUDE, -90.0f, 90.0f);
- SetPosition (skydomeScript.TIME);
- transform.position = sunPosition;
- }
- void SetPosition (float fTheta, float fPhi)
- {
- m_fTheta = fTheta;
- m_fPhi = fPhi;
-
- float fCosTheta = Mathf.Cos (m_fTheta);
- float fSinTheta = Mathf.Sin (m_fTheta);
- float fCosPhi = Mathf.Cos (m_fPhi);
- float fSinPhi = Mathf.Sin (m_fPhi);
-
- m_vDirection = new Vector3 (fSinTheta * fCosPhi, fCosTheta, fSinTheta * fSinPhi);
- float phiSun = (Mathf.PI * 2.0f) - SolarAzimuth;
-
- sunDirection.x = domeRadius;
- sunDirection.y = phiSun;
- sunDirection.z = solarAltitude;
- sunPosition = sphericalToCartesian (sunDirection);
-
- sunDirection2 = calcDirection (m_fTheta, phiSun);
- m_vDirection = Vector3.Normalize (m_vDirection);
- transform.LookAt (sunDirection2);
- ComputeAttenuation ();
- }
- void SetPosition (float fTime)
- {
- LATITUDE_RADIANS = Mathf.Deg2Rad * skydomeScript.LATITUDE;
- STD_MERIDIAN = skydomeScript.MERIDIAN * 15.0f;
-
- float t = fTime + 0.170f * Mathf.Sin ((4.0f * Mathf.PI * (skydomeScript.JULIANDATE - 80.0f)) / 373.0f) - 0.129f * Mathf.Sin ((2.0f * Mathf.PI * (skydomeScript.JULIANDATE - 8.0f)) / 355.0f) + (STD_MERIDIAN - skydomeScript.LONGITUDE) / 15.0f;
- float fDelta = 0.4093f * Mathf.Sin ((2.0f * Mathf.PI * (skydomeScript.JULIANDATE - 81.0f)) / 368.0f);
-
- float fSinLat = Mathf.Sin (LATITUDE_RADIANS);
- float fCosLat = Mathf.Cos (LATITUDE_RADIANS);
- float fSinDelta = Mathf.Sin (fDelta);
- float fCosDelta = Mathf.Cos (fDelta);
- float fSinT = Mathf.Sin ((Mathf.PI * t) / 12.0f);
- float fCosT = Mathf.Cos ((Mathf.PI * t) / 12.0f);
-
- solarAltitude = Mathf.Asin (fSinLat * fSinDelta - fCosLat * fCosDelta * fCosT);
- float fTheta = 0f;
- fTheta = Mathf.PI / 2.0f - solarAltitude;
-
- float opp = -fCosDelta * fSinT;
- float adj = -(fCosLat * fSinDelta + fSinLat * fCosDelta * fCosT);
- SolarAzimuth = Mathf.Atan2 (opp, adj);
-
- float fPhi = Mathf.Atan ((-fCosDelta * fSinT) / (fCosLat * fSinDelta - fSinLat * fCosDelta * fCosT));
- fPhi = -SolarAzimuth;
- SetPosition (fTheta, fPhi);
- }
- Vector3 calcDirection (float thetaSun, float phiSun)
- {
- Vector3 dir = new Vector3 ();
- dir.x = Mathf.Cos (0.5f * Mathf.PI - thetaSun) * Mathf.Cos (phiSun);
- dir.y = Mathf.Sin (0.5f * Mathf.PI - thetaSun);
- dir.z = Mathf.Cos (0.5f * Mathf.PI - thetaSun) * Mathf.Sin (phiSun);
- return dir.normalized;
- }
- Vector3 sphericalToCartesian (Vector3 sunDir)
- {
- Vector3 res = new Vector3 ();
- res.y = sunDir.x * Mathf.Sin (sunDir.z);
- float tmp = sunDir.x * Mathf.Cos (sunDir.z);
- res.x = tmp * Mathf.Cos (sunDir.y);
- res.z = tmp * Mathf.Sin (sunDir.y);
- return res;
- }
- void ComputeAttenuation ()
- {
- float fBeta = 0.04608365822050f * skydomeScript.m_fTurbidity - 0.04586025928522f;
- float fTauR, fTauA;
- float[] fTau = new float[3];
- float tmp = 93.885f - (m_fTheta / Mathf.PI * 180.0f);
-
- float m;
- m = (float)(1.0f / (Mathf.Cos (m_fTheta) + 0.15f * tmp));
- // Relative Optical Mass
- //m = (float)(1.0f / (Mathf.Cos(m_fTheta) + 0.15f * Mathf.Pow(93.885f - m_fTheta / Mathf.PI * 180.0f, -1.253f)));
- if (m < 0) {
- m = 20;
- }
- float[] fLambda = new float[3];
- fLambda[0] = 0.65f; // red (in um.)
- fLambda[1] = 0.57f; // green (in um.)
- fLambda[2] = 0.475f;// blue (in um.)
- for (int i = 0; i < 3; i++) {
- // Rayleigh Scattering
- // Results agree with the graph (pg 115, MI) */
- // lambda in um.
- fTauR = Mathf.Exp (-m * 0.008735f * Mathf.Pow (fLambda[i], -4.08f));
-
- // Aerosal (water + dust) attenuation
- // beta - amount of aerosols present
- // alpha - ratio of small to large particle sizes. (0:4,usually 1.3)
- // Results agree with the graph (pg 121, MI)
- const float fAlpha = 1.3f;
- fTauA = Mathf.Exp (-m * fBeta * Mathf.Pow (fLambda[i], -fAlpha));
- // lambda should be in um
- fTau[i] = fTauR * fTauA;
- }
-
- m_vColor = new Vector3 (fTau[0], fTau[1], fTau[2]);
- light.color = new Color (fTau[0], fTau[1], fTau[2]);
- RenderSettings.fogColor = new Color (fTau[0], fTau[1], fTau[2]);;
- }
+ public Vector3 m_vColor;
+ Vector3 sunDirection = new Vector3();
+ Vector3 sunDirection2 = new Vector3();
+ float SolarAzimuth;
+ float solarAltitude;
+ Vector3 sunPosition;
+ public float domeRadius;
+ public float m_fTheta;
+ public float m_fPhi;
+
+ float LATITUDE_RADIANS;
+ float STD_MERIDIAN;
+
+ // Use this for initialization
+ void Start()
+ {
+ skydomeScript = skydome.GetComponent(typeof(skydomeScript2)) as skydomeScript2;
+ }
+
+ void OnEnable()
+ {
+ skydomeScript = skydome.GetComponent(typeof(skydomeScript2)) as skydomeScript2;
+ }
+
+ void Update()
+ {
+ skydomeScript.LATITUDE = Mathf.Clamp(skydomeScript.LATITUDE, -90.0f, 90.0f);
+ SetPosition(skydomeScript.TIME);
+ transform.position = sunPosition;
+ }
+ void SetPosition(float fTheta, float fPhi )
+ {
+ m_fTheta = fTheta;
+ m_fPhi = fPhi;
+
+ float fCosTheta = Mathf.Cos( m_fTheta );
+ float fSinTheta = Mathf.Sin(m_fTheta);
+ float fCosPhi = Mathf.Cos(m_fPhi);
+ float fSinPhi = Mathf.Sin(m_fPhi);
+
+ m_vDirection = new Vector3( fSinTheta * fCosPhi,fCosTheta,fSinTheta * fSinPhi );
+ // if (solarAltitude > -0.06f)
+ // {
+ float phiSun = (Mathf.PI * 2.0f) - SolarAzimuth;
+
+ sunDirection.x = domeRadius;
+ sunDirection.y = phiSun;
+ sunDirection.z = solarAltitude;
+ sunPosition = sphericalToCartesian(sunDirection);
+
+ sunDirection2 = calcDirection(m_fTheta, phiSun);
+ m_vDirection = Vector3.Normalize(m_vDirection);
+ transform.LookAt(sunDirection2);
+ ComputeAttenuation();
+ //}
+ }
+ void SetPosition( float fTime )
+ {
+ LATITUDE_RADIANS = Mathf.Deg2Rad * skydomeScript.LATITUDE;
+ STD_MERIDIAN = skydomeScript.MERIDIAN * 15.0f;
+
+ float t = fTime + 0.170f * Mathf.Sin((4.0f * Mathf.PI * (skydomeScript.JULIANDATE - 80.0f)) / 373.0f)
+ - 0.129f * Mathf.Sin((2.0f * Mathf.PI * (skydomeScript.JULIANDATE - 8.0f)) / 355.0f)
+ + (STD_MERIDIAN - skydomeScript.LONGITUDE) / 15.0f;
+ float fDelta = 0.4093f * Mathf.Sin((2.0f * Mathf.PI * (skydomeScript.JULIANDATE - 81.0f)) / 368.0f);
+
+ float fSinLat = Mathf.Sin(LATITUDE_RADIANS);
+ float fCosLat = Mathf.Cos(LATITUDE_RADIANS);
+ float fSinDelta = Mathf.Sin(fDelta);
+ float fCosDelta = Mathf.Cos(fDelta);
+ float fSinT = Mathf.Sin((Mathf.PI * t) / 12.0f);
+ float fCosT = Mathf.Cos((Mathf.PI * t) / 12.0f);
+
+ solarAltitude = Mathf.Asin(fSinLat * fSinDelta - fCosLat * fCosDelta * fCosT);
+ float fTheta = 0f;
+ fTheta = Mathf.PI / 2.0f - solarAltitude;
+
+ float opp = -fCosDelta * fSinT;
+ float adj = -(fCosLat * fSinDelta+ fSinLat * fCosDelta * fCosT);
+ SolarAzimuth = Mathf.Atan2(opp, adj);
+
+ float fPhi = Mathf.Atan( (- fCosDelta * fSinT) / ( fCosLat * fSinDelta - fSinLat * fCosDelta * fCosT ) );
+ fPhi = -SolarAzimuth;
+ SetPosition( fTheta, fPhi );
+ }
+ Vector3 calcDirection(float thetaSun, float phiSun)
+ {
+ Vector3 dir = new Vector3();
+ dir.x = Mathf.Cos(0.5f * Mathf.PI - thetaSun) * Mathf.Cos(phiSun);
+ dir.y = Mathf.Sin(0.5f * Mathf.PI - thetaSun);
+ dir.z = Mathf.Cos(0.5f * Mathf.PI - thetaSun) * Mathf.Sin(phiSun);
+ return dir.normalized;
+ }
+ Vector3 sphericalToCartesian(Vector3 sunDir)
+ {
+ Vector3 res = new Vector3();
+ res.y = sunDir.x * Mathf.Sin(sunDir.z);
+ float tmp = sunDir.x * Mathf.Cos(sunDir.z);
+ res.x = tmp * Mathf.Cos(sunDir.y);
+ res.z = tmp * Mathf.Sin(sunDir.y);
+ return res;
+ }
+ void ComputeAttenuation()
+ {
+ float fBeta = 0.04608365822050f * skydomeScript.m_fTurbidity - 0.04586025928522f;
+ float fTauR, fTauA;
+ float[] fTau = new float[3];
+ float tmp = 93.885f - (m_fTheta / Mathf.PI * 180.0f);
+
+ float m;
+ m = (float)(1.0f / (Mathf.Cos(m_fTheta) + 0.15f * tmp)); // Relative Optical Mass
+ // m = (float)(1.0f / (Mathf.Cos(m_fTheta) + 0.15f * Mathf.Pow(93.885f - m_fTheta / Mathf.PI * 180.0f, -1.253f)));
+ if (m < 0)
+ {
+ m = 20;
+ }
+ float[] fLambda = new float[3];
+ fLambda[0] = 0.65f; // red (in um.)
+ fLambda[1] = 0.57f; // green (in um.)
+ fLambda[2] = 0.475f; // blue (in um.)
+ for(int i = 0; i < 3; i++)
+ {
+ // Rayleigh Scattering
+ // Results agree with the graph (pg 115, MI) */
+ // lambda in um.
+ fTauR = Mathf.Exp(-m * 0.008735f * Mathf.Pow(fLambda[i], -4.08f));
+
+ // Aerosal (water + dust) attenuation
+ // beta - amount of aerosols present
+ // alpha - ratio of small to large particle sizes. (0:4,usually 1.3)
+ // Results agree with the graph (pg 121, MI)
+ const float fAlpha =1.3f;
+ fTauA = Mathf.Exp(-m * fBeta * Mathf.Pow(fLambda[i], -fAlpha)); // lambda should be in um
+ fTau[i] = fTauR * fTauA;
+ }
+ //post processing...
+ Color pp = new Color(fTau[0], fTau[1], fTau[2]);
+
+ //pp = ColorCorrection.hsb(pp, 0, 0.2f, 0.2f);
+
+ light.color = new Color(pp.r, pp.g, pp.b);
+
+
+ m_vColor = new Vector3(pp.r,pp.g,pp.b);
+ }
}
View
BIN  Assets/Skydome/aScattering.mat
Binary file not shown
View
86 Assets/Standard Assets/MouseLook.cs
@@ -1,86 +0,0 @@
-using UnityEngine;
-using System.Collections;
-
-/// MouseLook rotates the transform based on the mouse delta.
-/// Minimum and Maximum values can be used to constrain the possible rotation
-
-/// To make an FPS style character:
-/// - Create a capsule.
-/// - Add a rigid body to the capsule
-/// - Add the MouseLook script to the capsule.
-/// -> Set the mouse look to use LookX. (You want to only turn character but not tilt it)
-/// - Add FPSWalker script to the capsule
-
-/// - Create a camera. Make the camera a child of the capsule. Reset it's transform.
-/// - Add a MouseLook script to the camera.
-/// -> Set the mouse look to use LookY. (You want the camera to tilt up and down like a head. The character already turns.)
-[AddComponentMenu("Camera-Control/Mouse Look")]
-public class MouseLook : MonoBehaviour {
-
- public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 }
- public RotationAxes axes = RotationAxes.MouseXAndY;
- public float sensitivityX = 15F;
- public float sensitivityY = 15F;
-
- public float minimumX = -360F;
- public float maximumX = 360F;
-
- public float minimumY = -60F;
- public float maximumY = 60F;
-
- float rotationX = 0F;
- float rotationY = 0F;
-
- Quaternion originalRotation;
-
- void Update ()
- {
- if (axes == RotationAxes.MouseXAndY)
- {
- // Read the mouse input axis
- rotationX += Input.GetAxis("Mouse X") * sensitivityX;
- rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
-
- rotationX = ClampAngle (rotationX, minimumX, maximumX);
- rotationY = ClampAngle (rotationY, minimumY, maximumY);
-
- Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up);
- Quaternion yQuaternion = Quaternion.AngleAxis (rotationY, Vector3.left);
-
- transform.localRotation = originalRotation * xQuaternion * yQuaternion;
- }
- else if (axes == RotationAxes.MouseX)
- {
- rotationX += Input.GetAxis("Mouse X") * sensitivityX;
- rotationX = ClampAngle (rotationX, minimumX, maximumX);
-
- Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up);
- transform.localRotation = originalRotation * xQuaternion;
- }
- else
- {
- rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
- rotationY = ClampAngle (rotationY, minimumY, maximumY);
-
- Quaternion yQuaternion = Quaternion.AngleAxis (rotationY, Vector3.left);
- transform.localRotation = originalRotation * yQuaternion;
- }
- }
-
- void Start ()
- {
- // Make the rigid body not change rotation
- if (rigidbody)
- rigidbody.freezeRotation = true;
- originalRotation = transform.localRotation;
- }
-
- public static float ClampAngle (float angle, float min, float max)
- {
- if (angle < -360F)
- angle += 360F;
- if (angle > 360F)
- angle -= 360F;
- return Mathf.Clamp (angle, min, max);
- }
-}
View
2  Assets/Standard Assets/MouseLook.cs.meta
@@ -1,2 +0,0 @@
-fileFormatVersion: 1
-guid: 7a2ff7e1112d3684a92c4fecf810babd
View
BIN  Assets/main.unity
Binary file not shown
View
2  Assets/main.unity.meta
@@ -1,2 +0,0 @@
-fileFormatVersion: 1
-guid: d9f0a0d0244e8824eb9b233b0cc56511
View
BIN  Library/InspectorExpandedItems.asset
Binary file not shown
View
BIN  Library/MonoManager.asset
Binary file not shown
View
BIN  Library/ScriptMapper
Binary file not shown
View
BIN  Library/assetDatabase3
Binary file not shown
View
BIN  Library/expandedItems
Binary file not shown
View
BIN  Library/guidmapper
Binary file not shown
View
5 Skydome.csproj
@@ -49,10 +49,13 @@
</ItemGroup>
<ItemGroup>
<None Include="Assets\Skydome\aScattering2.0.shader" />
+ <None Include="Assets\Skydome\aScattering2.1.shader" />
+ <Compile Include="Assets\Skydome\Skydome-old.cs" />
<Compile Include="Assets\Skydome\Skydome.cs" />
+ <Compile Include="Assets\Skydome\skydomeScript2.cs" />
<Compile Include="Assets\Skydome\Sun.cs" />
+ <Compile Include="Assets\Standard Assets\Camera Scripts\MouseLook.cs" />
<Compile Include="Assets\Standard Assets\fpsWalker.cs" />
- <Compile Include="Assets\Standard Assets\MouseLook.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
View
BIN  Skydome.pidb
Binary file not shown
View
9 Skydome.userprefs
@@ -1,10 +1,11 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" ctype="Workspace" />
- <MonoDevelop.Ide.Workbench ActiveDocument="Assets\Skydome\Sun.cs" ctype="Workbench">
+ <MonoDevelop.Ide.Workbench ActiveDocument="Assets\Skydome\skydomeScript2.cs" ctype="Workbench">
<Files>
- <File FileName="Assets\Skydome\skydomeScript2.cs" Line="38" Column="1" />
- <File FileName="Assets\Skydome\Sun.cs" Line="63" Column="13" />
- <File FileName="Assets\Skydome\aScattering2.0.shader" Line="1" Column="1" />
+ <File FileName="Assets\Skydome\skydomeScript2.cs" Line="48" Column="25" />
+ <File FileName="Assets\Skydome\Skydome.cs" Line="45" Column="2" />
+ <File FileName="Assets\Skydome\Skydome-old.cs" Line="5" Column="21" />
+ <File FileName="Assets\Skydome\Cloud.cs" Line="19" Column="32" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
Please sign in to comment.
Something went wrong with that request. Please try again.