Browse Source

Merge pull request #619 from LumaDigital/master

Cubemap & Lightmap techniques, 0b file build fix, EngineSettings support in player
JoshEngebretson 10 years ago
parent
commit
6000ea69c7

+ 31 - 23
Resources/CoreData/Shaders/HLSL/LitSolid.hlsl

@@ -225,33 +225,41 @@ void PS(
         float3 lightColor;
         float3 finalColor;
 
-        float diff = GetDiffuse(normal, iWorldPos.xyz, lightDir);
+        #if defined(LIGHTMAP) && defined(SHADOW)
+            float diff = 1-GetShadow(iShadowPos, iWorldPos.w);
 
-        #ifdef SHADOW
-            diff *= GetShadow(iShadowPos, iWorldPos.w);
-        #endif
+            finalColor = diff * diffColor.rgb * cAmbientColor;
 
-        #if defined(SPOTLIGHT)
-            lightColor = iSpotPos.w > 0.0 ? Sample2DProj(LightSpotMap, iSpotPos).rgb * cLightColor.rgb : 0.0;
-        #elif defined(CUBEMASK)
-            lightColor = SampleCube(LightCubeMap, iCubeMaskVec).rgb * cLightColor.rgb;
-        #else
-            lightColor = cLightColor.rgb;
-        #endif
-    
-        #ifdef SPECULAR
-            float spec = GetSpecular(normal, cCameraPosPS - iWorldPos.xyz, lightDir, cMatSpecColor.a);
-            finalColor = diff * lightColor * (diffColor.rgb + spec * specColor * cLightColor.a);
+            oColor = float4(GetLitFog(finalColor, fogFactor), diffColor.a);
         #else
-            finalColor = diff * lightColor * diffColor.rgb;
-        #endif
+            float diff = GetDiffuse(normal, iWorldPos.xyz, lightDir);
 
-        #ifdef AMBIENT
-            finalColor += cAmbientColor * diffColor.rgb;
-            finalColor += cMatEmissiveColor;
-            oColor = float4(GetFog(finalColor, fogFactor), diffColor.a);
-        #else
-            oColor = float4(GetLitFog(finalColor, fogFactor), diffColor.a);
+            #ifdef SHADOW
+                diff *= GetShadow(iShadowPos, iWorldPos.w);
+            #endif
+
+            #if defined(SPOTLIGHT)
+                lightColor = iSpotPos.w > 0.0 ? Sample2DProj(LightSpotMap, iSpotPos).rgb * cLightColor.rgb : 0.0;
+            #elif defined(CUBEMASK)
+                lightColor = SampleCube(LightCubeMap, iCubeMaskVec).rgb * cLightColor.rgb;
+            #else
+                lightColor = cLightColor.rgb;
+            #endif
+        
+            #ifdef SPECULAR
+                float spec = GetSpecular(normal, cCameraPosPS - iWorldPos.xyz, lightDir, cMatSpecColor.a);
+                finalColor = diff * lightColor * (diffColor.rgb + spec * specColor * cLightColor.a);
+            #else
+                finalColor = diff * lightColor * diffColor.rgb;
+            #endif
+
+            #ifdef AMBIENT
+                finalColor += cAmbientColor * diffColor.rgb;
+                finalColor += cMatEmissiveColor;
+                oColor = float4(GetFog(finalColor, fogFactor), diffColor.a);
+            #else
+                oColor = float4(GetLitFog(finalColor, fogFactor), diffColor.a);
+            #endif
         #endif
     #elif defined(PREPASS)
         // Fill light pre-pass G-Buffer

+ 9 - 0
Resources/CoreData/Techniques/DiffLightMapEnvCube.xml

@@ -0,0 +1,9 @@
+<technique vs="LitSolid" ps="LitSolid" psdefines="DIFFMAP">
+    <pass name="base" vsdefines="ENVCUBEMAP LIGHTMAP" psdefines="ENVCUBEMAP LIGHTMAP" />
+    <pass name="prepass" psdefines="PREPASS" />
+    <pass name="light" vsdefines="LIGHTMAP" psdefines="LIGHTMAP" depthtest="equal" depthwrite="false" blend="subtract" />
+    <pass name="material" vsdefines="ENVCUBEMAP LIGHTMAP" psdefines="MATERIAL ENVCUBEMAP LIGHTMAP" depthtest="equal" depthwrite="false" />
+    <pass name="deferred" vsdefines="ENVCUBEMAP LIGHTMAP" psdefines="DEFERRED ENVCUBEMAP LIGHTMAP" />
+    <pass name="depth" vs="Depth" ps="Depth" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 4 - 2
Script/AtomicEditor/ui/frames/inspector/MaterialInspector.ts

@@ -57,7 +57,9 @@ var techniqueLookup = {
     "Techniques/DiffAlpha.xml": "Alpha",
     "Techniques/DiffAlphaMask.xml": "Alpha Mask",
     "Techniques/DiffAdd.xml": "Additive",
-    "Techniques/NoTexture.xml": "No Texture"
+    "Techniques/NoTexture.xml": "No Texture",
+    "Techniques/DiffLightMap.xml": "Lightmap",
+    "Techniques/DiffLightMapAlpha.xml": "Lightmap Alpha"
 };
 
 var techniqueReverseLookup = {};
@@ -274,7 +276,7 @@ class MaterialInspector extends ScriptWidget {
         section.contentRoot.addChild(attrsVerticalLayout);
 
         // TODO: Filter on technique
-        var textureUnits = [Atomic.TU_DIFFUSE, Atomic.TU_NORMAL, Atomic.TU_SPECULAR]; // ,Atomic.TU_EMISSIVE, Atomic.TU_ENVIRONMENT,
+        var textureUnits = [Atomic.TU_DIFFUSE, Atomic.TU_NORMAL, Atomic.TU_SPECULAR ,Atomic.TU_EMISSIVE];//, Atomic.TU_ENVIRONMENT,
         //Atomic.TU_CUSTOM1, Atomic.TU_CUSTOM2];
 
         for (var i in textureUnits) {

+ 8 - 0
Source/Atomic/Engine/EngineConfig.cpp

@@ -190,6 +190,14 @@ bool EngineConfig::LoadWindowConfig(const JSONValue& jwindow)
             engineConfig_["Borderless"] = GetBoolValue(jvalue, false);
         else if (key == "resizable")
             engineConfig_["WindowResizable"] = GetBoolValue(jvalue, false);
+        else if (key == "width")
+            engineConfig_["WindowWidth"] = GetIntValue(jvalue, false);
+        else if (key == "height")
+            engineConfig_["WindowHeight"] = GetIntValue(jvalue, false);
+        else if (key == "positionx")
+            engineConfig_["WindowPositionX"] = GetIntValue(jvalue, false);
+        else if (key == "positiony")
+            engineConfig_["WindowPositionY"] = GetIntValue(jvalue, false);
 
     }
 

+ 17 - 0
Source/AtomicPlayer/Application/AtomicPlayer.cpp

@@ -23,6 +23,7 @@
 
 #include <Atomic/Atomic.h>
 #include <Atomic/Engine/Engine.h>
+#include <Atomic/Engine/EngineConfig.h>
 #include <Atomic/IO/FileSystem.h>
 #include <Atomic/IO/Log.h>
 #include <Atomic/IO/IOEvents.h>
@@ -76,6 +77,9 @@ void AtomicPlayerApp::Setup()
     FileSystem* filesystem = GetSubsystem<FileSystem>();
     context_->RegisterSubsystem(new ScriptSystem(context_));
 
+    // Read the engine configuration
+    ReadEngineConfig();
+
     engineParameters_.InsertNew("WindowTitle", "AtomicPlayer");
 
 #if (ATOMIC_PLATFORM_ANDROID)
@@ -258,5 +262,18 @@ void AtomicPlayerApp::HandleJSError(StringHash eventType, VariantMap& eventData)
 
 }
 
+void AtomicPlayerApp::ReadEngineConfig()
+{
+    FileSystem* fileSystem = GetSubsystem<FileSystem>();
+    String filename = fileSystem->GetProgramDir() + "Settings/Engine.json";
+
+    if (!fileSystem->FileExists(filename))
+        return;
+
+    if (EngineConfig::LoadFromFile(context_, filename))
+    {
+        EngineConfig::ApplyConfig(engineParameters_);
+    }
+}
 
 }

