Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubBala committed Feb 9, 2024
2 parents 29f5c6c + c46ee5e commit 5133449
Show file tree
Hide file tree
Showing 50 changed files with 2,732 additions and 132 deletions.
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-mgcb": {
"version": "3.8.1.303",
"commands": [
"mgcb"
]
},
"dotnet-mgcb-editor": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor"
]
},
"dotnet-mgcb-editor-linux": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-linux"
]
},
"dotnet-mgcb-editor-windows": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-windows"
]
},
"dotnet-mgcb-editor-mac": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-mac"
]
"version": 1,
"isRoot": true,
"tools": {
"dotnet-mgcb": {
"version": "3.8.1.303",
"commands": [
"mgcb"
]
},
"dotnet-mgcb-editor": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor"
]
},
"dotnet-mgcb-editor-linux": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-linux"
]
},
"dotnet-mgcb-editor-windows": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-windows"
]
},
"dotnet-mgcb-editor-mac": {
"version": "3.8.1.303",
"commands": [
"mgcb-editor-mac"
]
}
}
}
}
}
24 changes: 24 additions & 0 deletions GREngine.Core/GREngine.Core.PebbleRenderer/Content/Content.mgcb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,27 @@

#---------------------------------- Content ---------------------------------#

#begin defaultDiffuseShader.fx
/importer:EffectImporter
/processor:EffectProcessor
/processorParam:DebugMode=Auto
/build:defaultDiffuseShader.fx

#begin defaultNormalShader.fx
/importer:EffectImporter
/processor:EffectProcessor
/processorParam:DebugMode=Auto
/build:defaultNormalShader.fx

#begin pointLight.fx
/importer:EffectImporter
/processor:EffectProcessor
/processorParam:DebugMode=Auto
/build:pointLight.fx

#begin pointLightShaderShadowCasting.fx
/importer:EffectImporter
/processor:EffectProcessor
/processorParam:DebugMode=Auto
/build:pointLightShaderShadowCasting.fx

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_1
#define PS_SHADERMODEL ps_4_0_level_9_1
#endif

Texture2D SpriteTexture;

float4x4 viewProjection;
float time;


sampler2D screenSampler = sampler_state
{
Texture = <SpriteTexture>;
};

struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};

float2 curve(float2 uv)
{
uv = (uv - 0.5) * 2.0;
uv *= 1.1;
uv.x *= 1.0 + pow((abs(uv.y) / 5.0), 2.0);
uv.y *= 1.0 + pow((abs(uv.x) / 4.0), 2.0);
uv = (uv / 2.0) + 0.5;
uv = uv * 0.92 + 0.04;
return uv;
}

float4 MainPS(VertexShaderOutput input) : COLOR
{
//Curve
float2 uv = input.TextureCoordinates;
uv = curve(uv);

float3 col;

// Chromatic
col.r = tex2D(screenSampler, float2(uv.x + 0.003, uv.y)).x;
col.g = tex2D(screenSampler, float2(uv.x + 0.000, uv.y)).y;
col.b = tex2D(screenSampler, float2(uv.x - 0.003, uv.y)).z;

col *= step(0.0, uv.x) * step(0.0, uv.y);
col *= 1.0 - step(1.0, uv.x) * 1.0 - step(1.0, uv.y);

col *= 0.5 + 0.5 * 16.0 * uv.x * uv.y * (1.0 - uv.x) * (1.0 - uv.y);
col *= float3(0.95, 1.05, 0.95);

col *= 0.9 + 0.1 * sin(10.0 * time + uv.y * 700.0);

col *= 0.99 + 0.01 * sin(110.0 * time);

return float4(col, 1.0);

}

