diff --git a/Unity Studio/Resource1.Designer.cs b/Unity Studio/Resource1.Designer.cs new file mode 100644 index 0000000..9b50d65 --- /dev/null +++ b/Unity Studio/Resource1.Designer.cs @@ -0,0 +1,120 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace Unity_Studio { + using System; + + + /// + /// 一个强类型的资源类,用于查找本地化的字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resource1 { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resource1() { + } + + /// + /// 返回此类使用的缓存的 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Unity_Studio.Resource1", typeof(Resource1).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 使用此强类型资源类,为所有资源查找 + /// 重写当前线程的 CurrentUICulture 属性。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// 查找类似 #version 140 + /// + ///in vec3 surfaceNormal; + ///in vec3 toLightVector; + ///in vec4 color; + /// + ///out vec4 outputColor; + /// + ///void main() + ///{ + /// vec3 lightColor = vec3(0.5, 0.5, 0.5); + /// + /// // Ambient + /// float ambientStrength = 0.9; + /// vec3 ambient = ambientStrength * lightColor; + /// + /// // Diffuse + /// vec3 unitNormal = normalize(surfaceNormal); + /// vec3 unitLightVector = normalize(toLightVector); + /// float nDotProduct = dot(unitNormal, unitLightVector); + /// float brightness = clamp(nDotProduct, 0, 1); // max(nDotProduct, 0.0); + /// vec3 diffuse [字符串的其余部分被截断]"; 的本地化字符串。 + /// + internal static string fs { + get { + return ResourceManager.GetString("fs", resourceCulture); + } + } + + /// + /// 查找类似 #version 140 + /// + ///in vec3 vertexPosition; + ///in vec3 normalDirection; + ///in vec4 vertexColor; + ///uniform mat4 viewMatrix; + /// + ///out vec3 surfaceNormal; + ///out vec3 toLightVector; + ///out vec4 color; + /// + ///void main() + ///{ + /// vec3 lightPosition = vec3(200.0, 200.0, 200.0); + /// gl_Position = viewMatrix * vec4(vertexPosition, 1.0); + /// surfaceNormal = normalDirection; + /// toLightVector = lightPosition - vertexPosition; + /// color = vertexColor; + ///} 的本地化字符串。 + /// + internal static string vs { + get { + return ResourceManager.GetString("vs", resourceCulture); + } + } + } +} diff --git a/Unity Studio/Resource1.resx b/Unity Studio/Resource1.resx new file mode 100644 index 0000000..80f86dc --- /dev/null +++ b/Unity Studio/Resource1.resx @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + #version 140 + +in vec3 surfaceNormal; +in vec3 toLightVector; +in vec4 color; + +out vec4 outputColor; + +void main() +{ + vec3 lightColor = vec3(0.5, 0.5, 0.5); + + // Ambient + float ambientStrength = 0.9; + vec3 ambient = ambientStrength * lightColor; + + // Diffuse + vec3 unitNormal = normalize(surfaceNormal); + vec3 unitLightVector = normalize(toLightVector); + float nDotProduct = dot(unitNormal, unitLightVector); + float brightness = clamp(nDotProduct, 0, 1); // max(nDotProduct, 0.0); + vec3 diffuse = brightness * lightColor; + + // Output Color + vec4 result = color * vec4((ambient + diffuse/2), 0.0); + outputColor = result; +} + + + #version 140 + +in vec3 vertexPosition; +in vec3 normalDirection; +in vec4 vertexColor; +uniform mat4 viewMatrix; + +out vec3 surfaceNormal; +out vec3 toLightVector; +out vec4 color; + +void main() +{ + vec3 lightPosition = vec3(200.0, 200.0, 200.0); + gl_Position = viewMatrix * vec4(vertexPosition, 1.0); + surfaceNormal = normalDirection; + toLightVector = lightPosition - vertexPosition; + color = vertexColor; +} + + \ No newline at end of file diff --git a/Unity Studio/Unity Studio-x86.csproj b/Unity Studio/Unity Studio-x86.csproj index 5fa53d5..d201676 100644 --- a/Unity Studio/Unity Studio-x86.csproj +++ b/Unity Studio/Unity Studio-x86.csproj @@ -136,6 +136,11 @@ AboutBox.cs + + Resource1.resx + True + True + @@ -198,14 +203,15 @@ Resources.resx True + + ResXFileCodeGenerator + Resource1.Designer.cs + UnityStudioForm.cs Designer - - PreserveNewest - SettingsSingleFileGenerator Settings.Designer.cs @@ -215,9 +221,6 @@ Settings.settings True - - PreserveNewest - diff --git a/Unity Studio/Unity Studio.csproj b/Unity Studio/Unity Studio.csproj index a93c08a..c2bb927 100644 --- a/Unity Studio/Unity Studio.csproj +++ b/Unity Studio/Unity Studio.csproj @@ -136,6 +136,11 @@ AboutBox.cs + + True + True + Resource1.resx + @@ -198,14 +203,15 @@ Resources.resx True + + ResXFileCodeGenerator + Resource1.Designer.cs + UnityStudioForm.cs Designer - - PreserveNewest - SettingsSingleFileGenerator Settings.Designer.cs @@ -215,9 +221,6 @@ Settings.settings True - - PreserveNewest - diff --git a/Unity Studio/UnityStudioForm.cs b/Unity Studio/UnityStudioForm.cs index e79ba2c..f7765a9 100644 --- a/Unity Studio/UnityStudioForm.cs +++ b/Unity Studio/UnityStudioForm.cs @@ -1712,8 +1712,8 @@ namespace Unity_Studio GL.Viewport(0, 0, glControl1.ClientSize.Width, glControl1.ClientSize.Height); GL.ClearColor(Color.CadetBlue); pgmID = GL.CreateProgram(); - loadShader("vs.glsl", ShaderType.VertexShader, pgmID, out vsID); - loadShader("fs.glsl", ShaderType.FragmentShader, pgmID, out fsID); + loadShader("vs", ShaderType.VertexShader, pgmID, out vsID); + loadShader("fs", ShaderType.FragmentShader, pgmID, out fsID); GL.LinkProgram(pgmID); GL.UseProgram(pgmID); attributeVertexPosition = GL.GetAttribLocation(pgmID, "vertexPosition"); @@ -1726,10 +1726,8 @@ namespace Unity_Studio private void loadShader(string filename, ShaderType type, int program, out int address) { address = GL.CreateShader(type); - using (StreamReader sr = new StreamReader(filename)) - { - GL.ShaderSource(address, sr.ReadToEnd()); - } + var str = (string)Resource1.ResourceManager.GetObject(filename); + GL.ShaderSource(address, str); GL.CompileShader(address); GL.AttachShader(program, address); GL.DeleteShader(address); @@ -1872,7 +1870,7 @@ namespace Unity_Studio { if (e.Button == MouseButtons.Right) { - selectasset = (AssetPreloadData)assetListView.Items[assetListView.SelectedIndices[0]]; + selectasset = (AssetPreloadData)assetListView.Items[assetListView.SelectedIndices[0]]; contextMenuStrip1.Show(assetListView, e.X, e.Y); } } diff --git a/Unity Studio/fs.glsl b/Unity Studio/fs.glsl deleted file mode 100644 index 63b4fc3..0000000 --- a/Unity Studio/fs.glsl +++ /dev/null @@ -1,27 +0,0 @@ -#version 140 - -in vec3 surfaceNormal; -in vec3 toLightVector; -in vec4 color; - -out vec4 outputColor; - -void main() -{ - vec3 lightColor = vec3(0.5, 0.5, 0.5); - - // Ambient - float ambientStrength = 0.9; - vec3 ambient = ambientStrength * lightColor; - - // Diffuse - vec3 unitNormal = normalize(surfaceNormal); - vec3 unitLightVector = normalize(toLightVector); - float nDotProduct = dot(unitNormal, unitLightVector); - float brightness = clamp(nDotProduct, 0, 1); // max(nDotProduct, 0.0); - vec3 diffuse = brightness * lightColor; - - // Output Color - vec4 result = color * vec4((ambient + diffuse/2), 0.0); - outputColor = result; -} \ No newline at end of file diff --git a/Unity Studio/vs.glsl b/Unity Studio/vs.glsl deleted file mode 100644 index db8f5ca..0000000 --- a/Unity Studio/vs.glsl +++ /dev/null @@ -1,19 +0,0 @@ -#version 140 - -in vec3 vertexPosition; -in vec3 normalDirection; -in vec4 vertexColor; -uniform mat4 viewMatrix; - -out vec3 surfaceNormal; -out vec3 toLightVector; -out vec4 color; - -void main() -{ - vec3 lightPosition = vec3(200.0, 200.0, 200.0); - gl_Position = viewMatrix * vec4(vertexPosition, 1.0); - surfaceNormal = normalDirection; - toLightVector = lightPosition - vertexPosition; - color = vertexColor; -} \ No newline at end of file