This commit is contained in:
Joonas Rikkonen
2018-01-01 15:05:22 +02:00
50 changed files with 111775 additions and 72 deletions
@@ -233,8 +233,10 @@
<Reference Condition="$(DefineConstants.Contains('WINDOWS'))" Include="MonoGame.Framework.WindowsDX">
<HintPath>..\..\Libraries\NuGet\MonoGame.Framework.WindowsDX.3.6.0.1625\lib\net40\MonoGame.Framework.dll</HintPath>
</Reference>
<Reference Condition="$(DefineConstants.Contains('WINDOWS'))" Include="PresentationCore" />
<Reference Condition="$(DefineConstants.Contains('WINDOWS'))" Include="SharpDX">
<HintPath>..\..\Libraries\NuGet\SharpDX.4.0.1\lib\net45\SharpDX.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Libraries\NuGet\MonoGame.Framework.WindowsDX.3.6.0.1625\lib\net40\SharpDX.dll</HintPath>
</Reference>
<Reference Condition="$(DefineConstants.Contains('WINDOWS'))" Include="NVorbis">
<HintPath>..\..\Libraries\NuGet\NVorbis.0.8.5.0\lib\NVorbis.dll</HintPath>
@@ -328,4 +330,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
@@ -225,7 +225,7 @@ namespace Barotrauma
DebugConsole.Log(SelectedPackage == null ? "No content package selected" : "Content package \"" + SelectedPackage.Name + "\" selected");
yield return CoroutineStatus.Running;
LightManager = new Lights.LightManager(base.GraphicsDevice);
LightManager = new Lights.LightManager(base.GraphicsDevice, Content);
Hull.renderer = new WaterRenderer(base.GraphicsDevice, Content);
TitleScreen.LoadState = 1.0f;
@@ -43,12 +43,7 @@ namespace Barotrauma
waterEffect.Parameters["xWaveWidth"].SetValue(0.05f);
waterEffect.Parameters["xWaveHeight"].SetValue(0.05f);
#if WINDOWS
//waterEffect.Parameters["xTexture"].SetValue(waterTexture);
#endif
#if LINUX
waterEffect.Parameters["xWaterBumpMap"].SetValue(waterTexture);
#endif
if (basicEffect == null)
{
@@ -68,13 +63,13 @@ namespace Barotrauma
waterEffect.Parameters["xBlurDistance"].SetValue(blurAmount);
//waterEffect.CurrentTechnique.Passes[0].Apply();
#if WINDOWS
//#if WINDOWS
waterEffect.Parameters["xTexture"].SetValue(texture);
spriteBatch.Draw(waterTexture, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
#elif LINUX
spriteBatch.Draw(texture, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
#endif
//#elif LINUX
// spriteBatch.Draw(texture, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
//#endif
spriteBatch.End();
}
@@ -1,5 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using System.Collections.Generic;
using System.Linq;
@@ -36,6 +37,11 @@ namespace Barotrauma.Lights
}
BasicEffect lightEffect;
public Effect losEffect
{
get; private set;
}
private static Texture2D alphaClearTexture;
@@ -55,7 +61,7 @@ namespace Barotrauma.Lights
private float ambientLightUpdateTimer;
public LightManager(GraphicsDevice graphics)
public LightManager(GraphicsDevice graphics, ContentManager content)
{
lights = new List<LightSource>();
@@ -71,12 +77,18 @@ namespace Barotrauma.Lights
pp.BackBufferFormat, pp.DepthStencilFormat, pp.MultiSampleCount,
RenderTargetUsage.DiscardContents);
losTexture = new RenderTarget2D(graphics, (int)(GameMain.GraphicsWidth*lightmapScale), (int)(GameMain.GraphicsHeight*lightmapScale), false, SurfaceFormat.Alpha8, DepthFormat.None);
losTexture = new RenderTarget2D(graphics, (int)(GameMain.GraphicsWidth*lightmapScale), (int)(GameMain.GraphicsHeight*lightmapScale), false, SurfaceFormat.Color, DepthFormat.None);
losSource = new LightSource(Vector2.Zero, GameMain.GraphicsWidth, Color.White, null, false);
losSource.texture = new Texture2D(graphics, 1, 1);
losSource.texture.SetData(new Color[] { Color.White });// fill the texture with white
#if WINDOWS
losEffect = content.Load<Effect>("losshader");
#else
losEffect = content.Load<Effect>("losshader_opengl");
#endif
if (lightEffect == null)
{
lightEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
@@ -152,7 +152,7 @@ namespace Barotrauma
{
damageEffect.Parameters["aCutoff"].SetValue(newCutoff);
damageEffect.Parameters["cCutoff"].SetValue(newCutoff * 1.2f);
damageEffect.Parameters["color"].SetValue(color.ToVector4());
damageEffect.Parameters["inColor"].SetValue(color.ToVector4());
damageEffect.CurrentTechnique.Passes[0].Apply();
@@ -237,9 +237,10 @@ namespace Barotrauma
spriteBatch.Draw(renderTargetBackground, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
Color.Lerp(GameMain.LightManager.AmbientLight * 0.5f, Color.Red, r));
spriteBatch.End();
Hull.renderer.waterEffect.CurrentTechnique = Hull.renderer.waterEffect.Techniques["LosShader"];
Hull.renderer.waterEffect.Parameters["xLosTexture"].SetValue(GameMain.LightManager.losTexture);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.None, null, Hull.renderer.waterEffect, null);
GameMain.LightManager.losEffect.CurrentTechnique = GameMain.LightManager.losEffect.Techniques["LosShader"];
GameMain.LightManager.losEffect.Parameters["xTexture"].SetValue(renderTargetFinal);
GameMain.LightManager.losEffect.Parameters["xLosTexture"].SetValue(GameMain.LightManager.losTexture);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, null, GameMain.LightManager.losEffect, null);
}
spriteBatch.Draw(renderTargetFinal, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
spriteBatch.End();
@@ -763,6 +763,9 @@
<None Include="$(MSBuildThisFileDirectory)Content\blurshader.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\blurshader_opengl.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Characters\Carrier\alarm1.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@@ -904,6 +907,9 @@
<None Include="$(MSBuildThisFileDirectory)Content\damageshader.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\damageshader_opengl.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Exo2-Light.otf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@@ -1036,6 +1042,12 @@
<None Include="$(MSBuildThisFileDirectory)Content\Items\Weapons\syringegun.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\losshader.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\losshader_opengl.xnb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)Content\Map\TutorialSub.sub">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@@ -31,6 +31,12 @@
/processorParam:DebugMode=Auto
/build:damageshader.fx
#begin losshader.fx
/importer:EffectImporter
/processor:EffectProcessor
/processorParam:DebugMode=Auto
/build:losshader.fx
#begin utg_4.mp4
/importer:H264Importer
/processor:VideoProcessor
@@ -0,0 +1,44 @@
#----------------------------- Global Properties ----------------------------#
/outputDir:bin/$(Platform)
/intermediateDir:obj/$(Platform)
/platform:DesktopGL
/config:
/profile:Reach
/compress:False
#-------------------------------- References --------------------------------#
#---------------------------------- Content ---------------------------------#
#begin watershader_opengl.fx
/importer:EffectImporter
/processor:EffectProcessor
/processorParam:DebugMode=Auto
/build:watershader_opengl.fx
#begin blurshader_opengl.fx
/importer:EffectImporter
/processor:EffectProcessor
/processorParam:DebugMode=Auto
/build:blurshader_opengl.fx
#begin damageshader_opengl.fx
/importer:EffectImporter
/processor:EffectProcessor
/processorParam:DebugMode=Auto
/build:damageshader_opengl.fx
#begin losshader_opengl.fx
/importer:EffectImporter
/processor:EffectProcessor
/processorParam:DebugMode=Auto
/build:losshader_opengl.fx
#begin utg_4.mp4
/importer:H264Importer
/processor:VideoProcessor
/build:utg_4.mp4
@@ -0,0 +1,33 @@
// Pixel shader applies a one dimensional gaussian blur filter.
// This is used twice by the bloom postprocess, first to
// blur horizontally, and then again to blur vertically.
sampler TextureSampler : register(s0);
#define SAMPLE_COUNT 15
float2 SampleOffsets[SAMPLE_COUNT];
float SampleWeights[SAMPLE_COUNT];
float4 PixelShaderF(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
float4 c = 0;
// Combine a number of weighted image filter taps.
for (int i = 0; i < SAMPLE_COUNT; i++)
{
c += tex2D(TextureSampler, texCoord + SampleOffsets[i]) * SampleWeights[i];
}
return c;
}
technique GaussianBlur
{
pass Pass1
{
PixelShader = compile ps_2_0 PixelShaderF();
}
}
@@ -1,11 +1,11 @@
Texture xTexture;
Texture2D xTexture;
sampler TextureSampler : register (s0) = sampler_state { Texture = <xTexture>; };
Texture xStencil;
Texture2D xStencil;
sampler StencilSampler = sampler_state { Texture = <xStencil>; };
float4 color;
float4 inColor;
float aCutoff;
float aMultiplier;
@@ -15,7 +15,7 @@ float cMultiplier;
float4 main(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
float4 c = xTexture.Sample(TextureSampler, texCoord) * color;
float4 c = xTexture.Sample(TextureSampler, texCoord) * inColor;
float4 stencilColor = xStencil.Sample(StencilSampler, texCoord);
Binary file not shown.
@@ -0,0 +1,39 @@
Texture xTexture;
sampler TextureSampler : register (s0) = sampler_state { Texture = <xTexture>; };
Texture xStencil;
sampler StencilSampler = sampler_state { Texture = <xStencil>; };
float4 inColor;
float aCutoff;
float aMultiplier;
float cCutoff;
float cMultiplier;
float4 main(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
float4 c = tex2D(TextureSampler, texCoord) * inColor;
float4 stencilColor = tex2D(StencilSampler, texCoord);
float aDiff = stencilColor.a - aCutoff;
clip(aDiff);
float cDiff = stencilColor.a - cCutoff;
return float4(
lerp(stencilColor.rgb, c.rgb, clamp(cDiff * cMultiplier, 0.0f, 1.0f)),
min(aDiff * aMultiplier, c.a));
}
technique StencilShader
{
pass Pass1
{
PixelShader = compile ps_2_0 main();
}
}
@@ -0,0 +1,24 @@
Texture2D xTexture;
sampler TextureSampler : register (s0) = sampler_state { Texture = <xTexture>; };
Texture2D xLosTexture;
sampler LosSampler = sampler_state { Texture = <xLosTexture>; };
float4 main(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
float4 losColor = xLosTexture.Sample(LosSampler, texCoord);
float4 sample = xTexture.Sample(TextureSampler, texCoord);
float4 outColor = float4(sample.x*losColor.x, sample.y*losColor.x, sample.z*losColor.x, losColor.x);
return outColor;
}
technique LosShader
{
pass Pass1
{
PixelShader = compile ps_4_0_level_9_1 main();
}
}
Binary file not shown.
@@ -0,0 +1,24 @@
Texture2D xTexture;
sampler TextureSampler : register (s0) = sampler_state { Texture = <xTexture>; };
Texture2D xLosTexture;
sampler LosSampler = sampler_state { Texture = <xLosTexture>; };
float4 main(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
float4 losColor = tex2D(LosSampler, texCoord);
float4 sample = tex2D(TextureSampler, texCoord);
float4 outColor = float4(sample.x*losColor.x, sample.y*losColor.x, sample.z*losColor.x, losColor.x);
return outColor;
}
technique LosShader
{
pass Pass1
{
PixelShader = compile ps_2_0 main();
}
}
@@ -1,13 +1,9 @@
float xBlurDistance;
Texture xTexture;
Texture2D xTexture;
sampler TextureSampler = sampler_state { Texture = <xTexture>; };
Texture xLosTexture;
sampler LosSampler = sampler_state { Texture = <xLosTexture>; };
Texture xWaterBumpMap;
Texture2D xWaterBumpMap;
sampler WaterBumpSampler =
sampler_state
{
@@ -26,8 +22,8 @@ float2 xBumpPos;
float4 main(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
float4 bumpColor = tex2D(WaterBumpSampler, texCoord+xWavePos+xBumpPos);
bumpColor = (bumpColor + tex2D(WaterBumpSampler, texCoord-xWavePos*2.0f+xBumpPos))*0.5f;
float4 bumpColor = xWaterBumpMap.Sample(WaterBumpSampler, texCoord+xWavePos+xBumpPos);
bumpColor = (bumpColor + xWaterBumpMap.Sample(WaterBumpSampler, texCoord-xWavePos*2.0f+xBumpPos))*0.5f;
float2 samplePos = texCoord;
@@ -35,27 +31,16 @@ float4 main(float4 position : SV_Position, float4 color : COLOR0, float2 texCoor
samplePos.y+=(bumpColor.g-0.5f)*xWaveHeight;
float4 sample;
sample = tex2D( TextureSampler, float2(samplePos.x+xBlurDistance, samplePos.y+xBlurDistance));
sample += tex2D( TextureSampler, float2(samplePos.x-xBlurDistance, samplePos.y-xBlurDistance));
sample += tex2D( TextureSampler, float2(samplePos.x+xBlurDistance, samplePos.y-xBlurDistance));
sample += tex2D( TextureSampler, float2(samplePos.x-xBlurDistance, samplePos.y+xBlurDistance));
sample = xTexture.Sample( TextureSampler, float2(samplePos.x+xBlurDistance, samplePos.y+xBlurDistance));
sample += xTexture.Sample( TextureSampler, float2(samplePos.x-xBlurDistance, samplePos.y-xBlurDistance));
sample += xTexture.Sample( TextureSampler, float2(samplePos.x+xBlurDistance, samplePos.y-xBlurDistance));
sample += xTexture.Sample( TextureSampler, float2(samplePos.x-xBlurDistance, samplePos.y+xBlurDistance));
sample = sample * 0.25;
return sample;
}
float4 main2(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
float4 losColor = tex2D(LosSampler, texCoord);
float4 sample = tex2D(TextureSampler, texCoord);
float4 outColor = float4(sample.x, sample.y, sample.z, losColor.x);
return outColor;
}
technique WaterShader
{
pass Pass1
@@ -63,11 +48,3 @@ technique WaterShader
PixelShader = compile ps_4_0_level_9_1 main();
}
}
technique LosShader
{
pass Pass1
{
PixelShader = compile ps_4_0_level_9_1 main2();
}
}
Binary file not shown.
@@ -0,0 +1,50 @@
float xBlurDistance;
Texture xTexture;
sampler TextureSampler = sampler_state { Texture = <xTexture>; };
Texture xWaterBumpMap;
sampler WaterBumpSampler =
sampler_state
{
Texture = <xWaterBumpMap>;
MagFilter = LINEAR;
MinFilter = LINEAR;
MipFilter = LINEAR;
AddressU = WRAP;
AddressV = WRAP;
};
float xWaveWidth;
float xWaveHeight;
float2 xWavePos;
float2 xBumpPos;
float4 main(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
float4 bumpColor = tex2D(WaterBumpSampler, texCoord+xWavePos+xBumpPos);
bumpColor = (bumpColor + tex2D(WaterBumpSampler, texCoord-xWavePos*2.0f+xBumpPos))*0.5f;
float2 samplePos = texCoord;
samplePos.x+=(bumpColor.r-0.5f)*xWaveWidth;
samplePos.y+=(bumpColor.g-0.5f)*xWaveHeight;
float4 sample;
sample = tex2D( TextureSampler, float2(samplePos.x+xBlurDistance, samplePos.y+xBlurDistance));
sample += tex2D( TextureSampler, float2(samplePos.x-xBlurDistance, samplePos.y-xBlurDistance));
sample += tex2D( TextureSampler, float2(samplePos.x+xBlurDistance, samplePos.y-xBlurDistance));
sample += tex2D( TextureSampler, float2(samplePos.x-xBlurDistance, samplePos.y+xBlurDistance));
sample = sample * 0.25;
return sample;
}
technique WaterShader
{
pass Pass1
{
PixelShader = compile ps_2_0 main();
}
}