├── .gitignore ├── Assets ├── Lightmapping Extended.meta └── Lightmapping Extended │ ├── Editor.meta │ ├── Editor │ ├── ILConfig.cs │ ├── ILConfig.cs.meta │ ├── LMExtendedWindow.cs │ ├── LMExtendedWindow.cs.meta │ ├── SavePresetWindow.cs │ ├── SavePresetWindow.cs.meta │ ├── SerializedConfig.cs │ └── SerializedConfig.cs.meta │ ├── Presets.meta │ ├── Presets │ ├── Built-in.meta │ └── Built-in │ │ ├── High Quality.xml │ │ ├── High Quality.xml.meta │ │ ├── Low Quality.xml │ │ └── Low Quality.xml.meta │ ├── Shaders.meta │ └── Shaders │ ├── Alpha-BumpSpec.shader │ ├── Alpha-BumpSpec.shader.meta │ ├── Alpha-Bumped.shader │ ├── Alpha-Bumped.shader.meta │ ├── Alpha-Diffuse.shader │ ├── Alpha-Diffuse.shader.meta │ ├── Alpha-Glossy.shader │ ├── Alpha-Glossy.shader.meta │ ├── Alpha-Parallax.shader │ ├── Alpha-Parallax.shader.meta │ ├── Alpha-ParallaxSpec.shader │ ├── Alpha-ParallaxSpec.shader.meta │ ├── Alpha-VertexLit.shader │ ├── Alpha-VertexLit.shader.meta │ ├── AlphaTest-BumpSpec.shader │ ├── AlphaTest-BumpSpec.shader.meta │ ├── AlphaTest-Bumped.shader │ ├── AlphaTest-Bumped.shader.meta │ ├── AlphaTest-Diffuse.shader │ ├── AlphaTest-Diffuse.shader.meta │ ├── AlphaTest-Glossy.shader │ ├── AlphaTest-Glossy.shader.meta │ ├── AlphaTest-SoftEdgeUnlit.shader │ ├── AlphaTest-SoftEdgeUnlit.shader.meta │ ├── AlphaTest-VertexLit.shader │ └── AlphaTest-VertexLit.shader.meta ├── Documentation ├── Beast_XML_and_Lua_Reference_Manual.pdf └── beastapimanual.pdf ├── LICENSE ├── ProjectSettings ├── AudioManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── InputManager.asset ├── NavMeshLayers.asset ├── NetworkManager.asset ├── ProjectSettings.asset ├── QualitySettings.asset ├── TagManager.asset └── TimeManager.asset └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Library 3 | *.csproj 4 | *.pidb 5 | *.sln 6 | *.userprefs 7 | Temp -------------------------------------------------------------------------------- /Assets/Lightmapping Extended.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51508b18f9b584d6887f81c6a86bd27f 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dce65121085b14ad395b357538765498 3 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Editor/ILConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 Michael Stevenson 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in the 5 | // Software without restriction, including without limitation the rights to use, copy, 6 | // modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 7 | // and to permit persons to whom the Software is furnished to do so, subject to the 8 | // following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all copies 11 | // or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 15 | // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 16 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 17 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 18 | // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | using UnityEngine; 21 | using System.Collections; 22 | using System.Xml; 23 | using System.Xml.Serialization; 24 | using System.IO; 25 | 26 | 27 | [System.Serializable] 28 | public class ILConfig 29 | { 30 | public enum ShadowDepth 31 | { 32 | PrimaryRays = 1, 33 | PrimaryAndSecondaryRays = 2 34 | } 35 | 36 | #region Data types 37 | 38 | [System.Serializable] 39 | public class LMVec2 40 | { 41 | public float x; 42 | public float y; 43 | 44 | public LMVec2 () 45 | { 46 | x = 0; 47 | y = 0; 48 | } 49 | 50 | public LMVec2 (float x, float y) 51 | { 52 | this.x = x; 53 | this.y = y; 54 | } 55 | } 56 | 57 | [System.Serializable] 58 | public class LMColor 59 | { 60 | public float r; 61 | public float g; 62 | public float b; 63 | public float a; 64 | 65 | public LMColor () 66 | { 67 | this.r = 1; 68 | this.g = 1; 69 | this.b = 1; 70 | this.a = 1; 71 | } 72 | 73 | public LMColor (float r, float g, float b, float a) 74 | { 75 | this.r = r; 76 | this.g = g; 77 | this.b = b; 78 | this.a = a; 79 | } 80 | } 81 | 82 | #endregion 83 | 84 | [XmlElement(ElementName = "AASettings")] 85 | public AASettings aaSettings = new AASettings (); 86 | [XmlElement(ElementName = "RenderSettings")] 87 | public RenderSettings renderSettings = new RenderSettings (); 88 | [XmlElement(ElementName = "EnvironmentSettings")] 89 | public EnvironmentSettings environmentSettings = new EnvironmentSettings (); 90 | [XmlElement(ElementName = "FrameSettings")] 91 | public FrameSettings frameSettings = new FrameSettings (); 92 | [XmlElement(ElementName = "GISettings")] 93 | public GISettings giSettings = new GISettings (); 94 | [XmlElement(ElementName = "SurfaceTransferSettings")] 95 | public SurfaceTransferSettings surfaceTransferSettings = new SurfaceTransferSettings (); 96 | [XmlElement(ElementName = "TextureBakeSettings")] 97 | public TextureBakeSettings textureBakeSettings = new TextureBakeSettings (); 98 | 99 | 100 | public static ILConfig DeserializeFromPath (string path) 101 | { 102 | FileInfo info = new FileInfo (path); 103 | if (!info.Exists) { 104 | return null; 105 | } 106 | 107 | XmlSerializer serializer = new XmlSerializer (typeof(ILConfig)); 108 | FileStream stream = new FileStream (path, FileMode.Open); 109 | 110 | ILConfig config = (ILConfig)serializer.Deserialize (stream); 111 | stream.Close (); 112 | 113 | return config; 114 | } 115 | 116 | public void SerializeToPath (string path) 117 | { 118 | using (XmlTextWriter writer = new XmlTextWriter (path, System.Text.Encoding.GetEncoding ("ISO-8859-1"))) { 119 | XmlSerializerNamespaces ns = new XmlSerializerNamespaces (); 120 | ns.Add (string.Empty, string.Empty); 121 | writer.Formatting = Formatting.Indented; 122 | XmlSerializer serializer = new XmlSerializer (typeof(ILConfig)); 123 | serializer.Serialize (writer, this, ns); 124 | } 125 | } 126 | 127 | public string SerializeToString () 128 | { 129 | StringWriter writer = new StringWriter (); 130 | XmlSerializer serializer = new XmlSerializer (typeof(ILConfig)); 131 | serializer.Serialize (writer, this); 132 | return writer.ToString (); 133 | } 134 | 135 | public static ILConfig DeserializeFromString (string configString) 136 | { 137 | XmlSerializer serializer = new XmlSerializer (typeof(ILConfig)); 138 | TextReader reader = new StringReader (configString); 139 | ILConfig config = (ILConfig)serializer.Deserialize (reader); 140 | return config; 141 | } 142 | 143 | [System.Serializable] 144 | public class FrameSettings 145 | { 146 | /// 147 | /// Different ways for Beast to distribute tiles over the image plane. 148 | /// 149 | // public enum TileScheme 150 | // { 151 | // /// 152 | // /// Render from left to right. 153 | // /// 154 | // LeftToRight, 155 | // /// 156 | // /// A way for Beast to achieve maximum coherence, e.g., the fastest rendering time possible. 157 | // /// 158 | // Hilbert, 159 | // /// 160 | // /// A good way to get an early feel for the whole picture without rendering everything. 161 | // /// 162 | // Random, 163 | // /// 164 | // /// Starts in the middle and renders outward in a spiral. 165 | // /// 166 | // Concentric 167 | // } 168 | 169 | public enum ColorCorrection 170 | { 171 | None, 172 | Gamma, 173 | SRGB 174 | } 175 | 176 | [System.Serializable] 177 | public class OutputVerbosity 178 | { 179 | public bool errorPrint = true; 180 | public bool warningPrint = true; 181 | public bool benchmarkPrint = false; 182 | public bool progressPrint = true; 183 | public bool infoPrint = false; 184 | public bool verbosePrint = false; 185 | /// 186 | /// Used for development purposes. 187 | /// 188 | public bool debugPrint = false; 189 | /// 190 | /// Save all log messages to a file named debug.out. 191 | /// 192 | public bool debugFile = false; 193 | } 194 | 195 | [System.Serializable] 196 | public class OutputCorrection 197 | { 198 | /// 199 | /// Set the mode of output color correction to None, Gamma or SRGB. 200 | /// The Beast API assumes this is set to Gamma. 201 | /// 202 | public ColorCorrection colorCorrection = ColorCorrection.None; 203 | /// 204 | /// A float value specifying what gamma the output data should have. 205 | /// The Beast API assumes this is set to 2.2. 206 | /// 207 | public float gamma = 1; 208 | } 209 | 210 | /// 211 | /// If enabled, Beast will try to auto detect the CPU configuration and use one thread per core. 212 | /// 213 | public bool autoThreads = true; 214 | /// 215 | /// If autoThreads is enabled, this can be used to decrease the number of utilized cores, 216 | /// e.g. to leave one or two cores free to do other work. 217 | /// 218 | public int autoThreadsSubtract = 0; 219 | /// 220 | /// If autoThreads is disabled, this will set the number of threads beast uses. One per core is a good start. 221 | /// 222 | public int renderThreads = 2; 223 | /// 224 | /// If the output is LDR, and dither is true, the resulting image will be dithered. Default is true. 225 | /// 226 | public bool dither = true; 227 | /// 228 | /// A float value specifying what gamma the input data has. Always set this to 1.0 / 2.2 = 0.454545, 229 | /// which is the gamma the Beast API assumes is used. 230 | /// 231 | public float inputGamma = 1.0f; 232 | public OutputCorrection outputCorrection = new OutputCorrection (); 233 | /// 234 | /// Different ways for Beast to distribute tiles over the image plane. 235 | /// 236 | // public TileScheme tileScheme = TileScheme.Hilbert; 237 | /// 238 | /// A smaller tile gives better ray tracing coherence. There is no “best setting” for all scenes. 239 | /// Default value is 32, giving 32x32 pixel tiles. The largest allowed tile size is 128. 240 | /// 241 | // public int tileSize = 32; 242 | /// 243 | /// If this box is checked the alpha channel value is pre multiplied into the color channel of the pixel. 244 | /// Note that disabling premultiply alpha gives poor result if used with environment maps and other 245 | /// non constant camera backgrounds. Disabling premultiply alpha can be convenient when composing 246 | /// images in post. 247 | /// 248 | public bool premultiply = true; 249 | /// 250 | /// This is the alpha threshold for pixels to be considered opaque enough to be “un multiplied” 251 | /// when using premultiply alpha. 252 | /// 253 | public float premultiplyThreshold = 0.0f; 254 | /// 255 | /// Different levels of textual output that Beast can produce. 256 | /// 257 | public OutputVerbosity outputVerbosity = new OutputVerbosity (); 258 | } 259 | 260 | 261 | 262 | [System.Serializable] 263 | public class RenderSettings 264 | { 265 | /// 266 | /// An error threshold to avoid double intersections. 267 | /// For example, a shadow ray should not intersect the same triangle as the primary ray did, 268 | /// but because of limited numerical precision this can happen. The bias value moves the 269 | /// intersection point to eliminate this problem. If set to zero this value is computed 270 | /// automatically depending on the scene size. 271 | /// 272 | public float bias = 0.005f; 273 | /// 274 | /// Controls the maximum transparency depth for Global Illumination rays. 275 | /// Used to speed up renderings with a lot of transparency (for example trees). 276 | /// 277 | public int giTransparencyDepth = 2; 278 | /// 279 | /// If true, light-links will be ignored and all available light sources will be used. 280 | /// 281 | public bool ignoreLightLinks = false; 282 | /// 283 | /// The maximum amount of "bounces" a ray can have before being considered done. 284 | /// A bounce can be a reflection or refraction. 285 | /// 286 | public int maxRayDepth = 6; 287 | /// 288 | /// The maximum number of shadow rays per point that will be used to generate a soft shadow 289 | /// for any light source. Use this to shorten render times at the price of soft shadow quality. 290 | /// This will lower the maximum number of rays sent for any light sources that have a shadow 291 | /// samples setting higher than this value, but will not raise the number if shadow samples 292 | /// is set to a lower value. 293 | /// 294 | public int maxShadowRays = 10000; 295 | /// 296 | /// The minimum number of shadow rays that will be sent to determine if a point is lit by a 297 | /// specific light source. Use this value to ensure that you get enough quality in soft shadows 298 | /// at the price of render times. This will raise the minimum number of rays sent for any light 299 | /// sources that have a minShadowSamples setting lower than this value, but will not lower the 300 | /// number if minShadowSamples is set to a higher value. Setting this to a value higher than 301 | /// maxShadowRays will not send more rays than maxShadowRays. 302 | /// 303 | public int minShadowRays = 0; 304 | /// 305 | /// The maximum amount of reflections a ray can have before being considered done. 306 | /// 307 | public int reflectionDepth = 2; 308 | /// 309 | /// If the intensity of the reflected contribution is less than the threshold, the ray will be terminated. 310 | /// 311 | public float reflectionThreshold = 0.001f; 312 | /// 313 | /// Controls which rays that spawn shadow rays. If set to 1, only primary rays spawn shadow rays. 314 | /// If set to 2, the first secondary ray spawns a shadow ray as well. 315 | /// 316 | public int shadowDepth = 2; 317 | /// 318 | /// Make objects cast shadows from all light sources, not only the light-linked light sources. 319 | /// 320 | public bool shadowsIgnoreLightLinks = false; 321 | public int transparencyDepth = 50; 322 | /// 323 | /// Normalize tangent space basis vectors (tangent, binormal and normal) at every intersection point. 324 | /// 325 | public bool tsIntersectionNormalization = true; 326 | /// 327 | /// Orthogonalize tangent space basis vectors (tangent, binormal and normal) at every intersection point. 328 | /// 329 | public bool tsIntersectionOrthogonalization = true; 330 | /// 331 | /// Using this setting will force Beast to mirror tangent and binormal when UV has odd winding direction. 332 | /// 333 | public bool tsOddUVFlipping = true; 334 | /// 335 | /// Normalize tangent space basis vectors (tangent, binormal and normal) at every vertex. 336 | /// 337 | public bool tsVertexNormalization = true; 338 | /// 339 | /// Orthogonalize tangent space basis vectors (tangent, binormal and normal) at every vertex. 340 | /// 341 | public bool tsVertexOrthogonalization = true; 342 | /// 343 | /// Triangle vertices that are closer together than this threshold will be merged into one 344 | /// (if possible depending on other vertex data). 345 | /// 346 | public float vertexMergeThreshold = 0.001f; 347 | } 348 | 349 | 350 | 351 | [System.Serializable] 352 | public class AASettings 353 | { 354 | public enum SamplingMode { 355 | /// 356 | /// Anti-aliasing scheme for under/over sampling (from 1/256 up to 256 samples per pixel) 357 | /// 358 | Adaptive, 359 | /// 360 | /// Anti-aliasing scheme for super sampling (from 1 up to 128 samples per pixel) 361 | /// 362 | SuperSampling 363 | } 364 | 365 | public enum Filter { 366 | /// 367 | /// Each sample is treated as equally important. The fastest filter to execute but it gives blurry results. 368 | /// 369 | Box, 370 | CatmullRom, 371 | Cubic, 372 | /// 373 | /// Removes noise, preserves details. 374 | /// 375 | Gauss, 376 | Lanczos, 377 | Mitchell, 378 | /// 379 | /// Distant samples are considered less important. 380 | /// 381 | Triangle, 382 | } 383 | 384 | /// 385 | /// Controls the minimum number of samples per pixel. Values less than 0 allows using less than one 386 | /// sample per pixel (if AdaptiveSampling is used). Default value is 0. 387 | /// 388 | public int minSampleRate = 0; 389 | /// 390 | /// Controls the maximum number of samples per pixel. Default value is 0. 391 | /// 392 | public int maxSampleRate = 2; 393 | /// 394 | /// If the contrast differs less than this threshold Beast will consider the sampling good enough. 395 | /// Default value is 0.1. 396 | /// 397 | public float contrast = 0.1f; 398 | /// 399 | /// Enable this to diagnose the sampling. The brighter a pixel is, the more samples were taken at that position. 400 | /// 401 | public bool diagnose = false; 402 | /// 403 | /// To work efficiently on LDR images, the sampling algorithm can clamp the intensity of the image 404 | /// samples to the [minValue..maxValue] range. When rendering in HDR this is not desired. 405 | /// Clamp should then be disabled. 406 | /// 407 | public bool clamp = false; 408 | public SamplingMode samplingMode = SamplingMode.Adaptive; 409 | /// 410 | /// The sub-pixel filter to use. The following filters are available (default value is Box): 411 | /// 412 | public Filter filter = Filter.Gauss; 413 | /// 414 | /// The width and height of the filter kernel in pixels, given by setting the sub elements x and y (float). 415 | /// Default value is 1.0 for both x and y. 416 | /// 417 | public LMVec2 filterSize = new LMVec2 (2.2f, 2.2f); 418 | } 419 | 420 | 421 | [System.Serializable] 422 | /// 423 | /// Environment settings control what happens if a ray misses all geometry in the scene. 424 | /// 425 | /// 426 | /// Defining an environment is usually a very good way to get very pleasing outdoor illumination results, 427 | /// but might also increase bake times. 428 | /// 429 | /// Note that environments should only be used for effects that can be considered to be infinitely far away, 430 | /// meaning that only the directional component matters. 431 | /// 432 | public class EnvironmentSettings 433 | { 434 | public enum Environment { 435 | None, 436 | /// 437 | /// A constant color. 438 | /// 439 | SkyLight, 440 | /// 441 | /// An HDR image. 442 | /// 443 | IBL 444 | } 445 | 446 | /// 447 | /// The type of Environment: None, Skylight or IBL. 448 | /// 449 | public Environment giEnvironment = Environment.None; 450 | /// 451 | /// A constant environment color. In Unity: "Sky Light Color" 452 | /// 453 | /// 454 | /// Used if type is Skylight. It is often a good idea to keep the color below 1.0 in intensity 455 | /// to avoid boosting by gamma correction. Boost the intensity instead with the giEnvironmentIntensity setting. 456 | /// 457 | public LMColor skyLightColor = new LMColor (0.86f, 0.93f, 1, 1); 458 | /// 459 | /// A scale factor for Global Illumination intensity. In Unity: "Sky Light Intensity" 460 | /// 461 | /// 462 | /// Used for avoiding gamma correction errors and to scale HDR textures to something that fits your scene. 463 | /// 464 | public float giEnvironmentIntensity = 0.2f; 465 | /// 466 | /// The image file to use for IBL, using an absolute path. 467 | /// 468 | /// 469 | /// Accepts hdr or OpenEXR format. The file should be long-lat. Use giEnvironmentIntensity to boost 470 | /// the intensity of the image. 471 | /// 472 | public string iblImageFile = ""; 473 | /// 474 | /// Controls the appearance of the shadows, banded shadows look more aliased, but noisy shadows 475 | /// flicker more in animations. 476 | /// 477 | public float iblBandingVsNoise = 1; 478 | /// 479 | /// To remove diffuse lighting from IBL, set this to false. To get the diffuse lighting 480 | /// Final Gather could be used instead. 481 | /// 482 | public bool iblEmitDiffuse = true; 483 | /// 484 | /// Turns on the expensive IBL implementation. This will generate a number of (iblSamples) 485 | /// directional lights from the image. 486 | /// 487 | public bool iblEmitLight = false; 488 | /// 489 | /// To remove specular highlights from IBL, set this to false. 490 | /// 491 | public bool iblEmitSpecular = false; 492 | /// 493 | /// Pre-blur the environment image for Global Illumination calculations. Can help to reduce noise and flicker 494 | /// in images rendered with Final Gather. May increase render time as it is blurred at render time. It is 495 | /// always cheaper to pre-blur the image itself in an external application before loading it into Beast. 496 | /// 497 | public float iblGIEnvBlur = 0.05f; 498 | /// 499 | /// Sets the intensity of the lighting. 500 | /// 501 | public float iblIntensity = 1; 502 | /// 503 | /// The number of samples to be taken from the image. This will affect how soft the shadows will be, 504 | /// as well as the general lighting. The higher number of samples, the better the shadows and lighting. 505 | /// 506 | public int iblSamples = 300; 507 | /// 508 | /// Controls whether shadows should be created from IBL when this is used. 509 | /// 510 | public bool iblShadows = true; 511 | /// 512 | /// Further tweak the intensity by boosting the specular component. 513 | /// 514 | public float iblSpecularBoost = 1; 515 | /// 516 | /// Swap the Up Axis. Default value is false, meaning that Y is up. 517 | /// 518 | public bool iblSwapYZ = false; 519 | /// 520 | /// The sphere that the image is projected on can be rotated around the up axis. 521 | /// The amount of rotation is given in degrees. Default value is 0.0. 522 | /// 523 | public float iblTurnDome = 0; 524 | } 525 | 526 | 527 | [System.Serializable] 528 | public class GISettings 529 | { 530 | public enum ClampMaterials { 531 | /// 532 | /// No clamping at all 533 | /// 534 | None, 535 | /// 536 | /// clamps each color component (R, G, B) individually. 537 | /// 538 | Component, 539 | /// 540 | /// clamps the intensity of the color to 1. This can be useful to make sure the color of 541 | /// a surface is preserved when clamping. If using component clamp on a color like (3, 1, 1) will 542 | /// give the color (1, 1, 1) which means that all color bleeding is lost. 543 | /// 544 | Intensity, 545 | } 546 | 547 | public enum Integrator { 548 | None = 0, 549 | FinalGather = 1, 550 | /// 551 | /// Used if many indirect bounces are needed and Final Gather-only solution with acceptable 552 | /// quality would take to much time to render. 553 | /// 554 | PathTracer = 2, 555 | MonteCarlo = 3 556 | } 557 | 558 | 559 | // Global Illumination 560 | 561 | /// 562 | /// This setting controls if the materials should be clamped in any way for GI purposes. 563 | /// Typically you can use this to avoid problems with non physical materials making your scene 564 | /// extremely bright. This affects both the specular and diffuse components of materials. 565 | /// 566 | public ClampMaterials clampMaterials = ClampMaterials.None; 567 | /// 568 | /// This setting can be used to exaggerate light bouncing in dark scenes. Setting it to a value larger 569 | /// than 1 will push the diffuse color of materials towards 1 for GI computations. The typical use case 570 | /// is scenes authored with dark materials, this happens easily when doing only direct lighting since it’s 571 | /// easy to compensate dark materials with strong light sources. Indirect light will be very subtle in 572 | /// these scenes since the bounced light will fade out quickly. Setting a diffuse boost will compensate 573 | /// for this. Note that values between 0 and 1 will decrease the diffuse setting in a similar way making 574 | /// light bounce less than the materials says, values below 0 is invalid. The actual computation taking 575 | /// place is a per component pow(colorComponent, (1.0 / diffuseBoost)). 576 | /// 577 | public float diffuseBoost = 1; 578 | /// 579 | /// This setting globally scales all materials emissive components by the specified value when 580 | /// they are used by the GI. 581 | /// 582 | public float emissiveScale = 1; 583 | public bool enableCaustics = false; 584 | public bool enableGI = true; 585 | public bool ignoreNonDiffuse = true; 586 | /// 587 | /// Sets the sample rate used during the GI precalculation pass. The prepass is progressive, 588 | /// rendering from a low resolution up to a high resolution in multiple passes. The prepassMinSampleRate 589 | /// sets the initial resolution, where a negative value means a lower resolution than the original 590 | /// image (in powers of two), e.g. -4 gives the original resolution divided by 16. The 591 | /// prepassMaxSampleRate sets the resolution of the final prepass, e.g 0 giving the same resolution 592 | /// as the original resolution. The default values are -4/0. 593 | /// 594 | public int prepassMaxSampleRate = 0; 595 | /// 596 | /// Sets the sample rate used during the GI precalculation pass. The prepass is progressive, 597 | /// rendering from a low resolution up to a high resolution in multiple passes. The prepassMinSampleRate 598 | /// sets the initial resolution, where a negative value means a lower resolution than the original 599 | /// image (in powers of two), e.g. -4 gives the original resolution divided by 16. The 600 | /// prepassMaxSampleRate sets the resolution of the final prepass, e.g 0 giving the same resolution 601 | /// as the original resolution. The default values are -4/0. 602 | /// 603 | public int prepassMinSampleRate = -4; 604 | /// 605 | /// The Global Illumination system allows you to use two separate algorithms to calculate indirect lighting. 606 | /// You can for instance calculate multiple levels of light bounces with a fast algorithm like the 607 | /// Path Tracer, and still calculate the final bounce with Final Gather to get a fast high-quality 608 | /// global illumination render. Both subsystems have individual control of Intensity and Saturation 609 | /// to boost the effects if necessary. 610 | /// 611 | public Integrator primaryIntegrator = Integrator.FinalGather; 612 | /// 613 | /// Tweak the amount of illumination from the primary and secondary GI integrators. This lets you boost 614 | /// or reduce the amount of indirect light easily. 615 | /// 616 | public float primaryIntensity = 1; 617 | /// 618 | /// Lets you tweak the amount of color in the primary and secondary GI integrators. This lets you boost 619 | /// or reduce the perceived saturation of the bounced light. 620 | /// 621 | public float primarySaturation = 1; 622 | /// 623 | /// The Global Illumination system allows you to use two separate algorithms to calculate indirect lighting. 624 | /// You can for instance calculate multiple levels of light bounces with a fast algorithm like the 625 | /// Path Tracer, and still calculate the final bounce with Final Gather to get a fast high-quality 626 | /// global illumination render. Both subsystems have individual control of Intensity and Saturation 627 | /// to boost the effects if necessary. 628 | /// 629 | public Integrator secondaryIntegrator = Integrator.None; 630 | /// 631 | /// Lets you tweak the amount of color in the primary and secondary GI integrators. This lets you boost 632 | /// or reduce the perceived saturation of the bounced light. 633 | /// 634 | public float secondaryIntensity = 1; 635 | /// 636 | /// Lets you tweak the amount of color in the primary and secondary GI integrators. This lets you boost 637 | /// or reduce the perceived saturation of the bounced light. 638 | /// 639 | public float secondarySaturation = 1; 640 | /// 641 | /// This setting can be used to exaggerate or decrease specular light effects. All materials specular 642 | /// color is multiplied by this factor when they are used by the GI. 643 | /// 644 | public float specularScale = 1; 645 | 646 | 647 | // Final Gather 648 | 649 | public enum Cache { 650 | /// 651 | /// (Brute Force) disables caching and performs a final gathering for every shading point 652 | /// (same as Monte Carlo). 653 | /// 654 | Off, 655 | /// 656 | /// caches the irradiance at selected points in the scene and uses interpolation in between the points. 657 | /// This is the default method. 658 | /// 659 | Irradiance, 660 | /// 661 | /// caches radiance SH functions at selected points in the scene and uses interpolation in 662 | /// between the points. The radiance cache is very useful in some advanced baking passes 663 | /// (e.g. Radiosity Normal Maps), where directional indirect lighting is needed. 664 | /// 665 | RadianceSH 666 | } 667 | 668 | /// 669 | /// Can be used to adjust the contrast for ambient occlusion. 670 | /// 671 | public float fgAOContrast = 1; 672 | /// 673 | /// Controls a scaling of Final Gather with Ambient Occlusion which can be used to boost shadowing and get 674 | /// more contrast in you lighting. The value controls how much Ambient Occlusion to blend into the 675 | /// Final Gather solution. 676 | /// 677 | public float fgAOInfluence = 0; 678 | /// 679 | /// Max distance for the occlusion. Beyond this distance a ray is considered to be visible. 680 | /// Can be used to avoid full occlusion for closed scenes. 681 | /// 682 | public float fgAOMaxDistance = 0.3f; 683 | /// 684 | /// A scaling of the occlusion values. Can be used to increase or decrease the shadowing effect. 685 | /// 686 | public float fgAOScale = 2; 687 | /// 688 | /// Visualize just the ambient occlusion values. Useful when tweaking the occlusion sampling options. 689 | /// 690 | public bool fgAOVisualize = false; 691 | /// 692 | /// The distance where attenuation is started. There is no attenuation before this distance. 693 | /// Note that fgAttenuationStop must be set higher than 0.0 to enable attenuation. 694 | /// 695 | public float fgAttenuationStart = 0; 696 | /// 697 | /// Sets the distance where attenuation is stopped (fades to zero). There is zero intensity beyond this 698 | /// distance. To enable attenuation set this value higher than 0.0. The default value is 0.0. 699 | /// 700 | public float fgAttenuationStop = 0; 701 | /// 702 | /// When this is enabled final gather will also cache lighting from light sources. This increases performance 703 | /// since fewer direct light calculations are needed. It gives an approximate result, and hence can affect 704 | /// the quality of the lighting. For instance indirect light bounces from specular highlights might be lost. 705 | /// However this caching is only done for depths higher than 1, so the quality of direct light and shadows 706 | /// in the light map will not be reduced. 707 | /// 708 | public bool fgCacheDirectLight = false; 709 | /// 710 | /// Turn this on to reduce light leakage through walls. When points are collected to interpolate between, 711 | /// some of them can be located on the other side of geometry. 712 | /// As a result light will bleed through the geometry. So to prevent this Beast can reject points 713 | /// that are not visible. 714 | /// 715 | public bool fgCheckVisibility = true; 716 | public float fgCheckVisibilityDepth = 1; 717 | /// 718 | /// Turn this on to clamp the sampled values to [0, 1]. This will reduce high frequency noise when 719 | /// Final Gather is used together with other Global Illumination algorithms. 720 | /// 721 | public bool fgClampRadiance = false; 722 | /// 723 | /// Controls how sensitive the final gather should be for contrast differences between the points 724 | /// during pre calculation. If the contrast difference is above this threshold for neighbouring points, 725 | /// more points will be created in that area. This tells the algorithm to place points where they are really 726 | /// needed, e.g. at shadow boundaries or in areas where the indirect light changes quickly. Hence this 727 | /// threshold controls the number of points created in the scene adaptively. Note that if a low number of 728 | /// final gather rays are used, the points will have high variance and hence a high contrast difference, 729 | /// so in that case you might need to increase the contrast threshold to prevent points from clumping together. 730 | /// 731 | public float fgContrastThreshold = 0.05f; 732 | /// 733 | /// Sets the number of indirect light bounces calculated by final gather. A value higher than 1 will produce 734 | /// more global illumination effects, but note that it can be quite slow since the number of rays will increase 735 | /// exponentially with the depth. It’s often better to use a fast method for secondary GI. If a secondary GI is 736 | /// used the number of set final gather bounces will be calculated first, before the secondary GI is called. 737 | /// So in most cases the depth should be set to 1 if a secondary GI is used. 738 | /// 739 | public int fgDepth = 1; 740 | /// 741 | /// Sets the minimum number of points that should be used when estimating final gather in the pre calculation 742 | /// pass. The impact is that a higher value will create more points all over the scene. The default value 15 743 | /// rarely needs to be adjusted. 744 | /// 745 | public int fgEstimatePoints = 15; 746 | public bool fgExploitFrameCoherence = false; 747 | /// 748 | /// This can be used to adjust the rate by which lighting falls off by distance. A higher exponent gives a 749 | /// faster falloff. Note that fgAttenuationStop must be set higher than 0.0 to enable attenuation. 750 | /// 751 | public float fgFalloffExponent = 0; 752 | /// 753 | /// Controls how the irradiance gradient is used in the interpolation. Each point stores it’s irradiance 754 | /// gradient which can be used to improve the interpolation. However in some situations using the gradient 755 | /// can result in white ”halos” and other artifacts. This threshold can be used to reduce those artifacts. 756 | /// 757 | public float fgGradientThreshold = 0.5f; 758 | /// 759 | /// Sets the number of final gather points to interpolate between. A higher value will give a smoother result, 760 | /// but can also smooth out details. If light leakage is introduced through walls when this value is increased, 761 | /// checking the sample visibility solves that problem, see fgCheckVisibility below. 762 | /// 763 | public int fgInterpolationPoints = 15; 764 | /// 765 | /// Controls how far away from walls the final gather will be called again, instead of the secondary GI. 766 | /// If 0.0 is used a value will be calculated by Beast depending on the secondary GI used. The calculated 767 | /// value is printed in the output window. If you still get leakage you can adjust this by manually typing 768 | /// in a higher value. 769 | /// 770 | public float fgLightLeakRadius = 0; 771 | /// 772 | /// This setting can be used to reduce light leakage through walls when using final gather as primary GI and 773 | /// path tracing as secondary GI. Leakage, which can happen when e.g. the path tracer filters in values on the 774 | /// other side of a wall, is reduced by using final gather as a secondary GI fallback when sampling close to 775 | /// walls or corners. When this is enabled a final gather depth of 3 will be used automatically, but the higher 776 | /// depths will only be used close to walls or corners. Note that this is only used when path tracing is set 777 | /// as secondary GI. 778 | /// 779 | public bool fgLightLeakReduction = false; 780 | /// 781 | /// The max distance a ray can be traced before it’s considered to be a “miss”. 782 | /// This can improve performance in very large scenes. If the value is set to 0.0 the entire scene will be used. 783 | /// 784 | public float fgMaxRayLength = 0; 785 | /// 786 | /// Controls how sensitive the final gather should be for differences in the points normals. 787 | /// A lower value will give more points in areas of high curvature. 788 | /// 789 | public float fgNormalThreshold = 0.2f; 790 | /// 791 | /// Turn this on to visualize the final gather prepass. Using the Preview Calculation Pass enables a quick 792 | /// preview of the final image lighting, reducing lighting setup time. 793 | /// 794 | public bool fgPreview = false; 795 | /// 796 | /// Sets the maximum number of rays to use for each Final Gather sample point. 797 | /// A higher number gives higher quality, but longer rendering time. 798 | /// 799 | public int fgRays = 1000; 800 | /// 801 | /// Selects what caching method to use for final gathering. 802 | /// 803 | public Cache fgUseCache = Cache.Irradiance; 804 | 805 | 806 | // PathTracer 807 | 808 | /// 809 | /// Selects the filter to use when querying the cache during rendering. None will return the closest 810 | /// cache point (unfiltered). The filter type can be set to None, Box, Gauss or Triangle. 811 | /// 812 | public enum PTFilterType { 813 | None, 814 | Box, 815 | Gauss, 816 | Triangle 817 | } 818 | 819 | /// 820 | /// Sets the number of paths that are traced for each sample element (pixel, texel or vertex). 821 | /// For preview renderings, you can use a low value like 0.5 or 0.1, which means 822 | /// that half of the pixels or 1/10 of the pixels will generate a path. For production renderings 823 | /// you can use values above 1.0, if needed to get good quality. 824 | /// 825 | public float ptAccuracy = 1; 826 | /// 827 | /// When this is enabled the path tracer will also cache lighting from light sources. This increases 828 | /// performance since fewer direct light calculations are needed. It gives an approximate result, and 829 | /// hence can affect the quality of the lighting. For instance indirect light bounces from specular 830 | /// highlights might be lost. 831 | /// 832 | public bool ptCacheDirectLight = false; 833 | /// 834 | /// Turn this on to reduce light leakage through walls. When points are collected to interpolate between, 835 | /// some of them can be located on the other side of geometry. As a result light will bleed through the 836 | /// geometry. So to prevent this Beast can reject points that are not visible. 837 | /// 838 | public bool ptCheckVisibility = true; 839 | public float ptConservativeEnergyLimit = 0.95f; 840 | public LMColor ptDefaultColor = new LMColor (0, 0, 0, 1); 841 | public int ptDepth = 5; 842 | public bool ptDiffuseIllum = true; 843 | public string ptFile = ""; 844 | /// 845 | /// Sets the size of the filter as a multiplier of the Cache Point Spacing value. For example; 846 | /// a value of 3.0 will use a filter that is three times larges then the cache point spacing. 847 | /// If this value is below 1.0 there is no guarantee that any cache point is found. If no cache 848 | /// point is found the Default Color will be returned instead for that query. 849 | /// 850 | public float ptFilterSize = 3; 851 | /// 852 | /// Selects the filter to use when querying the cache during rendering. None will return the closest 853 | /// cache point (unfiltered). The filter type can be set to None, Box, Gauss or Triangle. 854 | /// 855 | public PTFilterType ptFilterType = PTFilterType.Gauss; 856 | /// 857 | /// Sets the amount of normal deviation that is allowed during cache point filtering. ptFilterType 858 | /// Selects the filter to use when querying the cache during rendering. None will return the closest 859 | /// cache point (unfiltered). The filter type can be set to None, Box, Gauss or Triangle. 860 | /// 861 | public float ptNormalThreshold = 0.7f; 862 | /// 863 | /// Sets the maximum distance between the points in the path tracer cache. If set to 0 a value will be 864 | /// calculated automatically based on the size of the scene. The automatic value will be printed out 865 | /// during rendering, which is a good starting value if the point spacing needs to be adjusted. 866 | /// 867 | public float ptPointSize = 0; 868 | /// 869 | /// If enabled the cache points will be pre-filtered before the final pass starts. This increases the 870 | /// performance using the final render pass. 871 | /// 872 | public bool ptPrecalcIrradiance = true; 873 | /// 874 | /// If enabled the pre-render pass will be visible in the render view. 875 | /// 876 | public bool ptPreview = false; 877 | public bool ptSpecularIllum = true; 878 | public bool ptTransmissiveIllum = true; 879 | 880 | 881 | // Monte Carlo 882 | 883 | /// 884 | /// Sets the number of indirect light bounces calculated by monte carlo. 885 | /// 886 | public int mcDepth = 2; 887 | /// 888 | /// The max distance a ray can be traced before it’s considered to be a “miss”. This can improve 889 | /// performance in very large scenes. If the value is set to 0.0 the entire scene will be used. 890 | /// 891 | public float mcMaxRayLength = 0; 892 | /// 893 | /// Sets the number of rays to use for each calculation. A higher number gives higher quality, 894 | /// but longer rendering time. 895 | /// 896 | public int mcRays = 16; 897 | } 898 | 899 | 900 | [System.Serializable] 901 | public class ADSSettings 902 | { 903 | public enum Instancing { 904 | /// 905 | /// Never use instancing while rendering. 906 | /// 907 | Never, 908 | /// 909 | /// Use instancing whenever a shape is used more than once (default). 910 | /// 911 | AutoDetect 912 | } 913 | 914 | public int gridDensity = 1; 915 | /// 916 | /// Decides how deep the Acceleration Data Structure can subdivide. 917 | /// 918 | public int gridMaxDepth = 4; 919 | /// 920 | /// Decides how many triangles that can reside in a leaf before it is split up. The Recursion Depth 921 | /// has precedence over the threshold. A leaf at max depth will never be split. The Recursion Depth 922 | /// and Recursion Threshold are advanced settings that shouldn't be altered unless Acceleration Data 923 | /// Structures are second nature to you. 924 | /// 925 | public int gridThreshold = 25; 926 | /// 927 | /// Specifies the minimum number of triangles that an instance is allowed to have in order 928 | /// for geometry instancing to be used. 929 | /// 930 | public int instancingThreshold = 500; 931 | /// 932 | /// This tag lets the user control if instances should be used or not during rendering. 933 | /// Instancing allows the user to place a single shape in several different places, each with an 934 | /// individual transform. This preserves disk space and will lower memory consumption when rendering, 935 | /// but might increase render times quite a bit if there are many large instances. 936 | /// 937 | public Instancing useInstancing = Instancing.AutoDetect; 938 | /// 939 | /// Beast uses specialized vector instructions to speed up the rendering. The cost is higher memory usage. 940 | /// Turn off SSE if Beast starts swapping. 941 | /// 942 | public bool useSSE = true; 943 | } 944 | 945 | 946 | [System.Serializable] 947 | public class SurfaceTransferSettings 948 | { 949 | public enum SelectionMode { 950 | Normal 951 | } 952 | 953 | public float frontRange = 0; 954 | public float frontBias = 0; 955 | public float backRange = 2; 956 | public float backBias = -1; 957 | public SelectionMode selectionMode = SelectionMode.Normal; 958 | } 959 | 960 | 961 | [System.Serializable] 962 | public class TextureBakeSettings 963 | { 964 | public LMColor bgColor = new LMColor (1, 1, 1, 1); 965 | /// 966 | /// Counteract unwanted light seams for tightly packed UV patches. 967 | /// 968 | public bool bilinearFilter = true; 969 | /// 970 | /// Find pixels which are only partially covered by the UV map. 971 | /// 972 | public bool conservativeRasterization = true; 973 | /// 974 | /// Expands the lightmap with the number of pixels specified to avoid black borders. 975 | /// 976 | public int edgeDilation = 3; 977 | } 978 | } 979 | 980 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Editor/ILConfig.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7959cc4b896264643bf3898d7c38e7a8 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Editor/LMExtendedWindow.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 Michael Stevenson 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in the 5 | // Software without restriction, including without limitation the rights to use, copy, 6 | // modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 7 | // and to permit persons to whom the Software is furnished to do so, subject to the 8 | // following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all copies 11 | // or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 15 | // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 16 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 17 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 18 | // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | using UnityEngine; 21 | using UnityEditor; 22 | using UnityEditorInternal; 23 | using System; 24 | using System.IO; 25 | using System.Linq; 26 | using System.Collections; 27 | using System.Collections.Generic; 28 | 29 | public class LMExtendedWindow : EditorWindow 30 | { 31 | const string assetFolderName = "Lightmapping Extended"; 32 | 33 | private SerializedConfig _sc; 34 | public SerializedConfig sc { 35 | get { 36 | if (_sc == null) 37 | _sc = ScriptableObject.CreateInstance (); 38 | return _sc; 39 | } 40 | } 41 | 42 | [MenuItem ("Window/Lightmapping Extended", false, 2098)] 43 | static void Init () 44 | { 45 | var window = EditorWindow.GetWindow (false, "LM Extended"); 46 | window.autoRepaintOnSceneChange = true; 47 | } 48 | 49 | #region Configuration 50 | 51 | public string ConfigFilePath { 52 | get { 53 | if (string.IsNullOrEmpty (EditorApplication.currentScene)) 54 | return ""; 55 | string root = Path.GetDirectoryName (EditorApplication.currentScene); 56 | string dir = Path.GetFileNameWithoutExtension (EditorApplication.currentScene); 57 | string path = Path.Combine (root, dir); 58 | path = Path.Combine (path, "BeastSettings.xml"); 59 | return path; 60 | } 61 | } 62 | 63 | void SaveConfig () 64 | { 65 | sc.config.SerializeToPath (ConfigFilePath); 66 | } 67 | 68 | #endregion 69 | 70 | 71 | #region Unity Events 72 | 73 | void OnEnable () 74 | { 75 | presetsFolderPath = GetPresetsFolderPath (); 76 | } 77 | 78 | void OnSelectionChange () 79 | { 80 | if (!File.Exists (ConfigFilePath)) { 81 | SetPresetToDefault (); 82 | sc.config = null; 83 | } 84 | Repaint (); 85 | } 86 | 87 | void OnFocus () 88 | { 89 | if (!File.Exists (ConfigFilePath)) 90 | sc.config = null; 91 | Repaint (); 92 | } 93 | 94 | void OnProjectChange () 95 | { 96 | if (!File.Exists (ConfigFilePath)) 97 | sc.config = null; 98 | Repaint (); 99 | } 100 | 101 | 102 | [SerializeField] 103 | int toolbarSelected; 104 | [SerializeField] 105 | Vector2 scroll; 106 | 107 | void OnGUI () 108 | { 109 | string path = ConfigFilePath; 110 | if (string.IsNullOrEmpty (path)) { 111 | EditorGUILayout.HelpBox ("Open a scene file to edit its lightmapping settings.", MessageType.Info); 112 | return; 113 | } 114 | 115 | // Determine if config file exists 116 | bool haveConfigFile = false; 117 | if (sc.config == null) { 118 | if (File.Exists (path)) { 119 | sc.config = ILConfig.DeserializeFromPath (path); 120 | haveConfigFile = true; 121 | } 122 | } else { 123 | haveConfigFile = true; 124 | } 125 | 126 | // Option to generate a config file 127 | if (!haveConfigFile) { 128 | EditorGUILayout.Space (); 129 | if (GUILayout.Button ("Generate Beast settings file for current scene")) { 130 | SetPresetToDefault (); 131 | ILConfig newConfig = new ILConfig (); 132 | var dir = Path.GetDirectoryName (ConfigFilePath); 133 | if (!Directory.Exists (dir)) 134 | Directory.CreateDirectory (dir); 135 | newConfig.SerializeToPath (ConfigFilePath); 136 | sc.config = ILConfig.DeserializeFromPath (path); 137 | AssetDatabase.Refresh (); 138 | GUIUtility.ExitGUI (); 139 | } 140 | return; 141 | } 142 | 143 | EditorGUILayout.Space (); 144 | 145 | PresetSelectionGUI (); 146 | 147 | EditorGUILayout.Space (); 148 | 149 | int lastSelected = toolbarSelected; 150 | toolbarSelected = GUILayout.Toolbar (toolbarSelected, new string[] {"Settings", "Global Illum", "Environment"}); 151 | // Prevent text fields from grabbing focus when switching tabs 152 | if (toolbarSelected != lastSelected) { 153 | GUI.FocusControl (""); 154 | } 155 | 156 | EditorGUILayout.Space (); 157 | 158 | scroll = EditorGUILayout.BeginScrollView (scroll); 159 | { 160 | SerializedObject configObj = new SerializedObject (sc); 161 | switch (toolbarSelected) { 162 | case 0: 163 | PerformanceSettingsGUI (configObj); 164 | TextureBakeGUI (configObj); 165 | AASettingsGUI (configObj); 166 | RenderSettingsGUI (configObj); 167 | break; 168 | case 1: 169 | GlobalIlluminationGUI (configObj); 170 | break; 171 | case 2: 172 | EnvironmentGUI (configObj); 173 | break; 174 | } 175 | 176 | if (GUI.changed) { 177 | configObj.ApplyModifiedProperties (); 178 | SaveConfig (); 179 | } 180 | } 181 | 182 | EditorGUILayout.EndScrollView (); 183 | 184 | EditorGUILayout.Space (); 185 | GUILayout.BeginHorizontal (); 186 | { 187 | BakeButtonsGUI (); 188 | } 189 | GUILayout.EndHorizontal (); 190 | EditorGUILayout.Space (); 191 | 192 | // Use FocusControl to release focus from text fields when switching tabs 193 | GUI.SetNextControlName (""); 194 | } 195 | 196 | #endregion 197 | 198 | 199 | #region Presets 200 | 201 | string presetsFolderPath; 202 | string currentPresetName = ""; 203 | 204 | void PresetSelectionGUI () 205 | { 206 | GUILayout.BeginHorizontal (); 207 | { 208 | GUILayout.Label ("Preset: "); 209 | currentPresetName = PresetsPopup (currentPresetName); 210 | EditorGUILayout.BeginHorizontal (); 211 | { 212 | int width = 42; 213 | GUILayout.FlexibleSpace (); 214 | if (IsCurrentPresetDefault) 215 | GUI.enabled = false; 216 | if (GUILayout.Button ("Delete", EditorStyles.miniButtonLeft, GUILayout.Width (width))) { 217 | if (EditorUtility.DisplayDialog ("Delete Preset", "Do you want to delete the lightmapping preset named \"" + currentPresetName + "\"?", "OK", "Cancel")) { 218 | DeletePreset (currentPresetName); 219 | } 220 | } 221 | GUI.enabled = true; 222 | 223 | if (IsCurrentPresetDefault) 224 | GUI.enabled = false; 225 | if (GUILayout.Button ("Save", EditorStyles.miniButtonMid, GUILayout.Width (width))) { 226 | SavePreset (currentPresetName); 227 | } 228 | GUI.enabled = true; 229 | if (GUILayout.Button ("Create", EditorStyles.miniButtonRight, GUILayout.Width (width))) { 230 | SetPresetToDefault (); 231 | CreatePreset (); 232 | } 233 | } 234 | EditorGUILayout.EndHorizontal (); 235 | if (GUI.changed && !IsCurrentPresetDefault) { 236 | LoadPreset (currentPresetName); 237 | } 238 | } 239 | GUILayout.EndHorizontal (); 240 | } 241 | 242 | private string PresetsPopup (string presetString) 243 | { 244 | List presets = new List (GetPresetNames ()); 245 | int presetIndex = presets.IndexOf (presetString); 246 | 247 | // Include a "Custom" option at the beginning of the list 248 | presets.Insert (0, "Custom"); 249 | // Shift the indexes forward to account for the new "Custom" option 250 | presetIndex++; 251 | 252 | presetIndex = EditorGUILayout.Popup (presetIndex, presets.ToArray ()); 253 | string newPresetName = presets [presetIndex]; 254 | return newPresetName; 255 | } 256 | 257 | void CreatePreset () 258 | { 259 | var w = EditorWindow.GetWindow (); 260 | Rect pos = new Rect (w.position.x, w.position.y, w.position.width, 55); 261 | var window = EditorWindow.GetWindowWithRect (pos, true, "Create Lightmapping Preset", true); 262 | window.position = pos; 263 | window.lmExtendedWindow = this; 264 | } 265 | 266 | static string GetPresetsFolderPath () 267 | { 268 | string[] assets = AssetDatabase.GetAllAssetPaths (); 269 | foreach (var a in assets) { 270 | if (Path.GetFileName (a) == assetFolderName) { 271 | if (Directory.Exists (a)) { 272 | return a + "/Presets"; 273 | } 274 | } 275 | } 276 | return null; 277 | } 278 | 279 | string[] GetPresetNames () 280 | { 281 | if (Directory.Exists (presetsFolderPath)) { 282 | string[] files = Directory.GetFiles (presetsFolderPath, "*.xml", SearchOption.AllDirectories); 283 | string[] presetNames = files.Select (s => s.Remove (0, presetsFolderPath.Length + 1).Replace (".xml", "")).ToArray (); 284 | return presetNames; 285 | } else { 286 | return new string[0]; 287 | } 288 | } 289 | 290 | public void SavePreset (string name) 291 | { 292 | var dir = presetsFolderPath + "/" + Path.GetDirectoryName (name); 293 | if (!Directory.Exists (dir)) { 294 | Debug.Log ("Create " + dir); 295 | Directory.CreateDirectory (dir); 296 | } 297 | sc.config.SerializeToPath (GetPresetPath (name)); 298 | AssetDatabase.Refresh (); 299 | currentPresetName = name; 300 | } 301 | 302 | void DeletePreset (string name) 303 | { 304 | if (Directory.Exists (presetsFolderPath)) { 305 | AssetDatabase.DeleteAsset (GetPresetPath (name)); 306 | SetPresetToDefault (); 307 | } 308 | } 309 | 310 | void LoadPreset (string name) 311 | { 312 | // Load the preset config file 313 | sc.config = ILConfig.DeserializeFromPath (GetPresetPath (name)); 314 | // Save preset data back out to our scene's config file 315 | SaveConfig (); 316 | } 317 | 318 | string GetPresetPath (string presetName) 319 | { 320 | return presetsFolderPath + "/" + presetName + ".xml"; 321 | } 322 | 323 | void SetPresetToDefault () 324 | { 325 | currentPresetName = "Custom"; 326 | } 327 | 328 | bool IsCurrentPresetDefault { 329 | get { 330 | return currentPresetName == "Custom"; 331 | } 332 | } 333 | 334 | #endregion 335 | 336 | 337 | #region Settings 338 | 339 | void PerformanceSettingsGUI (SerializedObject serializedObject) 340 | { 341 | SerializedProperty autoThreads = serializedObject.FindProperty ("config.frameSettings.autoThreads"); 342 | SerializedProperty autoThreadsSubtract = serializedObject.FindProperty ("config.frameSettings.autoThreadsSubtract"); 343 | SerializedProperty renderThreads = serializedObject.FindProperty ("config.frameSettings.renderThreads"); 344 | 345 | // Threads 346 | GUILayout.Label ("CPU", EditorStyles.boldLabel); 347 | EditorGUI.indentLevel++; 348 | EditorGUILayout.PropertyField (autoThreads, new GUIContent ("Auto Threads", "If enabled, Beast will try to auto detect the CPU configuration and use one thread per core.")); 349 | EditorGUI.indentLevel++; 350 | if (!sc.config.frameSettings.autoThreads) 351 | GUI.enabled = false; 352 | EditorGUILayout.PropertyField (autoThreadsSubtract, new GUIContent ("Subtract Threads", "If autoThreads is enabled, this can be used to decrease the number of utilized cores, e.g. to leave one or two cores free to do other work.")); 353 | GUI.enabled = true; 354 | if (sc.config.frameSettings.autoThreads) 355 | GUI.enabled = false; 356 | EditorGUILayout.PropertyField (renderThreads, new GUIContent ("Render Threads", "If autoThreads is disabled, this will set the number of threads beast uses. One per core is a good start.")); 357 | GUI.enabled = true; 358 | EditorGUI.indentLevel--; 359 | EditorGUI.indentLevel--; 360 | 361 | // The following options are not useful unless using Beast's own UI. This UI is accessible if Unity's embedded Beast tool is called 362 | 363 | // GUILayout.Label ("Tiles", EditorStyles.boldLabel); 364 | // EditorGUI.indentLevel++; 365 | // config.frameSettings.tileScheme = (ILConfig.FrameSettings.TileScheme)EditorGUILayout.EnumPopup (new GUIContent ("Tile Scheme", "Different ways for Beast to distribute tiles over the image plane."), config.frameSettings.tileScheme); 366 | // IntField ("Tile Size", ref config.frameSettings.tileSize, "A smaller tile gives better ray tracing coherence. There is no 'best setting' for all scenes. Default value is 32, giving 32x32 pixel tiles. The largest allowed tile size is 128."); 367 | // EditorGUI.indentLevel--; 368 | 369 | // GUILayout.Label ("Output Verbosity"); 370 | // EditorGUI.indentLevel++; 371 | // Toggle ("Debug File", ref config.frameSettings.outputVerbosity.debugFile, "Save all log messages to a file named debug.out."); 372 | // Toggle ("Debug Print", ref config.frameSettings.outputVerbosity.debugPrint, "Used for development purposes."); 373 | // Toggle ("Error Print", ref config.frameSettings.outputVerbosity.errorPrint, ""); 374 | // Toggle ("Warning Print", ref config.frameSettings.outputVerbosity.warningPrint, ""); 375 | // Toggle ("Benchmark Print", ref config.frameSettings.outputVerbosity.benchmarkPrint, ""); 376 | // Toggle ("Progress Print", ref config.frameSettings.outputVerbosity.progressPrint, ""); 377 | // Toggle ("Info Print", ref config.frameSettings.outputVerbosity.infoPrint, ""); 378 | // Toggle ("Verbose Print", ref config.frameSettings.outputVerbosity.verbosePrint, ""); 379 | // EditorGUI.indentLevel--; 380 | } 381 | 382 | void AASettingsGUI (SerializedObject serializedConfig) 383 | { 384 | SerializedProperty samplingMode = serializedConfig.FindProperty ("config.aaSettings.samplingMode"); 385 | SerializedProperty minSampleRate = serializedConfig.FindProperty ("config.aaSettings.minSampleRate"); 386 | SerializedProperty maxSampleRate = serializedConfig.FindProperty ("config.aaSettings.maxSampleRate"); 387 | SerializedProperty contrast = serializedConfig.FindProperty ("config.aaSettings.contrast"); 388 | SerializedProperty filter = serializedConfig.FindProperty ("config.aaSettings.filter"); 389 | SerializedProperty filterSizeX = serializedConfig.FindProperty ("config.aaSettings.filterSize.x"); 390 | SerializedProperty filterSizeY = serializedConfig.FindProperty ("config.aaSettings.filterSize.y"); 391 | 392 | GUILayout.Label ("Antialiasing", EditorStyles.boldLabel); 393 | EditorGUI.indentLevel++; 394 | EditorGUILayout.PropertyField (samplingMode, new GUIContent ("Sampling Mode", "")); 395 | EditorGUI.indentLevel++; 396 | EditorGUILayout.PropertyField (minSampleRate, new GUIContent ("Min Sample Rate", "Controls the minimum number of samples per pixel. The formula used is 4^maxSampleRate (1, 4, 16, 64, 256 samples per pixel)")); 397 | EditorGUILayout.PropertyField (maxSampleRate, new GUIContent ("Max Sample Rate", "Controls the maximum number of samples per pixel. Values less than 0 allows using less than one sample per pixel (if AdaptiveSampling is used). The formula used is 4^maxSampleRate (1, 4, 16, 64, 256 samples per pixel)")); 398 | EditorGUI.indentLevel--; 399 | EditorGUILayout.PropertyField (contrast, new GUIContent ("Contrast", "If the contrast differs less than this threshold Beast will consider the sampling good enough. Default value is 0.1.")); 400 | EditorGUILayout.PropertyField (filter, new GUIContent ("Filter", "The sub-pixel filter to use.")); 401 | EditorGUILayout.PrefixLabel (new GUIContent ("Filter Size")); 402 | EditorGUI.indentLevel++; 403 | EditorGUILayout.PropertyField (filterSizeX, new GUIContent ("X", "")); 404 | EditorGUILayout.PropertyField (filterSizeY, new GUIContent ("Y", "")); 405 | EditorGUI.indentLevel--; 406 | EditorGUI.indentLevel--; 407 | } 408 | 409 | void RenderSettingsGUI (SerializedObject serializedConfig) 410 | { 411 | SerializedProperty maxRayDepth = serializedConfig.FindProperty ("config.renderSettings.maxRayDepth"); 412 | SerializedProperty bias = serializedConfig.FindProperty ("config.renderSettings.bias"); 413 | SerializedProperty reflectionDepth = serializedConfig.FindProperty ("config.renderSettings.reflectionDepth"); 414 | SerializedProperty reflectionThreshold = serializedConfig.FindProperty ("config.renderSettings.reflectionThreshold"); 415 | SerializedProperty giTransparencyDepth = serializedConfig.FindProperty ("config.renderSettings.giTransparencyDepth"); 416 | // SerializedProperty shadowDepth = serializedConfig.FindProperty ("config.renderSettings.shadowDepth"); 417 | SerializedProperty minShadowRays = serializedConfig.FindProperty ("config.renderSettings.minShadowRays"); 418 | SerializedProperty maxShadowRays = serializedConfig.FindProperty ("config.renderSettings.maxShadowRays"); 419 | SerializedProperty vertexMergeThreshold = serializedConfig.FindProperty ("config.renderSettings.vertexMergeThreshold"); 420 | SerializedProperty tsOddUVFlipping = serializedConfig.FindProperty ("config.renderSettings.tsOddUVFlipping"); 421 | SerializedProperty tsVertexOrthogonalization = serializedConfig.FindProperty ("config.renderSettings.tsVertexOrthogonalization"); 422 | SerializedProperty tsVertexNormalization = serializedConfig.FindProperty ("config.renderSettings.tsVertexNormalization"); 423 | SerializedProperty tsIntersectionOrthogonalization = serializedConfig.FindProperty ("config.renderSettings.tsIntersectionOrthogonalization"); 424 | SerializedProperty tsIntersectionNormalization = serializedConfig.FindProperty ("config.renderSettings.tsIntersectionNormalization"); 425 | 426 | 427 | GUILayout.Label ("Rays", EditorStyles.boldLabel); 428 | EditorGUI.indentLevel++; 429 | EditorGUILayout.PropertyField (maxRayDepth, new GUIContent ("Max Bounces", "The maximum amount of 'bounces' a ray can have before being considered done. A bounce can be a reflection or refraction.")); 430 | EditorGUILayout.PropertyField (bias, new GUIContent ("Bias", "An error threshold to avoid double intersections. For example, a shadow ray should not intersect the same triangle as the primary ray did, but because of limited numerical precision this can happen. The bias value moves the intersection point to eliminate this problem. If set to zero this value is computed automatically depending on the scene size.")); 431 | EditorGUI.indentLevel--; 432 | 433 | GUILayout.Label ("Reflections & Transparency", EditorStyles.boldLabel); 434 | EditorGUI.indentLevel++; 435 | EditorGUILayout.PropertyField (reflectionDepth, new GUIContent ("Max Reflection Bounces", "The maximum amount of reflections a ray can have before being considered done.")); 436 | EditorGUILayout.PropertyField (reflectionThreshold, new GUIContent ("Reflection Threshold", "If the intensity of the reflected contribution is less than the threshold, the ray will be terminated.")); 437 | EditorGUILayout.PropertyField (giTransparencyDepth, new GUIContent ("GI Transparency Depth", "Controls the maximum transparency depth for Global Illumination rays. Used to speed up renderings with a lot of transparency (for example trees).")); 438 | EditorGUI.indentLevel--; 439 | 440 | GUILayout.Label ("Shadows", EditorStyles.boldLabel); 441 | EditorGUI.indentLevel++; 442 | 443 | // FIXME add undo 444 | sc.config.renderSettings.shadowDepth = (int)((ILConfig.ShadowDepth)EditorGUILayout.EnumPopup (new GUIContent ("Shadow Depth", "Controls which rays that spawn shadow rays."), (ILConfig.ShadowDepth)System.Enum.Parse (typeof(ILConfig.ShadowDepth), sc.config.renderSettings.shadowDepth.ToString ()))); 445 | 446 | EditorGUILayout.PropertyField (minShadowRays, new GUIContent ("Min Shadow Rays", "The minimum number of shadow rays that will be sent to determine if a point is lit by a specific light source. Use this value to ensure that you get enough quality in soft shadows at the price of render times. This will raise the minimum number of rays sent for any light sources that have a minShadowSamples setting lower than this value, but will not lower the number if minShadowSamples is set to a higher value. Setting this to a value higher than maxShadowRays will not send more rays than maxShadowRays.")); 447 | EditorGUILayout.PropertyField (maxShadowRays, new GUIContent ("Max Shadow Rays", "The maximum number of shadow rays per point that will be used to generate a soft shadow for any light source. Use this to shorten render times at the price of soft shadow quality. This will lower the maximum number of rays sent for any light sources that have a shadow samples setting higher than this value, but will not raise the number if shadow samples is set to a lower value.")); 448 | EditorGUI.indentLevel--; 449 | 450 | GUILayout.Label ("Geometry", EditorStyles.boldLabel); 451 | EditorGUI.indentLevel++; 452 | EditorGUILayout.PropertyField (vertexMergeThreshold, new GUIContent ("Vertex Merge Threshold", "Triangle vertices that are closer together than this threshold will be merged into one (if possible depending on other vertex data).")); 453 | EditorGUILayout.PropertyField (tsOddUVFlipping, new GUIContent ("Odd UV Flipping", "Using this setting will force Beast to mirror tangent and binormal when UV has odd winding direction.")); 454 | EditorGUILayout.PropertyField (tsVertexOrthogonalization, new GUIContent ("Vertex Orthogonalization", "Orthogonalize tangent space basis vectors (tangent, binormal and normal) at every vertex.")); 455 | EditorGUILayout.PropertyField (tsVertexNormalization, new GUIContent ("Vertex Normalization", "Normalize tangent space basis vectors (tangent, binormal and normal) at every vertex.")); 456 | EditorGUILayout.PropertyField (tsIntersectionOrthogonalization, new GUIContent ("Intersection Orthogonalization", "Orthogonalize tangent space basis vectors (tangent, binormal and normal) at every intersection point.")); 457 | EditorGUILayout.PropertyField (tsIntersectionNormalization, new GUIContent ("Intersection Normalization", "Normalize tangent space basis vectors (tangent, binormal and normal) at every intersection point.")); 458 | EditorGUI.indentLevel--; 459 | } 460 | 461 | void GlobalIlluminationGUI (SerializedObject serializedConfig) 462 | { 463 | SerializedProperty enableGI = serializedConfig.FindProperty ("config.giSettings.enableGI"); 464 | SerializedProperty fgLightLeakReduction = serializedConfig.FindProperty ("config.giSettings.fgLightLeakReduction"); 465 | SerializedProperty fgLightLeakRadius = serializedConfig.FindProperty ("config.giSettings.fgLightLeakRadius"); 466 | 467 | EditorGUILayout.PropertyField (enableGI, new GUIContent ("Enable GI", "")); 468 | EditorGUI.BeginDisabledGroup (!sc.config.giSettings.enableGI); 469 | 470 | // Caustics have no effect as of Unity 4.0 471 | // Toggle ("Enable Caustics", ref config.giSettings.enableCaustics, ""); 472 | 473 | EditorGUILayout.Space (); 474 | 475 | GUILayout.Label ("Primary Integrator", EditorStyles.boldLabel); 476 | IntegratorPopup (serializedConfig, true); 477 | IntegratorSettings (serializedConfig, sc.config.giSettings.primaryIntegrator, true); 478 | 479 | EditorGUILayout.Space (); 480 | 481 | GUILayout.Label ("Secondary Integrator", EditorStyles.boldLabel); 482 | IntegratorPopup (serializedConfig, false); 483 | IntegratorSettings (serializedConfig, sc.config.giSettings.secondaryIntegrator, false); 484 | 485 | if (sc.config.giSettings.primaryIntegrator == ILConfig.GISettings.Integrator.FinalGather && sc.config.giSettings.secondaryIntegrator == ILConfig.GISettings.Integrator.PathTracer) { 486 | EditorGUILayout.Space (); 487 | GUILayout.Label ("Final Gather & Path Tracer Blending", EditorStyles.boldLabel); 488 | EditorGUILayout.PropertyField (fgLightLeakReduction, new GUIContent ("Light Leak Reduction", "This setting can be used to reduce light leakage through walls when using final gather as primary GI and path tracing as secondary GI. Leakage, which can happen when e.g. the path tracer filters in values on the other side of a wall, is reduced by using final gather as a secondary GI fallback when sampling close to walls or corners. When this is enabled a final gather depth of 3 will be used automatically, but the higher depths will only be used close to walls or corners. Note that this is only used when path tracing is set as secondary GI.")); 489 | if (!sc.config.giSettings.fgLightLeakReduction) 490 | GUI.enabled = false; 491 | EditorGUILayout.PropertyField (fgLightLeakRadius, new GUIContent ("Light Leak Radius", "Controls how far away from walls the final gather will be called again, instead of the secondary GI. If 0.0 is used a value will be calculated by Beast depending on the secondary GI used. The calculated value is printed in the output window. If you still get leakage you can adjust this by manually typing in a higher value.")); 492 | if (sc.config.giSettings.enableGI) 493 | GUI.enabled = true; 494 | } 495 | 496 | EditorGUI.EndDisabledGroup (); 497 | } 498 | 499 | void IntegratorPopup (SerializedObject serializedObject, bool isPrimary) 500 | { 501 | SerializedProperty primaryIntegrator = serializedObject.FindProperty ("config.giSettings.primaryIntegrator"); 502 | SerializedProperty secondaryIntegrator = serializedObject.FindProperty ("config.giSettings.secondaryIntegrator"); 503 | 504 | if (isPrimary) { 505 | EditorGUILayout.PropertyField (primaryIntegrator, new GUIContent ("")); 506 | } else { 507 | EditorGUILayout.PropertyField (secondaryIntegrator, new GUIContent ("")); 508 | } 509 | } 510 | 511 | void IntegratorSettings (SerializedObject serializedObject, ILConfig.GISettings.Integrator integrator, bool isPrimary) 512 | { 513 | if (integrator != ILConfig.GISettings.Integrator.None) { 514 | if (isPrimary) { 515 | SerializedProperty primaryIntensity = serializedObject.FindProperty ("config.giSettings.primaryIntensity"); 516 | SerializedProperty primarySaturation = serializedObject.FindProperty ("config.giSettings.primarySaturation"); 517 | EditorGUILayout.PropertyField (primaryIntensity, new GUIContent ("Intensity", "Tweak the amount of illumination from the primary and secondary GI integrators. This lets you boost or reduce the amount of indirect light easily.")); 518 | EditorGUILayout.PropertyField (primarySaturation, new GUIContent ("Saturation", "Lets you tweak the amount of color in the primary and secondary GI integrators. This lets you boost or reduce the perceived saturation of the bounced light.")); 519 | } else { 520 | SerializedProperty secondaryIntensity = serializedObject.FindProperty ("config.giSettings.secondaryIntensity"); 521 | SerializedProperty secondarySaturation = serializedObject.FindProperty ("config.giSettings.secondarySaturation"); 522 | EditorGUILayout.PropertyField (secondaryIntensity, new GUIContent ("Intensity", "Tweak the amount of illumination from the primary and secondary GI integrators. This lets you boost or reduce the amount of indirect light easily.")); 523 | EditorGUILayout.PropertyField (secondarySaturation, new GUIContent ("Saturation", "Lets you tweak the amount of color in the primary and secondary GI integrators. This lets you boost or reduce the perceived saturation of the bounced light.")); 524 | } 525 | } 526 | 527 | switch (integrator) { 528 | case ILConfig.GISettings.Integrator.None: 529 | if (isPrimary && sc.config.giSettings.primaryIntegrator != ILConfig.GISettings.Integrator.None) 530 | sc.config.giSettings.primaryIntegrator = ILConfig.GISettings.Integrator.None; 531 | else if (!isPrimary && sc.config.giSettings.secondaryIntegrator != ILConfig.GISettings.Integrator.None) 532 | sc.config.giSettings.secondaryIntegrator = ILConfig.GISettings.Integrator.None; 533 | break; 534 | case ILConfig.GISettings.Integrator.FinalGather: 535 | FinalGatherSettings (serializedObject, isPrimary); 536 | break; 537 | case ILConfig.GISettings.Integrator.PathTracer: 538 | PathTracerSettings (serializedObject, isPrimary); 539 | break; 540 | case ILConfig.GISettings.Integrator.MonteCarlo: 541 | MonteCarloSettings (serializedObject, isPrimary); 542 | break; 543 | } 544 | } 545 | 546 | void FinalGatherSettings (SerializedObject serializedConfig, bool isPrimaryIntegrator) 547 | { 548 | SerializedProperty fgDepth = serializedConfig.FindProperty ("config.giSettings.fgDepth"); 549 | SerializedProperty diffuseBoost = serializedConfig.FindProperty ("config.giSettings.diffuseBoost"); 550 | SerializedProperty fgRays = serializedConfig.FindProperty ("config.giSettings.fgRays"); 551 | SerializedProperty fgMaxRayLength = serializedConfig.FindProperty ("config.giSettings.fgMaxRayLength"); 552 | SerializedProperty fgAttenuationStart = serializedConfig.FindProperty ("config.giSettings.fgAttenuationStart"); 553 | SerializedProperty fgAttenuationStop = serializedConfig.FindProperty ("config.giSettings.fgAttenuationStop"); 554 | SerializedProperty fgFalloffExponent = serializedConfig.FindProperty ("config.giSettings.fgFalloffExponent"); 555 | SerializedProperty fgInterpolationPoints = serializedConfig.FindProperty ("config.giSettings.fgInterpolationPoints"); 556 | SerializedProperty fgEstimatePoints = serializedConfig.FindProperty ("config.giSettings.fgEstimatePoints"); 557 | SerializedProperty fgCheckVisibility = serializedConfig.FindProperty ("config.giSettings.fgCheckVisibility"); 558 | SerializedProperty fgContrastThreshold = serializedConfig.FindProperty ("config.giSettings.fgContrastThreshold"); 559 | SerializedProperty fgGradientThreshold = serializedConfig.FindProperty ("config.giSettings.fgGradientThreshold"); 560 | SerializedProperty fgNormalThreshold = serializedConfig.FindProperty ("config.giSettings.fgNormalThreshold"); 561 | SerializedProperty fgClampRadiance = serializedConfig.FindProperty ("config.giSettings.fgClampRadiance"); 562 | SerializedProperty fgAOInfluence = serializedConfig.FindProperty ("config.giSettings.fgAOInfluence"); 563 | SerializedProperty fgAOContrast = serializedConfig.FindProperty ("config.giSettings.fgAOContrast"); 564 | SerializedProperty fgAOMaxDistance = serializedConfig.FindProperty ("config.giSettings.fgAOMaxDistance"); 565 | SerializedProperty fgAOScale = serializedConfig.FindProperty ("config.giSettings.fgAOScale"); 566 | SerializedProperty fgPreview = serializedConfig.FindProperty ("config.giSettings.fgPreview"); 567 | SerializedProperty fgUseCache = serializedConfig.FindProperty ("config.giSettings.fgUseCache"); 568 | SerializedProperty fgCacheDirectLight = serializedConfig.FindProperty ("config.giSettings.fgCacheDirectLight"); 569 | 570 | if (isPrimaryIntegrator && sc.config.giSettings.primaryIntegrator != ILConfig.GISettings.Integrator.FinalGather) 571 | sc.config.giSettings.primaryIntegrator = ILConfig.GISettings.Integrator.FinalGather; 572 | else if (!isPrimaryIntegrator && sc.config.giSettings.secondaryIntegrator != ILConfig.GISettings.Integrator.FinalGather) 573 | sc.config.giSettings.secondaryIntegrator = ILConfig.GISettings.Integrator.FinalGather; 574 | 575 | // Bounces 576 | 577 | GUILayout.Label ("Bounces", EditorStyles.boldLabel); 578 | EditorGUI.indentLevel++; 579 | EditorGUILayout.IntSlider (fgDepth, 1, 10, new GUIContent ("Bounces", "Sets the number of indirect light bounces calculated by final gather. A value higher than 1 will produce more global illumination effects, but note that it can be quite slow since the number of rays will increase exponentially with the depth. It's often better to use a fast method for secondary GI. If a secondary GI is used the number of set final gather bounces will be calculated first, before the secondary GI is called. So in most cases the depth should be set to 1 if a secondary GI is used.")); 580 | EditorGUILayout.PropertyField (diffuseBoost, new GUIContent ("Bounce Boost", "This setting can be used to exaggerate light bouncing in dark scenes. Setting it to a value larger than 1 will push the diffuse color of materials towards 1 for GI computations. The typical use case is scenes authored with dark materials, this happens easily when doing only direct lighting since it's easy to compensate dark materials with strong light sources. Indirect light will be very subtle in these scenes since the bounced light will fade out quickly. Setting a diffuse boost will compensate for this. Note that values between 0 and 1 will decrease the diffuse setting in a similar way making light bounce less than the materials says, values below 0 is invalid. The actual computation taking place is a per component pow(colorComponent, (1.0 / diffuseBoost)).")); 581 | EditorGUI.indentLevel--; 582 | 583 | // Rays 584 | 585 | GUILayout.Label ("Rays", EditorStyles.boldLabel); 586 | EditorGUI.indentLevel++; 587 | EditorGUILayout.PropertyField (fgRays, new GUIContent ("Rays", "Sets the maximum number of rays to use for each Final Gather sample point. A higher number gives higher quality, but longer rendering time.")); 588 | EditorGUILayout.PropertyField (fgMaxRayLength, new GUIContent ("Max Ray Length", "The max distance a ray can be traced before it's considered to be a 'miss'. This can improve performance in very large scenes. If the value is set to 0.0 the entire scene will be used.")); 589 | 590 | // Attenuation 591 | 592 | GUILayout.Label ("Attenuation", EditorStyles.boldLabel); 593 | EditorGUILayout.PropertyField (fgAttenuationStart, new GUIContent ("Attenuation Start", "The distance between which attenuation begins and fades to zero. There is no attenuation before this range, and no intensity beyond it. If zero, there will be no attenuation.")); 594 | EditorGUILayout.PropertyField (fgAttenuationStop, new GUIContent ("Attenuation Stop", "The distance between which attenuation begins and fades to zero. There is no attenuation before this range, and no intensity beyond it. If zero, there will be no attenuation.")); 595 | if (sc.config.giSettings.fgAttenuationStop == 0) 596 | GUI.enabled = false; 597 | EditorGUILayout.PropertyField (fgFalloffExponent, new GUIContent ("Falloff Exponent", "This can be used to adjust the rate by which lighting falls off by distance. A higher exponent gives a faster falloff. Note that fgAttenuationStop must be set higher than 0.0 to enable attenuation.")); 598 | if (sc.config.giSettings.enableGI) 599 | GUI.enabled = true; 600 | EditorGUI.indentLevel--; 601 | 602 | // Points 603 | 604 | GUILayout.Label ("Points", EditorStyles.boldLabel); 605 | EditorGUI.indentLevel++; 606 | EditorGUILayout.IntSlider (fgInterpolationPoints, 1, 40, new GUIContent ("Interpolation Points", "Sets the number of final gather points to interpolate between. A higher value will give a smoother result, but can also smooth out details. If light leakage is introduced through walls when this value is increased, checking the sample visibility solves that problem, see fgCheckVisibility below.")); 607 | EditorGUILayout.IntSlider (fgEstimatePoints, 1, 40, new GUIContent ("Estimate Points", "Sets the minimum number of points that should be used when estimating final gather in the pre calculation pass. The impact is that a higher value will create more points all over the scene. The default value 15 rarely needs to be adjusted.")); 608 | EditorGUILayout.PropertyField (fgCheckVisibility, new GUIContent ("Check Visibility", "Turn this on to reduce light leakage through walls. When points are collected to interpolate between, some of them can be located on the other side of geometry. As a result light will bleed through the geometry. So to prevent this Beast can reject points that are not visible.")); 609 | EditorGUILayout.PropertyField (fgContrastThreshold, new GUIContent ("Contrast Threshold", "Controls how sensitive the final gather should be for contrast differences between the points during pre calculation. If the contrast difference is above this threshold for neighbouring points, more points will be created in that area. This tells the algorithm to place points where they are really needed, e.g. at shadow boundaries or in areas where the indirect light changes quickly. Hence this threshold controls the number of points created in the scene adaptively. Note that if a low number of final gather rays are used, the points will have high variance and hence a high contrast difference, so in that case you might need to increase the contrast threshold to prevent points from clumping together.")); 610 | EditorGUILayout.PropertyField (fgGradientThreshold, new GUIContent ("Gradient Threshold", "Controls how the irradiance gradient is used in the interpolation. Each point stores it's irradiance gradient which can be used to improve the interpolation. However in some situations using the gradient can result in white 'halos' and other artifacts. This threshold can be used to reduce those artifacts.")); 611 | EditorGUILayout.PropertyField (fgNormalThreshold, new GUIContent ("Normal Threshold", "Controls how sensitive the final gather should be for differences in the points normals. A lower value will give more points in areas of high curvature.")); 612 | EditorGUILayout.PropertyField (fgClampRadiance, new GUIContent ("Clamp Radiance", "Turn this on to clamp the sampled values to [0, 1]. This will reduce high frequency noise when Final Gather is used together with other Global Illumination algorithms.")); 613 | EditorGUI.indentLevel--; 614 | 615 | // Ambient Occlusion 616 | 617 | GUILayout.Label ("Ambient Occlusion", EditorStyles.boldLabel); 618 | EditorGUI.indentLevel++; 619 | // Visualize AO is not available as of Unity 4.0 620 | // Toggle ("Visualize AO", ref config.giSettings.fgAOVisualize, "Visualize just the ambient occlusion values. Useful when tweaking the occlusion sampling options."); 621 | EditorGUILayout.Slider (fgAOInfluence, 0, 1, new GUIContent ("Influence", "Controls a scaling of Final Gather with Ambient Occlusion which can be used to boost shadowing and get more contrast in you lighting. The value controls how much Ambient Occlusion to blend into the Final Gather solution.")); 622 | LightmapEditorSettings.aoAmount = sc.config.giSettings.fgAOInfluence; 623 | if (sc.config.giSettings.fgAOInfluence <= 0) 624 | GUI.enabled = false; 625 | EditorGUILayout.Slider (fgAOContrast, 0, 2, new GUIContent ("Contrast", "Can be used to adjust the contrast for ambient occlusion.")); 626 | LightmapEditorSettings.aoContrast = sc.config.giSettings.fgAOContrast; 627 | EditorGUILayout.PropertyField (fgAOMaxDistance, new GUIContent ("Max Distance", "Max distance for the occlusion. Beyond this distance a ray is considered to be visible. Can be used to avoid full occlusion for closed scenes.")); 628 | LightmapEditorSettings.aoMaxDistance = sc.config.giSettings.fgAOMaxDistance; 629 | EditorGUILayout.PropertyField (fgAOScale, new GUIContent ("Scale", "A scaling of the occlusion values. Can be used to increase or decrease the shadowing effect.")); 630 | if (sc.config.giSettings.enableGI) 631 | GUI.enabled = true; 632 | 633 | // Performance 634 | 635 | GUILayout.Label ("Performance", EditorStyles.boldLabel); 636 | EditorGUILayout.PropertyField (fgPreview, new GUIContent ("Fast Preview", "Turn this on to visualize the final gather prepass. Using the Preview Calculation Pass enables a quick preview of the final image lighting, reducing lighting setup time.")); 637 | EditorGUILayout.PropertyField (fgUseCache, new GUIContent ("Use Cache", "Selects what caching method to use for final gathering.")); 638 | EditorGUILayout.PropertyField (fgCacheDirectLight, new GUIContent ("Cache Direct Light", "When this is enabled final gather will also cache lighting from light sources. This increases performance since fewer direct light calculations are needed. It gives an approximate result, and hence can affect the quality of the lighting. For instance indirect light bounces from specular highlights might be lost. However this caching is only done for depths higher than 1, so the quality of direct light and shadows in the light map will not be reduced.")); 639 | } 640 | 641 | void PathTracerSettings (SerializedObject serializedConfig, bool isPrimaryIntegrator) 642 | { 643 | SerializedProperty ptDepth = serializedConfig.FindProperty ("config.giSettings.ptDepth"); 644 | SerializedProperty ptAccuracy = serializedConfig.FindProperty ("config.giSettings.ptAccuracy"); 645 | SerializedProperty ptPointSize = serializedConfig.FindProperty ("config.giSettings.ptPointSize"); 646 | SerializedProperty ptNormalThreshold = serializedConfig.FindProperty ("config.giSettings.ptNormalThreshold"); 647 | SerializedProperty ptFilterType = serializedConfig.FindProperty ("config.giSettings.ptFilterType"); 648 | SerializedProperty ptFilterSize = serializedConfig.FindProperty ("config.giSettings.ptFilterSize"); 649 | SerializedProperty ptCheckVisibility = serializedConfig.FindProperty ("config.giSettings.ptCheckVisibility"); 650 | SerializedProperty ptPreview = serializedConfig.FindProperty ("config.giSettings.ptPreview"); 651 | SerializedProperty ptCacheDirectLight = serializedConfig.FindProperty ("config.giSettings.ptCacheDirectLight"); 652 | SerializedProperty ptPrecalcIrradiance = serializedConfig.FindProperty ("config.giSettings.ptPrecalcIrradiance"); 653 | 654 | if (isPrimaryIntegrator && sc.config.giSettings.primaryIntegrator != ILConfig.GISettings.Integrator.PathTracer) 655 | sc.config.giSettings.primaryIntegrator = ILConfig.GISettings.Integrator.PathTracer; 656 | else if (!isPrimaryIntegrator && sc.config.giSettings.secondaryIntegrator != ILConfig.GISettings.Integrator.PathTracer) 657 | sc.config.giSettings.secondaryIntegrator = ILConfig.GISettings.Integrator.PathTracer; 658 | 659 | EditorGUILayout.IntSlider (ptDepth, 0, 20, new GUIContent ("Bounces", "")); 660 | EditorGUILayout.PropertyField (ptAccuracy, new GUIContent ("Accuracy", "Sets the number of paths that are traced for each sample element (pixel, texel or vertex). For preview renderings, you can use a low value like 0.5 or 0.1, which means that half of the pixels or 1/10 of the pixels will generate a path. For production renderings you can use values above 1.0, if needed to get good quality.")); 661 | // ptDefaultColor has no apparent effect as of Unity 4.0 662 | // LMColorPicker ("Default Color", ref config.giSettings.ptDefaultColor, ""); 663 | 664 | // Points 665 | 666 | GUILayout.Label ("Points", EditorStyles.boldLabel); 667 | EditorGUILayout.PropertyField (ptPointSize, new GUIContent ("Point Size", "Sets the maximum distance between the points in the path tracer cache. If set to 0 a value will be calculated automatically based on the size of the scene. The automatic value will be printed out during rendering, which is a good starting value if the point spacing needs to be adjusted.")); 668 | EditorGUILayout.PropertyField (ptNormalThreshold, new GUIContent ("Normal Threshold", "Sets the amount of normal deviation that is allowed during cache point filtering.")); 669 | EditorGUILayout.PropertyField (ptFilterType, new GUIContent ("Filter Type", "Selects the filter to use when querying the cache during rendering. None will return the closest cache point (unfiltered).")); 670 | EditorGUILayout.PropertyField (ptFilterSize, new GUIContent ("Filter Size", "Sets the size of the filter as a multiplier of the Cache Point Spacing value. For example; a value of 3.0 will use a filter that is three times larges then the cache point spacing. If this value is below 1.0 there is no guarantee that any cache point is found. If no cache point is found the Default Color will be returned instead for that query.")); 671 | EditorGUILayout.PropertyField (ptCheckVisibility, new GUIContent ("Check Visibility", "Turn this on to reduce light leakage through walls. When points are collected to interpolate between, some of them can be located on the other side of geometry. As a result light will bleed through the geometry. So to prevent this Beast can reject points that are not visible.")); 672 | 673 | // Performance 674 | 675 | GUILayout.Label ("Performance", EditorStyles.boldLabel); 676 | EditorGUILayout.PropertyField (ptPreview, new GUIContent ("Fast Preview", "If enabled the pre-render pass will be visible in the render view.")); 677 | EditorGUILayout.PropertyField (ptCacheDirectLight, new GUIContent ("Cache Direct Light", "When this is enabled the path tracer will also cache lighting from light sources. This increases performance since fewer direct light calculations are needed. It gives an approximate result, and hence can affect the quality of the lighting. For instance indirect light bounces from specular highlights might be lost.")); 678 | EditorGUILayout.PropertyField (ptPrecalcIrradiance, new GUIContent ("Precalc Irradiance", "If enabled the cache points will be pre-filtered before the final pass starts. This increases the performance using the final render pass.")); 679 | } 680 | 681 | void MonteCarloSettings (SerializedObject serializedConfig, bool isPrimaryIntegrator) 682 | { 683 | SerializedProperty mcDepth = serializedConfig.FindProperty ("config.giSettings.mcDepth"); 684 | SerializedProperty mcRays = serializedConfig.FindProperty ("config.giSettings.mcRays"); 685 | SerializedProperty mcMaxRayLength = serializedConfig.FindProperty ("config.giSettings.mcMaxRayLength"); 686 | 687 | if (isPrimaryIntegrator && sc.config.giSettings.primaryIntegrator != ILConfig.GISettings.Integrator.MonteCarlo) 688 | sc.config.giSettings.primaryIntegrator = ILConfig.GISettings.Integrator.MonteCarlo; 689 | else if (!isPrimaryIntegrator && sc.config.giSettings.secondaryIntegrator != ILConfig.GISettings.Integrator.MonteCarlo) 690 | sc.config.giSettings.secondaryIntegrator = ILConfig.GISettings.Integrator.MonteCarlo; 691 | 692 | EditorGUILayout.IntSlider (mcDepth, 1, 20, new GUIContent ("Bounces", "Sets the number of indirect light bounces calculated by monte carlo.")); 693 | EditorGUILayout.PropertyField (mcRays, new GUIContent ("Rays", "Sets the number of rays to use for each calculation. A higher number gives higher quality, but longer rendering time.")); 694 | EditorGUILayout.PropertyField (mcMaxRayLength, new GUIContent ("Ray Length", "The max distance a ray can be traced before it's considered to be a 'miss'. This can improve performance in very large scenes. If the value is set to 0.0 the entire scene will be used.")); 695 | } 696 | 697 | void EnvironmentGUI (SerializedObject serializedConfig) 698 | { 699 | SerializedProperty giEnvironment = serializedConfig.FindProperty ("config.environmentSettings.giEnvironment"); 700 | SerializedProperty giEnvironmentIntensity = serializedConfig.FindProperty ("config.environmentSettings.giEnvironmentIntensity"); 701 | SerializedProperty iblImageFile = serializedConfig.FindProperty ("config.environmentSettings.iblImageFile"); 702 | SerializedProperty iblSwapYZ = serializedConfig.FindProperty ("config.environmentSettings.iblSwapYZ"); 703 | SerializedProperty iblTurnDome = serializedConfig.FindProperty ("config.environmentSettings.iblTurnDome"); 704 | SerializedProperty iblGIEnvBlur = serializedConfig.FindProperty ("config.environmentSettings.iblGIEnvBlur"); 705 | SerializedProperty iblEmitLight = serializedConfig.FindProperty ("config.environmentSettings.iblEmitLight"); 706 | SerializedProperty iblSamples = serializedConfig.FindProperty ("config.environmentSettings.iblSamples"); 707 | SerializedProperty iblIntensity = serializedConfig.FindProperty ("config.environmentSettings.iblIntensity"); 708 | SerializedProperty iblEmitDiffuse = serializedConfig.FindProperty ("config.environmentSettings.iblEmitDiffuse"); 709 | SerializedProperty iblEmitSpecular = serializedConfig.FindProperty ("config.environmentSettings.iblEmitSpecular"); 710 | SerializedProperty iblSpecularBoost = serializedConfig.FindProperty ("config.environmentSettings.iblSpecularBoost"); 711 | SerializedProperty iblShadows = serializedConfig.FindProperty ("config.environmentSettings.iblShadows"); 712 | SerializedProperty iblBandingVsNoise = serializedConfig.FindProperty ("config.environmentSettings.iblBandingVsNoise"); 713 | 714 | EditorGUILayout.PropertyField (giEnvironment, new GUIContent ("Environment Type", "")); 715 | 716 | EditorGUI.BeginDisabledGroup (sc.config.environmentSettings.giEnvironment == ILConfig.EnvironmentSettings.Environment.None); 717 | 718 | EditorGUI.indentLevel++; 719 | 720 | EditorGUILayout.PropertyField (giEnvironmentIntensity, new GUIContent ("Intensity", "")); 721 | 722 | if (sc.config.environmentSettings.giEnvironment == ILConfig.EnvironmentSettings.Environment.SkyLight) { 723 | // FIXME add undo 724 | LMColorPicker ("Sky Light Color", ref sc.config.environmentSettings.skyLightColor, "It is often a good idea to keep the color below 1.0 in intensity to avoid boosting by gamma correction. Boost the intensity instead with the giEnvironmentIntensity setting."); 725 | } else if (sc.config.environmentSettings.giEnvironment == ILConfig.EnvironmentSettings.Environment.IBL) { 726 | GUILayout.Label ("IBL Image", EditorStyles.boldLabel); 727 | EditorGUILayout.PrefixLabel (new GUIContent ("Image Path", "The absolute image file path to use for IBL. Accepts hdr or OpenEXR format. The file should be long-lat. Use giEnvironmentIntensity to boost the intensity of the image.")); 728 | EditorGUILayout.PropertyField (iblImageFile, new GUIContent ("")); 729 | GUILayout.BeginHorizontal (); 730 | { 731 | GUILayout.FlexibleSpace (); 732 | if (!string.IsNullOrEmpty (sc.config.environmentSettings.iblImageFile)) { 733 | if (GUILayout.Button ("Reveal", GUILayout.Width (55))) { 734 | EditorUtility.OpenWithDefaultApp (Path.GetDirectoryName (sc.config.environmentSettings.iblImageFile)); 735 | } 736 | if (GUILayout.Button ("Edit", GUILayout.Width (55))) { 737 | EditorUtility.OpenWithDefaultApp (sc.config.environmentSettings.iblImageFile); 738 | } 739 | } 740 | if (GUILayout.Button ("Choose", GUILayout.Width (55))) { 741 | string file = EditorUtility.OpenFilePanel ("Select EXR or HDR file", "", ""); 742 | string ext = Path.GetExtension (file); 743 | if (!string.IsNullOrEmpty (file)) { 744 | if (ext == ".exr" || ext == ".hdr") { 745 | sc.config.environmentSettings.iblImageFile = file; 746 | iblImageFile.stringValue = file; 747 | GUI.changed = true; 748 | Repaint (); 749 | SaveConfig (); 750 | GUIUtility.ExitGUI (); 751 | } else { 752 | Debug.LogError ("IBL image files must use the extension .exr or .hdr"); 753 | } 754 | } 755 | } 756 | } 757 | GUILayout.EndHorizontal (); 758 | EditorGUILayout.PropertyField (iblSwapYZ, new GUIContent ("Swap Y/Z", "Swap the Up Axis. Default value is false, meaning that Y is up.")); 759 | EditorGUILayout.Slider (iblTurnDome, 0, 360, new GUIContent ("Dome Rotation", "The sphere that the image is projected on can be rotated around the up axis. The amount of rotation is given in degrees. Default value is 0.0.")); 760 | EditorGUILayout.PropertyField (iblGIEnvBlur, new GUIContent ("Blur", "Pre-blur the environment image for Global Illumination calculations. Can help to reduce noise and flicker in images rendered with Final Gather. May increase render time as it is blurred at render time. It is always cheaper to pre-blur the image itself in an external application before loading it into Beast.")); 761 | 762 | GUILayout.Label ("IBL Light", EditorStyles.boldLabel); 763 | 764 | EditorGUILayout.PropertyField (iblEmitLight, new GUIContent ("Emit Light", "Turns on the expensive IBL implementation. This will generate a number of (iblSamples) directional lights from the image.")); 765 | if (sc.config.environmentSettings.iblEmitLight) 766 | EditorGUILayout.HelpBox ("The scene will be lit by a number of directional lights with colors sampled from the IBL image. Very expensive.", MessageType.None); 767 | else 768 | EditorGUILayout.HelpBox ("The scene will be lit with Global Illumination using the IBL image as a simple environment.", MessageType.None); 769 | 770 | EditorGUI.BeginDisabledGroup (!sc.config.environmentSettings.iblEmitLight); 771 | { 772 | EditorGUILayout.PropertyField (iblSamples, new GUIContent ("Samples", "The number of samples to be taken from the image. This will affect how soft the shadows will be, as well as the general lighting. The higher number of samples, the better the shadows and lighting.")); 773 | EditorGUILayout.PropertyField (iblIntensity, new GUIContent ("IBL Intensity", "Sets the intensity of the lighting.")); 774 | EditorGUILayout.PropertyField (iblEmitDiffuse, new GUIContent ("Diffuse", "To remove diffuse lighting from IBL, set this to false. To get the diffuse lighting Final Gather could be used instead.")); 775 | EditorGUILayout.PropertyField (iblEmitSpecular, new GUIContent ("Specular", "To remove specular highlights from IBL, set this to false.")); 776 | EditorGUI.indentLevel++; 777 | { 778 | if (!sc.config.environmentSettings.iblEmitSpecular) 779 | GUI.enabled = false; 780 | EditorGUILayout.PropertyField (iblSpecularBoost, new GUIContent ("Specular Boost", "Further tweak the intensity by boosting the specular component.")); 781 | if (sc.config.environmentSettings.iblEmitLight) 782 | GUI.enabled = true; 783 | } 784 | EditorGUI.indentLevel--; 785 | EditorGUILayout.PropertyField (iblShadows, new GUIContent ("Shadows", "Controls whether shadows should be created from IBL when this is used.")); 786 | { 787 | EditorGUI.indentLevel++; 788 | if (!sc.config.environmentSettings.iblShadows) 789 | GUI.enabled = false; 790 | EditorGUILayout.PropertyField (iblBandingVsNoise, new GUIContent ("Shadow Noise", "Controls the appearance of the shadows, banded shadows look more aliased, but noisy shadows flicker more in animations.")); 791 | if (sc.config.environmentSettings.iblEmitLight) 792 | GUI.enabled = true; 793 | } 794 | EditorGUI.indentLevel--; 795 | } 796 | EditorGUI.EndDisabledGroup (); 797 | 798 | EditorGUILayout.Space (); 799 | } 800 | EditorGUI.indentLevel--; 801 | 802 | EditorGUI.EndDisabledGroup (); 803 | } 804 | 805 | void TextureBakeGUI (SerializedObject serializedConfig) 806 | { 807 | SerializedProperty bilinearFilter = serializedConfig.FindProperty ("config.textureBakeSettings.bilinearFilter"); 808 | SerializedProperty conservativeRasterization = serializedConfig.FindProperty ("config.textureBakeSettings.conservativeRasterization"); 809 | 810 | GUILayout.Label ("Texture", EditorStyles.boldLabel); 811 | EditorGUI.indentLevel++; 812 | 813 | // The following have no effect as of Unity 4.0 814 | 815 | // LMColorPicker ("Background Color", ref config.textureBakeSettings.bgColor, ""); 816 | // IntField ("Edge Dilation", ref config.textureBakeSettings.edgeDilation, "Expands the lightmap with the number of pixels specified to avoid black borders."); 817 | // Toggle ("Premultiply", ref config.frameSettings.premultiply, "If this box is checked the alpha channel value is pre multiplied into the color channel of the pixel. Note that disabling premultiply alpha gives poor result if used with environment maps and other non constant camera backgrounds. Disabling premultiply alpha can be convenient when composing images in post."); 818 | // EditorGUI.indentLevel++; 819 | // if (!config.frameSettings.premultiply) { 820 | // GUI.enabled = false; 821 | // } 822 | // FloatField ("Premultiply Threshold", ref config.frameSettings.premultiplyThreshold, "This is the alpha threshold for pixels to be considered opaque enough to be 'un multiplied' when using premultiply alpha."); 823 | // EditorGUI.indentLevel--; 824 | // GUI.enabled = true; 825 | 826 | EditorGUILayout.PropertyField (bilinearFilter, new GUIContent ("Bilinear Filter", "Counteract unwanted light seams for tightly packed UV patches.")); 827 | EditorGUILayout.PropertyField (conservativeRasterization, new GUIContent ("Conservative Rasterization", "Find pixels which are only partially covered by the UV map.")); 828 | 829 | EditorGUI.indentLevel--; 830 | } 831 | 832 | #endregion 833 | 834 | 835 | #region Bake 836 | 837 | enum BakeMode 838 | { 839 | BakeScene, 840 | BakeSelected, 841 | BakeProbes, 842 | } 843 | 844 | void BakeButtonsGUI () 845 | { 846 | float width = 120; 847 | bool disabled = LightmapSettings.lightmapsMode == LightmapsMode.Directional && !InternalEditorUtility.HasPro (); 848 | EditorGUI.BeginDisabledGroup (disabled); 849 | { 850 | GUILayout.BeginHorizontal (); 851 | { 852 | GUILayout.FlexibleSpace (); 853 | if (GUILayout.Button ("Clear", GUILayout.Width (width))) { 854 | Lightmapping.Clear (); 855 | } 856 | if (!Lightmapping.isRunning) { 857 | if (BakeButton (GUILayout.Width (width))) { 858 | this.DoBake (); 859 | GUIUtility.ExitGUI (); 860 | } 861 | } else { 862 | if (GUILayout.Button ("Cancel", GUILayout.Width (width))) { 863 | Lightmapping.Cancel (); 864 | } 865 | } 866 | } 867 | GUILayout.EndHorizontal (); 868 | } 869 | EditorGUI.EndDisabledGroup (); 870 | } 871 | 872 | private bool BakeButton (params GUILayoutOption[] options) 873 | { 874 | GUIContent content = new GUIContent (ObjectNames.NicifyVariableName (bakeMode.ToString ())); 875 | 876 | Rect dropdownRect = GUILayoutUtility.GetRect (content, (GUIStyle)"DropDownButton", options); 877 | Rect buttonRect = dropdownRect; 878 | buttonRect.xMin = buttonRect.xMax - 20; 879 | if (Event.current.type != EventType.MouseDown || !buttonRect.Contains (Event.current.mousePosition)) 880 | return GUI.Button (dropdownRect, content, (GUIStyle)"DropDownButton"); 881 | GenericMenu genericMenu = new GenericMenu (); 882 | string[] names = Enum.GetNames (typeof(BakeMode)); 883 | int num1 = Array.IndexOf (names, Enum.GetName (typeof(BakeMode), this.bakeMode)); 884 | int num2 = 0; 885 | foreach (string text in Enumerable.Select (names, x => ObjectNames.NicifyVariableName(x))) { 886 | genericMenu.AddItem (new GUIContent (text), num2 == num1, new GenericMenu.MenuFunction2 (this.BakeDropDownCallback), num2++); 887 | } 888 | genericMenu.DropDown (dropdownRect); 889 | Event.current.Use (); 890 | return false; 891 | } 892 | 893 | void BakeDropDownCallback (object data) 894 | { 895 | bakeMode = (BakeMode)data; 896 | DoBake (); 897 | } 898 | 899 | BakeMode bakeMode { 900 | get { 901 | return (BakeMode)EditorPrefs.GetInt ("LightmapEditor.BakeMode", 0); 902 | } 903 | set { 904 | EditorPrefs.SetInt ("LightmapEditor.BakeMode", (int)value); 905 | } 906 | } 907 | 908 | void DoBake () 909 | { 910 | if (!CheckSettingsIntegrity ()) 911 | return; 912 | 913 | switch (bakeMode) { 914 | case BakeMode.BakeScene: 915 | Lightmapping.BakeAsync (); 916 | break; 917 | case BakeMode.BakeSelected: 918 | Lightmapping.BakeSelectedAsync (); 919 | break; 920 | case BakeMode.BakeProbes: 921 | Lightmapping.BakeLightProbesOnlyAsync (); 922 | break; 923 | } 924 | } 925 | 926 | bool CheckSettingsIntegrity () 927 | { 928 | if (sc.config.environmentSettings.giEnvironment == ILConfig.EnvironmentSettings.Environment.IBL) { 929 | if (string.IsNullOrEmpty (sc.config.environmentSettings.iblImageFile)) { 930 | EditorUtility.DisplayDialog ("Missing IBL image", "The lightmapping environment type is set to IBL, but no IBL image file is available. Either change the environment type or specify an HDR or EXR image file path.", "Ok"); 931 | Debug.LogError ("Lightmapping cancelled, environment type set to IBL but no IBL image file was specified."); 932 | return false; 933 | } else if (!File.Exists (sc.config.environmentSettings.iblImageFile)) { 934 | EditorUtility.DisplayDialog ("Missing IBL image", "The lightmapping environment type is set to IBL, but there is no compatible image file at the specified path. Either change the environment type or specify an absolute path to an HDR or EXR image file.", "Ok"); 935 | Debug.LogError ("Lightmapping cancelled, environment type set to IBL but the absolute path to an IBL image is incorrect."); 936 | return false; 937 | } 938 | } 939 | return true; 940 | } 941 | 942 | #endregion 943 | 944 | private void LMColorPicker (string name, ref ILConfig.LMColor color, string tooltip) 945 | { 946 | Color c = EditorGUILayout.ColorField (new GUIContent (name, tooltip), new Color (color.r, color.g, color.b, color.a)); 947 | color = new ILConfig.LMColor (c.r, c.g, c.b, c.a); 948 | } 949 | } 950 | 951 | 952 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Editor/LMExtendedWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44bbaf4e5cbb24d488585d190f5ad05b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Editor/SavePresetWindow.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012 Michael Stevenson 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in the 5 | // Software without restriction, including without limitation the rights to use, copy, 6 | // modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 7 | // and to permit persons to whom the Software is furnished to do so, subject to the 8 | // following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in all copies 11 | // or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 14 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 15 | // PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 16 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 17 | // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 18 | // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | 20 | using UnityEngine; 21 | using UnityEditor; 22 | using System.Collections; 23 | 24 | public class SavePresetWindow : EditorWindow 25 | { 26 | internal bool didFocus; 27 | 28 | string presetName = ""; 29 | 30 | public LMExtendedWindow lmExtendedWindow; 31 | 32 | void OnGUI () 33 | { 34 | Event current = Event.current; 35 | bool enterKeyDown = current.type == EventType.KeyDown && (current.keyCode == KeyCode.Return || current.keyCode == KeyCode.KeypadEnter); 36 | GUI.SetNextControlName ("name"); 37 | presetName = EditorGUILayout.TextField (presetName); 38 | if (!this.didFocus) { 39 | this.didFocus = true; 40 | GUI.FocusControl ("name"); 41 | } 42 | GUI.enabled = presetName.Length != 0 && presetName != "Custom"; 43 | 44 | if (GUILayout.Button ("Save") || enterKeyDown) { 45 | Close (); 46 | lmExtendedWindow.SavePreset (presetName); 47 | GUIUtility.ExitGUI (); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Editor/SavePresetWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b7f7275534f204bc08968e519023affe 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Editor/SerializedConfig.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | // Workaround for incompatibility between Unity's serialization 5 | // of ScriptableObjects and XML serialization of ILConfig 6 | public class SerializedConfig : ScriptableObject 7 | { 8 | public ILConfig config; 9 | } 10 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Editor/SerializedConfig.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4994aac5af003405d89c18a9f23eee90 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Presets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a68438db44994130a811df427f55dca 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Presets/Built-in.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 71b960e3f7bee45ad9fd8bbe62d33f45 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Presets/Built-in/High Quality.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 0 5 | 2 6 | 0.1 7 | false 8 | false 9 | Adaptive 10 | Gauss 11 | 12 | 2.2 13 | 2.2 14 | 15 | 16 | 17 | 0.005 18 | 2 19 | false 20 | 6 21 | 10000 22 | 0 23 | 2 24 | 0.001 25 | 2 26 | false 27 | 50 28 | true 29 | true 30 | true 31 | true 32 | true 33 | 0.001 34 | 35 | 36 | None 37 | 38 | 0.86 39 | 0.93 40 | 1 41 | 1 42 | 43 | 0.2 44 | 45 | 1 46 | true 47 | false 48 | false 49 | 0.05 50 | 1 51 | 300 52 | true 53 | 1 54 | false 55 | 0 56 | 57 | 58 | true 59 | 0 60 | 2 61 | true 62 | 1 63 | 64 | None 65 | 1 66 | 67 | true 68 | 0 69 | 70 | true 71 | true 72 | false 73 | true 74 | false 75 | false 76 | false 77 | false 78 | 79 | 80 | 81 | None 82 | 1 83 | 1 84 | false 85 | true 86 | true 87 | 0 88 | -4 89 | FinalGather 90 | 1 91 | 1 92 | None 93 | 1 94 | 1 95 | 1 96 | 1 97 | 0 98 | 0.3 99 | 2 100 | false 101 | 0 102 | 0 103 | false 104 | true 105 | 1 106 | false 107 | 0.05 108 | 1 109 | 15 110 | false 111 | 0 112 | 0.5 113 | 15 114 | 0 115 | false 116 | 0 117 | 0.2 118 | false 119 | 1000 120 | Irradiance 121 | 1 122 | false 123 | true 124 | 0.95 125 | 126 | 0 127 | 0 128 | 0 129 | 1 130 | 131 | 5 132 | true 133 | 134 | 3 135 | Gauss 136 | 0.7 137 | 0 138 | true 139 | false 140 | true 141 | true 142 | 2 143 | 0 144 | 16 145 | 146 | 147 | 0 148 | 0 149 | 2 150 | -1 151 | Normal 152 | 153 | 154 | 155 | 1 156 | 1 157 | 1 158 | 1 159 | 160 | true 161 | true 162 | 3 163 | 164 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Presets/Built-in/High Quality.xml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 584e1117cccc1407297e7ebf627c4110 3 | TextScriptImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Presets/Built-in/Low Quality.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 0 5 | 2 6 | 0.1 7 | false 8 | false 9 | Adaptive 10 | Box 11 | 12 | 1 13 | 1 14 | 15 | 16 | 17 | 0.005 18 | 2 19 | false 20 | 6 21 | 4 22 | 0 23 | 2 24 | 0.001 25 | 2 26 | false 27 | 50 28 | true 29 | true 30 | true 31 | true 32 | true 33 | 0.001 34 | 35 | 36 | None 37 | 38 | 0.86 39 | 0.93 40 | 1 41 | 1 42 | 43 | 0.2 44 | 45 | 1 46 | true 47 | false 48 | false 49 | 0.05 50 | 1 51 | 300 52 | true 53 | 1 54 | false 55 | 0 56 | 57 | 58 | true 59 | 0 60 | 2 61 | true 62 | 1 63 | 64 | None 65 | 1 66 | 67 | true 68 | 0 69 | 70 | true 71 | true 72 | false 73 | true 74 | false 75 | false 76 | false 77 | false 78 | 79 | 80 | 81 | None 82 | 1 83 | 1 84 | false 85 | true 86 | true 87 | 0 88 | -4 89 | FinalGather 90 | 1 91 | 1 92 | None 93 | 1 94 | 1 95 | 1 96 | 1 97 | 0 98 | 0.3 99 | 2 100 | false 101 | 0 102 | 0 103 | false 104 | false 105 | 1 106 | false 107 | 0.1 108 | 1 109 | 15 110 | false 111 | 0 112 | 0.5 113 | 15 114 | 0 115 | false 116 | 0 117 | 0.2 118 | true 119 | 200 120 | Irradiance 121 | 1 122 | false 123 | true 124 | 0.95 125 | 126 | 0 127 | 0 128 | 0 129 | 1 130 | 131 | 5 132 | true 133 | 134 | 3 135 | Gauss 136 | 0.7 137 | 0 138 | true 139 | false 140 | true 141 | true 142 | 2 143 | 0 144 | 16 145 | 146 | 147 | 0 148 | 0 149 | 2 150 | -1 151 | Normal 152 | 153 | 154 | 155 | 1 156 | 1 157 | 1 158 | 1 159 | 160 | true 161 | true 162 | 3 163 | 164 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Presets/Built-in/Low Quality.xml.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 235f15b356b59499ba66ce511afe2b9a 3 | TextScriptImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b95746a6dae1743d6b857645f08c6a73 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/Alpha-BumpSpec.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Transmissive/Bumped Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TransparencyLM ("Transmissive Color", 2D) = "white" {} 5 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) 6 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 7 | _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} 8 | _BumpMap ("Normalmap", 2D) = "bump" {} 9 | } 10 | 11 | SubShader { 12 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 13 | LOD 400 14 | 15 | CGPROGRAM 16 | #pragma surface surf BlinnPhong alpha 17 | 18 | sampler2D _MainTex; 19 | sampler2D _BumpMap; 20 | fixed4 _Color; 21 | half _Shininess; 22 | 23 | struct Input { 24 | float2 uv_MainTex; 25 | float2 uv_BumpMap; 26 | }; 27 | 28 | void surf (Input IN, inout SurfaceOutput o) { 29 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 30 | o.Albedo = tex.rgb * _Color.rgb; 31 | o.Gloss = tex.a; 32 | o.Alpha = tex.a * _Color.a; 33 | o.Specular = _Shininess; 34 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 35 | } 36 | ENDCG 37 | } 38 | 39 | FallBack "Transparent/VertexLit" 40 | } -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/Alpha-BumpSpec.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 46c0cde596a9e4a77b72e2743c3095db 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/Alpha-Bumped.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Transmissive/Bumped Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TransparencyLM ("Transmissive Color", 2D) = "white" {} 5 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 6 | _BumpMap ("Normalmap", 2D) = "bump" {} 7 | } 8 | 9 | SubShader { 10 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 11 | LOD 300 12 | 13 | CGPROGRAM 14 | #pragma surface surf Lambert alpha 15 | 16 | sampler2D _MainTex; 17 | sampler2D _BumpMap; 18 | fixed4 _Color; 19 | 20 | struct Input { 21 | float2 uv_MainTex; 22 | float2 uv_BumpMap; 23 | }; 24 | 25 | void surf (Input IN, inout SurfaceOutput o) { 26 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 27 | o.Albedo = c.rgb; 28 | o.Alpha = c.a; 29 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 30 | } 31 | ENDCG 32 | } 33 | 34 | FallBack "Transparent/Diffuse" 35 | } -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/Alpha-Bumped.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7bf86b8e8b0384b028fbe6559b4e76aa 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/Alpha-Diffuse.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Transmissive/Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TransparencyLM ("Transmissive Color", 2D) = "white" {} 5 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 6 | } 7 | 8 | SubShader { 9 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 10 | LOD 200 11 | 12 | CGPROGRAM 13 | #pragma surface surf Lambert alpha 14 | 15 | sampler2D _MainTex; 16 | fixed4 _Color; 17 | 18 | struct Input { 19 | float2 uv_MainTex; 20 | }; 21 | 22 | void surf (Input IN, inout SurfaceOutput o) { 23 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 24 | o.Albedo = c.rgb; 25 | o.Alpha = c.a; 26 | } 27 | ENDCG 28 | } 29 | 30 | Fallback "Transparent/VertexLit" 31 | } 32 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/Alpha-Diffuse.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c47aa33a72200441ebe4d8bbaa6f29b8 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/Alpha-Glossy.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Transmissive/Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TransparencyLM ("Transmissive Color", 2D) = "white" {} 5 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) 6 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 7 | _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} 8 | } 9 | 10 | SubShader { 11 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 12 | LOD 300 13 | 14 | CGPROGRAM 15 | #pragma surface surf BlinnPhong alpha 16 | 17 | sampler2D _MainTex; 18 | fixed4 _Color; 19 | half _Shininess; 20 | 21 | struct Input { 22 | float2 uv_MainTex; 23 | }; 24 | 25 | void surf (Input IN, inout SurfaceOutput o) { 26 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 27 | o.Albedo = tex.rgb * _Color.rgb; 28 | o.Gloss = tex.a; 29 | o.Alpha = tex.a * _Color.a; 30 | o.Specular = _Shininess; 31 | } 32 | ENDCG 33 | } 34 | 35 | Fallback "Transparent/VertexLit" 36 | } 37 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/Alpha-Glossy.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d7ad1ed38328a44c0b6524ca20a90a1c 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/Alpha-Parallax.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Transmissive/Parallax Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TransparencyLM ("Transmissive Color", 2D) = "white" {} 5 | _Parallax ("Height", Range (0.005, 0.08)) = 0.02 6 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 7 | _BumpMap ("Normalmap", 2D) = "bump" {} 8 | _ParallaxMap ("Heightmap (A)", 2D) = "black" {} 9 | } 10 | 11 | SubShader { 12 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 13 | LOD 500 14 | 15 | CGPROGRAM 16 | #pragma surface surf Lambert alpha 17 | 18 | sampler2D _MainTex; 19 | sampler2D _BumpMap; 20 | sampler2D _ParallaxMap; 21 | fixed4 _Color; 22 | float _Parallax; 23 | 24 | struct Input { 25 | float2 uv_MainTex; 26 | float2 uv_BumpMap; 27 | float3 viewDir; 28 | }; 29 | 30 | void surf (Input IN, inout SurfaceOutput o) { 31 | half h = tex2D (_ParallaxMap, IN.uv_BumpMap).w; 32 | float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir); 33 | IN.uv_MainTex += offset; 34 | IN.uv_BumpMap += offset; 35 | 36 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 37 | o.Albedo = c.rgb; 38 | o.Alpha = c.a; 39 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 40 | } 41 | ENDCG 42 | } 43 | 44 | FallBack "Transparent/Bumped Diffuse" 45 | } -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/Alpha-Parallax.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43f6114993fe54606923410f58b712ae 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/Alpha-ParallaxSpec.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Transmissive/Parallax Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TransparencyLM ("Transmissive Color", 2D) = "white" {} 5 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) 6 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 7 | _Parallax ("Height", Range (0.005, 0.08)) = 0.02 8 | _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} 9 | _BumpMap ("Normalmap", 2D) = "bump" {} 10 | _ParallaxMap ("Heightmap (A)", 2D) = "black" {} 11 | } 12 | 13 | SubShader { 14 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 15 | LOD 600 16 | 17 | CGPROGRAM 18 | #pragma surface surf BlinnPhong alpha 19 | #pragma exclude_renderers flash 20 | 21 | sampler2D _MainTex; 22 | sampler2D _BumpMap; 23 | sampler2D _ParallaxMap; 24 | fixed4 _Color; 25 | half _Shininess; 26 | float _Parallax; 27 | 28 | struct Input { 29 | float2 uv_MainTex; 30 | float2 uv_BumpMap; 31 | float3 viewDir; 32 | }; 33 | 34 | void surf (Input IN, inout SurfaceOutput o) { 35 | half h = tex2D (_ParallaxMap, IN.uv_BumpMap).w; 36 | float2 offset = ParallaxOffset (h, _Parallax, IN.viewDir); 37 | IN.uv_MainTex += offset; 38 | IN.uv_BumpMap += offset; 39 | 40 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 41 | o.Albedo = tex.rgb * _Color.rgb; 42 | o.Gloss = tex.a; 43 | o.Alpha = tex.a * _Color.a; 44 | o.Specular = _Shininess; 45 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 46 | } 47 | ENDCG 48 | } 49 | 50 | FallBack "Transparent/Bumped Specular" 51 | } 52 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/Alpha-ParallaxSpec.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef217556eda7b4022ba3c3b259e4b8e2 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/Alpha-VertexLit.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Transmissive/VertexLit" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TransparencyLM ("Transmissive Color", 2D) = "white" {} 5 | _SpecColor ("Spec Color", Color) = (1,1,1,0) 6 | _Emission ("Emissive Color", Color) = (0,0,0,0) 7 | _Shininess ("Shininess", Range (0.1, 1)) = 0.7 8 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 9 | } 10 | 11 | // 2/3 texture stage GPUs 12 | SubShader { 13 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 14 | LOD 100 15 | 16 | Alphatest Greater 0 17 | ZWrite Off 18 | Blend SrcAlpha OneMinusSrcAlpha 19 | ColorMask RGB 20 | 21 | // Non-lightmapped 22 | Pass { 23 | Tags { "LightMode" = "Vertex" } 24 | Material { 25 | Diffuse [_Color] 26 | Ambient [_Color] 27 | Shininess [_Shininess] 28 | Specular [_SpecColor] 29 | Emission [_Emission] 30 | } 31 | Lighting On 32 | SeparateSpecular On 33 | SetTexture [_MainTex] { 34 | Combine texture * primary DOUBLE, texture * primary 35 | } 36 | } 37 | 38 | // Lightmapped, encoded as dLDR 39 | Pass { 40 | Tags { "LightMode" = "VertexLM" } 41 | 42 | BindChannels { 43 | Bind "Vertex", vertex 44 | Bind "normal", normal 45 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 46 | Bind "texcoord", texcoord1 // main uses 1st uv 47 | } 48 | SetTexture [unity_Lightmap] { 49 | matrix [unity_LightmapMatrix] 50 | constantColor [_Color] 51 | combine texture * constant 52 | } 53 | SetTexture [_MainTex] { 54 | combine texture * previous DOUBLE, texture * primary 55 | } 56 | } 57 | 58 | // Lightmapped, encoded as RGBM 59 | Pass { 60 | Tags { "LightMode" = "VertexLMRGBM" } 61 | 62 | BindChannels { 63 | Bind "Vertex", vertex 64 | Bind "normal", normal 65 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 66 | Bind "texcoord1", texcoord1 // unused 67 | Bind "texcoord", texcoord2 // main uses 1st uv 68 | } 69 | 70 | SetTexture [unity_Lightmap] { 71 | matrix [unity_LightmapMatrix] 72 | combine texture * texture alpha DOUBLE 73 | } 74 | SetTexture [unity_Lightmap] { 75 | constantColor [_Color] 76 | combine previous * constant 77 | } 78 | SetTexture [_MainTex] { 79 | combine texture * previous QUAD, texture * primary 80 | } 81 | } 82 | } 83 | 84 | // 1 texture stage GPUs 85 | SubShader { 86 | Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} 87 | LOD 100 88 | 89 | Alphatest Greater 0 90 | ZWrite Off 91 | Blend SrcAlpha OneMinusSrcAlpha 92 | ColorMask RGB 93 | 94 | Pass { 95 | Tags { "LightMode" = "Always" } 96 | Material { 97 | Diffuse [_Color] 98 | Ambient [_Color] 99 | Shininess [_Shininess] 100 | Specular [_SpecColor] 101 | Emission [_Emission] 102 | } 103 | Lighting On 104 | SeparateSpecular On 105 | SetTexture [_MainTex] { 106 | Combine texture * primary DOUBLE, texture * primary 107 | } 108 | } 109 | } 110 | } -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/Alpha-VertexLit.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1eb6ec33a40a14a83926cc4608fed397 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/AlphaTest-BumpSpec.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Cutout/Transmissive/Bumped Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TransparencyLM ("Transmissive Color", 2D) = "white" {} 5 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) 6 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 7 | _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} 8 | _BumpMap ("Normalmap", 2D) = "bump" {} 9 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 10 | } 11 | 12 | SubShader { 13 | Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} 14 | LOD 400 15 | 16 | CGPROGRAM 17 | #pragma surface surf BlinnPhong alphatest:_Cutoff 18 | #pragma exclude_renderers flash 19 | 20 | sampler2D _MainTex; 21 | sampler2D _BumpMap; 22 | fixed4 _Color; 23 | half _Shininess; 24 | 25 | struct Input { 26 | float2 uv_MainTex; 27 | float2 uv_BumpMap; 28 | }; 29 | 30 | void surf (Input IN, inout SurfaceOutput o) { 31 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 32 | o.Albedo = tex.rgb * _Color.rgb; 33 | o.Gloss = tex.a; 34 | o.Alpha = tex.a * _Color.a; 35 | o.Specular = _Shininess; 36 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 37 | } 38 | ENDCG 39 | } 40 | 41 | FallBack "Transparent/Cutout/VertexLit" 42 | } 43 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/AlphaTest-BumpSpec.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6466db0250b442cea806d44421c36ae 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/AlphaTest-Bumped.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Cutout/Transmissive/Bumped Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TransparencyLM ("Transmissive Color", 2D) = "white" {} 5 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 6 | _BumpMap ("Normalmap", 2D) = "bump" {} 7 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 8 | } 9 | 10 | SubShader { 11 | Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} 12 | LOD 300 13 | 14 | CGPROGRAM 15 | #pragma surface surf Lambert alphatest:_Cutoff 16 | 17 | sampler2D _MainTex; 18 | sampler2D _BumpMap; 19 | fixed4 _Color; 20 | 21 | struct Input { 22 | float2 uv_MainTex; 23 | float2 uv_BumpMap; 24 | }; 25 | 26 | void surf (Input IN, inout SurfaceOutput o) { 27 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 28 | o.Albedo = c.rgb; 29 | o.Alpha = c.a; 30 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap)); 31 | } 32 | ENDCG 33 | } 34 | 35 | FallBack "Transparent/Cutout/Diffuse" 36 | } 37 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/AlphaTest-Bumped.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab143c743e2244492a3ddf65c91c1133 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/AlphaTest-Diffuse.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Cutout/Transmissive/Diffuse" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TransparencyLM ("Transmissive Color", 2D) = "white" {} 5 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 6 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 7 | } 8 | 9 | SubShader { 10 | Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} 11 | LOD 200 12 | 13 | CGPROGRAM 14 | #pragma surface surf Lambert alphatest:_Cutoff 15 | 16 | sampler2D _MainTex; 17 | fixed4 _Color; 18 | 19 | struct Input { 20 | float2 uv_MainTex; 21 | }; 22 | 23 | void surf (Input IN, inout SurfaceOutput o) { 24 | fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color; 25 | o.Albedo = c.rgb; 26 | o.Alpha = c.a; 27 | } 28 | ENDCG 29 | } 30 | 31 | Fallback "Transparent/Cutout/VertexLit" 32 | } 33 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/AlphaTest-Diffuse.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b2bb9a8b8e31428b97d38f6ae73c36d 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/AlphaTest-Glossy.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Cutout/Transmissive/Specular" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TransparencyLM ("Transmissive Color", 2D) = "white" {} 5 | _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) 6 | _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 7 | _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} 8 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 9 | } 10 | 11 | SubShader { 12 | Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} 13 | LOD 300 14 | 15 | CGPROGRAM 16 | #pragma surface surf BlinnPhong alphatest:_Cutoff 17 | 18 | sampler2D _MainTex; 19 | fixed4 _Color; 20 | half _Shininess; 21 | 22 | struct Input { 23 | float2 uv_MainTex; 24 | }; 25 | 26 | void surf (Input IN, inout SurfaceOutput o) { 27 | fixed4 tex = tex2D(_MainTex, IN.uv_MainTex); 28 | o.Albedo = tex.rgb * _Color.rgb; 29 | o.Gloss = tex.a; 30 | o.Alpha = tex.a * _Color.a; 31 | o.Specular = _Shininess; 32 | } 33 | ENDCG 34 | } 35 | 36 | Fallback "Transparent/Cutout/VertexLit" 37 | } 38 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/AlphaTest-Glossy.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3061a84fb143e443aa7fb410a5b8c3b2 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/AlphaTest-SoftEdgeUnlit.shader: -------------------------------------------------------------------------------- 1 | /* 2 | Renders doubled sides objects without lighting. Useful for 3 | grass, trees or foliage. 4 | 5 | This shader renders two passes for all geometry, one 6 | for opaque parts and one with semitransparent details. 7 | 8 | This makes it possible to render transparent objects 9 | like grass without them being sorted by depth. 10 | */ 11 | 12 | Shader "Transparent/Cutout/Transmissive/Soft Edge Unlit" { 13 | Properties { 14 | _Color ("Main Color", Color) = (1, 1, 1, 1) 15 | _TransparencyLM ("Transmissive Color", 2D) = "white" {} 16 | _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} 17 | _Cutoff ("Base Alpha cutoff", Range (0,.9)) = .5 18 | } 19 | 20 | SubShader { 21 | Tags { "Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout" } 22 | Lighting off 23 | 24 | // Render both front and back facing polygons. 25 | Cull Off 26 | 27 | // first pass: 28 | // render any pixels that are more than [_Cutoff] opaque 29 | Pass { 30 | CGPROGRAM 31 | #pragma vertex vert 32 | #pragma fragment frag 33 | 34 | #include "UnityCG.cginc" 35 | 36 | struct appdata_t { 37 | float4 vertex : POSITION; 38 | float4 color : COLOR; 39 | float2 texcoord : TEXCOORD0; 40 | }; 41 | 42 | struct v2f { 43 | float4 vertex : POSITION; 44 | float4 color : COLOR; 45 | float2 texcoord : TEXCOORD0; 46 | }; 47 | 48 | sampler2D _MainTex; 49 | float4 _MainTex_ST; 50 | float _Cutoff; 51 | 52 | v2f vert (appdata_t v) 53 | { 54 | v2f o; 55 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 56 | o.color = v.color; 57 | o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); 58 | return o; 59 | } 60 | 61 | float4 _Color; 62 | half4 frag (v2f i) : COLOR 63 | { 64 | half4 col = _Color * tex2D(_MainTex, i.texcoord); 65 | clip(col.a - _Cutoff); 66 | return col; 67 | } 68 | ENDCG 69 | } 70 | 71 | // Second pass: 72 | // render the semitransparent details. 73 | Pass { 74 | Tags { "RequireOption" = "SoftVegetation" } 75 | 76 | // Dont write to the depth buffer 77 | ZWrite off 78 | 79 | // Set up alpha blending 80 | Blend SrcAlpha OneMinusSrcAlpha 81 | 82 | CGPROGRAM 83 | #pragma vertex vert 84 | #pragma fragment frag 85 | 86 | #include "UnityCG.cginc" 87 | 88 | struct appdata_t { 89 | float4 vertex : POSITION; 90 | float4 color : COLOR; 91 | float2 texcoord : TEXCOORD0; 92 | }; 93 | 94 | struct v2f { 95 | float4 vertex : POSITION; 96 | float4 color : COLOR; 97 | float2 texcoord : TEXCOORD0; 98 | }; 99 | 100 | sampler2D _MainTex; 101 | float4 _MainTex_ST; 102 | float _Cutoff; 103 | 104 | v2f vert (appdata_t v) 105 | { 106 | v2f o; 107 | o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); 108 | o.color = v.color; 109 | o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); 110 | return o; 111 | } 112 | 113 | float4 _Color; 114 | half4 frag (v2f i) : COLOR 115 | { 116 | half4 col = _Color * tex2D(_MainTex, i.texcoord); 117 | clip(-(col.a - _Cutoff)); 118 | return col; 119 | } 120 | ENDCG 121 | } 122 | } 123 | 124 | SubShader { 125 | Tags { "IgnoreProjector"="True" "RenderType"="TransparentCutout" } 126 | Lighting off 127 | 128 | // Render both front and back facing polygons. 129 | Cull Off 130 | 131 | // first pass: 132 | // render any pixels that are more than [_Cutoff] opaque 133 | Pass { 134 | AlphaTest Greater [_Cutoff] 135 | SetTexture [_MainTex] { 136 | constantColor [_Color] 137 | combine texture * constant, texture * constant 138 | } 139 | } 140 | 141 | // Second pass: 142 | // render the semitransparent details. 143 | Pass { 144 | Tags { "RequireOption" = "SoftVegetation" } 145 | 146 | // Dont write to the depth buffer 147 | ZWrite off 148 | 149 | // Only render pixels less or equal to the value 150 | AlphaTest LEqual [_Cutoff] 151 | 152 | // Set up alpha blending 153 | Blend SrcAlpha OneMinusSrcAlpha 154 | 155 | SetTexture [_MainTex] { 156 | constantColor [_Color] 157 | Combine texture * constant, texture * constant 158 | } 159 | } 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/AlphaTest-SoftEdgeUnlit.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02fc2cd9c9df64969bc6a2b4e25dbe2e 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/AlphaTest-VertexLit.shader: -------------------------------------------------------------------------------- 1 | Shader "Transparent/Cutout/Transmissive/VertexLit" { 2 | Properties { 3 | _Color ("Main Color", Color) = (1,1,1,1) 4 | _TransparencyLM ("Transmissive Color", 2D) = "white" {} 5 | _SpecColor ("Spec Color", Color) = (1,1,1,0) 6 | _Emission ("Emissive Color", Color) = (0,0,0,0) 7 | _Shininess ("Shininess", Range (0.1, 1)) = 0.7 8 | _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} 9 | _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 10 | } 11 | 12 | // 2/3 texture stage GPUs 13 | SubShader { 14 | Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"} 15 | LOD 100 16 | 17 | // Non-lightmapped 18 | Pass { 19 | Tags { "LightMode" = "Vertex" } 20 | Alphatest Greater [_Cutoff] 21 | AlphaToMask True 22 | ColorMask RGB 23 | Material { 24 | Diffuse [_Color] 25 | Ambient [_Color] 26 | Shininess [_Shininess] 27 | Specular [_SpecColor] 28 | Emission [_Emission] 29 | } 30 | Lighting On 31 | SeparateSpecular On 32 | SetTexture [_MainTex] { 33 | Combine texture * primary DOUBLE, texture * primary 34 | } 35 | } 36 | 37 | // Lightmapped, encoded as dLDR 38 | Pass { 39 | Tags { "LightMode" = "VertexLM" } 40 | Alphatest Greater [_Cutoff] 41 | AlphaToMask True 42 | ColorMask RGB 43 | 44 | BindChannels { 45 | Bind "Vertex", vertex 46 | Bind "normal", normal 47 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 48 | Bind "texcoord", texcoord1 // main uses 1st uv 49 | } 50 | SetTexture [unity_Lightmap] { 51 | matrix [unity_LightmapMatrix] 52 | constantColor [_Color] 53 | combine texture * constant 54 | } 55 | SetTexture [_MainTex] { 56 | combine texture * previous DOUBLE, texture * primary 57 | } 58 | } 59 | 60 | // Lightmapped, encoded as RGBM 61 | Pass { 62 | Tags { "LightMode" = "VertexLMRGBM" } 63 | Alphatest Greater [_Cutoff] 64 | AlphaToMask True 65 | ColorMask RGB 66 | 67 | BindChannels { 68 | Bind "Vertex", vertex 69 | Bind "normal", normal 70 | Bind "texcoord1", texcoord0 // lightmap uses 2nd uv 71 | Bind "texcoord1", texcoord1 // unused 72 | Bind "texcoord", texcoord2 // main uses 1st uv 73 | } 74 | 75 | SetTexture [unity_Lightmap] { 76 | matrix [unity_LightmapMatrix] 77 | combine texture * texture alpha DOUBLE 78 | } 79 | SetTexture [unity_Lightmap] { 80 | constantColor [_Color] 81 | combine previous * constant 82 | } 83 | SetTexture [_MainTex] { 84 | combine texture * previous QUAD, texture * primary 85 | } 86 | } 87 | 88 | // Pass to render object as a shadow caster 89 | Pass { 90 | Name "Caster" 91 | Tags { "LightMode" = "ShadowCaster" } 92 | Offset 1, 1 93 | 94 | Fog {Mode Off} 95 | ZWrite On ZTest LEqual Cull Off 96 | 97 | CGPROGRAM 98 | #pragma vertex vert 99 | #pragma fragment frag 100 | #pragma multi_compile_shadowcaster 101 | #pragma fragmentoption ARB_precision_hint_fastest 102 | #include "UnityCG.cginc" 103 | 104 | struct v2f { 105 | V2F_SHADOW_CASTER; 106 | float2 uv : TEXCOORD1; 107 | }; 108 | 109 | uniform float4 _MainTex_ST; 110 | 111 | v2f vert( appdata_base v ) 112 | { 113 | v2f o; 114 | TRANSFER_SHADOW_CASTER(o) 115 | o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); 116 | return o; 117 | } 118 | 119 | uniform sampler2D _MainTex; 120 | uniform fixed _Cutoff; 121 | uniform fixed4 _Color; 122 | 123 | float4 frag( v2f i ) : COLOR 124 | { 125 | fixed4 texcol = tex2D( _MainTex, i.uv ); 126 | clip( texcol.a*_Color.a - _Cutoff ); 127 | 128 | SHADOW_CASTER_FRAGMENT(i) 129 | } 130 | ENDCG 131 | 132 | } 133 | 134 | // Pass to render object as a shadow collector 135 | Pass { 136 | Name "ShadowCollector" 137 | Tags { "LightMode" = "ShadowCollector" } 138 | 139 | Fog {Mode Off} 140 | ZWrite On ZTest LEqual 141 | 142 | CGPROGRAM 143 | #pragma vertex vert 144 | #pragma fragment frag 145 | #pragma fragmentoption ARB_precision_hint_fastest 146 | #pragma multi_compile_shadowcollector 147 | 148 | #define SHADOW_COLLECTOR_PASS 149 | #include "UnityCG.cginc" 150 | 151 | struct v2f { 152 | V2F_SHADOW_COLLECTOR; 153 | float2 uv : TEXCOORD5; 154 | }; 155 | 156 | uniform float4 _MainTex_ST; 157 | 158 | v2f vert (appdata_base v) 159 | { 160 | v2f o; 161 | TRANSFER_SHADOW_COLLECTOR(o) 162 | o.uv = TRANSFORM_TEX(v.texcoord, _MainTex); 163 | return o; 164 | } 165 | 166 | uniform sampler2D _MainTex; 167 | uniform fixed _Cutoff; 168 | uniform fixed4 _Color; 169 | 170 | fixed4 frag (v2f i) : COLOR 171 | { 172 | fixed4 texcol = tex2D( _MainTex, i.uv ); 173 | clip( texcol.a*_Color.a - _Cutoff ); 174 | 175 | SHADOW_COLLECTOR_FRAGMENT(i) 176 | } 177 | ENDCG 178 | 179 | } 180 | } 181 | 182 | // 1 texture stage GPUs 183 | SubShader { 184 | Tags {"IgnoreProjector"="True" "RenderType"="TransparentCutout"} 185 | LOD 100 186 | 187 | Pass { 188 | Tags { "LightMode" = "Always" } 189 | Alphatest Greater [_Cutoff] 190 | AlphaToMask True 191 | ColorMask RGB 192 | Material { 193 | Diffuse [_Color] 194 | Ambient [_Color] 195 | Shininess [_Shininess] 196 | Specular [_SpecColor] 197 | Emission [_Emission] 198 | } 199 | Lighting On 200 | SeparateSpecular On 201 | SetTexture [_MainTex] { 202 | Combine texture * primary DOUBLE, texture * primary 203 | } 204 | } 205 | } 206 | } -------------------------------------------------------------------------------- /Assets/Lightmapping Extended/Shaders/AlphaTest-VertexLit.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8bb99b7cf58304bb3ac0380a9671ffd5 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Documentation/Beast_XML_and_Lua_Reference_Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mstevenson/Lightmapping-Extended/55b24260c53b2b6d6516dc0be6ea393bbd9dbaf7/Documentation/Beast_XML_and_Lua_Reference_Manual.pdf -------------------------------------------------------------------------------- /Documentation/beastapimanual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mstevenson/Lightmapping-Extended/55b24260c53b2b6d6516dc0be6ea393bbd9dbaf7/Documentation/beastapimanual.pdf -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2013 Michael Stevenson 2 | http://mstevenson.net 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the “Software”), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mstevenson/Lightmapping-Extended/55b24260c53b2b6d6516dc0be6ea393bbd9dbaf7/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mstevenson/Lightmapping-Extended/55b24260c53b2b6d6516dc0be6ea393bbd9dbaf7/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mstevenson/Lightmapping-Extended/55b24260c53b2b6d6516dc0be6ea393bbd9dbaf7/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mstevenson/Lightmapping-Extended/55b24260c53b2b6d6516dc0be6ea393bbd9dbaf7/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mstevenson/Lightmapping-Extended/55b24260c53b2b6d6516dc0be6ea393bbd9dbaf7/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mstevenson/Lightmapping-Extended/55b24260c53b2b6d6516dc0be6ea393bbd9dbaf7/ProjectSettings/NavMeshLayers.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mstevenson/Lightmapping-Extended/55b24260c53b2b6d6516dc0be6ea393bbd9dbaf7/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mstevenson/Lightmapping-Extended/55b24260c53b2b6d6516dc0be6ea393bbd9dbaf7/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mstevenson/Lightmapping-Extended/55b24260c53b2b6d6516dc0be6ea393bbd9dbaf7/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mstevenson/Lightmapping-Extended/55b24260c53b2b6d6516dc0be6ea393bbd9dbaf7/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mstevenson/Lightmapping-Extended/55b24260c53b2b6d6516dc0be6ea393bbd9dbaf7/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | Lightmapping Extended 2 | ===================== 3 | 4 | **Lightmapping Extended** is an editor tool for the Unity game engine. It exposes all compatible XML configuration options for Unity's integrated Autodesk Beast lightmapper through a simple UI. 5 | 6 | The most notable additions to Unity's built-in lightmapping settings are **image-based lighting**, **Path Tracer GI**, and **Monte Carlo GI**. 7 | 8 | Installation 9 | ------------ 10 | 11 | To add Lightmapping Extended to an existing Unity project, copy the directory ***Assets/Lightmapping Extended/*** into your project's Assets folder. Once installed, the Lightmapping Extended editor window can be accessed from the menu ***Window > Lightmapping Extended***. 12 | 13 | Configuration 14 | ------------- 15 | 16 | Lightmapping configuration options are unique to each scene. If the current scene does not include a configuration file, the Lightmapping Extended editor window will provide an option to create one. If a configuration file exists for the current scene, it will be automatically loaded. 17 | 18 | Presets 19 | ------- 20 | 21 | Configuration settings may be saved as presets. Presets are stored in the folder ***Lightmapping Extended/Presets*** and may be checked into source control. Presets are available per-project, making them easy to re-use across multiple scenes. Preset files may be organized into folders and will be displayed hierarchically in the Presets selection menu at the top of the Lightmapping Extended window. 22 | 23 | Shaders 24 | ------- 25 | 26 | A set of transmissive shaders are included with Lightmapping Extended. These shaders are identical to Unity's built-in transparent shaders, with the addition of a *Transmissive Color* property. This property defines which colors of light are able to pass through the material, producing colored shadows. Colored shadows are only supported in baked lightmaps and will not be displayed by Unity's real-time shadow system. --------------------------------------------------------------------------------