You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

226 lines
5.5 KiB

5 years ago
  1. #ifndef FOG_VOLUME_COMMON_INPUTS_INCLUDED
  2. #define FOG_VOLUME_COMMON_INPUTS_INCLUDED
  3. uniform sampler2D
  4. _Gradient,
  5. _ValueNoise;
  6. #ifdef _FOG_VOLUME_NOISE
  7. uniform sampler3D _NoiseVolume, _NoiseVolume2;
  8. sampler2D CoverageTex;
  9. #endif
  10. float Collisions = 0;
  11. half4 _AmbientHeightAbsorption;
  12. #define _AmbientHeightAbsorptionMin _AmbientHeightAbsorption.x
  13. #define _AmbientHeightAbsorptionMax _AmbientHeightAbsorption.y
  14. #ifdef HEIGHT_GRAD
  15. half4 _VerticalGradientParams;
  16. #define GradMin _VerticalGradientParams.x
  17. #define GradMax _VerticalGradientParams.y
  18. #define GradMin2 _VerticalGradientParams.z
  19. #define GradMax2 _VerticalGradientParams.w
  20. #endif
  21. #ifdef DEBUG
  22. sampler2D _PerformanceLUT;
  23. #endif
  24. #ifdef _FOG_LOWRES_RENDERER
  25. sampler2D RT_Depth, RT_DepthR;
  26. #endif
  27. #ifdef VOLUME_SHADOWS
  28. sampler2D LightshaftTex;
  29. #endif
  30. #ifdef HALO
  31. sampler2D _LightHaloTexture;
  32. fixed _HaloOpticalDispersion,
  33. _HaloIntensity,
  34. _HaloWidth,
  35. _HaloRadius,
  36. _HaloAbsorption;
  37. #endif
  38. #ifdef ExternalDepth
  39. sampler2D _CustomCameraDepthTexture;
  40. #else
  41. sampler2D _CameraDepthTexture;
  42. #endif
  43. int STEP_COUNT = 200;
  44. int _ProxyVolume;
  45. int _AmbientAffectsFogColor;
  46. #ifdef DF
  47. uniform float4x4 _PrimitivesTransform[20];
  48. uniform half _PrimitiveEdgeSoftener;
  49. uniform float4 _PrimitivePosition[20],
  50. _PrimitiveScale[20], _PrimitiveData[20];
  51. int _PrimitiveCount = 0;
  52. // Smaller than 1.0f -> BoxCollider.
  53. // Larger than 1.0f and smaller than 2.0f -> SphereCollider.
  54. #define _PrimitiveShapeType(i) _PrimitiveData[i].x
  55. // Smaller than 1.0f -> Additive.
  56. // Larger than 1.0f and smaller than 2.0f -> Subtractive.
  57. #define _PrimitiveActionType(i) _PrimitiveData[i].y
  58. #endif
  59. const static int MaxVisibleLights = 64;
  60. #if SHADER_API_GLCORE || SHADER_API_D3D11 | SHADER_API_METAL
  61. #if ATTEN_METHOD_1 || ATTEN_METHOD_2 || ATTEN_METHOD_3
  62. uniform float4 _LightData[MaxVisibleLights];
  63. #define _LightIntensity(i) _LightData[i].x
  64. #define _LightRange(i) _LightData[i].y
  65. #define _LightSpotAngle(i) _LightData[i].z
  66. uniform float4 _LightPositions[MaxVisibleLights], _LightColors[MaxVisibleLights], _LightRotations[MaxVisibleLights];
  67. half PointLightingDistance,
  68. PointLightingDistance2Camera;
  69. #endif
  70. #endif
  71. #ifdef _SHADE
  72. int _SelfShadowSteps;
  73. float4 _SelfShadowColor;
  74. #endif
  75. //uniform int STEP_COUNT = 50,
  76. int _LightsCount = 0,
  77. Octaves,
  78. _DebugMode,
  79. SamplingMethod,
  80. DirectLightingShadowSteps;
  81. #if DIRECTIONAL_LIGHTING
  82. half DirectLightingShadowDensity;
  83. float4 LightExtinctionColor;
  84. #endif
  85. uniform float4 _Color,
  86. _FogColor,
  87. _InscatteringColor,
  88. _BoxMin,
  89. _BoxMax,
  90. Stretch,
  91. _LightColor,
  92. _AmbientColor,
  93. VolumeSize,
  94. VolumeFogInscatteringColor,
  95. _VolumePosition;
  96. uniform float3 L = float3(0, 0, 1),
  97. _LightLocalDirection,
  98. //_CameraForward,
  99. _SliceNormal,
  100. Speed = 1;
  101. int VolumeFogInscatterColorAffectedWithFogColor = 1;
  102. uniform half DetailTiling,
  103. _PrimitiveCutout,
  104. HeightAbsorption,
  105. _LightExposure,
  106. VolumeFogInscatteringIntensity,
  107. VolumeFogInscatteringAnisotropy,
  108. VolumeFogInscatteringStartDistance,
  109. VolumeFogInscatteringTransitionWideness,
  110. _PushAlpha,
  111. _DetailMaskingThreshold,
  112. //_DetailSamplingBaseOpacityLimit,
  113. _OptimizationFactor,
  114. _BaseRelativeSpeed,
  115. _DetailRelativeSpeed,
  116. _NoiseDetailRange,
  117. _Curl,
  118. Absorption,
  119. BaseTiling,
  120. _Cutoff,
  121. Coverage,
  122. NoiseDensity,
  123. LambertianBias,
  124. DirectLightingAmount,
  125. NormalDistance,
  126. _Vortex = 1,
  127. _RotationSpeed,
  128. _Rotation,
  129. DirectLightingDistance,
  130. _FOV,
  131. _DirectionalLightingDistance,
  132. //GradMin,
  133. // GradMax,
  134. Constrain,
  135. SphericalFadeDistance,
  136. DetailDistance,
  137. _SceneIntersectionSoftness,
  138. _InscatteringIntensity = 1,
  139. InscatteringShape,
  140. _Visibility,
  141. InscatteringStartDistance = 100,
  142. IntersectionThreshold,
  143. InscatteringTransitionWideness = 500,
  144. _3DNoiseScale,
  145. _RayStep,
  146. gain = 1,
  147. threshold = 0,
  148. Shade,
  149. _SceneIntersectionThreshold,
  150. ShadowBrightness,
  151. _jitter,
  152. FadeDistance,
  153. Offset = 0,
  154. Gamma = 1,
  155. Exposure;
  156. struct v2f
  157. {
  158. float4 pos : SV_POSITION;
  159. float3 Wpos : TEXCOORD0;
  160. float4 ScreenUVs : TEXCOORD1;
  161. float3 LocalPos : TEXCOORD2;
  162. float3 ViewPos : TEXCOORD3;
  163. float3 LocalEyePos : TEXCOORD4;
  164. float3 LightLocalDir : TEXCOORD5;
  165. float3 WorldEyeDir : TEXCOORD6;
  166. float2 uv0 : TEXCOORD7;
  167. float3 SliceNormal : TEXCOORD8;
  168. float3 worldNormal : TEXCOORD9;
  169. };
  170. v2f vert(appdata_full i)
  171. {
  172. v2f o;
  173. o.pos = UnityObjectToClipPos(i.vertex);
  174. o.Wpos = mul((float4x4)unity_ObjectToWorld, float4(i.vertex.xyz, 1)).xyz;
  175. o.ScreenUVs = ComputeScreenPos(o.pos);
  176. o.ViewPos = UnityObjectToViewPos( float4(i.vertex.xyz, 1)).xyz;
  177. o.LocalPos = i.vertex.xyz;
  178. o.LocalEyePos = mul((float4x4)unity_WorldToObject, (float4(_WorldSpaceCameraPos, 1))).xyz;
  179. o.LightLocalDir = mul((float4x4)unity_WorldToObject, (float4(L.xyz, 1))).xyz;
  180. o.WorldEyeDir = (o.Wpos.xyz - _WorldSpaceCameraPos.xyz);
  181. o.uv0 = i.texcoord;
  182. //WIN http://answers.unity3d.com/questions/192553/camera-forward-vector-in-shader.html
  183. o.SliceNormal = UNITY_MATRIX_IT_MV[2].xyz;// mul((float4x4)unity_WorldToObject, _SliceNormal).xyz;
  184. o.worldNormal = float3(0, -1, 0);//upwards
  185. //o.worldNormal = UnityObjectToWorldNormal(float3(0,0 , 1));
  186. return o;
  187. }
  188. #endif