Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Migarting code over to NetCore and creating new project for latest ve…
Browse files Browse the repository at this point in the history
…rsion of MonoGame.
  • Loading branch information
jessefreeman committed May 19, 2020
1 parent cd7f7d4 commit 27ca0f3
Show file tree
Hide file tree
Showing 2,883 changed files with 1,105,700 additions and 582 deletions.
Binary file added Disks/PixelVisionOS/PixelVisionOS.pv8
Binary file not shown.
16 changes: 8 additions & 8 deletions Disks/PixelVisionOS/System/Tools/SpriteTool/saves.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"GameChip":
{
"savedData":{
"selectedSprite": "0",
"selectedPalette": "-1",
"selectedColor": "-1",
"rootDirectory": "/Workspace/NewProject/",
"sessionID": "202005051245326336",
"selectedSpritePage": "1",
"selectedPalettePage": "1",
"spriteSize": "1",
"editing": "undefined",
"spriteSize": "1"
"selectedPalettePage": "1",
"selectedSpritePage": "1",
"sessionID": "202005051245326336",
"rootDirectory": "/Workspace/NewProject/",
"selectedColor": "-1",
"selectedPalette": "-1",
"selectedSprite": "0"
}
}
}
2 changes: 1 addition & 1 deletion Disks/PixelVisionOS/System/Tools/WorkspaceTool/saves.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"lastPath": "/Workspace/",
"selection": "0",
"scrollPos": "0",
"sessionID": "202005190711345294"
"sessionID": "202005191423293450"
}
}
}
16 changes: 16 additions & 0 deletions Effects/QuickDraw.fx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
sampler2D screen: register(s0);
sampler colorPallete: register(s1);

float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0
{
float4 color = tex2D(screen, coords);
return tex2D(colorPallete, float2(color.r, 0.5f));
}

