mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-22 20:02:48 +00:00
Move the shaders to C# resources
This commit is contained in:
parent
da57945db7
commit
7f6ff8929d
43 changed files with 1251 additions and 1693 deletions
|
@ -649,7 +649,17 @@
|
|||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<EmbeddedResource Include="Resources\display2d.vp" />
|
||||
<EmbeddedResource Include="Resources\display2d_fsaa.fp" />
|
||||
<EmbeddedResource Include="Resources\display2d_fullbright.fp" />
|
||||
<EmbeddedResource Include="Resources\display2d_normal.fp" />
|
||||
<None Include="Resources\MissingTexture.png" />
|
||||
<EmbeddedResource Include="Resources\plotter.fp" />
|
||||
<EmbeddedResource Include="Resources\plotter.vp" />
|
||||
<EmbeddedResource Include="Resources\things2d.vp" />
|
||||
<EmbeddedResource Include="Resources\things2d_fill.fp" />
|
||||
<EmbeddedResource Include="Resources\things2d_sprite.fp" />
|
||||
<EmbeddedResource Include="Resources\things2d_thing.fp" />
|
||||
<None Include="Resources\UnknownImage.png" />
|
||||
<None Include="Resources\treeview.png" />
|
||||
<None Include="Resources\Folder.png" />
|
||||
|
@ -665,6 +675,21 @@
|
|||
<None Include="Resources\Status2.png" />
|
||||
<None Include="Resources\Status0.png" />
|
||||
<None Include="Resources\ColorPick.png" />
|
||||
<EmbeddedResource Include="Resources\world3d_constant_color.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_customvertexcolor.vp" />
|
||||
<EmbeddedResource Include="Resources\world3d_customvertexcolor_fog.vp" />
|
||||
<EmbeddedResource Include="Resources\world3d_fullbright.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_fullbright_highlight.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_lightpass.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_lightpass.vp" />
|
||||
<EmbeddedResource Include="Resources\world3d_main.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_main.vp" />
|
||||
<EmbeddedResource Include="Resources\world3d_main_fog.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_main_highlight.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_main_highlight_fog.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_skybox.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_skybox.vp" />
|
||||
<EmbeddedResource Include="Resources\world3d_vertex_color.fp" />
|
||||
<None Include="Resources\Zoom.png" />
|
||||
<None Include="Resources\Properties.png" />
|
||||
<None Include="Resources\NewMap2.png" />
|
||||
|
@ -754,10 +779,7 @@
|
|||
<DependentUpon>VertexInfoPanel.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Resources\Actions.cfg" />
|
||||
<EmbeddedResource Include="Resources\display2d.fx" />
|
||||
<EmbeddedResource Include="Resources\ThingTexture2D.png" />
|
||||
<EmbeddedResource Include="Resources\things2d.fx" />
|
||||
<EmbeddedResource Include="Resources\world3d.fx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\MissingTexture3D.png" />
|
||||
|
|
|
@ -639,7 +639,17 @@
|
|||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<EmbeddedResource Include="Resources\display2d.vp" />
|
||||
<EmbeddedResource Include="Resources\display2d_fsaa.fp" />
|
||||
<EmbeddedResource Include="Resources\display2d_fullbright.fp" />
|
||||
<EmbeddedResource Include="Resources\display2d_normal.fp" />
|
||||
<None Include="Resources\MissingTexture.png" />
|
||||
<EmbeddedResource Include="Resources\plotter.fp" />
|
||||
<EmbeddedResource Include="Resources\plotter.vp" />
|
||||
<EmbeddedResource Include="Resources\things2d.vp" />
|
||||
<EmbeddedResource Include="Resources\things2d_fill.fp" />
|
||||
<EmbeddedResource Include="Resources\things2d_sprite.fp" />
|
||||
<EmbeddedResource Include="Resources\things2d_thing.fp" />
|
||||
<None Include="Resources\UnknownImage.png" />
|
||||
<None Include="Resources\treeview.png" />
|
||||
<None Include="Resources\Folder.png" />
|
||||
|
@ -655,6 +665,21 @@
|
|||
<None Include="Resources\Status2.png" />
|
||||
<None Include="Resources\Status0.png" />
|
||||
<None Include="Resources\ColorPick.png" />
|
||||
<EmbeddedResource Include="Resources\world3d_constant_color.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_customvertexcolor.vp" />
|
||||
<EmbeddedResource Include="Resources\world3d_customvertexcolor_fog.vp" />
|
||||
<EmbeddedResource Include="Resources\world3d_fullbright.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_fullbright_highlight.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_lightpass.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_lightpass.vp" />
|
||||
<EmbeddedResource Include="Resources\world3d_main.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_main.vp" />
|
||||
<EmbeddedResource Include="Resources\world3d_main_fog.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_main_highlight.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_main_highlight_fog.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_skybox.fp" />
|
||||
<EmbeddedResource Include="Resources\world3d_skybox.vp" />
|
||||
<EmbeddedResource Include="Resources\world3d_vertex_color.fp" />
|
||||
<None Include="Resources\Zoom.png" />
|
||||
<None Include="Resources\Properties.png" />
|
||||
<None Include="Resources\NewMap2.png" />
|
||||
|
@ -744,10 +769,7 @@
|
|||
<DependentUpon>VertexInfoPanel.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Resources\Actions.cfg" />
|
||||
<EmbeddedResource Include="Resources\display2d.fx" />
|
||||
<EmbeddedResource Include="Resources\ThingTexture2D.png" />
|
||||
<EmbeddedResource Include="Resources\things2d.fx" />
|
||||
<EmbeddedResource Include="Resources\world3d.fx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\MissingTexture3D.png" />
|
||||
|
|
250
Source/Core/Properties/Resources.Designer.cs
generated
250
Source/Core/Properties/Resources.Designer.cs
generated
|
@ -360,6 +360,46 @@ namespace CodeImp.DoomBuilder.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] display2d_fsaa {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("display2d_fsaa", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] display2d_fullbright {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("display2d_fullbright", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] display2d_normal {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("display2d_normal", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] display2d_vp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("display2d_vp", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
@ -1020,6 +1060,26 @@ namespace CodeImp.DoomBuilder.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] plotter {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("plotter", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] plotter_vp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("plotter_vp", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
@ -1510,6 +1570,46 @@ namespace CodeImp.DoomBuilder.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] things2d_fill {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("things2d_fill", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] things2d_sprite {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("things2d_sprite", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] things2d_thing {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("things2d_thing", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] things2d_vp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("things2d_vp", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
@ -1690,6 +1790,156 @@ namespace CodeImp.DoomBuilder.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_constant_color {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_constant_color", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_customvertexcolor_fog_vp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_customvertexcolor_fog_vp", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_customvertexcolor_vp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_customvertexcolor_vp", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_fullbright {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_fullbright", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_fullbright_highlight {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_fullbright_highlight", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_lightpass {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_lightpass", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_lightpass_vp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_lightpass_vp", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_main {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_main", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_main_fog {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_main_fog", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_main_highlight {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_main_highlight", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_main_highlight_fog {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_main_highlight_fog", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_main_vp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_main_vp", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_skybox {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_skybox", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_skybox_vp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_skybox_vp", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] world3d_vertex_color {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("world3d_vertex_color", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
|
|
@ -112,12 +112,12 @@
|
|||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="Clear" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Clear.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
@ -613,4 +613,79 @@
|
|||
<data name="Github" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Github.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="display2d_vp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\display2d.vp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="display2d_fsaa" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\display2d_fsaa.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="display2d_fullbright" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\display2d_fullbright.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="display2d_normal" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\display2d_normal.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="plotter_vp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\plotter.vp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="plotter" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\plotter.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="things2d_vp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\things2d.vp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="things2d_fill" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\things2d_fill.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="things2d_sprite" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\things2d_sprite.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="things2d_thing" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\things2d_thing.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_constant_color" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_constant_color.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_customvertexcolor_vp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_customvertexcolor.vp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_customvertexcolor_fog_vp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_customvertexcolor_fog.vp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_fullbright" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_fullbright.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_fullbright_highlight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_fullbright_highlight.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_lightpass_vp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_lightpass.vp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_lightpass" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_lightpass.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_main_vp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_main.vp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_main" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_main.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_main_fog" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_main_fog.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_main_highlight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_main_highlight.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_main_highlight_fog" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_main_highlight_fog.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_skybox_vp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_skybox.vp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_skybox" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_skybox.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="world3d_vertex_color" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\world3d_vertex_color.fp;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
</root>
|
|
@ -24,6 +24,9 @@ using CodeImp.DoomBuilder.Controls;
|
|||
using CodeImp.DoomBuilder.Geometry;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -38,20 +41,41 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
{
|
||||
public RenderDevice(RenderTargetControl rendertarget)
|
||||
{
|
||||
|
||||
// Grab the X11 Display handle by abusing reflection to access internal classes in the mono implementation.
|
||||
// That's par for the course for everything in Linux, so yeah..
|
||||
IntPtr display = IntPtr.Zero;
|
||||
Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
|
||||
if (xplatui != null)
|
||||
{
|
||||
display = (IntPtr)xplatui.GetField("DisplayHandle", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
|
||||
}
|
||||
// Grab the X11 Display handle by abusing reflection to access internal classes in the mono implementation.
|
||||
// That's par for the course for everything in Linux, so yeah..
|
||||
IntPtr display = IntPtr.Zero;
|
||||
Type xplatui = Type.GetType("System.Windows.Forms.XplatUIX11, System.Windows.Forms");
|
||||
if (xplatui != null)
|
||||
{
|
||||
display = (IntPtr)xplatui.GetField("DisplayHandle", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
|
||||
}
|
||||
|
||||
Handle = RenderDevice_New(display, rendertarget.Handle);
|
||||
if (Handle == IntPtr.Zero)
|
||||
throw new Exception("RenderDevice_New failed");
|
||||
|
||||
DeclareShader(ShaderName.display2d_fsaa, "display2d.vp", "display2d_fsaa.fp");
|
||||
DeclareShader(ShaderName.display2d_normal, "display2d.vp", "display2d_normal.fp");
|
||||
DeclareShader(ShaderName.display2d_fullbright, "display2d.vp", "display2d_fullbright.fp");
|
||||
DeclareShader(ShaderName.things2d_thing, "things2d.vp", "things2d_thing.fp");
|
||||
DeclareShader(ShaderName.things2d_sprite, "things2d.vp", "things2d_sprite.fp");
|
||||
DeclareShader(ShaderName.things2d_fill, "things2d.vp", "things2d_fill.fp");
|
||||
DeclareShader(ShaderName.plotter, "plotter.vp", "plotter.fp");
|
||||
DeclareShader(ShaderName.world3d_main, "world3d_main.vp", "world3d_main.fp");
|
||||
DeclareShader(ShaderName.world3d_fullbright, "world3d_main.vp", "world3d_fullbright.fp");
|
||||
DeclareShader(ShaderName.world3d_main_highlight, "world3d_main.vp", "world3d_main_highlight.fp");
|
||||
DeclareShader(ShaderName.world3d_fullbright_highlight, "world3d_main.vp", "world3d_fullbright_highlight.fp");
|
||||
DeclareShader(ShaderName.world3d_main_vertexcolor, "world3d_customvertexcolor.vp", "world3d_main.fp");
|
||||
DeclareShader(ShaderName.world3d_skybox, "world3d_skybox.vp", "world3d_skybox.fp");
|
||||
DeclareShader(ShaderName.world3d_main_highlight_vertexcolor, "world3d_customvertexcolor.vp", "world3d_main_highlight.fp");
|
||||
DeclareShader(ShaderName.world3d_main_fog, "world3d_lightpass.vp", "world3d_main_fog.fp");
|
||||
DeclareShader(ShaderName.world3d_main_highlight_fog, "world3d_lightpass.vp", "world3d_main_highlight_fog.fp");
|
||||
DeclareShader(ShaderName.world3d_main_fog_vertexcolor, "world3d_customvertexcolor_fog.vp", "world3d_main_fog.fp");
|
||||
DeclareShader(ShaderName.world3d_main_highlight_fog_vertexcolor, "world3d_customvertexcolor_fog.vp", "world3d_main_highlight_fog.fp");
|
||||
DeclareShader(ShaderName.world3d_vertex_color, "world3d_main.vp", "world3d_vertex_color.fp");
|
||||
DeclareShader(ShaderName.world3d_constant_color, "world3d_customvertexcolor.vp", "world3d_constant_color.fp");
|
||||
DeclareShader(ShaderName.world3d_lightpass, "world3d_lightpass.vp", "world3d_lightpass.fp");
|
||||
|
||||
RenderTarget = rendertarget;
|
||||
|
||||
SetupSettings();
|
||||
|
@ -79,6 +103,25 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
}
|
||||
}
|
||||
|
||||
public void DeclareShader(ShaderName name, string vertResourceName, string fragResourceName)
|
||||
{
|
||||
RenderDevice_DeclareShader(Handle, name, GetResourceText(vertResourceName), GetResourceText(fragResourceName));
|
||||
}
|
||||
|
||||
static string GetResourceText(string name)
|
||||
{
|
||||
string fullname = string.Format("CodeImp.DoomBuilder.Resources.{0}", name);
|
||||
using (Stream stream = General.ThisAssembly.GetManifestResourceStream(fullname))
|
||||
{
|
||||
if (stream == null)
|
||||
throw new Exception(string.Format("Resource {0} not found!", fullname));
|
||||
byte[] data = new byte[stream.Length];
|
||||
if (stream.Read(data, 0, data.Length) != data.Length)
|
||||
throw new Exception("Could not read resource stream");
|
||||
return Encoding.UTF8.GetString(data);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetShader(ShaderName shader)
|
||||
{
|
||||
RenderDevice_SetShader(Handle, shader);
|
||||
|
@ -382,6 +425,9 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
[DllImport("BuilderNative", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void RenderDevice_Delete(IntPtr handle);
|
||||
|
||||
[DllImport("BuilderNative", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
static extern void RenderDevice_DeclareShader(IntPtr handle, ShaderName name, string vertexShader, string fragShader);
|
||||
|
||||
[DllImport("BuilderNative", CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr RenderDevice_GetError(IntPtr handle);
|
||||
|
||||
|
|
|
@ -1,140 +0,0 @@
|
|||
// 2D display rendering shader
|
||||
// Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
||||
|
||||
// Vertex input data
|
||||
struct VertexData
|
||||
{
|
||||
float3 pos : POSITION;
|
||||
float4 color : COLOR0;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Pixel input data
|
||||
struct PixelData
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float4 color : COLOR0;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Render settings
|
||||
// x = texel width
|
||||
// y = texel height
|
||||
// z = FSAA blend factor
|
||||
// w = transparency
|
||||
float4 rendersettings;
|
||||
|
||||
// Transform settings
|
||||
float4x4 transformsettings;
|
||||
|
||||
// Filter settings
|
||||
dword filtersettings;
|
||||
|
||||
//
|
||||
float desaturation;
|
||||
|
||||
// Texture1 input
|
||||
texture texture1
|
||||
<
|
||||
string UIName = "Texture1";
|
||||
string ResourceType = "2D";
|
||||
>;
|
||||
|
||||
// Texture sampler settings
|
||||
sampler2D texture1samp = sampler_state
|
||||
{
|
||||
Texture = <texture1>;
|
||||
MagFilter = filtersettings;
|
||||
MinFilter = filtersettings;
|
||||
MipFilter = filtersettings;
|
||||
AddressU = Wrap;
|
||||
AddressV = Wrap;
|
||||
MipMapLodBias = 0.0f;
|
||||
};
|
||||
|
||||
// Transformation
|
||||
PixelData vs_transform(VertexData vd)
|
||||
{
|
||||
PixelData pd = (PixelData)0;
|
||||
pd.pos = mul(float4(vd.pos, 1.0f), transformsettings);
|
||||
pd.color = vd.color;
|
||||
pd.uv = vd.uv;
|
||||
return pd;
|
||||
}
|
||||
|
||||
// This blends the max of 2 pixels
|
||||
float4 addcolor(float4 c1, float4 c2)
|
||||
{
|
||||
return float4(max(c1.r, c2.r),
|
||||
max(c1.g, c2.g),
|
||||
max(c1.b, c2.b),
|
||||
saturate(c1.a + c2.a * 0.5f));
|
||||
}
|
||||
|
||||
// [ZZ] desaturation routine. almost literal quote from GZDoom's GLSL
|
||||
float3 desaturate(float3 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return lerp(texel, float3(gray,gray,gray), desaturation);
|
||||
}
|
||||
|
||||
// Pixel shader for antialiased drawing
|
||||
float4 ps_fsaa(PixelData pd) : COLOR
|
||||
{
|
||||
// Take this pixel's color
|
||||
float4 c = tex2D(texture1samp, pd.uv);
|
||||
|
||||
// If this pixel is not drawn on...
|
||||
if(c.a < 0.1f)
|
||||
{
|
||||
// Mix the colors of nearby pixels
|
||||
float4 n = (float4)0;
|
||||
n = addcolor(n, tex2D(texture1samp, float2(pd.uv.x + rendersettings.x, pd.uv.y)));
|
||||
n = addcolor(n, tex2D(texture1samp, float2(pd.uv.x - rendersettings.x, pd.uv.y)));
|
||||
n = addcolor(n, tex2D(texture1samp, float2(pd.uv.x, pd.uv.y + rendersettings.y)));
|
||||
n = addcolor(n, tex2D(texture1samp, float2(pd.uv.x, pd.uv.y - rendersettings.y)));
|
||||
|
||||
// If any pixels nearby where found, return a blend, otherwise return nothing
|
||||
//if(n.a > 0.1f) return float4(desaturate(n.rgb), n.a * settings.z); else return (float4)0;
|
||||
return float4(desaturate(n.rgb), n.a * rendersettings.z * rendersettings.w);
|
||||
}
|
||||
else return float4(desaturate(c.rgb), c.a * rendersettings.w) * pd.color;
|
||||
}
|
||||
|
||||
// Pixel shader for normal drawing
|
||||
float4 ps_normal(PixelData pd) : COLOR
|
||||
{
|
||||
// Take this pixel's color
|
||||
float4 c = tex2D(texture1samp, pd.uv);
|
||||
return float4(desaturate(c.rgb), c.a * rendersettings.w) * pd.color;
|
||||
}
|
||||
|
||||
//mxd. Pixel shader for full bright drawing
|
||||
float4 ps_fullbright(PixelData pd) : COLOR
|
||||
{
|
||||
// Take this pixel's color
|
||||
float4 c = tex2D(texture1samp, pd.uv);
|
||||
return float4(c.rgb, c.a * rendersettings.w);
|
||||
}
|
||||
|
||||
// Technique for shader model 2.0
|
||||
technique SM20
|
||||
{
|
||||
pass p0
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_transform();
|
||||
PixelShader = compile ps_2_0 ps_fsaa();
|
||||
}
|
||||
|
||||
pass p1
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_transform();
|
||||
PixelShader = compile ps_2_0 ps_normal();
|
||||
}
|
||||
|
||||
pass p2 //mxd
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_transform();
|
||||
PixelShader = compile ps_2_0 ps_fullbright();
|
||||
}
|
||||
}
|
16
Source/Core/Resources/display2d.vp
Normal file
16
Source/Core/Resources/display2d.vp
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
in vec3 AttrPosition;
|
||||
in vec4 AttrColor;
|
||||
in vec2 AttrUV;
|
||||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
|
||||
uniform mat4 projection;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = projection * vec4(AttrPosition, 1.0f);
|
||||
Color = AttrColor;
|
||||
UV = AttrUV;
|
||||
}
|
60
Source/Core/Resources/display2d_fsaa.fp
Normal file
60
Source/Core/Resources/display2d_fsaa.fp
Normal file
|
@ -0,0 +1,60 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
// Render settings
|
||||
// x = texel width
|
||||
// y = texel height
|
||||
// z = FSAA blend factor
|
||||
// w = transparency
|
||||
uniform vec4 rendersettings;
|
||||
uniform float desaturation;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
// This blends the max of 2 pixels
|
||||
vec4 addcolor(vec4 c1, vec4 c2)
|
||||
{
|
||||
return vec4(
|
||||
max(c1.r, c2.r),
|
||||
max(c1.g, c2.g),
|
||||
max(c1.b, c2.b),
|
||||
clamp(c1.a + c2.a * 0.5, 0.0, 1.0));
|
||||
}
|
||||
|
||||
vec3 desaturate(vec3 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return mix(texel, vec3(gray), desaturation);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 c = texture(texture1, UV);
|
||||
|
||||
// If this pixel is not drawn on...
|
||||
if(c.a < 0.1f)
|
||||
{
|
||||
// Mix the colors of nearby pixels
|
||||
vec4 n = vec4(0.0);
|
||||
n = addcolor(n, texture(texture1, vec2(UV.x + rendersettings.x, UV.y)));
|
||||
n = addcolor(n, texture(texture1, vec2(UV.x - rendersettings.x, UV.y)));
|
||||
n = addcolor(n, texture(texture1, vec2(UV.x, UV.y + rendersettings.y)));
|
||||
n = addcolor(n, texture(texture1, vec2(UV.x, UV.y - rendersettings.y)));
|
||||
|
||||
FragColor = vec4(desaturate(n.rgb), n.a * rendersettings.z * rendersettings.w);
|
||||
}
|
||||
else
|
||||
{
|
||||
FragColor = vec4(desaturate(c.rgb), c.a * rendersettings.w) * Color;
|
||||
}
|
||||
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
}
|
26
Source/Core/Resources/display2d_fullbright.fp
Normal file
26
Source/Core/Resources/display2d_fullbright.fp
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
// Render settings
|
||||
// x = texel width
|
||||
// y = texel height
|
||||
// z = FSAA blend factor
|
||||
// w = transparency
|
||||
uniform vec4 rendersettings;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 c = texture(texture1, UV);
|
||||
FragColor = vec4(c.rgb, c.a * rendersettings.w);
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
}
|
33
Source/Core/Resources/display2d_normal.fp
Normal file
33
Source/Core/Resources/display2d_normal.fp
Normal file
|
@ -0,0 +1,33 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
// Render settings
|
||||
// x = texel width
|
||||
// y = texel height
|
||||
// z = FSAA blend factor
|
||||
// w = transparency
|
||||
uniform vec4 rendersettings;
|
||||
uniform float desaturation;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
vec3 desaturate(vec3 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return mix(texel, vec3(gray), desaturation);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 c = texture(texture1, UV);
|
||||
FragColor = vec4(desaturate(c.rgb), c.a * rendersettings.w) * Color;
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
}
|
20
Source/Core/Resources/plotter.fp
Normal file
20
Source/Core/Resources/plotter.fp
Normal file
|
@ -0,0 +1,20 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
// line stipple
|
||||
if (mod(UV.x, 2.0) > 1.0)
|
||||
discard;
|
||||
|
||||
// line smoothing
|
||||
float linewidth = 3.0;
|
||||
float falloff = 1.8; //1.5..2.5
|
||||
float centerdist = abs(UV.y);
|
||||
float a = pow(clamp((linewidth - centerdist) / linewidth, 0.0, 1.0), falloff);
|
||||
|
||||
FragColor = vec4(Color.rgb, Color.a * a);
|
||||
}
|
16
Source/Core/Resources/plotter.vp
Normal file
16
Source/Core/Resources/plotter.vp
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
in vec3 AttrPosition;
|
||||
in vec4 AttrColor;
|
||||
in vec2 AttrUV;
|
||||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
|
||||
uniform mat4 projection;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = projection * vec4(AttrPosition, 1.0f);
|
||||
Color = AttrColor;
|
||||
UV = AttrUV;
|
||||
}
|
|
@ -1,133 +0,0 @@
|
|||
// Things 2D rendering shader
|
||||
// Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
||||
|
||||
// Vertex input data
|
||||
struct VertexData
|
||||
{
|
||||
float3 pos : POSITION;
|
||||
float4 color : COLOR0;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Pixel input data
|
||||
struct PixelData
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float4 color : COLOR0;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Render settings
|
||||
// w = transparency
|
||||
float4 rendersettings;
|
||||
|
||||
//mxd. solid fill color. used in model wireframe rendering
|
||||
float4 fillColor;
|
||||
|
||||
//[ZZ]
|
||||
float desaturation;
|
||||
|
||||
// Transform settings
|
||||
float4x4 transformsettings;
|
||||
|
||||
// Texture1 input
|
||||
texture texture1
|
||||
<
|
||||
string UIName = "Texture1";
|
||||
string ResourceType = "2D";
|
||||
>;
|
||||
|
||||
// Texture sampler settings
|
||||
sampler2D texture1samp = sampler_state
|
||||
{
|
||||
Texture = <texture1>;
|
||||
MagFilter = Linear;
|
||||
MinFilter = Linear;
|
||||
MipFilter = Linear;
|
||||
AddressU = Wrap;
|
||||
AddressV = Wrap;
|
||||
MipMapLodBias = -0.9f;
|
||||
};
|
||||
|
||||
//mxd. Texture sampler settings for sprite rendering
|
||||
sampler2D texture1sprite = sampler_state
|
||||
{
|
||||
Texture = <texture1>;
|
||||
MagFilter = Point;
|
||||
MinFilter = Point;
|
||||
MipFilter = Point;
|
||||
AddressU = Clamp;
|
||||
AddressV = Clamp;
|
||||
MipMapLodBias = 0.0f;
|
||||
};
|
||||
|
||||
// Transformation
|
||||
PixelData vs_transform(VertexData vd)
|
||||
{
|
||||
PixelData pd = (PixelData)0;
|
||||
pd.pos = mul(float4(vd.pos, 1.0f), transformsettings);
|
||||
pd.color = vd.color;
|
||||
pd.uv = vd.uv;
|
||||
return pd;
|
||||
}
|
||||
|
||||
// [ZZ] desaturation routine. almost literal quote from GZDoom's GLSL
|
||||
float3 desaturate(float3 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return lerp(texel, float3(gray,gray,gray), desaturation);
|
||||
}
|
||||
|
||||
//mxd. Pixel shader for sprite drawing
|
||||
float4 ps_sprite(PixelData pd) : COLOR
|
||||
{
|
||||
// Take this pixel's color
|
||||
float4 c = tex2D(texture1sprite, pd.uv);
|
||||
|
||||
// Modulate it by selection color
|
||||
if(pd.color.a > 0)
|
||||
{
|
||||
float3 cr = desaturate(c.rgb);
|
||||
return float4((cr.r + pd.color.r) / 2.0f, (cr.g + pd.color.g) / 2.0f, (cr.b + pd.color.b) / 2.0f, c.a * rendersettings.w * pd.color.a);
|
||||
}
|
||||
|
||||
// Or leave it as it is
|
||||
return float4(desaturate(c.rgb), c.a * rendersettings.w);
|
||||
}
|
||||
|
||||
//mxd. Pixel shader for thing box and arrow drawing
|
||||
float4 ps_thing(PixelData pd) : COLOR
|
||||
{
|
||||
// Take this pixel's color
|
||||
float4 c = tex2D(texture1samp, pd.uv);
|
||||
return float4(desaturate(c.rgb), c.a * rendersettings.w) * pd.color;
|
||||
}
|
||||
|
||||
//mxd. Pretty darn simple pixel shader for wireframe rendering :)
|
||||
float4 ps_fill(PixelData pd) : COLOR
|
||||
{
|
||||
return fillColor;
|
||||
}
|
||||
|
||||
// Technique for shader model 2.0
|
||||
technique SM20
|
||||
{
|
||||
pass p0 //mxd
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_transform();
|
||||
PixelShader = compile ps_2_0 ps_thing();
|
||||
}
|
||||
|
||||
pass p1 //mxd
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_transform();
|
||||
PixelShader = compile ps_2_0 ps_sprite();
|
||||
}
|
||||
|
||||
|
||||
pass p2 //mxd
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_transform();
|
||||
PixelShader = compile ps_2_0 ps_fill();
|
||||
}
|
||||
}
|
16
Source/Core/Resources/things2d.vp
Normal file
16
Source/Core/Resources/things2d.vp
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
in vec3 AttrPosition;
|
||||
in vec4 AttrColor;
|
||||
in vec2 AttrUV;
|
||||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
|
||||
uniform mat4 projection;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = projection * vec4(AttrPosition, 1.0f);
|
||||
Color = AttrColor;
|
||||
UV = AttrUV;
|
||||
}
|
16
Source/Core/Resources/things2d_fill.fp
Normal file
16
Source/Core/Resources/things2d_fill.fp
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 fillColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = fillColor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
}
|
43
Source/Core/Resources/things2d_sprite.fp
Normal file
43
Source/Core/Resources/things2d_sprite.fp
Normal file
|
@ -0,0 +1,43 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
// Render settings
|
||||
// w = transparency
|
||||
uniform vec4 rendersettings;
|
||||
uniform float desaturation;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
vec3 desaturate(vec3 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return mix(texel, vec3(gray), desaturation);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// Take this pixel's color
|
||||
vec4 c = texture(texture1, UV);
|
||||
|
||||
// Modulate it by selection color
|
||||
if (Color.a > 0.0)
|
||||
{
|
||||
vec3 cr = desaturate(c.rgb);
|
||||
FragColor = vec4((cr.r + Color.r) / 2.0f, (cr.g + Color.g) / 2.0f, (cr.b + Color.b) / 2.0f, c.a * rendersettings.w * Color.a);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Or leave it as it is
|
||||
FragColor = vec4(desaturate(c.rgb), c.a * rendersettings.w);
|
||||
}
|
||||
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
}
|
31
Source/Core/Resources/things2d_thing.fp
Normal file
31
Source/Core/Resources/things2d_thing.fp
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
// Render settings
|
||||
// w = transparency
|
||||
uniform vec4 rendersettings;
|
||||
uniform float desaturation;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
vec3 desaturate(vec3 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return mix(texel, vec3(gray), desaturation);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 c = texture(texture1, UV);
|
||||
FragColor = vec4(desaturate(c.rgb), c.a * rendersettings.w) * Color;
|
||||
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
}
|
|
@ -1,434 +0,0 @@
|
|||
// 3D world rendering shader
|
||||
// Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
||||
|
||||
// Vertex input data
|
||||
struct VertexData
|
||||
{
|
||||
float3 pos : POSITION;
|
||||
float4 color : COLOR0;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 normal : NORMAL; //mxd
|
||||
};
|
||||
|
||||
// Pixel input data
|
||||
struct PixelData
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float4 color : COLOR0;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
//mxd. Vertex input data for sky rendering
|
||||
struct SkyVertexData
|
||||
{
|
||||
float3 pos : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
//mxd. Pixel input data for sky rendering
|
||||
struct SkyPixelData
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float3 tex : TEXCOORD0;
|
||||
};
|
||||
|
||||
//mxd. Pixel input data for light pass
|
||||
struct LitPixelData
|
||||
{
|
||||
float4 pos : POSITION;
|
||||
float4 color : COLOR0;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 pos_w : TEXCOORD1; //mxd. pixel position in world space
|
||||
float3 normal : TEXCOORD2; //mxd. normal
|
||||
};
|
||||
|
||||
// Highlight color
|
||||
float4 highlightcolor;
|
||||
|
||||
// Matrix for final transformation
|
||||
const float4x4 worldviewproj;
|
||||
|
||||
//mxd
|
||||
float4x4 world;
|
||||
float4x4 modelnormal;
|
||||
float4 vertexColor;
|
||||
// [ZZ]
|
||||
float4 stencilColor;
|
||||
|
||||
//light
|
||||
float4 lightPosAndRadius;
|
||||
float3 lightOrientation; // this is a vector that points in light's direction
|
||||
float2 light2Radius; // this is used with spotlights
|
||||
float4 lightColor; //also used as fog color
|
||||
float desaturation;
|
||||
float ignoreNormals; // ignore normals in lighting equation. used for non-attenuated lights on models.
|
||||
float spotLight; // use lightOrientation
|
||||
|
||||
//fog
|
||||
const float4 campos; //w is set to fade factor (distance, at wich fog color completely overrides pixel color)
|
||||
|
||||
//sky
|
||||
static const float4 skynormal = float4(0.0f, 1.0f, 0.0f, 0.0f);
|
||||
|
||||
// Texture input
|
||||
const texture texture1;
|
||||
|
||||
// Filter settings
|
||||
const dword minfiltersettings;
|
||||
const dword magfiltersettings;
|
||||
const dword mipfiltersettings;
|
||||
const float maxanisotropysetting;
|
||||
|
||||
// Texture sampler settings
|
||||
sampler2D texturesamp = sampler_state
|
||||
{
|
||||
Texture = <texture1>;
|
||||
MagFilter = magfiltersettings;
|
||||
MinFilter = minfiltersettings;
|
||||
MipFilter = mipfiltersettings;
|
||||
MipMapLodBias = 0.0f;
|
||||
MaxAnisotropy = maxanisotropysetting;
|
||||
};
|
||||
|
||||
//mxd. Skybox texture sampler settings
|
||||
samplerCUBE skysamp = sampler_state
|
||||
{
|
||||
Texture = <texture1>;
|
||||
MagFilter = magfiltersettings;
|
||||
MinFilter = minfiltersettings;
|
||||
MipFilter = mipfiltersettings;
|
||||
MipMapLodBias = 0.0f;
|
||||
MaxAnisotropy = maxanisotropysetting;
|
||||
};
|
||||
|
||||
// Vertex shader
|
||||
PixelData vs_main(VertexData vd)
|
||||
{
|
||||
PixelData pd;
|
||||
|
||||
// Fill pixel data input
|
||||
pd.pos = mul(float4(vd.pos, 1.0f), worldviewproj);
|
||||
pd.color = vd.color;
|
||||
pd.uv = vd.uv;
|
||||
|
||||
// Return result
|
||||
return pd;
|
||||
}
|
||||
|
||||
//mxd. same as vs_main, but uses vertexColor var instead of actual vertex color. used in models rendering
|
||||
PixelData vs_customvertexcolor(VertexData vd)
|
||||
{
|
||||
PixelData pd;
|
||||
|
||||
// Fill pixel data input
|
||||
pd.pos = mul(float4(vd.pos, 1.0f), worldviewproj);
|
||||
pd.color = vertexColor;
|
||||
pd.uv = vd.uv;
|
||||
|
||||
// Return result
|
||||
return pd;
|
||||
}
|
||||
|
||||
LitPixelData vs_customvertexcolor_fog(VertexData vd)
|
||||
{
|
||||
LitPixelData pd;
|
||||
|
||||
// Fill pixel data input
|
||||
pd.pos = mul(float4(vd.pos, 1.0f), worldviewproj);
|
||||
pd.pos_w = mul(float4(vd.pos, 1.0f), world).xyz;
|
||||
pd.color = vertexColor;
|
||||
pd.uv = vd.uv;
|
||||
pd.normal = normalize(mul(float4(vd.normal, 1.0f), modelnormal).xyz);
|
||||
|
||||
// Return result
|
||||
return pd;
|
||||
}
|
||||
|
||||
//mxd. light pass vertex shader
|
||||
LitPixelData vs_lightpass(VertexData vd)
|
||||
{
|
||||
LitPixelData pd;
|
||||
pd.pos = mul(float4(vd.pos, 1.0f), worldviewproj);
|
||||
pd.pos_w = mul(float4(vd.pos, 1.0f), world).xyz;
|
||||
pd.color = vd.color;
|
||||
pd.uv = vd.uv;
|
||||
pd.normal = normalize(mul(float4(vd.normal, 1.0f), modelnormal).xyz);
|
||||
|
||||
// Return result
|
||||
return pd;
|
||||
}
|
||||
|
||||
// [ZZ] desaturation routine. almost literal quote from GZDoom's GLSL
|
||||
float4 desaturate(float4 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return lerp(texel, float4(gray,gray,gray,texel.a), desaturation);
|
||||
}
|
||||
|
||||
// Normal pixel shader
|
||||
float4 ps_main(PixelData pd) : COLOR
|
||||
{
|
||||
float4 tcolor = tex2D(texturesamp, pd.uv);
|
||||
tcolor = lerp(tcolor, float4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
return desaturate(tcolor * pd.color);
|
||||
}
|
||||
|
||||
// Full-bright pixel shader
|
||||
float4 ps_fullbright(PixelData pd) : COLOR
|
||||
{
|
||||
float4 tcolor = tex2D(texturesamp, pd.uv);
|
||||
tcolor = lerp(tcolor, float4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
tcolor.a *= pd.color.a;
|
||||
return tcolor;
|
||||
}
|
||||
|
||||
// Normal pixel shader with highlight
|
||||
float4 ps_main_highlight(PixelData pd) : COLOR
|
||||
{
|
||||
float4 tcolor = tex2D(texturesamp, pd.uv);
|
||||
tcolor = lerp(tcolor, float4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if(tcolor.a == 0) return tcolor;
|
||||
|
||||
// Blend texture color and vertex color
|
||||
float4 ncolor = desaturate(tcolor * pd.color);
|
||||
|
||||
return float4(highlightcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4f * highlightcolor.a), max(pd.color.a + 0.25f, 0.5f));
|
||||
}
|
||||
|
||||
// Full-bright pixel shader with highlight
|
||||
float4 ps_fullbright_highlight(PixelData pd) : COLOR
|
||||
{
|
||||
float4 tcolor = tex2D(texturesamp, pd.uv);
|
||||
tcolor = lerp(tcolor, float4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if(tcolor.a == 0) return tcolor;
|
||||
|
||||
// Blend texture color and vertex color
|
||||
float4 ncolor = tcolor * pd.color;
|
||||
|
||||
return float4(highlightcolor.rgb * highlightcolor.a + (tcolor.rgb - 0.4f * highlightcolor.a), max(pd.color.a + 0.25f, 0.5f));
|
||||
}
|
||||
|
||||
//mxd. This adds fog color to current pixel color
|
||||
float4 getFogColor(LitPixelData pd, float4 color)
|
||||
{
|
||||
float fogdist = max(16.0f, distance(pd.pos_w, campos.xyz));
|
||||
float fogfactor = exp2(campos.w * fogdist);
|
||||
|
||||
color.rgb = lerp(lightColor.rgb, color.rgb, fogfactor);
|
||||
return color;
|
||||
}
|
||||
|
||||
//mxd. Shaders with fog calculation
|
||||
// Normal pixel shader
|
||||
float4 ps_main_fog(LitPixelData pd) : COLOR
|
||||
{
|
||||
float4 tcolor = tex2D(texturesamp, pd.uv);
|
||||
tcolor = lerp(tcolor, float4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if(tcolor.a == 0) return tcolor;
|
||||
|
||||
return desaturate(getFogColor(pd, tcolor * pd.color));
|
||||
}
|
||||
|
||||
// Normal pixel shader with highlight
|
||||
float4 ps_main_highlight_fog(LitPixelData pd) : COLOR
|
||||
{
|
||||
float4 tcolor = tex2D(texturesamp, pd.uv);
|
||||
tcolor = lerp(tcolor, float4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if(tcolor.a == 0) return tcolor;
|
||||
|
||||
// Blend texture color and vertex color
|
||||
float4 ncolor = desaturate(getFogColor(pd, tcolor * pd.color));
|
||||
|
||||
return float4(highlightcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4f * highlightcolor.a), max(ncolor.a + 0.25f, 0.5f));
|
||||
}
|
||||
|
||||
//mxd: used to draw bounding boxes
|
||||
float4 ps_constant_color(PixelData pd) : COLOR
|
||||
{
|
||||
return vertexColor;
|
||||
}
|
||||
|
||||
//mxd: used to draw event lines
|
||||
float4 ps_vertex_color(PixelData pd) : COLOR
|
||||
{
|
||||
return pd.color;
|
||||
}
|
||||
|
||||
//mxd. dynamic light pixel shader pass, dood!
|
||||
float4 ps_lightpass(LitPixelData pd) : COLOR
|
||||
{
|
||||
//is face facing away from light source?
|
||||
// [ZZ] oddly enough pd.normal is not a proper normal, so using dot on it returns rather unexpected results. wrapped in normalize().
|
||||
// update 01.02.2017: offset the equation by 3px back to try to emulate GZDoom's broken visibility check.
|
||||
float diffuseContribution = dot(pd.normal, normalize(lightPosAndRadius.xyz - pd.pos_w + pd.normal*3));
|
||||
if (diffuseContribution < 0 && ignoreNormals < 0.5)
|
||||
clip(-1);
|
||||
diffuseContribution = max(diffuseContribution, 0); // to make sure
|
||||
|
||||
//is pixel in light range?
|
||||
float dist = distance(pd.pos_w, lightPosAndRadius.xyz);
|
||||
if(dist > lightPosAndRadius.w)
|
||||
clip(-1);
|
||||
|
||||
//is pixel tranparent?
|
||||
float4 tcolor = tex2D(texturesamp, pd.uv);
|
||||
tcolor = lerp(tcolor, float4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if(tcolor.a == 0.0f)
|
||||
clip(-1);
|
||||
|
||||
//if it is - calculate color at current pixel
|
||||
float4 lightColorMod = float4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
lightColorMod.rgb = lightColor.rgb * max(lightPosAndRadius.w - dist, 0.0f) / lightPosAndRadius.w;
|
||||
|
||||
if (spotLight > 0.5)
|
||||
{
|
||||
float3 lightDirection = normalize(lightPosAndRadius.xyz - pd.pos_w);
|
||||
float cosDir = dot(lightDirection, lightOrientation);
|
||||
float df = smoothstep(light2Radius.y, light2Radius.x, cosDir);
|
||||
lightColorMod.rgb *= df;
|
||||
}
|
||||
|
||||
if (lightColor.a > 0.979f && lightColor.a < 0.981f) // attenuated light 98%
|
||||
lightColorMod.rgb *= diffuseContribution;
|
||||
if (lightColorMod.r > 0.0f || lightColorMod.g > 0.0f || lightColorMod.b > 0.0f)
|
||||
{
|
||||
lightColorMod.rgb *= lightColor.a;
|
||||
if (lightColor.a > 0.4f) //Normal, vavoom or negative light (or attenuated)
|
||||
lightColorMod *= tcolor;
|
||||
return desaturate(lightColorMod); //Additive light
|
||||
}
|
||||
clip(-1);
|
||||
return lightColorMod; //should never get here
|
||||
}
|
||||
|
||||
//mxd. Vertex skybox shader
|
||||
SkyPixelData vs_skybox(SkyVertexData vd)
|
||||
{
|
||||
SkyPixelData pd;
|
||||
pd.pos = mul(float4(vd.pos, 1.0f), worldviewproj);
|
||||
float3 worldpos = mul(float4(vd.pos, 1.0f), world).xyz;
|
||||
pd.tex = reflect(worldpos - campos.xyz, normalize(mul(skynormal, world).xyz));
|
||||
return pd;
|
||||
}
|
||||
|
||||
//mxd. Pixel skybox shader
|
||||
float4 ps_skybox(SkyPixelData pd) : COLOR
|
||||
{
|
||||
float4 ncolor = texCUBE(skysamp, pd.tex);
|
||||
return float4(highlightcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4f * highlightcolor.a), 1.0f);
|
||||
}
|
||||
|
||||
// Technique for shader model 2.0
|
||||
technique SM20
|
||||
{
|
||||
// Normal
|
||||
pass p0
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_main();
|
||||
PixelShader = compile ps_2_0 ps_main();
|
||||
}
|
||||
|
||||
// Full brightness mode
|
||||
pass p1
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_main();
|
||||
PixelShader = compile ps_2_0 ps_fullbright();
|
||||
}
|
||||
|
||||
// Normal with highlight
|
||||
pass p2
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_main();
|
||||
PixelShader = compile ps_2_0 ps_main_highlight();
|
||||
}
|
||||
|
||||
// Full brightness mode with highlight
|
||||
pass p3
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_main();
|
||||
PixelShader = compile ps_2_0 ps_fullbright_highlight();
|
||||
}
|
||||
|
||||
//mxd. same as p0-p3, but using vertexColor variable
|
||||
// Normal
|
||||
pass p4
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_customvertexcolor();
|
||||
PixelShader = compile ps_2_0 ps_main();
|
||||
}
|
||||
|
||||
//mxd. Skybox shader
|
||||
pass p5
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_skybox();
|
||||
PixelShader = compile ps_2_0 ps_skybox();
|
||||
}
|
||||
|
||||
// Normal with highlight
|
||||
pass p6
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_customvertexcolor();
|
||||
PixelShader = compile ps_2_0 ps_main_highlight();
|
||||
}
|
||||
|
||||
pass p7 {} //mxd. need this only to maintain offset
|
||||
|
||||
//mxd. same as p0-p3, but with fog calculation
|
||||
// Normal
|
||||
pass p8
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_lightpass();
|
||||
PixelShader = compile ps_2_0 ps_main_fog();
|
||||
}
|
||||
|
||||
pass p9 {} //mxd. need this only to maintain offset
|
||||
|
||||
// Normal with highlight
|
||||
pass p10
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_lightpass();
|
||||
PixelShader = compile ps_2_0 ps_main_highlight_fog();
|
||||
}
|
||||
|
||||
pass p11 {} //mxd. need this only to maintain offset
|
||||
|
||||
//mxd. same as p4-p7, but with fog calculation
|
||||
// Normal
|
||||
pass p12
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_customvertexcolor_fog();
|
||||
PixelShader = compile ps_2_0 ps_main_fog();
|
||||
}
|
||||
|
||||
pass p13 {} //mxd. need this only to maintain offset
|
||||
|
||||
// Normal with highlight
|
||||
pass p14
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_customvertexcolor_fog();
|
||||
PixelShader = compile ps_2_0 ps_main_highlight_fog();
|
||||
}
|
||||
|
||||
//mxd. Used to render event lines
|
||||
pass p15
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_main();
|
||||
PixelShader = compile ps_2_0 ps_vertex_color();
|
||||
}
|
||||
|
||||
//mxd. Just fills everything with vertexColor. Used in ThingCage rendering.
|
||||
pass p16
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_customvertexcolor();
|
||||
PixelShader = compile ps_2_0 ps_constant_color();
|
||||
}
|
||||
|
||||
//mxd. Light pass
|
||||
pass p17
|
||||
{
|
||||
VertexShader = compile vs_2_0 vs_lightpass();
|
||||
PixelShader = compile ps_2_0 ps_lightpass();
|
||||
AlphaBlendEnable = true;
|
||||
}
|
||||
}
|
22
Source/Core/Resources/world3d_constant_color.fp
Normal file
22
Source/Core/Resources/world3d_constant_color.fp
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 vertexColor;
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = vertexColor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0f) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
23
Source/Core/Resources/world3d_customvertexcolor.vp
Normal file
23
Source/Core/Resources/world3d_customvertexcolor.vp
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
in vec3 AttrPosition;
|
||||
in vec4 AttrColor;
|
||||
in vec2 AttrUV;
|
||||
in vec3 AttrNormal;
|
||||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
out vec4 viewpos;
|
||||
|
||||
uniform mat4 world;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
uniform vec4 vertexColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
viewpos = view * world * vec4(AttrPosition, 1.0);
|
||||
gl_Position = projection * viewpos;
|
||||
Color = vertexColor;
|
||||
UV = AttrUV;
|
||||
}
|
28
Source/Core/Resources/world3d_customvertexcolor_fog.vp
Normal file
28
Source/Core/Resources/world3d_customvertexcolor_fog.vp
Normal file
|
@ -0,0 +1,28 @@
|
|||
|
||||
in vec3 AttrPosition;
|
||||
in vec4 AttrColor;
|
||||
in vec2 AttrUV;
|
||||
in vec3 AttrNormal;
|
||||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
out vec3 PosW;
|
||||
out vec3 Normal;
|
||||
out vec4 viewpos;
|
||||
|
||||
uniform mat4 world;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 modelnormal;
|
||||
|
||||
uniform vec4 vertexColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
viewpos = view * world * vec4(AttrPosition, 1.0);
|
||||
gl_Position = projection * viewpos;
|
||||
PosW = (world * vec4(AttrPosition, 1.0)).xyz;
|
||||
Color = vertexColor;
|
||||
UV = AttrUV;
|
||||
Normal = normalize((modelnormal * vec4(AttrNormal, 1.0)).xyz);
|
||||
}
|
27
Source/Core/Resources/world3d_fullbright.fp
Normal file
27
Source/Core/Resources/world3d_fullbright.fp
Normal file
|
@ -0,0 +1,27 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 stencilColor;
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tcolor = texture(texture1, UV);
|
||||
tcolor = mix(tcolor, vec4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
tcolor.a *= Color.a;
|
||||
FragColor = tcolor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0f) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
37
Source/Core/Resources/world3d_fullbright_highlight.fp
Normal file
37
Source/Core/Resources/world3d_fullbright_highlight.fp
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 highlightcolor;
|
||||
uniform vec4 stencilColor;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tcolor = texture(texture1, UV);
|
||||
tcolor = mix(tcolor, vec4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if(tcolor.a == 0.0)
|
||||
{
|
||||
FragColor = tcolor;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Blend texture color and vertex color
|
||||
vec4 ncolor = tcolor * Color;
|
||||
|
||||
FragColor = vec4(highlightcolor.rgb * highlightcolor.a + (tcolor.rgb - 0.4 * highlightcolor.a), max(Color.a + 0.25, 0.5));
|
||||
}
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0f) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
74
Source/Core/Resources/world3d_lightpass.fp
Normal file
74
Source/Core/Resources/world3d_lightpass.fp
Normal file
|
@ -0,0 +1,74 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec3 PosW;
|
||||
in vec3 Normal;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 stencilColor;
|
||||
uniform vec4 lightPosAndRadius;
|
||||
uniform vec3 lightOrientation; // this is a vector that points in light's direction
|
||||
uniform vec2 light2Radius; // this is used with spotlights
|
||||
uniform vec4 lightColor;
|
||||
uniform float ignoreNormals; // ignore normals in lighting equation. used for non-attenuated lights on models.
|
||||
uniform float spotLight; // use lightOrientation
|
||||
uniform float desaturation;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
|
||||
vec4 desaturate(vec4 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return vec4(mix(texel.rgb, vec3(gray), desaturation), texel.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
//is face facing away from light source?
|
||||
// update 01.02.2017: offset the equation by 3px back to try to emulate GZDoom's broken visibility check.
|
||||
float diffuseContribution = dot(Normal, normalize(lightPosAndRadius.xyz - PosW + Normal * 3.0));
|
||||
if (diffuseContribution < 0.0 && ignoreNormals < 0.5)
|
||||
discard;
|
||||
diffuseContribution = max(diffuseContribution, 0.0); // to make sure
|
||||
|
||||
//is pixel in light range?
|
||||
float dist = distance(PosW, lightPosAndRadius.xyz);
|
||||
if (dist > lightPosAndRadius.w)
|
||||
discard;
|
||||
|
||||
//is pixel tranparent?
|
||||
vec4 tcolor = texture(texture1, UV);
|
||||
tcolor = mix(tcolor, vec4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if (tcolor.a == 0.0)
|
||||
discard;
|
||||
|
||||
//if it is - calculate color at current pixel
|
||||
vec4 lightColorMod = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
lightColorMod.rgb = lightColor.rgb * max(lightPosAndRadius.w - dist, 0.0) / lightPosAndRadius.w;
|
||||
|
||||
if (spotLight > 0.5)
|
||||
{
|
||||
vec3 lightDirection = normalize(lightPosAndRadius.xyz - PosW);
|
||||
float cosDir = dot(lightDirection, lightOrientation);
|
||||
float df = smoothstep(light2Radius.y, light2Radius.x, cosDir);
|
||||
lightColorMod.rgb *= df;
|
||||
}
|
||||
|
||||
if (lightColor.a > 0.979f && lightColor.a < 0.981f) // attenuated light 98%
|
||||
lightColorMod.rgb *= diffuseContribution;
|
||||
|
||||
if (lightColorMod.r <= 0.0 && lightColorMod.g <= 0.0 && lightColorMod.b <= 0.0)
|
||||
discard;
|
||||
|
||||
lightColorMod.rgb *= lightColor.a;
|
||||
if (lightColor.a > 0.4) //Normal, vavoom or negative light (or attenuated)
|
||||
lightColorMod *= tcolor;
|
||||
|
||||
FragColor = desaturate(lightColorMod); //Additive light
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
}
|
26
Source/Core/Resources/world3d_lightpass.vp
Normal file
26
Source/Core/Resources/world3d_lightpass.vp
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
in vec3 AttrPosition;
|
||||
in vec4 AttrColor;
|
||||
in vec2 AttrUV;
|
||||
in vec3 AttrNormal;
|
||||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
out vec3 PosW;
|
||||
out vec3 Normal;
|
||||
out vec4 viewpos;
|
||||
|
||||
uniform mat4 world;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 modelnormal;
|
||||
|
||||
void main()
|
||||
{
|
||||
viewpos = view * world * vec4(AttrPosition, 1.0);
|
||||
gl_Position = projection * viewpos;
|
||||
PosW = (world * vec4(AttrPosition, 1.0)).xyz;
|
||||
Color = AttrColor;
|
||||
UV = AttrUV;
|
||||
Normal = normalize((modelnormal * vec4(AttrNormal, 1.0)).xyz);
|
||||
}
|
33
Source/Core/Resources/world3d_main.fp
Normal file
33
Source/Core/Resources/world3d_main.fp
Normal file
|
@ -0,0 +1,33 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 stencilColor;
|
||||
uniform float desaturation;
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
|
||||
vec4 desaturate(vec4 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return vec4(mix(texel.rgb, vec3(gray), desaturation), texel.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tcolor = texture(texture1, UV);
|
||||
tcolor = mix(tcolor, vec4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
FragColor = desaturate(tcolor * Color);
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0f) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
21
Source/Core/Resources/world3d_main.vp
Normal file
21
Source/Core/Resources/world3d_main.vp
Normal file
|
@ -0,0 +1,21 @@
|
|||
|
||||
in vec3 AttrPosition;
|
||||
in vec4 AttrColor;
|
||||
in vec2 AttrUV;
|
||||
in vec3 AttrNormal;
|
||||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
out vec4 viewpos;
|
||||
|
||||
uniform mat4 world;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
void main()
|
||||
{
|
||||
viewpos = view * world * vec4(AttrPosition, 1.0);
|
||||
gl_Position = projection * viewpos;
|
||||
Color = AttrColor;
|
||||
UV = AttrUV;
|
||||
}
|
54
Source/Core/Resources/world3d_main_fog.fp
Normal file
54
Source/Core/Resources/world3d_main_fog.fp
Normal file
|
@ -0,0 +1,54 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec3 PosW;
|
||||
in vec3 Normal;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 stencilColor;
|
||||
uniform vec4 lightColor;
|
||||
uniform float desaturation;
|
||||
uniform vec4 campos; //w is set to fade factor (distance, at wich fog color completely overrides pixel color)
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
|
||||
// This adds fog color to current pixel color
|
||||
vec4 getFogColor(vec4 color)
|
||||
{
|
||||
float fogdist = max(16.0, distance(PosW, campos.xyz));
|
||||
float fogfactor = exp2(campos.w * fogdist);
|
||||
|
||||
color.rgb = mix(lightColor.rgb, color.rgb, fogfactor);
|
||||
return color;
|
||||
}
|
||||
|
||||
vec4 desaturate(vec4 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return vec4(mix(texel.rgb, vec3(gray), desaturation), texel.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tcolor = texture(texture1, UV);
|
||||
tcolor = mix(tcolor, vec4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if (tcolor.a == 0.0)
|
||||
{
|
||||
FragColor = tcolor;
|
||||
}
|
||||
else
|
||||
{
|
||||
FragColor = desaturate(getFogColor(tcolor * Color));
|
||||
}
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0f) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
44
Source/Core/Resources/world3d_main_highlight.fp
Normal file
44
Source/Core/Resources/world3d_main_highlight.fp
Normal file
|
@ -0,0 +1,44 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 highlightcolor;
|
||||
uniform vec4 stencilColor;
|
||||
uniform float desaturation;
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
|
||||
vec4 desaturate(vec4 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return vec4(mix(texel.rgb, vec3(gray), desaturation), texel.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tcolor = texture(texture1, UV);
|
||||
tcolor = mix(tcolor, vec4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if (tcolor.a == 0.0)
|
||||
{
|
||||
FragColor = tcolor;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Blend texture color and vertex color
|
||||
vec4 ncolor = desaturate(tcolor * Color);
|
||||
|
||||
FragColor = vec4(highlightcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4 * highlightcolor.a), max(Color.a + 0.25, 0.5));
|
||||
}
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0f) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
58
Source/Core/Resources/world3d_main_highlight_fog.fp
Normal file
58
Source/Core/Resources/world3d_main_highlight_fog.fp
Normal file
|
@ -0,0 +1,58 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec3 PosW;
|
||||
in vec3 Normal;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 highlightcolor;
|
||||
uniform vec4 stencilColor;
|
||||
uniform vec4 lightColor;
|
||||
uniform float desaturation;
|
||||
uniform vec4 campos; //w is set to fade factor (distance, at wich fog color completely overrides pixel color)
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
|
||||
// This adds fog color to current pixel color
|
||||
vec4 getFogColor(vec4 color)
|
||||
{
|
||||
float fogdist = max(16.0, distance(PosW, campos.xyz));
|
||||
float fogfactor = exp2(campos.w * fogdist);
|
||||
|
||||
color.rgb = mix(lightColor.rgb, color.rgb, fogfactor);
|
||||
return color;
|
||||
}
|
||||
|
||||
vec4 desaturate(vec4 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return vec4(mix(texel.rgb, vec3(gray), desaturation), texel.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tcolor = texture(texture1, UV);
|
||||
tcolor = mix(tcolor, vec4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if (tcolor.a == 0.0)
|
||||
{
|
||||
FragColor = tcolor;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Blend texture color and vertex color
|
||||
vec4 ncolor = desaturate(getFogColor(tcolor * Color));
|
||||
|
||||
FragColor = vec4(highlightcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4 * highlightcolor.a), max(ncolor.a + 0.25, 0.5));
|
||||
}
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0f) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
24
Source/Core/Resources/world3d_skybox.fp
Normal file
24
Source/Core/Resources/world3d_skybox.fp
Normal file
|
@ -0,0 +1,24 @@
|
|||
|
||||
in vec3 Tex;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 highlightcolor;
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
uniform samplerCube texture1;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 ncolor = texture(texture1, Tex);
|
||||
FragColor = vec4(highlightcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4 * highlightcolor.a), 1.0);
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0f) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
22
Source/Core/Resources/world3d_skybox.vp
Normal file
22
Source/Core/Resources/world3d_skybox.vp
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
in vec3 AttrPosition;
|
||||
in vec2 AttrUV;
|
||||
|
||||
out vec3 Tex;
|
||||
out vec4 viewpos;
|
||||
|
||||
uniform mat4 world;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
uniform vec4 campos; //w is set to fade factor (distance, at wich fog color completely overrides pixel color)
|
||||
|
||||
void main()
|
||||
{
|
||||
viewpos = view * world * vec4(AttrPosition, 1.0);
|
||||
gl_Position = projection * viewpos;
|
||||
vec3 worldpos = (world * vec4(AttrPosition, 1.0)).xyz;
|
||||
vec4 skynormal = vec4(0.0, 1.0, 0.0, 0.0);
|
||||
vec3 normal = normalize((world * skynormal).xyz);
|
||||
Tex = reflect(worldpos - campos.xyz, normal);
|
||||
}
|
20
Source/Core/Resources/world3d_vertex_color.fp
Normal file
20
Source/Core/Resources/world3d_vertex_color.fp
Normal file
|
@ -0,0 +1,20 @@
|
|||
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = Color;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0f) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
|
@ -109,6 +109,12 @@ RenderDevice::~RenderDevice()
|
|||
}
|
||||
}
|
||||
|
||||
void RenderDevice::DeclareShader(ShaderName shadername, const char* vertexshader, const char* fragmentshader)
|
||||
{
|
||||
if (!mContextIsCurrent) Context->MakeCurrent();
|
||||
mShaderManager->DeclareShader(shadername, vertexshader, fragmentshader);
|
||||
}
|
||||
|
||||
void RenderDevice::SetVertexBuffer(VertexBuffer* buffer)
|
||||
{
|
||||
if (buffer != nullptr)
|
||||
|
@ -859,6 +865,11 @@ const char* RenderDevice_GetError(RenderDevice* device)
|
|||
return device->GetError();
|
||||
}
|
||||
|
||||
void RenderDevice_DeclareShader(RenderDevice* device, ShaderName name, const char* vertexshader, const char* fragmentshader)
|
||||
{
|
||||
device->DeclareShader(name, vertexshader, fragmentshader);
|
||||
}
|
||||
|
||||
void RenderDevice_SetShader(RenderDevice* device, ShaderName name)
|
||||
{
|
||||
device->SetShader(name);
|
||||
|
|
|
@ -21,35 +21,7 @@ enum class ShaderFlags : int { None, Debug };
|
|||
enum class PrimitiveType : int { LineList, TriangleList, TriangleStrip };
|
||||
enum class TextureFilter : int { None, Point, Linear, Anisotropic };
|
||||
|
||||
enum class ShaderName
|
||||
{
|
||||
display2d_fsaa,
|
||||
display2d_normal,
|
||||
display2d_fullbright,
|
||||
things2d_thing,
|
||||
things2d_sprite,
|
||||
things2d_fill,
|
||||
plotter,
|
||||
world3d_main,
|
||||
world3d_fullbright,
|
||||
world3d_main_highlight,
|
||||
world3d_fullbright_highlight,
|
||||
world3d_main_vertexcolor,
|
||||
world3d_skybox,
|
||||
world3d_main_highlight_vertexcolor,
|
||||
world3d_p7,
|
||||
world3d_main_fog,
|
||||
world3d_p9,
|
||||
world3d_main_highlight_fog,
|
||||
world3d_p11,
|
||||
world3d_main_fog_vertexcolor,
|
||||
world3d_p13,
|
||||
world3d_main_highlight_fog_vertexcolor,
|
||||
world3d_vertex_color,
|
||||
world3d_constant_color,
|
||||
world3d_lightpass,
|
||||
count
|
||||
};
|
||||
typedef int ShaderName;
|
||||
|
||||
enum class UniformName : int
|
||||
{
|
||||
|
@ -82,6 +54,7 @@ public:
|
|||
RenderDevice(void* disp, void* window);
|
||||
~RenderDevice();
|
||||
|
||||
void DeclareShader(ShaderName shadername, const char* vertexshader, const char* fragmentshader);
|
||||
void SetShader(ShaderName name);
|
||||
void SetUniform(UniformName name, const void* values, int count);
|
||||
void SetVertexBuffer(VertexBuffer* buffer);
|
||||
|
@ -175,7 +148,7 @@ public:
|
|||
std::unique_ptr<SharedVertexBuffer> mSharedVertexBuffers[2];
|
||||
|
||||
std::unique_ptr<ShaderManager> mShaderManager;
|
||||
ShaderName mShaderName = ShaderName::display2d_normal;
|
||||
ShaderName mShaderName = {};
|
||||
|
||||
enum class UniformType { Matrix, Vec4f, Vec3f, Vec2f, Float };
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ enum class DeclarationUsage : int32_t { Position, Color, TextureCoordinate, Norm
|
|||
class Shader
|
||||
{
|
||||
public:
|
||||
Shader() = default;
|
||||
void ReleaseResources();
|
||||
|
||||
void Setup(const std::string& identifier, const std::string& vertexShader, const std::string& fragmentShader, bool alphatest);
|
||||
|
@ -35,7 +34,4 @@ private:
|
|||
GLuint mVertexShader = 0;
|
||||
GLuint mFragmentShader = 0;
|
||||
std::string mErrors;
|
||||
|
||||
Shader(const Shader&) = delete;
|
||||
Shader& operator=(const Shader&) = delete;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,144 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
static const char* display2D_vs = R"(
|
||||
in vec3 AttrPosition;
|
||||
in vec4 AttrColor;
|
||||
in vec2 AttrUV;
|
||||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
|
||||
uniform mat4 projection;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = projection * vec4(AttrPosition, 1.0);
|
||||
Color = AttrColor;
|
||||
UV = AttrUV;
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* display2D_ps_fsaa = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
// Render settings
|
||||
// x = texel width
|
||||
// y = texel height
|
||||
// z = FSAA blend factor
|
||||
// w = transparency
|
||||
uniform vec4 rendersettings;
|
||||
uniform float desaturation;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
// This blends the max of 2 pixels
|
||||
vec4 addcolor(vec4 c1, vec4 c2)
|
||||
{
|
||||
return vec4(
|
||||
max(c1.r, c2.r),
|
||||
max(c1.g, c2.g),
|
||||
max(c1.b, c2.b),
|
||||
clamp(c1.a + c2.a * 0.5, 0.0, 1.0));
|
||||
}
|
||||
|
||||
vec3 desaturate(vec3 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return mix(texel, vec3(gray), desaturation);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 c = texture(texture1, UV);
|
||||
|
||||
// If this pixel is not drawn on...
|
||||
if(c.a < 0.1)
|
||||
{
|
||||
// Mix the colors of nearby pixels
|
||||
vec4 n = vec4(0.0);
|
||||
n = addcolor(n, texture(texture1, vec2(UV.x + rendersettings.x, UV.y)));
|
||||
n = addcolor(n, texture(texture1, vec2(UV.x - rendersettings.x, UV.y)));
|
||||
n = addcolor(n, texture(texture1, vec2(UV.x, UV.y + rendersettings.y)));
|
||||
n = addcolor(n, texture(texture1, vec2(UV.x, UV.y - rendersettings.y)));
|
||||
|
||||
FragColor = vec4(desaturate(n.rgb), n.a * rendersettings.z * rendersettings.w);
|
||||
}
|
||||
else
|
||||
{
|
||||
FragColor = vec4(desaturate(c.rgb), c.a * rendersettings.w) * Color;
|
||||
}
|
||||
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
|
||||
const char* display2D_ps_normal = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
// Render settings
|
||||
// x = texel width
|
||||
// y = texel height
|
||||
// z = FSAA blend factor
|
||||
// w = transparency
|
||||
uniform vec4 rendersettings;
|
||||
uniform float desaturation;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
vec3 desaturate(vec3 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return mix(texel, vec3(gray), desaturation);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 c = texture(texture1, UV);
|
||||
FragColor = vec4(desaturate(c.rgb), c.a * rendersettings.w) * Color;
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
|
||||
const char* display2D_ps_fullbright = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
// Render settings
|
||||
// x = texel width
|
||||
// y = texel height
|
||||
// z = FSAA blend factor
|
||||
// w = transparency
|
||||
uniform vec4 rendersettings;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 c = texture(texture1, UV);
|
||||
FragColor = vec4(c.rgb, c.a * rendersettings.w);
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
}
|
||||
)";
|
|
@ -1,85 +1,22 @@
|
|||
|
||||
#include "Precomp.h"
|
||||
#include "ShaderManager.h"
|
||||
#include "ShaderDisplay2D.h"
|
||||
#include "ShaderThings2D.h"
|
||||
#include "ShaderWorld3D.h"
|
||||
#include "ShaderPlotter.h"
|
||||
#include <stdexcept>
|
||||
|
||||
struct ShaderPair { const char* vs; const char* ps; };
|
||||
|
||||
static const ShaderPair ShaderSources[(int)ShaderName::count] = {
|
||||
{ display2D_vs, display2D_ps_fsaa },
|
||||
{ display2D_vs, display2D_ps_normal },
|
||||
{ display2D_vs, display2D_ps_fullbright },
|
||||
{ things2D_vs, things2D_ps_thing },
|
||||
{ things2D_vs, things2D_ps_sprite },
|
||||
{ things2D_vs, things2D_ps_fill },
|
||||
{ plotter_vs, plotter_ps },
|
||||
{ world3D_vs_main, world3D_ps_main },
|
||||
{ world3D_vs_main, world3D_ps_fullbright },
|
||||
{ world3D_vs_main, world3D_ps_main_highlight },
|
||||
{ world3D_vs_main, world3D_ps_fullbright_highlight },
|
||||
{ world3D_vs_customvertexcolor, world3D_ps_main },
|
||||
{ world3D_vs_skybox, world3D_ps_skybox },
|
||||
{ world3D_vs_customvertexcolor, world3D_ps_main_highlight },
|
||||
{ nullptr, nullptr },
|
||||
{ world3D_vs_lightpass, world3D_ps_main_fog },
|
||||
{ nullptr, nullptr },
|
||||
{ world3D_vs_lightpass, world3D_ps_main_highlight_fog },
|
||||
{ nullptr, nullptr },
|
||||
{ world3D_vs_customvertexcolor_fog, world3D_ps_main_fog },
|
||||
{ nullptr, nullptr },
|
||||
{ world3D_vs_customvertexcolor_fog, world3D_ps_main_highlight_fog },
|
||||
{ world3D_vs_main, world3D_ps_vertex_color },
|
||||
{ world3D_vs_customvertexcolor, world3D_ps_constant_color },
|
||||
{ world3D_vs_lightpass, world3D_ps_lightpass }
|
||||
};
|
||||
|
||||
static const std::string ShaderNames[(int)ShaderName::count] = {
|
||||
"display2d_fsaa",
|
||||
"display2d_normal",
|
||||
"display2d_fullbright",
|
||||
"things2d_thing",
|
||||
"things2d_sprite",
|
||||
"things2d_fill",
|
||||
"plotter",
|
||||
"world3d_main",
|
||||
"world3d_fullbright",
|
||||
"world3d_main_highlight",
|
||||
"world3d_fullbright_highlight",
|
||||
"world3d_main_vertexcolor",
|
||||
"world3d_skybox",
|
||||
"world3d_main_highlight_vertexcolor",
|
||||
"world3d_p7",
|
||||
"world3d_main_fog",
|
||||
"world3d_p9",
|
||||
"world3d_main_highlight_fog",
|
||||
"world3d_p11",
|
||||
"world3d_main_fog_vertexcolor",
|
||||
"world3d_p13",
|
||||
"world3d_main_highlight_fog_vertexcolor",
|
||||
"world3d_vertex_color",
|
||||
"world3d_constant_color",
|
||||
"world3d_lightpass",
|
||||
};
|
||||
|
||||
ShaderManager::ShaderManager()
|
||||
void ShaderManager::DeclareShader(int i, const char* vs, const char* ps)
|
||||
{
|
||||
for (int i = 0; i < (int)ShaderName::count; i++)
|
||||
if (Shaders.size() <= (size_t)i)
|
||||
{
|
||||
if (ShaderSources[i].vs && ShaderSources[i].ps)
|
||||
{
|
||||
Shaders[i].Setup(ShaderNames[i], ShaderSources[i].vs, ShaderSources[i].ps, false);
|
||||
AlphaTestShaders[i].Setup(ShaderNames[i], ShaderSources[i].vs, ShaderSources[i].ps, true);
|
||||
}
|
||||
Shaders.resize((size_t)i + 1);
|
||||
AlphaTestShaders.resize((size_t)i + 1);
|
||||
}
|
||||
|
||||
Shaders[i].Setup(vs, ps, false);
|
||||
AlphaTestShaders[i].Setup(vs, ps, true);
|
||||
}
|
||||
|
||||
void ShaderManager::ReleaseResources()
|
||||
{
|
||||
for (int i = 0; i < (int)ShaderName::count; i++)
|
||||
for (size_t i = 0; i < Shaders.size(); i++)
|
||||
{
|
||||
Shaders[i].ReleaseResources();
|
||||
AlphaTestShaders[i].ReleaseResources();
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
class ShaderManager
|
||||
{
|
||||
public:
|
||||
ShaderManager();
|
||||
void ReleaseResources();
|
||||
|
||||
Shader AlphaTestShaders[(int)ShaderName::count];
|
||||
Shader Shaders[(int)ShaderName::count];
|
||||
void DeclareShader(int index, const char* vs, const char* ps);
|
||||
|
||||
std::vector<Shader> AlphaTestShaders;
|
||||
std::vector<Shader> Shaders;
|
||||
};
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
static const char* plotter_vs = R"(
|
||||
in vec3 AttrPosition;
|
||||
in vec4 AttrColor;
|
||||
in vec2 AttrUV;
|
||||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
out vec2 Pos;
|
||||
|
||||
uniform mat4 projection;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = projection * vec4(AttrPosition, 1.0);
|
||||
Color = AttrColor;
|
||||
UV = AttrUV;
|
||||
Pos = AttrPosition.xy;
|
||||
}
|
||||
)";
|
||||
|
||||
const char* plotter_ps = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec2 Pos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 rendersettings;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (UV.x < 0)
|
||||
{
|
||||
float yFrac = -(UV.x + 1);
|
||||
|
||||
vec2 tPos = vec2(
|
||||
gl_FragCoord.x,
|
||||
gl_FragCoord.y
|
||||
);
|
||||
|
||||
// line stipple
|
||||
if (mod(floor(mix(tPos.x, tPos.y, yFrac)), 2.0) > 0.0)
|
||||
discard;
|
||||
}
|
||||
|
||||
// line smoothing
|
||||
float linewidth = 3.0;
|
||||
float falloff = 1.8; //1.5..2.5
|
||||
float centerdist = abs(UV.y);
|
||||
float a = pow(clamp((linewidth - centerdist) / linewidth, 0.0, 1.0), falloff);
|
||||
|
||||
FragColor = vec4(Color.rgb, Color.a * a);
|
||||
}
|
||||
)";
|
|
@ -1,115 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
static const char* things2D_vs = R"(
|
||||
in vec3 AttrPosition;
|
||||
in vec4 AttrColor;
|
||||
in vec2 AttrUV;
|
||||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
|
||||
uniform mat4 projection;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = projection * vec4(AttrPosition, 1.0);
|
||||
Color = AttrColor;
|
||||
UV = AttrUV;
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* things2D_ps_sprite = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
// Render settings
|
||||
// w = transparency
|
||||
uniform vec4 rendersettings;
|
||||
uniform float desaturation;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
vec3 desaturate(vec3 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return mix(texel, vec3(gray), desaturation);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// Take this pixel's color
|
||||
vec4 c = texture(texture1, UV);
|
||||
|
||||
// Modulate it by selection color
|
||||
if (Color.a > 0.0)
|
||||
{
|
||||
vec3 cr = desaturate(c.rgb);
|
||||
FragColor = vec4((cr.r + Color.r) / 2.0, (cr.g + Color.g) / 2.0, (cr.b + Color.b) / 2.0, c.a * rendersettings.w * Color.a);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Or leave it as it is
|
||||
FragColor = vec4(desaturate(c.rgb), c.a * rendersettings.w);
|
||||
}
|
||||
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* things2D_ps_thing = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
// Render settings
|
||||
// w = transparency
|
||||
uniform vec4 rendersettings;
|
||||
uniform float desaturation;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
uniform vec4 texturefactor;
|
||||
|
||||
vec3 desaturate(vec3 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return mix(texel, vec3(gray), desaturation);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 c = texture(texture1, UV);
|
||||
FragColor = vec4(desaturate(c.rgb), c.a * rendersettings.w) * Color;
|
||||
|
||||
FragColor *= texturefactor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* things2D_ps_fill = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 fillColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = fillColor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
}
|
||||
)";
|
|
@ -1,544 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
static const char* world3D_vs_main = R"(
|
||||
in vec3 AttrPosition;
|
||||
in vec4 AttrColor;
|
||||
in vec2 AttrUV;
|
||||
in vec3 AttrNormal;
|
||||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
out vec4 viewpos;
|
||||
|
||||
uniform mat4 world;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
void main()
|
||||
{
|
||||
viewpos = view * world * vec4(AttrPosition, 1.0);
|
||||
gl_Position = projection * viewpos;
|
||||
Color = AttrColor;
|
||||
UV = AttrUV;
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* world3D_vs_customvertexcolor = R"(
|
||||
in vec3 AttrPosition;
|
||||
in vec4 AttrColor;
|
||||
in vec2 AttrUV;
|
||||
in vec3 AttrNormal;
|
||||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
out vec4 viewpos;
|
||||
|
||||
uniform mat4 world;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
uniform vec4 vertexColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
viewpos = view * world * vec4(AttrPosition, 1.0);
|
||||
gl_Position = projection * viewpos;
|
||||
Color = vertexColor;
|
||||
UV = AttrUV;
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* world3D_vs_customvertexcolor_fog = R"(
|
||||
in vec3 AttrPosition;
|
||||
in vec4 AttrColor;
|
||||
in vec2 AttrUV;
|
||||
in vec3 AttrNormal;
|
||||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
out vec3 PosW;
|
||||
out vec3 Normal;
|
||||
out vec4 viewpos;
|
||||
|
||||
uniform mat4 world;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 modelnormal;
|
||||
|
||||
uniform vec4 vertexColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
viewpos = view * world * vec4(AttrPosition, 1.0);
|
||||
gl_Position = projection * viewpos;
|
||||
PosW = (world * vec4(AttrPosition, 1.0)).xyz;
|
||||
Color = vertexColor;
|
||||
UV = AttrUV;
|
||||
Normal = normalize((modelnormal * vec4(AttrNormal, 1.0)).xyz);
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* world3D_vs_lightpass = R"(
|
||||
in vec3 AttrPosition;
|
||||
in vec4 AttrColor;
|
||||
in vec2 AttrUV;
|
||||
in vec3 AttrNormal;
|
||||
|
||||
out vec4 Color;
|
||||
out vec2 UV;
|
||||
out vec3 PosW;
|
||||
out vec3 Normal;
|
||||
out vec4 viewpos;
|
||||
|
||||
uniform mat4 world;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform mat4 modelnormal;
|
||||
|
||||
void main()
|
||||
{
|
||||
viewpos = view * world * vec4(AttrPosition, 1.0);
|
||||
gl_Position = projection * viewpos;
|
||||
PosW = (world * vec4(AttrPosition, 1.0)).xyz;
|
||||
Color = AttrColor;
|
||||
UV = AttrUV;
|
||||
Normal = normalize((modelnormal * vec4(AttrNormal, 1.0)).xyz);
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* world3D_vs_skybox = R"(
|
||||
in vec3 AttrPosition;
|
||||
in vec2 AttrUV;
|
||||
|
||||
out vec3 Tex;
|
||||
out vec4 viewpos;
|
||||
|
||||
uniform mat4 world;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
|
||||
uniform vec4 campos; //w is set to fade factor (distance, at wich fog color completely overrides pixel color)
|
||||
|
||||
void main()
|
||||
{
|
||||
viewpos = view * world * vec4(AttrPosition, 1.0);
|
||||
gl_Position = projection * viewpos;
|
||||
vec3 worldpos = (world * vec4(AttrPosition, 1.0)).xyz;
|
||||
vec4 skynormal = vec4(0.0, 1.0, 0.0, 0.0);
|
||||
vec3 normal = normalize((world * skynormal).xyz);
|
||||
Tex = reflect(worldpos - campos.xyz, normal);
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* world3D_ps_main = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 stencilColor;
|
||||
uniform float desaturation;
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
|
||||
vec4 desaturate(vec4 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return vec4(mix(texel.rgb, vec3(gray), desaturation), texel.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tcolor = texture(texture1, UV);
|
||||
tcolor = mix(tcolor, vec4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
FragColor = desaturate(tcolor * Color);
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* world3D_ps_fullbright = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 stencilColor;
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tcolor = texture(texture1, UV);
|
||||
tcolor = mix(tcolor, vec4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
tcolor.a *= Color.a;
|
||||
FragColor = tcolor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* world3D_ps_main_highlight = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 highlightcolor;
|
||||
uniform vec4 stencilColor;
|
||||
uniform float desaturation;
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
|
||||
vec4 desaturate(vec4 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return vec4(mix(texel.rgb, vec3(gray), desaturation), texel.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tcolor = texture(texture1, UV);
|
||||
tcolor = mix(tcolor, vec4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if (tcolor.a == 0.0)
|
||||
{
|
||||
FragColor = tcolor;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Blend texture color and vertex color
|
||||
vec4 ncolor = desaturate(tcolor * Color);
|
||||
|
||||
FragColor = vec4(highlightcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4 * highlightcolor.a), max(Color.a + 0.25, 0.5));
|
||||
}
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* world3D_ps_fullbright_highlight = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 highlightcolor;
|
||||
uniform vec4 stencilColor;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tcolor = texture(texture1, UV);
|
||||
tcolor = mix(tcolor, vec4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if(tcolor.a == 0.0)
|
||||
{
|
||||
FragColor = tcolor;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Blend texture color and vertex color
|
||||
vec4 ncolor = tcolor * Color;
|
||||
|
||||
FragColor = vec4(highlightcolor.rgb * highlightcolor.a + (tcolor.rgb - 0.4 * highlightcolor.a), max(Color.a + 0.25, 0.5));
|
||||
}
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* world3D_ps_main_fog = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec3 PosW;
|
||||
in vec3 Normal;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 stencilColor;
|
||||
uniform vec4 lightColor;
|
||||
uniform float desaturation;
|
||||
uniform vec4 campos; //w is set to fade factor (distance, at wich fog color completely overrides pixel color)
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
|
||||
// This adds fog color to current pixel color
|
||||
vec4 getFogColor(vec4 color)
|
||||
{
|
||||
float fogdist = max(16.0, distance(PosW, campos.xyz));
|
||||
float fogfactor = exp2(campos.w * fogdist);
|
||||
|
||||
color.rgb = mix(lightColor.rgb, color.rgb, fogfactor);
|
||||
return color;
|
||||
}
|
||||
|
||||
vec4 desaturate(vec4 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return vec4(mix(texel.rgb, vec3(gray), desaturation), texel.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tcolor = texture(texture1, UV);
|
||||
tcolor = mix(tcolor, vec4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if (tcolor.a == 0.0)
|
||||
{
|
||||
FragColor = tcolor;
|
||||
}
|
||||
else
|
||||
{
|
||||
FragColor = desaturate(getFogColor(tcolor * Color));
|
||||
}
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* world3D_ps_main_highlight_fog = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec3 PosW;
|
||||
in vec3 Normal;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 highlightcolor;
|
||||
uniform vec4 stencilColor;
|
||||
uniform vec4 lightColor;
|
||||
uniform float desaturation;
|
||||
uniform vec4 campos; //w is set to fade factor (distance, at wich fog color completely overrides pixel color)
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
|
||||
// This adds fog color to current pixel color
|
||||
vec4 getFogColor(vec4 color)
|
||||
{
|
||||
float fogdist = max(16.0, distance(PosW, campos.xyz));
|
||||
float fogfactor = exp2(campos.w * fogdist);
|
||||
|
||||
color.rgb = mix(lightColor.rgb, color.rgb, fogfactor);
|
||||
return color;
|
||||
}
|
||||
|
||||
vec4 desaturate(vec4 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return vec4(mix(texel.rgb, vec3(gray), desaturation), texel.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tcolor = texture(texture1, UV);
|
||||
tcolor = mix(tcolor, vec4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if (tcolor.a == 0.0)
|
||||
{
|
||||
FragColor = tcolor;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Blend texture color and vertex color
|
||||
vec4 ncolor = desaturate(getFogColor(tcolor * Color));
|
||||
|
||||
FragColor = vec4(highlightcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4 * highlightcolor.a), max(ncolor.a + 0.25, 0.5));
|
||||
}
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* world3D_ps_constant_color = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 vertexColor;
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = vertexColor;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* world3D_ps_vertex_color = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = Color;
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* world3D_ps_lightpass = R"(
|
||||
in vec4 Color;
|
||||
in vec2 UV;
|
||||
in vec3 PosW;
|
||||
in vec3 Normal;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 stencilColor;
|
||||
uniform vec4 lightPosAndRadius;
|
||||
uniform vec3 lightOrientation; // this is a vector that points in light's direction
|
||||
uniform vec2 light2Radius; // this is used with spotlights
|
||||
uniform vec4 lightColor;
|
||||
uniform float ignoreNormals; // ignore normals in lighting equation. used for non-attenuated lights on models.
|
||||
uniform float spotLight; // use lightOrientation
|
||||
uniform float desaturation;
|
||||
|
||||
uniform sampler2D texture1;
|
||||
|
||||
vec4 desaturate(vec4 texel)
|
||||
{
|
||||
float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14);
|
||||
return vec4(mix(texel.rgb, vec3(gray), desaturation), texel.a);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
//is face facing away from light source?
|
||||
// update 01.02.2017: offset the equation by 3px back to try to emulate GZDoom's broken visibility check.
|
||||
float diffuseContribution = dot(Normal, normalize(lightPosAndRadius.xyz - PosW + Normal * 3.0));
|
||||
if (diffuseContribution < 0.0 && ignoreNormals < 0.5)
|
||||
discard;
|
||||
diffuseContribution = max(diffuseContribution, 0.0); // to make sure
|
||||
|
||||
//is pixel in light range?
|
||||
float dist = distance(PosW, lightPosAndRadius.xyz);
|
||||
if (dist > lightPosAndRadius.w)
|
||||
discard;
|
||||
|
||||
//is pixel tranparent?
|
||||
vec4 tcolor = texture(texture1, UV);
|
||||
tcolor = mix(tcolor, vec4(stencilColor.rgb, tcolor.a), stencilColor.a);
|
||||
if (tcolor.a == 0.0)
|
||||
discard;
|
||||
|
||||
//if it is - calculate color at current pixel
|
||||
vec4 lightColorMod = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
lightColorMod.rgb = lightColor.rgb * max(lightPosAndRadius.w - dist, 0.0) / lightPosAndRadius.w;
|
||||
|
||||
if (spotLight > 0.5)
|
||||
{
|
||||
vec3 lightDirection = normalize(lightPosAndRadius.xyz - PosW);
|
||||
float cosDir = dot(lightDirection, lightOrientation);
|
||||
float df = smoothstep(light2Radius.y, light2Radius.x, cosDir);
|
||||
lightColorMod.rgb *= df;
|
||||
}
|
||||
|
||||
if (lightColor.a > 0.979 && lightColor.a < 0.981) // attenuated light 98%
|
||||
lightColorMod.rgb *= diffuseContribution;
|
||||
|
||||
if (lightColorMod.r <= 0.0 && lightColorMod.g <= 0.0 && lightColorMod.b <= 0.0)
|
||||
discard;
|
||||
|
||||
lightColorMod.rgb *= lightColor.a;
|
||||
if (lightColor.a > 0.4) //Normal, vavoom or negative light (or attenuated)
|
||||
lightColorMod *= tcolor;
|
||||
|
||||
FragColor = desaturate(lightColorMod); //Additive light
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
}
|
||||
)";
|
||||
|
||||
static const char* world3D_ps_skybox = R"(
|
||||
in vec3 Tex;
|
||||
in vec4 viewpos;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec4 highlightcolor;
|
||||
|
||||
uniform vec4 fogsettings;
|
||||
uniform vec4 fogcolor;
|
||||
|
||||
uniform samplerCube texture1;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 ncolor = texture(texture1, Tex);
|
||||
FragColor = vec4(highlightcolor.rgb * highlightcolor.a + (ncolor.rgb - 0.4 * highlightcolor.a), 1.0);
|
||||
|
||||
#if defined(ALPHA_TEST)
|
||||
if (FragColor.a < 0.5) discard;
|
||||
#endif
|
||||
|
||||
if (fogsettings.x >= 0.0) FragColor = mix(FragColor, fogcolor, clamp((-viewpos.z - fogsettings.x) / (fogsettings.y - fogsettings.x), 0.0, 1.0));
|
||||
}
|
||||
)";
|
|
@ -4,6 +4,7 @@ EXPORTS
|
|||
RenderDevice_New
|
||||
RenderDevice_Delete
|
||||
RenderDevice_GetError
|
||||
RenderDevice_DeclareShader
|
||||
RenderDevice_SetShader
|
||||
RenderDevice_SetUniform
|
||||
RenderDevice_SetVertexBuffer
|
||||
|
|
Loading…
Reference in a new issue