Files
LuaCsForBarotraumaEP/Barotrauma/BarotraumaShared/Content/watershader.fx
T
juanjp600 7a413aee93 Optimized GameScreen.DrawMap
- Downscaled lightmap, since blurring will make this unnoticeable anyway
(TODO: make this optional)
- Render LOS in fewer passes by using a shader
- Use light volume to calculate LOS
- This also means we can use the override texture to render the diving
suit obstruct effect
- Don't render bunks and labels onto LOS background (TODO: add the
option to render back into the LOS background, i.e. just use
multiplicative blending as if it was the lightmap)
- Prefer SpriteSortMode.Deferred over all others, prefer
SamplerState.LinearClamp/PointClamp over all others
- Remove shader blur in favor of geometry blur (TODO: improve on this
further, right now it has a few artifacts)
- Trim light volumes
- Do some weird shit with the background particles (use DrawTiled
instead of relying on SamplerState.LinearWrap, because that's faster
somehow :/ )
- Pressing up/down in the console only returns a typed command now
2017-12-20 19:41:23 -03:00

74 lines
1.8 KiB
HLSL

float xBlurDistance;
Texture xTexture;
sampler TextureSampler = sampler_state { Texture = <xTexture>; };
Texture xLosTexture;
sampler LosSampler = sampler_state { Texture = <xLosTexture>; };
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;
}
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
{
PixelShader = compile ps_4_0_level_9_1 main();
}
}
technique LosShader
{
pass Pass1
{
PixelShader = compile ps_4_0_level_9_1 main2();
}
}