technique SpriteDrawing
{
pass P0
{
PixelShader = compile PS_SHADERMODEL MainPS();
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_1
#define PS_SHADERMODEL ps_4_0_level_9_1
#endif

int width;
int height;
float time;
float3 ambientColor;


sampler diffuseSampler : register(s0);
sampler lightMap : register(s1);

struct VertexShaderOutput
{
float4 Position : SV_POSITION0;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};

float4 MainPS(VertexShaderOutput input) : COLOR
{
float2 ligtmapUV = float2(input.Position.x / width, input.Position.y / height);
float3 lightColor = tex2D(lightMap, ligtmapUV).rgb + ambientColor; //baked in ambient todo make it a parameter

float2 uv = input.TextureCoordinates;
float4 sample = tex2D(diffuseSampler, uv);
return float4(sample * lightColor, sample.a) * input.Color; //a is alpha right?
//+ (max(dot(lightColor, lightColor) - 2, 0) * lightColor * 0.2) //crude hdr

}

technique SpriteDrawing
{
pass P0
{
PixelShader = compile PS_SHADERMODEL MainPS();
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_1
#define PS_SHADERMODEL ps_4_0_level_9_1
#endif

Texture2D SpriteTexture;

float4x4 viewProjection;
float time;


sampler2D SpriteTextureSampler = sampler_state
{
Texture = <SpriteTexture>;
};

struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
float Depth : DEPTH0; //?
};

float4 MainPS(VertexShaderOutput input) : COLOR
{
float4 sample = tex2D(SpriteTextureSampler, input.TextureCoordinates) * input.Color;
if (input.Color.r == 0 && input.Color.g == 0 && input.Color.b == 0 && sample.a != 0)
{
sample = float4(0.5, 0.5, 1, 1);
}
return sample;
}

technique SpriteDrawing
{
pass P0
{
PixelShader = compile PS_SHADERMODEL MainPS();
}
};
74 changes: 74 additions & 0 deletions GREngine.Core/GREngine.Core.PebbleRenderer/Content/dither.fx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_1
#define PS_SHADERMODEL ps_4_0_level_9_1
#endif

Texture2D SpriteTexture;

sampler SpriteTextureSampler : register(s0);
sampler ditherSampler : register(s1);

struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};

float2 ditherSize = float2(8., 8.);
float3 RGB_CHANNELS = float3(10, 10, 10);
float dither_f(float x, float c)
{
x = min(x, 0.999);
return floor(c * x) / c + 1. / (2. * c);
}
float3 dither(float3 color, float2 pixCoord)
{
float3 col = color;
float3 col2 = color;


float3 col3 = float3(0,0,0);
col3.r = dither_f(col.r, RGB_CHANNELS.r - 1.);
col3.g = dither_f(col.g, RGB_CHANNELS.g - 1.);
col3.b = dither_f(col.b, RGB_CHANNELS.b - 1.);

col2 = col3 - 1. / (2. * (RGB_CHANNELS - 1.));
col = col3 + 1. / (2. * (RGB_CHANNELS - 1.));


float lerpR = (color.r - col.r) / (col2.r - col.r);
float lerpG = (color.g - col.g) / (col2.g - col.g);
float lerpB = (color.b - col.b) / (col2.b - col.b);

float2 ditherCoordinate = pixCoord / ditherSize;

float ditherval = tex2D(ditherSampler, ditherCoordinate).r;

float3 ditheredval = float3(step(ditherval, lerpR), step(ditherval, lerpG), step(ditherval, lerpB));

col = lerp(col, col2, ditheredval);

return col;
}



float4 MainPS(VertexShaderOutput input) : COLOR
{

float4 col = tex2D(SpriteTextureSampler, input.TextureCoordinates);
return float4(dither(col.rgb, input.TextureCoordinates),1);
}

technique SpriteDrawing
{
pass P0
{
PixelShader = compile PS_SHADERMODEL MainPS();
}
};
38 changes: 38 additions & 0 deletions GREngine.Core/GREngine.Core.PebbleRenderer/Content/isolate.fx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_1
#define PS_SHADERMODEL ps_4_0_level_9_1
#endif

Texture2D SpriteTexture;
float threshold = 0.9;// add param

sampler2D SpriteTextureSampler = sampler_state
{
Texture = <SpriteTexture>;
};

struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};

float4 MainPS(VertexShaderOutput input) : COLOR
{
float4 sample = tex2D(SpriteTextureSampler, input.TextureCoordinates);

return float4(step(0.9, dot(sample.rgb, sample.rgb)) * sample.rgb*2, sample.a)*0.1;
}

technique SpriteDrawing
{
pass P0
{
PixelShader = compile PS_SHADERMODEL MainPS();
}
};
Loading

0 comments on commit 5133449

Please sign in to comment.