Fix shader problems on GLES2
This commit is contained in:
@@ -22,8 +22,17 @@
|
|||||||
id: Singularity
|
id: Singularity
|
||||||
kind: source
|
kind: source
|
||||||
path: "/Textures/Shaders/singularity.swsl"
|
path: "/Textures/Shaders/singularity.swsl"
|
||||||
|
params:
|
||||||
|
positionInput: 0,0
|
||||||
|
falloff: 5
|
||||||
|
intensity: 5
|
||||||
|
|
||||||
- type: shader
|
- type: shader
|
||||||
id: Texture
|
id: Texture
|
||||||
kind: source
|
kind: source
|
||||||
path: "/Textures/Shaders/texture.swsl"
|
path: "/Textures/Shaders/texture.swsl"
|
||||||
|
params:
|
||||||
|
positionInput: 0, 0
|
||||||
|
pixelSize: 32, 32
|
||||||
|
alphaCutoff: 0
|
||||||
|
removeTransparency: false
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//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)
|
//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 vec4 borderColor = vec4(230.0, 0.0, 0.0, 1.0);
|
||||||
const highp float borderSize = 30; //Pixel size of border
|
const highp float borderSize = 30.0; //Pixel size of border
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
highp vec2 pixelSize = vec2(1.0/SCREEN_PIXEL_SIZE.x, 1.0/SCREEN_PIXEL_SIZE.y);
|
highp vec2 pixelSize = vec2(1.0/SCREEN_PIXEL_SIZE.x, 1.0/SCREEN_PIXEL_SIZE.y);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ void fragment() {
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
highp float intensity = (distance-innerCircleRadius)/(outerCircleRadius-innerCircleRadius);
|
highp float intensity = (distance-innerCircleRadius)/(outerCircleRadius-innerCircleRadius);
|
||||||
COLOR = vec4(0.0, 0.0, 0.0, (1-intensity)*darknessAlphaInner + intensity);
|
COLOR = vec4(0.0, 0.0, 0.0, (1.0-intensity)*darknessAlphaInner + intensity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
//Gravitational lensing effect. Edited from https://unionassets.com/blog/the-effect-of-the-gravitational-lens-195 to be Clyde based (based on what)
|
//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 sampler2D SCREEN_TEXTURE;
|
||||||
uniform highp vec2 positionInput = vec2(0,0);
|
uniform highp vec2 positionInput;
|
||||||
uniform highp float falloff = 5.0;
|
uniform highp float falloff;
|
||||||
uniform highp float intensity = 5.0;
|
uniform highp float intensity;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
float distanceToCenter = length(FRAGCOORD.xy-positionInput);
|
highp float distanceToCenter = length(FRAGCOORD.xy-positionInput);
|
||||||
|
|
||||||
vec2 finalCoords = FRAGCOORD.xy - positionInput;
|
highp vec2 finalCoords = FRAGCOORD.xy - positionInput;
|
||||||
highp float deformation = (pow(intensity, 2)*500) / pow(distanceToCenter, pow(falloff, 0.5));
|
highp float deformation = (pow(intensity, 2.0)*500.0) / pow(distanceToCenter, pow(falloff, 0.5));
|
||||||
if(deformation > 0.8) //Edit this for inward effect
|
if(deformation > 0.8) //Edit this for inward effect
|
||||||
deformation = pow(deformation, 0.3);
|
deformation = pow(deformation, 0.3);
|
||||||
if(deformation > 0.001){
|
if(deformation > 0.001){
|
||||||
finalCoords *= 1-deformation; //Change this to 1+deformation for inward effect
|
finalCoords *= 1.0-deformation; //Change this to 1+deformation for inward effect
|
||||||
finalCoords += positionInput;
|
finalCoords += positionInput;
|
||||||
//float darkenCircleSize = 600; //Calculate optional darkening effect (darker the closer we are to the center of the singularity)
|
//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 alph = (distanceToCenter-30)/(darkenCircleSize-30);
|
||||||
@@ -23,10 +23,10 @@ void fragment() {
|
|||||||
|
|
||||||
//Darkening effect optional (Darker the closer you are to the center)
|
//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 = 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);
|
COLOR = zTextureSpec(SCREEN_TEXTURE, finalCoords*SCREEN_PIXEL_SIZE);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
COLOR = texture(SCREEN_TEXTURE, FRAGCOORD.xy*SCREEN_PIXEL_SIZE);
|
COLOR = zTextureSpec(SCREEN_TEXTURE, FRAGCOORD.xy*SCREEN_PIXEL_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,17 +3,17 @@
|
|||||||
//Currently does not work with AtlasTextures, going to need some work.
|
//Currently does not work with AtlasTextures, going to need some work.
|
||||||
|
|
||||||
uniform sampler2D tex;
|
uniform sampler2D tex;
|
||||||
uniform highp vec2 positionInput = vec2(0,0);
|
uniform highp vec2 positionInput;
|
||||||
uniform highp vec2 pixelSize = vec2(32, 32);
|
uniform highp vec2 pixelSize;
|
||||||
uniform highp float alphaCutoff = 0.0;
|
uniform highp float alphaCutoff;
|
||||||
uniform bool removeTransparency = false;
|
uniform bool removeTransparency;
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
float pixelLength = pixelSize.x*2;
|
highp float pixelLength = pixelSize.x*2.0;
|
||||||
float halvedLength = pixelLength/2;
|
highp float halvedLength = pixelLength/2.0;
|
||||||
if(FRAGCOORD.x > positionInput.x - halvedLength && FRAGCOORD.x < positionInput.x + halvedLength && FRAGCOORD.y > positionInput.y - halvedLength && FRAGCOORD.y < positionInput.y + halvedLength){
|
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;
|
highp vec2 finalCoords = (FRAGCOORD.xy-positionInput+(pixelLength/2.0))/pixelLength;
|
||||||
vec4 color = texture(tex, finalCoords);
|
highp vec4 color = texture2D(tex, finalCoords);
|
||||||
if(color.a > alphaCutoff){
|
if(color.a > alphaCutoff){
|
||||||
if(removeTransparency)
|
if(removeTransparency)
|
||||||
color.a = 1.0;
|
color.a = 1.0;
|
||||||
|
|||||||
Reference in New Issue
Block a user