Singularity Shaders and a lot of Shader Stuff (#2517)
* Beginnings of singulo shader * LOTS of changes!! * Minor changes * Singulo stuff * Aesthetic changes to singulo * Combining singulo change * ShaderAura uses IEntities now, not IPlayerSession * Fixes? * Fixes draw order for atmos * using fix * Address reviews * nuget.config whaaa * nuget haha * nuget why are you so dum * happy now * Preparing for omegachange * Merge from seventh level of hell * woork * Ignorecomponents add * mmf * RobustToolbox? * Fixes * Fixes Robust? * adds sprite * Nullables * Crit overlay stuff * Commits Robust
This commit is contained in:
21
Resources/Textures/Shaders/colored_screen_border.swsl
Normal file
21
Resources/Textures/Shaders/colored_screen_border.swsl
Normal file
@@ -0,0 +1,21 @@
|
||||
//Creates a border on the edges of the screen of the specified color and of the specified size (no uniforms yet cause I'm lazy)
|
||||
|
||||
const highp vec4 borderColor = vec4(230.0, 0.0, 0.0, 1.0);
|
||||
const highp float borderSize = 30; //Pixel size of border
|
||||
|
||||
void fragment() {
|
||||
highp vec2 pixelSize = vec2(1.0/SCREEN_PIXEL_SIZE.x, 1.0/SCREEN_PIXEL_SIZE.y);
|
||||
highp float smallestLength = FRAGCOORD.x;
|
||||
if(smallestLength > FRAGCOORD.y){
|
||||
smallestLength = FRAGCOORD.y;
|
||||
}
|
||||
if(smallestLength > pixelSize.x-FRAGCOORD.x){
|
||||
smallestLength = pixelSize.x-FRAGCOORD.x;
|
||||
}
|
||||
if(smallestLength > pixelSize.y-FRAGCOORD.y){
|
||||
smallestLength = pixelSize.y-FRAGCOORD.y;
|
||||
}
|
||||
if(smallestLength <= borderSize){
|
||||
COLOR = vec4(borderColor.r, borderColor.g, borderColor.b, abs((1.0-(smallestLength/borderSize))*(abs(sin(TIME))*0.8+0.2)));
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
//This shader defines two circles - everything inside the inner circle will be darkened, while everything outside the outer circle
|
||||
//will be full black. Between the inner and outer circle it LERPs from the inner darkness to full black.
|
||||
|
||||
light_mode unshaded;
|
||||
|
||||
const highp float percentagedistanceshow = 0.05;
|
||||
const highp float gradientfalloffwidth = 3.0;
|
||||
|
||||
highp vec4 circle(in highp vec2 uv, in highp vec2 pos, highp float rad, in highp vec3 color) {
|
||||
highp float d = length(pos - uv) - rad;
|
||||
highp float t = clamp(d, 0.0, 1.0);
|
||||
return vec4(color, t);
|
||||
}
|
||||
const highp float darknessAlphaInner = 0.6;
|
||||
const highp float innerCircleRadius = 40; //Note: this is in pixels
|
||||
const highp float outerCircleRadius = 80;
|
||||
|
||||
void fragment() {
|
||||
highp vec2 uv = FRAGCOORD.xy;
|
||||
highp vec2 res_xy = vec2(1.0/SCREEN_PIXEL_SIZE.x, 1.0/SCREEN_PIXEL_SIZE.y);
|
||||
highp vec2 center = res_xy*0.5;
|
||||
highp float radius = percentagedistanceshow * res_xy.y;
|
||||
|
||||
highp vec4 grad = vec4(0.8 - length( uv - center )/res_xy.y * gradientfalloffwidth);
|
||||
|
||||
highp vec4 layer1 = vec4(vec3(255.0),0.0);
|
||||
|
||||
highp vec4 layer2 = circle(uv, center, radius, grad.rgb);
|
||||
|
||||
COLOR = mix(layer1, layer2, layer2.a);
|
||||
highp vec2 pixelSize = vec2(1.0/SCREEN_PIXEL_SIZE.x, 1.0/SCREEN_PIXEL_SIZE.y);
|
||||
highp vec2 pixelCenter = pixelSize*0.5;
|
||||
highp float distance = length(FRAGCOORD.xy - pixelCenter);
|
||||
if(distance > outerCircleRadius){
|
||||
COLOR = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
else if(distance < innerCircleRadius){
|
||||
COLOR = vec4(0.0, 0.0, 0.0, darknessAlphaInner);
|
||||
}
|
||||
else{
|
||||
highp float intensity = (distance-innerCircleRadius)/(outerCircleRadius-innerCircleRadius);
|
||||
COLOR = vec4(0.0, 0.0, 0.0, (1-intensity)*darknessAlphaInner + intensity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
32
Resources/Textures/Shaders/singularity.swsl
Normal file
32
Resources/Textures/Shaders/singularity.swsl
Normal file
@@ -0,0 +1,32 @@
|
||||
//Gravitational lensing effect. Edited from https://unionassets.com/blog/the-effect-of-the-gravitational-lens-195 to be Clyde based (based on what)
|
||||
|
||||
uniform sampler2D SCREEN_TEXTURE;
|
||||
uniform highp vec2 positionInput = vec2(0,0);
|
||||
uniform highp float falloff = 5.0;
|
||||
uniform highp float intensity = 5.0;
|
||||
|
||||
|
||||
|
||||
void fragment() {
|
||||
float distanceToCenter = length(FRAGCOORD.xy-positionInput);
|
||||
|
||||
vec2 finalCoords = FRAGCOORD.xy - positionInput;
|
||||
highp float deformation = (pow(intensity, 2)*500) / pow(distanceToCenter, pow(falloff, 0.5));
|
||||
if(deformation > 0.8) //Edit this for inward effect
|
||||
deformation = pow(deformation, 0.3);
|
||||
if(deformation > 0.001){
|
||||
finalCoords *= 1-deformation; //Change this to 1+deformation for inward effect
|
||||
finalCoords += positionInput;
|
||||
//float darkenCircleSize = 600; //Calculate optional darkening effect (darker the closer we are to the center of the singularity)
|
||||
//float alph = (distanceToCenter-30)/(darkenCircleSize-30);
|
||||
//float darkening = 0.9-(alph*0.9);
|
||||
|
||||
//Darkening effect optional (Darker the closer you are to the center)
|
||||
//COLOR = mix(texture(SCREEN_TEXTURE, finalCoords*SCREEN_PIXEL_SIZE), vec4(0.0, 0.0, 0.0, 1.0), darkening);
|
||||
COLOR = texture(SCREEN_TEXTURE, finalCoords*SCREEN_PIXEL_SIZE);
|
||||
}
|
||||
else{
|
||||
COLOR = texture(SCREEN_TEXTURE, FRAGCOORD.xy*SCREEN_PIXEL_SIZE);
|
||||
}
|
||||
|
||||
}
|
||||
23
Resources/Textures/Shaders/texture.swsl
Normal file
23
Resources/Textures/Shaders/texture.swsl
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
//Draws the given texture at the given screen coords. Useful in specific scenarios (i.e. this was made for drawing singularity sprites over the lensing effect but below FOV)
|
||||
//Currently does not work with AtlasTextures, going to need some work.
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform highp vec2 positionInput = vec2(0,0);
|
||||
uniform highp vec2 pixelSize = vec2(32, 32);
|
||||
uniform highp float alphaCutoff = 0.0;
|
||||
uniform bool removeTransparency = false;
|
||||
|
||||
void fragment() {
|
||||
float pixelLength = pixelSize.x*2;
|
||||
float halvedLength = pixelLength/2;
|
||||
if(FRAGCOORD.x > positionInput.x - halvedLength && FRAGCOORD.x < positionInput.x + halvedLength && FRAGCOORD.y > positionInput.y - halvedLength && FRAGCOORD.y < positionInput.y + halvedLength){
|
||||
vec2 finalCoords = (FRAGCOORD.xy-positionInput+(pixelLength/2))/pixelLength;
|
||||
vec4 color = texture(tex, finalCoords);
|
||||
if(color.a > alphaCutoff){
|
||||
if(removeTransparency)
|
||||
color.a = 1.0;
|
||||
COLOR = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user