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

Commit

Permalink
New shader with editor support.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessefreeman committed May 25, 2020
1 parent 9a21fb4 commit 1c3f655
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
12 changes: 6 additions & 6 deletions Disks/PixelVisionOS/System/Tools/ColorTool/saves.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"GameChip":
{
"savedData":{
"selectedSprite": "-1",
"selectedPalette": "-1",
"selectedColor": "-1",
"rootDirectory": "/Workspace/MyFirstGame/",
"sessionID": "202005231324236163",
"selectedPalettePage": "0",
"selectedSpritePage": "1",
"selectedPalettePage": "0"
"sessionID": "202005242131242796",
"rootDirectory": "/Workspace/MyFirstGame/",
"selectedColor": "-1",
"selectedPalette": "-1",
"selectedSprite": "-1"
}
}
}
6 changes: 3 additions & 3 deletions Disks/PixelVisionOS/System/Tools/WorkspaceTool/saves.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"GameChip":
{
"savedData":{
"lastPath": "/Workspace/",
"selection": "0",
"sessionID": "202005242133137514",
"scrollPos": "0",
"sessionID": "202005242105019704"
"selection": "9",
"lastPath": "/Workspace/DragonSweeper/"
}
}
}
13 changes: 11 additions & 2 deletions Effects/crt-lottes-mg.fx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ float2 textureSize;
float2 videoSize;
float2 outputSize;
float crtOn = 0;
float4 maskColor;

//Uncomment to reduce instructions with simpler linearization
//(fixes HD3000 Sandy Bridge IGP)
Expand All @@ -71,10 +72,18 @@ float3 Fetch(float2 pos, float2 off, float2 texture_size){
pos=(floor(pos*texture_size.xy+off*crtOn)+float2(0.5,0.5))/texture_size.xy;

// find the color on the scren texture
float4 color = tex2D(screen, pos);
float4 inColor = tex2D(screen, pos);

float4 outColor;

if (inColor.b == 1 && inColor.g == 1 && inColor.r == 1)
outColor = maskColor;
else
// After 256, the color wraps over to green
outColor = tex2D(colorPallete, float2(inColor.r, inColor.g * 256));

// Convert the color to a palette color and brighten it
return brightboost * pow(tex2D(colorPallete, float2(color.r, 0.5f)).rgb, 2);
return brightboost * pow(outColor.rgb, 2);
}

// Distance in emulated pixels to nearest texel.
Expand Down
Binary file modified Effects/crt-lottes-mg.ogl.mgfxo
Binary file not shown.
8 changes: 7 additions & 1 deletion SDK/Runner/Data/DisplayTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ public void RebuildColorPalette(ColorChip colorChip)

// spriteBatch = new SpriteBatch(graphicManager.GraphicsDevice);

_colorPalette = new Texture2D(graphicManager.GraphicsDevice, colors.Length, 1);
var width = 256;
var height = (int)Math.Ceiling(colors.Length / (double)width);

_colorPalette = new Texture2D(graphicManager.GraphicsDevice, width, height);

var fullPalette = new Color[_colorPalette.Width];
for (int i = 0; i < fullPalette.Length; i++) { fullPalette[i] = i < colors.Length ? colors[i] : colors[0]; }
Expand All @@ -239,6 +242,9 @@ public void RebuildColorPalette(ColorChip colorChip)

colorChip.ResetValidation();

// Set palette total
crtShader.Parameters["maskColor"].SetValue(Color.Magenta.ToVector4());

}

public void Render(int[] pixels)
Expand Down

0 comments on commit 1c3f655

Please sign in to comment.