瀏覽代碼

Merge pull request #658 from LumaDigital/master

Shader fix, engine settings precedence, "Force reimport" context menu option
JoshEngebretson 9 年之前
父節點
當前提交
31d6b85545

+ 4 - 0
AUTHORS.md

@@ -23,6 +23,10 @@
 
 - Nick Minkler (https://github.com/Sleaker)
 
+- Raheel Hassim (https://github.com/raheelx)
+
+- Gareth Fouche (https://github.com/GarethNN)
+
 ### Contribution Copyright and Licensing
 
 Atomic Game Engine contribution copyrights are held by their authors.  Each author retains the copyright to their contribution and agrees to irrevocably license the contribution under the Atomic Game Engine Contribution License `CONTRIBUTION_LICENSE.md`.  Please see `CONTRIBUTING.md` for more details.

+ 10 - 3
Resources/CoreData/Shaders/HLSL/LitSolid.hlsl

@@ -231,6 +231,8 @@ void PS(
             finalColor = diff * diffColor.rgb * cAmbientColor;
 
             oColor = float4(GetLitFog(finalColor, fogFactor), diffColor.a);
+		#elif defined(LIGHTMAP)            
+            oColor = float4(0.0, 0.0, 0.0, 0.0);
         #else
             float diff = GetDiffuse(normal, iWorldPos.xyz, lightDir);
 
@@ -310,11 +312,16 @@ void PS(
             finalColor += lightInput.rgb * diffColor.rgb + lightSpecColor * specColor;
         #endif
 
-        #ifdef ENVCUBEMAP
-            finalColor += cMatEnvMapColor * SampleCube(EnvCubeMap, reflect(iReflectionVec, normal)).rgb;
-        #endif
         #ifdef LIGHTMAP
             finalColor += Sample2D(EmissiveMap, iTexCoord2).rgb * diffColor.rgb;
+			
+			#ifdef ENVCUBEMAP
+				finalColor += cMatEnvMapColor * SampleCube(EnvCubeMap, reflect(iReflectionVec, normal)).rgb * Sample2D(EmissiveMap, iTexCoord2).rgb;
+			#endif
+		#else
+			#ifdef ENVCUBEMAP
+				finalColor += cMatEnvMapColor * SampleCube(EnvCubeMap, reflect(iReflectionVec, normal)).rgb;
+			#endif
         #endif
         #ifdef EMISSIVEMAP
             finalColor += cMatEmissiveColor * Sample2D(EmissiveMap, iTexCoord.xy).rgb;

+ 1 - 1
Resources/CoreData/Techniques/DiffLightMap.xml

@@ -1,6 +1,6 @@
 <technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP">
     <pass name="base" vsdefines="LIGHTMAP" psdefines="LIGHTMAP" />
-    <pass name="light" depthtest="equal" depthwrite="false" blend="add" />
+    <pass name="light" vsdefines="LIGHTMAP" psdefines="LIGHTMAP" depthtest="equal" depthwrite="false" blend="subtract" />
     <pass name="prepass" psdefines="PREPASS" />
     <pass name="material" vsdefines="LIGHTMAP" psdefines="MATERIAL LIGHTMAP" depthtest="equal" depthwrite="false" />
     <pass name="deferred" vsdefines="LIGHTMAP" psdefines="DEFERRED LIGHTMAP" />

+ 1 - 1
Script/AtomicEditor/ui/Shortcuts.ts

@@ -35,7 +35,7 @@ class Shortcuts extends Atomic.ScriptObject {
                     var args = "--resizable";
                     Atomic.editorMode.playProject(args, debug);
                 } else {
-                    var args = "--windowposx " + playerWindow.x + " --windowposy " + playerWindow.y + " --windowwidth " + playerWindow.width + " --windowheight " + playerWindow.height + " --resizable";
+                    var args = "--windowposx " + playerWindow.x + " --windowposy " + playerWindow.y + " --windowwidth " + playerWindow.width + " --windowheight " + playerWindow.height + " --resizable" + " --fromEditorPlay";
                     if (playerWindow.maximized) {
                         args += " --maximize";
                     }

+ 8 - 0
Script/AtomicEditor/ui/frames/menus/ProjectFrameMenu.ts

@@ -79,6 +79,13 @@ class ProjectFrameMenus extends Atomic.ScriptObject {
                 utils.revealInFinder(path);
                 return true;
             }
+
+            if (refid == "force_reimport") {
+                asset.setDirty(true);
+                ToolCore.assetDatabase.scan();
+                return true;
+            }
+
         }
 
         return false;
@@ -144,6 +151,7 @@ else if (Atomic.platform == "MacOSX") {
 
 var assetGeneralContextItems = {
     "Rename": ["rename_asset", undefined, ""],
+    "Force Reimport": ["force_reimport", undefined, ""],
     [showInFs]: ["reveal_folder", undefined, ""], 
     "-1": null,
     "Delete": ["delete_asset", undefined, ""]

+ 15 - 4
Source/Atomic/Engine/EngineConfig.cpp

@@ -326,13 +326,24 @@ bool EngineConfig::LoadFromFile(Context *context, const String& filename)
     return LoadFromJSON(json);
 }
 
-void EngineConfig::ApplyConfig(VariantMap& settings)
+void EngineConfig::ApplyConfig(VariantMap& settings, bool overwrite)
 {
     VariantMap::ConstIterator itr = engineConfig_.Begin();
-    while (itr != engineConfig_.End())
+    if (overwrite)
+    { 
+        while (itr != engineConfig_.End())
+        {
+            settings[itr->first_] = itr->second_;
+            itr++;
+        }
+    }
+    else
     {
-        settings.InsertNew(itr->first_, itr->second_);
-        itr++;
+        while (itr != engineConfig_.End())
+        {
+            settings.InsertNew(itr->first_, itr->second_);
+            itr++;
+        }
     }
 
 }

+ 1 - 1
Source/Atomic/Engine/EngineConfig.h

@@ -40,7 +40,7 @@ public:
     static bool LoadFromJSON(const String& json);
 
     /// Apply the configuration to a setting variant map, values that exist will not be overriden
-    static void ApplyConfig(VariantMap& settings);
+    static void ApplyConfig(VariantMap& settings, bool overwrite = false);
 
     static const VariantMap& GetConfig() { return engineConfig_; }
 

+ 86 - 67
Source/AtomicEditor/Application/AEPlayerApp.cpp

@@ -52,7 +52,8 @@ namespace AtomicEditor
 
 AEPlayerApplication::AEPlayerApplication(Context* context) :
     AEEditorCommon(context),
-    debugPlayer_(false)
+    debugPlayer_(false),
+    launchedByEditor_(false)
 {
 }
 
@@ -60,44 +61,98 @@ void AEPlayerApplication::Setup()
 {
     AEEditorCommon::Setup();
 
-    // Read the engine configuration
+    // Read the project engine configuration
     ReadEngineConfig();
 
     engine_->SetAutoExit(false);
 
     engineParameters_.InsertNew("WindowTitle", "AtomicPlayer");
 
+    // Set defaults not already set from config
 #if (ATOMIC_PLATFORM_ANDROID)
-    engineParameters_["FullScreen"] = true;
-    engineParameters_["ResourcePaths"] = "CoreData;AtomicResources";
+    engineParameters_.InsertNew("FullScreen", true);
+    engineParameters_.InsertNew("ResourcePaths", "CoreData;AtomicResources");
 #elif ATOMIC_PLATFORM_WEB
-    engineParameters_["FullScreen"] = false;
-    engineParameters_["ResourcePaths"] = "AtomicResources";
-    // engineParameters_["WindowWidth"] = 1280;
-    // engineParameters_["WindowHeight"] = 720;
+    engineParameters_.InsertNew("FullScreen", false);
+    engineParameters_.InsertNew("ResourcePaths", "AtomicResources");
+    // engineParameters_.InsertNew("WindowWidth", 1280);
+    // engineParameters_.InsertNew("WindowHeight", 720);
 #elif ATOMIC_PLATFORM_IOS
-    engineParameters_["FullScreen"] = false;
-    engineParameters_["ResourcePaths"] = "AtomicResources";
+    engineParameters_.InsertNew("FullScreen", false);
+    engineParameters_.InsertNew("ResourcePaths", "AtomicResources)";
 #else
-    engineParameters_["FullScreen"] = false;
-    engineParameters_["WindowWidth"] = 1280;
-    engineParameters_["WindowHeight"] = 720;
+    engineParameters_.InsertNew("FullScreen", false);
+    engineParameters_.InsertNew("WindowWidth", 1280);
+    engineParameters_.InsertNew("WindowHeight", 720);
 #endif
 
     engineParameters_.InsertNew("LogLevel", LOG_DEBUG);
 
 #if ATOMIC_PLATFORM_WINDOWS || ATOMIC_PLATFORM_LINUX
-    engineParameters_["WindowIcon"] = "Images/AtomicLogo32.png";
-    engineParameters_["ResourcePrefixPath"] = "AtomicPlayer_Resources";
+    engineParameters_.InsertNew("WindowIcon", "Images/AtomicLogo32.png");
+    engineParameters_.InsertNew("ResourcePrefixPath", "AtomicPlayer_Resources");
 #elif ATOMIC_PLATFORM_ANDROID
-    //engineParameters_["ResourcePrefixPath"] = "assets";
+    //engineParameters_.InsertNew("ResourcePrefixPath", "assets");
 #elif ATOMIC_PLATFORM_OSX
-    engineParameters_["ResourcePrefixPath"] = "../Resources";
+    engineParameters_.InsertNew("ResourcePrefixPath", "../Resources");
 #endif
 
-    FileSystem* filesystem = GetSubsystem<FileSystem>();
+    // Read command line arguments, potentially overwriting project settings
+    ReadCommandLineArguments();
 
+    // Re-apply project settings if running from editor play button
+    if (launchedByEditor_)
+    {
+        EngineConfig::ApplyConfig(engineParameters_, true);
+    }
+
+    // Use the script file name as the base name for the log file
+    engineParameters_["LogName"] = GetSubsystem<FileSystem>()->GetAppPreferencesDir("AtomicPlayer", "Logs") + "AtomicPlayer.log";
+}
+
+void AEPlayerApplication::ReadEngineConfig()
+{
+    // find the project path from the command line args
+
+    String projectPath;
+    const Vector<String>& arguments = GetArguments();
+
+    for (unsigned i = 0; i < arguments.Size(); ++i)
+    {
+        if (arguments[i].Length() > 1)
+        {
+            String argument = arguments[i].ToLower();
+            String value = i + 1 < arguments.Size() ? arguments[i + 1] : String::EMPTY;
+
+            if (argument == "--project" && value.Length())
+            {
+                projectPath = AddTrailingSlash(value);
+                break;
+            }
+
+        }
+    }
+
+    if (!projectPath.Length())
+        return;
+
+    String filename = projectPath + "Settings/Engine.json";
+
+    FileSystem* fileSystem = GetSubsystem<FileSystem>();
+    if (!fileSystem->FileExists(filename))
+        return;
+
+    if (EngineConfig::LoadFromFile(context_, filename))
+    {
+        EngineConfig::ApplyConfig(engineParameters_);
+    }
+
+}
+
+void AEPlayerApplication::ReadCommandLineArguments()
+{
     const Vector<String>& arguments = GetArguments();
+    FileSystem* fileSystem = GetSubsystem<FileSystem>();
 
     for (unsigned i = 0; i < arguments.Size(); ++i)
     {
@@ -110,6 +165,12 @@ void AEPlayerApplication::Setup()
             {
                 SubscribeToEvent(E_LOGMESSAGE, HANDLER(AEPlayerApplication, HandleLogMessage));
             }
+            else if (argument.StartsWith("--ipc-server=") || argument.StartsWith("--ipc-client="))
+            {
+                // If we have IPC server/client we're being launched from the Editor
+                // TODO: Unify this with AEPlayerMode handling
+                launchedByEditor_ = true;
+            }
             else if (argument == "--debug")
             {
                 debugPlayer_ = true;
@@ -121,7 +182,7 @@ void AEPlayerApplication::Setup()
                 value = AddTrailingSlash(value);
 
                 // check that cache exists
-                if (!filesystem->DirExists(value + "Cache"))
+                if (!fileSystem->DirExists(value + "Cache"))
                 {
                     ErrorExit("Project cache folder does not exist, projects must be loaded into the Atomic Editor at least once before using the --player command line mode");
                     return;
@@ -130,18 +191,18 @@ void AEPlayerApplication::Setup()
 #ifdef ATOMIC_DEV_BUILD
 
                 String resourcePaths = ToString("%s/Resources/CoreData;%s/Resources/PlayerData;%sResources;%s;%sCache",
-                         ATOMIC_ROOT_SOURCE_DIR, ATOMIC_ROOT_SOURCE_DIR, value.CString(), value.CString(), value.CString());
+                    ATOMIC_ROOT_SOURCE_DIR, ATOMIC_ROOT_SOURCE_DIR, value.CString(), value.CString(), value.CString());
 
 #else
 
 #ifdef __APPLE__
                 engineParameters_["ResourcePrefixPath"] = "../Resources";
 #else
-				engineParameters_["ResourcePrefixPath"] = filesystem->GetProgramDir() + "Resources";
+                engineParameters_["ResourcePrefixPath"] = fileSystem->GetProgramDir() + "Resources";
 #endif
 
                 String resourcePaths = ToString("CoreData;PlayerData;%s/;%s/Resources;%s;%sCache",
-                                                              value.CString(), value.CString(), value.CString(), value.CString());
+                    value.CString(), value.CString(), value.CString(), value.CString());
 #endif
 
                 LOGINFOF("Adding ResourcePaths: %s", resourcePaths.CString());
@@ -155,7 +216,7 @@ void AEPlayerApplication::Setup()
 #endif
 
             }
-            else if (argument == "--windowposx" && value.Length()) 
+            else if (argument == "--windowposx" && value.Length())
             {
                 engineParameters_["WindowPositionX"] = atoi(value.CString());
             }
@@ -171,58 +232,16 @@ void AEPlayerApplication::Setup()
             {
                 engineParameters_["WindowHeight"] = atoi(value.CString());
             }
-            else if (argument == "--resizable") 
+            else if (argument == "--resizable")
             {
                 engineParameters_["WindowResizable"] = true;
-            } 
+            }
             else if (argument == "--maximize")
             {
                 engineParameters_["WindowMaximized"] = true;
             }
         }
     }
-
-    // Use the script file name as the base name for the log file
-    engineParameters_["LogName"] = filesystem->GetAppPreferencesDir("AtomicPlayer", "Logs") + "AtomicPlayer.log";
-}
-
-void AEPlayerApplication::ReadEngineConfig()
-{
-    // find the project path from the command line args
-
-    String projectPath;
-    const Vector<String>& arguments = GetArguments();
-
-    for (unsigned i = 0; i < arguments.Size(); ++i)
-    {
-        if (arguments[i].Length() > 1)
-        {
-            String argument = arguments[i].ToLower();
-            String value = i + 1 < arguments.Size() ? arguments[i + 1] : String::EMPTY;
-
-            if (argument == "--project" && value.Length())
-            {
-                projectPath = AddTrailingSlash(value);
-                break;
-            }
-
-        }
-    }
-
-    if (!projectPath.Length())
-        return;
-
-    FileSystem* filesystem = GetSubsystem<FileSystem>();
-    String filename = projectPath + "Settings/Engine.json";
-
-    if (!filesystem->FileExists(filename))
-        return;
-
-    if (EngineConfig::LoadFromFile(context_, filename))
-    {
-        EngineConfig::ApplyConfig(engineParameters_);
-    }
-
 }
 
 void AEPlayerApplication::Start()

+ 4 - 0
Source/AtomicEditor/Application/AEPlayerApp.h

@@ -45,8 +45,12 @@ private:
 
     void ReadEngineConfig();
 
+    void ReadCommandLineArguments();
+
     bool debugPlayer_;
 
+    bool launchedByEditor_;
+
 };
 
 }