+ 2 - 0
Source/AtomicPlayer/Application/AtomicPlayer.h

@@ -65,6 +65,8 @@ private:
 
     void HandleLogMessage(StringHash eventType, VariantMap& eventData);
 
+    void ReadEngineConfig();
+
 };
 
 }

+ 4 - 0
Source/ToolCore/Build/BuildBase.cpp

@@ -252,6 +252,10 @@ void BuildBase::GetDefaultResourcePaths(Vector<String>& paths)
     paths.Push(AddTrailingSlash(tenv->GetPlayerDataDir()));
 }
 
+String BuildBase::GetSettingsDirectory()
+{
+    return project_->GetProjectPath() + "/Settings";
+}
 
 void BuildBase::ScanResourceDirectory(const String& resourceDir)
 {

+ 1 - 0
Source/ToolCore/Build/BuildBase.h

@@ -62,6 +62,7 @@ protected:
     void BuildResourceEntries();
 
     void GetDefaultResourcePaths(Vector<String>& paths);
+    String GetSettingsDirectory();
 
     String buildPath_;
     PODVector<BuildResourceEntry*> resourceEntries_;

+ 6 - 0
Source/ToolCore/Build/BuildWindows.cpp

@@ -152,6 +152,12 @@ void BuildWindows::Build(const String& buildPath)
     if (buildFailed_)
         return;
    
+    if (!BuildCreateDirectory(buildPath_ + "/Settings"))
+        return;
+
+    if (!BuildCopyFile(GetSettingsDirectory() + "/Engine.json", buildPath_ + "/Settings/Engine.json"))
+        return;
+
     if (!BuildCopyFile(playerBinary, buildPath_ + "/AtomicPlayer.exe"))
         return;
 

+ 0 - 5
Source/ToolCore/Build/ResourcePackager.cpp

@@ -201,11 +201,6 @@ void ResourcePackager::GeneratePackage(const String& destFilePath)
             return;
         }
 
-        if (!file.GetSize())
-        {
-            return;
-        }
-
         entry->size_ = file.GetSize();
     }