technique Technique1
{
pass Pass1
{
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}
20 changes: 20 additions & 0 deletions Effects/QuickDrawBytes.fx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
sampler main: register(s0);
sampler colorPallete: register(s1);
sampler screen: register(s2);
float imageWidth;

float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0
{
float4 color = tex2D(screen, float2(coords.x, coords.y));
int subpart = int(coords.x * imageWidth) % 4;

return tex2D(colorPallete, float2(color[subpart], 0.5f));
}

technique Technique1
{
pass Pass1
{
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}
147 changes: 32 additions & 115 deletions Effects/crt-lottes-mg.fx
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,17 @@ struct VertexShaderOutput
// Please take and use, change, or whatever.
//

// -- config -- //
// #pragma parameter hardScan "hardScan" -8.0 -20.0 0.0 1.0 // default, minimum, maximum, optional step
// #pragma parameter hardPix "hardPix" -3.0 -20.0 0.0 1.0
// #pragma parameter warpX "warpX" 0.031 0.0 0.125 0.01
// #pragma parameter warpY "warpY" 0.041 0.0 0.125 0.01
// #pragma parameter maskDark "maskDark" 0.5 0.0 2.0 0.1
// #pragma parameter maskLight "maskLight" 1.5 0.0 2.0 0.1
// #pragma parameter scaleInLinearGamma "scaleInLinearGamma" 1.0 0.0 1.0 1.0
// #pragma parameter shadowMask "shadowMask" 3.0 0.0 4.0 1.0
// #pragma parameter brightboost "brightness" 1.0 0.0 2.0 0.05
// #pragma parameter hardBloomPix "bloom-x soft" -1.5 -2.0 -0.5 0.1
// #pragma parameter hardBloomScan "bloom-y soft" -2.0 -4.0 -1.0 0.1
// #pragma parameter bloomAmount "bloom amt" 0.15 0.0 1.0 0.05
// #pragma parameter shape "filter kernel shape" 2.0 0.0 10.0 0.05

#define hardPix -3.0
#define shadowMask 3
#define hardScan -8.0
#define hardBloomPix -2.0
#define hardBloomScan -1.5
#define hardPix -10.0
#define hardScan -10.0
#define shadowMask 0
#define hardBloomPix -4.0
#define hardBloomScan -3
#define maskDark 0.5
#define maskLight 1.5
#define bloomAmount 0.15
#define warp float2(0.008,0.01)

float brightboost;
float shape;

float brightboost = 1.0;
float2 textureSize;
float2 videoSize;
float2 outputSize;
Expand All @@ -80,59 +64,24 @@ float4x4 modelViewProj;

// sRGB to Linear.
// Assuing using sRGB typed textures this should not be needed.
#if SIMPLE_LINEAR_GAMMA > 0

float3 ToSrgb(float3 c)
{
#if SIMPLE_LINEAR_GAMMA == 1
return pow(c, 1 / 2.2);
#else

return sqrt(c);
#endif
}
#else
float ToLinear1(float c)
{
if (scaleInLinearGamma==0) return c;
return(c<=0.04045)?c/12.92:pow((c+0.055)/1.055,2.4);
}
float3 ToLinear(float3 c)
{
if (scaleInLinearGamma==0) return c;
return float3(ToLinear1(c.r),ToLinear1(c.g),ToLinear1(c.b));
}

// Linear to sRGB.
// Assuming using sRGB typed textures this should not be needed.
float ToSrgb1(float c)
{
if (scaleInLinearGamma==0) return c;
return(c<0.0031308?c*12.92:1.055*pow(c,0.41666)-0.055);
}

float3 ToSrgb(float3 c)
{
if (scaleInLinearGamma==0) return c;
return float3(ToSrgb1(c.r),ToSrgb1(c.g),ToSrgb1(c.b));
}
#endif

// Nearest emulated sample given floating point position and texel offset.
// Also zero's off screen.
float3 Fetch(float2 pos, float2 off, float2 texture_size){
pos=(floor(pos*texture_size.xy+off)+float2(0.5,0.5))/texture_size.xy;
#if SIMPLE_LINEAR_GAMMA == 1
return brightboost * pow(tex2D(DecalSampler,pos.xy).rgb, 2.2);
#elif SIMPLE_LINEAR_GAMMA == 2
return brightboost * pow(tex2D(DecalSampler,pos.xy).rgb, 2);
#else
return ToLinear(brightboost * tex2D(DecalSampler,pos.xy).rgb);
#endif
}

// Distance in emulated pixels to nearest texel.
float2 Dist(float2 pos, float2 texture_size){pos=pos*texture_size.xy;return -(frac(pos)-float2(0.5, 0.5));}

// 1D Gaussian.
float Gaus(float pos,float scale){return exp2(scale*pos*pos);}

Expand All @@ -149,7 +98,7 @@ float3 Horz3(float2 pos, float off, float2 texture_size){
float wd=Gaus(dst+1.0,scale);
// Return filtered sample.
return (b*wb+c*wc+d*wd)/(wb+wc+wd);}

// 5-tap Gaussian filter along horz line.
float3 Horz5(float2 pos, float off, float2 texture_size){
float3 a=Fetch(pos,float2(-2.0,off),texture_size);
Expand Down Expand Up @@ -194,7 +143,7 @@ float3 Horz7(float2 pos, float off, float2 texture_size){
float Scan(float2 pos,float off, float2 texture_size){
float dst=Dist(pos, texture_size).y;
return Gaus(dst+off,hardScan);}

// Return scanline weight for bloom.
float BloomScan(float2 pos,float off, float2 texture_size){
float dst=Dist(pos, texture_size).y;
Expand All @@ -209,7 +158,7 @@ float3 Tri(float2 pos, float2 texture_size){
float wb=Scan(pos, 0.0, texture_size);
float wc=Scan(pos, 1.0, texture_size);
return a*wa+b*wb+c*wc;}

// Small bloom.
float3 Bloom(float2 pos, float2 texture_size){
float3 a=Horz5(pos,-2.0, texture_size);
Expand All @@ -224,78 +173,46 @@ float3 Bloom(float2 pos, float2 texture_size){
float we=BloomScan(pos, 2.0, texture_size);
return a*wa+b*wb+c*wc+d*wd+e*we;}

// Shadow mask
// Distortion of scanlines, and end of screen alpha.
float2 Warp(float2 pos){
pos=pos*2.0-1.0;
pos*=float2(1.0+(pos.y*pos.y)*warp.x,1.0+(pos.x*pos.x)*warp.y);
return pos*0.5+0.5;}

// Shadow mask
float3 Mask(float2 pos){
float3 mask = maskDark;

// Very compressed TV style shadow mask.
#if shadowMask == 1
float mask_line = maskLight;
float odd=0.0;
if(frac(pos.x/6.0)<0.5) odd = 1.0;
if(frac((pos.y+odd)/2.0)<0.5) mask_line = maskDark;
pos.x=frac(pos.x/3.0);

if(pos.x<0.333)mask.r=maskLight;
else if(pos.x<0.666)mask.g=maskLight;
else mask.b=maskLight;
mask *= mask_line;

#elif shadowMask == 2

// Aperture-grille.
pos.x=frac(pos.x/3.0);

if(pos.x<0.333)mask.r=maskLight;
else if(pos.x<0.666)mask.g=maskLight;
else mask.b=maskLight;

#elif shadowMask == 3
// Stretched VGA style shadow mask (same as prior shaders).
pos.x+=pos.y*3.0;

/*pos.x=frac(pos.x/6.0);
if(pos.x<0.333)mask.r=maskLight;
else if(pos.x<0.666)mask.g=maskLight;
else mask.b=maskLight;*/

pos.x=frac(pos.x/6.0) * 3;
mask = -min(floor(float3(pos.x, 2 * abs(pos.x - 1.5), 3 - pos.x)), 1) + 1.5;

#else
// VGA style shadow mask.
pos.xy=floor(pos.xy*float2(1.0,0.5));
pos.x+=pos.y*3.0;
pos.x=frac(pos.x/6.0);
pos.xy=floor(pos.xy*float2(1.0,0.5));
pos.x+=pos.y*3.0;
pos.x=frac(pos.x/6.0);

if(pos.x<0.333)mask.r=maskLight;
else if(pos.x<0.666)mask.g=maskLight;
else mask.b=maskLight;
#endif
if(pos.x<0.333)mask.r=maskLight;
else if(pos.x<0.666)mask.g=maskLight;
else mask.b=maskLight;

return mask;
}
}

float4 crt_lottes(float2 tex)
float4 crt_lottes(float2 texture_size, float2 video_size, float2 tex, sampler2D s0)
{
float2 pos = tex.xy;
float3 outColor = Tri(pos, textureSize);

float2 pos=Warp(tex.xy*(texture_size.xy/video_size.xy))*(video_size.xy/texture_size.xy);
float3 outColor = Tri(pos, texture_size);

#ifdef DO_BLOOM
//Add Bloom
outColor.rgb+=Bloom(pos, textureSize)*bloomAmount;
#endif

#if shadowMask != 0
outColor.rgb*=Mask(floor(tex.xy*outputSize.xy) + 0.5);
#endif

return float4(ToSrgb(outColor.rgb),1.0);
}

float4 main_fragment(VertexShaderOutput VOUT) : COLOR0
{
return crt_lottes(VOUT.texCoord);
return crt_lottes(textureSize, videoSize, VOUT.texCoord, DecalSampler);
}

technique
Expand All @@ -304,4 +221,4 @@ technique
{
PixelShader = compile PS_SHADERMODEL main_fragment();
}
}
}
Binary file modified Effects/crt-lottes-mg.ogl.mgfxo
Binary file not shown.
Binary file added Effects/mgfxc.exe
Binary file not shown.
Binary file added Effects/quick-draw-bytes.ogl.mgfxc
Binary file not shown.
Binary file added Effects/quick-draw.ogl.mgfxc
Binary file not shown.
12 changes: 12 additions & 0 deletions MonoGame/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# http://EditorConfig.org

root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.cs]
indent_style = space
indent_size = 4

0 comments on commit 27ca0f3

Please sign in to comment.