Added Post Processing, Improved UI a lot, Made File Explorer look nicer, Fixed up Raycast Selection, Added Placeholder Playmode Button, Added cameras, Organized Create menu in Inspector, Added outlines to selected objects, added view output for viewing cameras while in Playmode area.
This commit is contained in:
31
Resources/Shaders/postfx_blur_frag.glsl
Normal file
31
Resources/Shaders/postfx_blur_frag.glsl
Normal file
@@ -0,0 +1,31 @@
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 TexCoord;
|
||||
|
||||
uniform sampler2D image;
|
||||
uniform vec2 texelSize;
|
||||
uniform bool horizontal = true;
|
||||
uniform float sigma = 3.0;
|
||||
uniform int radius = 5;
|
||||
|
||||
const float PI = 3.14159265359;
|
||||
|
||||
void main() {
|
||||
float twoSigma2 = 2.0 * sigma * sigma;
|
||||
vec2 dir = horizontal ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
|
||||
|
||||
vec3 result = texture(image, TexCoord).rgb;
|
||||
float weightSum = 1.0;
|
||||
|
||||
for (int i = 1; i <= radius; ++i) {
|
||||
float w = exp(-(float(i * i)) / twoSigma2);
|
||||
vec2 offset = dir * texelSize * float(i);
|
||||
result += texture(image, TexCoord + offset).rgb * w;
|
||||
result += texture(image, TexCoord - offset).rgb * w;
|
||||
weightSum += 2.0 * w;
|
||||
}
|
||||
|
||||
result /= weightSum;
|
||||
FragColor = vec4(result, 1.0);
|
||||
}
|
||||
15
Resources/Shaders/postfx_bright_frag.glsl
Normal file
15
Resources/Shaders/postfx_bright_frag.glsl
Normal file
@@ -0,0 +1,15 @@
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 TexCoord;
|
||||
|
||||
uniform sampler2D sceneTex;
|
||||
uniform float threshold = 1.0;
|
||||
|
||||
void main() {
|
||||
vec3 c = texture(sceneTex, TexCoord).rgb;
|
||||
float luma = dot(c, vec3(0.2125, 0.7154, 0.0721));
|
||||
float bright = max(luma - threshold, 0.0);
|
||||
vec3 masked = c * step(0.0, bright);
|
||||
FragColor = vec4(masked, 1.0);
|
||||
}
|
||||
49
Resources/Shaders/postfx_frag.glsl
Normal file
49
Resources/Shaders/postfx_frag.glsl
Normal file
@@ -0,0 +1,49 @@
|
||||
#version 330 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec2 TexCoord;
|
||||
|
||||
uniform sampler2D sceneTex;
|
||||
uniform sampler2D bloomTex;
|
||||
uniform sampler2D historyTex;
|
||||
|
||||
uniform bool enableBloom = false;
|
||||
uniform float bloomIntensity = 0.8;
|
||||
|
||||
uniform bool enableColorAdjust = false;
|
||||
uniform float exposure = 0.0; // EV stops
|
||||
uniform float contrast = 1.0;
|
||||
uniform float saturation = 1.0;
|
||||
uniform vec3 colorFilter = vec3(1.0);
|
||||
|
||||
uniform bool enableMotionBlur = false;
|
||||
uniform bool hasHistory = false;
|
||||
uniform float motionBlurStrength = 0.15;
|
||||
|
||||
vec3 applyColorAdjust(vec3 color) {
|
||||
if (enableColorAdjust) {
|
||||
color *= exp2(exposure);
|
||||
color = (color - 0.5) * contrast + 0.5;
|
||||
float luma = dot(color, vec3(0.299, 0.587, 0.114));
|
||||
color = mix(vec3(luma), color, saturation);
|
||||
color *= colorFilter;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec3 color = texture(sceneTex, TexCoord).rgb;
|
||||
if (enableBloom) {
|
||||
vec3 glow = texture(bloomTex, TexCoord).rgb;
|
||||
color += glow * bloomIntensity;
|
||||
}
|
||||
|
||||
color = applyColorAdjust(color);
|
||||
|
||||
if (enableMotionBlur && hasHistory) {
|
||||
vec3 history = texture(historyTex, TexCoord).rgb;
|
||||
color = mix(color, history, clamp(motionBlurStrength, 0.0, 0.98));
|
||||
}
|
||||
|
||||
FragColor = vec4(color, 1.0);
|
||||
}
|
||||
10
Resources/Shaders/postfx_vert.glsl
Normal file
10
Resources/Shaders/postfx_vert.glsl
Normal file
@@ -0,0 +1,10 @@
|
||||
#version 330 core
|
||||
layout (location = 0) in vec2 aPos;
|
||||
layout (location = 1) in vec2 aTexCoord;
|
||||
|
||||
out vec2 TexCoord;
|
||||
|
||||
void main() {
|
||||
TexCoord = aTexCoord;
|
||||
gl_Position = vec4(aPos, 0.0, 1.0);
|
||||
}
|
||||
144
Resources/ThirdParty/BloomFilter/BloomFilter.pde
vendored
Normal file
144
Resources/ThirdParty/BloomFilter/BloomFilter.pde
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
import controlP5.*;
|
||||
|
||||
ControlP5 cp5;
|
||||
|
||||
PGraphics canvas;
|
||||
|
||||
PGraphics brightPass;
|
||||
PGraphics horizontalBlurPass;
|
||||
PGraphics verticalBlurPass;
|
||||
|
||||
PShader bloomFilter;
|
||||
PShader blurFilter;
|
||||
|
||||
int angle = 0;
|
||||
|
||||
final int surfaceWidth = 250;
|
||||
final int surfaceHeight = 250;
|
||||
|
||||
float luminanceFilter = 0.8;
|
||||
float blurSize = 20;
|
||||
float sigma = 12;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(1000, 250, P3D);
|
||||
|
||||
addUI();
|
||||
|
||||
canvas = createGraphics(surfaceWidth, surfaceHeight, P3D);
|
||||
|
||||
brightPass = createGraphics(surfaceWidth, surfaceHeight, P2D);
|
||||
brightPass.noSmooth();
|
||||
|
||||
horizontalBlurPass = createGraphics(surfaceWidth, surfaceHeight, P2D);
|
||||
horizontalBlurPass.noSmooth();
|
||||
|
||||
verticalBlurPass = createGraphics(surfaceWidth, surfaceHeight, P2D);
|
||||
verticalBlurPass.noSmooth();
|
||||
|
||||
bloomFilter = loadShader("bloomFrag.glsl");
|
||||
blurFilter = loadShader("blurFrag.glsl");
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(0);
|
||||
|
||||
bloomFilter.set("brightPassThreshold", luminanceFilter);
|
||||
|
||||
blurFilter.set("blurSize", (int)blurSize);
|
||||
blurFilter.set("sigma", sigma);
|
||||
|
||||
canvas.beginDraw();
|
||||
render(canvas);
|
||||
canvas.endDraw();
|
||||
|
||||
// bright pass
|
||||
brightPass.beginDraw();
|
||||
brightPass.shader(bloomFilter);
|
||||
brightPass.image(canvas, 0, 0);
|
||||
brightPass.endDraw();
|
||||
|
||||
// blur horizontal pass
|
||||
horizontalBlurPass.beginDraw();
|
||||
blurFilter.set("horizontalPass", 1);
|
||||
horizontalBlurPass.shader(blurFilter);
|
||||
horizontalBlurPass.image(brightPass, 0, 0);
|
||||
horizontalBlurPass.endDraw();
|
||||
|
||||
// blur vertical pass
|
||||
verticalBlurPass.beginDraw();
|
||||
blurFilter.set("horizontalPass", 0);
|
||||
verticalBlurPass.shader(blurFilter);
|
||||
verticalBlurPass.image(horizontalBlurPass, 0, 0);
|
||||
verticalBlurPass.endDraw();
|
||||
|
||||
// draw original
|
||||
image(canvas.copy(), 0, 0);
|
||||
text("Original", 20, height - 20);
|
||||
|
||||
// draw bright pass
|
||||
image(brightPass, surfaceWidth, 0);
|
||||
text("Bright Pass", surfaceWidth + 20, height - 20);
|
||||
|
||||
image(verticalBlurPass, (surfaceWidth * 2), 0);
|
||||
text("Blur", (surfaceWidth * 2) + 20, height - 20);
|
||||
|
||||
// draw
|
||||
image(canvas, (surfaceWidth * 3), 0);
|
||||
blendMode(SCREEN);
|
||||
image(verticalBlurPass, (surfaceWidth * 3), 0);
|
||||
blendMode(BLEND);
|
||||
text("Combined", (surfaceWidth * 3) + 20, height - 20);
|
||||
|
||||
// fps
|
||||
fill(0, 255, 0);
|
||||
text("FPS: " + frameRate, 20, 20);
|
||||
}
|
||||
|
||||
void render(PGraphics pg)
|
||||
{
|
||||
pg.background(0, 0);
|
||||
pg.stroke(255, 0, 0);
|
||||
|
||||
for (int i = -1; i < 2; i++)
|
||||
{
|
||||
if (i == -1)
|
||||
pg.fill(0, 255, 0);
|
||||
else if (i == 0)
|
||||
pg.fill(255);
|
||||
else
|
||||
pg.fill(0, 200, 200);
|
||||
|
||||
pg.pushMatrix();
|
||||
// left-right, up-down, near-far
|
||||
pg.translate(surfaceWidth / 2 + (i * 50), surfaceHeight / 2, 0);
|
||||
pg.rotateX(radians(angle));
|
||||
pg.rotateZ(radians(angle));
|
||||
pg.box(30);
|
||||
pg.popMatrix();
|
||||
}
|
||||
|
||||
angle = ++angle % 360;
|
||||
}
|
||||
|
||||
void addUI()
|
||||
{
|
||||
cp5 = new ControlP5(this);
|
||||
|
||||
cp5.addSlider("luminanceFilter")
|
||||
.setPosition(200, 5)
|
||||
.setRange(0, 1)
|
||||
;
|
||||
|
||||
cp5.addSlider("blurSize")
|
||||
.setPosition(400, 5)
|
||||
.setRange(0, 100)
|
||||
;
|
||||
|
||||
cp5.addSlider("sigma")
|
||||
.setPosition(600, 5)
|
||||
.setRange(1, 100)
|
||||
;
|
||||
}
|
||||
23
Resources/ThirdParty/BloomFilter/bloomFrag.glsl
vendored
Normal file
23
Resources/ThirdParty/BloomFilter/bloomFrag.glsl
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
varying vec4 vertColor;
|
||||
varying vec4 vertTexCoord;
|
||||
|
||||
uniform float brightPassThreshold;
|
||||
|
||||
void main() {
|
||||
vec3 luminanceVector = vec3(0.2125, 0.7154, 0.0721);
|
||||
vec4 c = texture2D(texture, vertTexCoord.st) * vertColor;
|
||||
|
||||
float luminance = dot(luminanceVector, c.xyz);
|
||||
luminance = max(0.0, luminance - brightPassThreshold);
|
||||
c.xyz *= sign(luminance);
|
||||
c.a = 1.0;
|
||||
|
||||
gl_FragColor = c;
|
||||
}
|
||||
18
Resources/ThirdParty/BloomFilter/bloomVert.glsl
vendored
Normal file
18
Resources/ThirdParty/BloomFilter/bloomVert.glsl
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
#define PROCESSING_TEXTURE_SHADER
|
||||
|
||||
uniform mat4 transform;
|
||||
uniform mat4 texMatrix;
|
||||
|
||||
attribute vec4 vertex;
|
||||
attribute vec4 color;
|
||||
attribute vec2 texCoord;
|
||||
|
||||
varying vec4 vertColor;
|
||||
varying vec4 vertTexCoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = transform * vertex;
|
||||
|
||||
vertColor = color;
|
||||
vertTexCoord = texMatrix * vec4(texCoord, 1.0, 1.0);
|
||||
}
|
||||
59
Resources/ThirdParty/BloomFilter/blurFrag.glsl
vendored
Normal file
59
Resources/ThirdParty/BloomFilter/blurFrag.glsl
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
// Adapted from:
|
||||
// <a href="http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html" target="_blank" rel="nofollow">http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html</a>
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
#define PROCESSING_TEXTURE_SHADER
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
// The inverse of the texture dimensions along X and Y
|
||||
uniform vec2 texOffset;
|
||||
|
||||
varying vec4 vertColor;
|
||||
varying vec4 vertTexCoord;
|
||||
|
||||
uniform int blurSize;
|
||||
uniform int horizontalPass; // 0 or 1 to indicate vertical or horizontal pass
|
||||
uniform float sigma; // The sigma value for the gaussian function: higher value means more blur
|
||||
// A good value for 9x9 is around 3 to 5
|
||||
// A good value for 7x7 is around 2.5 to 4
|
||||
// A good value for 5x5 is around 2 to 3.5
|
||||
// ... play around with this based on what you need <span class="Emoticon Emoticon1"><span>:)</span></span>
|
||||
|
||||
const float pi = 3.14159265;
|
||||
|
||||
void main() {
|
||||
float numBlurPixelsPerSide = float(blurSize / 2);
|
||||
|
||||
vec2 blurMultiplyVec = 0 < horizontalPass ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
|
||||
|
||||
// Incremental Gaussian Coefficent Calculation (See GPU Gems 3 pp. 877 - 889)
|
||||
vec3 incrementalGaussian;
|
||||
incrementalGaussian.x = 1.0 / (sqrt(2.0 * pi) * sigma);
|
||||
incrementalGaussian.y = exp(-0.5 / (sigma * sigma));
|
||||
incrementalGaussian.z = incrementalGaussian.y * incrementalGaussian.y;
|
||||
|
||||
vec4 avgValue = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
float coefficientSum = 0.0;
|
||||
|
||||
// Take the central sample first...
|
||||
avgValue += texture2D(texture, vertTexCoord.st) * incrementalGaussian.x;
|
||||
coefficientSum += incrementalGaussian.x;
|
||||
incrementalGaussian.xy *= incrementalGaussian.yz;
|
||||
|
||||
// Go through the remaining 8 vertical samples (4 on each side of the center)
|
||||
for (float i = 1.0; i <= numBlurPixelsPerSide; i++) {
|
||||
avgValue += texture2D(texture, vertTexCoord.st - i * texOffset *
|
||||
blurMultiplyVec) * incrementalGaussian.x;
|
||||
avgValue += texture2D(texture, vertTexCoord.st + i * texOffset *
|
||||
blurMultiplyVec) * incrementalGaussian.x;
|
||||
coefficientSum += 2.0 * incrementalGaussian.x;
|
||||
incrementalGaussian.xy *= incrementalGaussian.yz;
|
||||
}
|
||||
|
||||
gl_FragColor = avgValue / coefficientSum;
|
||||
}
|
||||
18
Resources/ThirdParty/BloomFilter/blurVert.glsl
vendored
Normal file
18
Resources/ThirdParty/BloomFilter/blurVert.glsl
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
#define PROCESSING_TEXTURE_SHADER
|
||||
|
||||
uniform mat4 transform;
|
||||
uniform mat4 texMatrix;
|
||||
|
||||
attribute vec4 vertex;
|
||||
attribute vec4 color;
|
||||
attribute vec2 texCoord;
|
||||
|
||||
varying vec4 vertColor;
|
||||
varying vec4 vertTexCoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = transform * vertex;
|
||||
|
||||
vertColor = color;
|
||||
vertTexCoord = texMatrix * vec4(texCoord, 1.0, 1.0);
|
||||
}
|
||||
48
Resources/ThirdParty/MotionBlur/motionBlur_f.glsl
vendored
Normal file
48
Resources/ThirdParty/MotionBlur/motionBlur_f.glsl
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
#version 330 core
|
||||
//Per-Object Motion Blur
|
||||
|
||||
uniform sampler2D uTexInput; // texture we're blurring
|
||||
uniform sampler2D uTexVelocity; // velocity buffer
|
||||
|
||||
in vec2 texture_coordinate;
|
||||
|
||||
uniform float uVelocityScale; //currentFps / targetFps
|
||||
/*
|
||||
What's uVelocityScale? It's used to address the following problem:
|
||||
if the framerate is very high, velocity will be very small as the
|
||||
amount of motion in between frames will be low. Correspondingly, if
|
||||
the framerate is very low the motion between frames will be high
|
||||
and velocity will be much larger. This ties the blur size to the
|
||||
framerate, which is technically correct if you equate framrate with
|
||||
shutter speed, however is undesirable for realtime rendering where
|
||||
the framerate can vary. To fix it we need to cancel out the framerate
|
||||
*/
|
||||
|
||||
int MAX_SAMPLES = 16; //32
|
||||
|
||||
layout (location=0) out vec4 result;
|
||||
|
||||
void main(void) {
|
||||
|
||||
vec2 velocity = texture(uTexVelocity, texture_coordinate).rg * 2.0 - 1.0;
|
||||
velocity *= uVelocityScale;
|
||||
|
||||
//get the size of on pixel (texel)
|
||||
vec2 texelSize = 1.0 / vec2(textureSize(uTexInput, 0));
|
||||
//mprove performance by adapting the number of samples according to the velocity
|
||||
float speed = length(velocity / texelSize);
|
||||
int nSamples = clamp(int(speed), 1, MAX_SAMPLES);
|
||||
result = vec4(0.0);
|
||||
|
||||
velocity = normalize(velocity) * texelSize;
|
||||
float hlim = float(-nSamples) * 0.5 + 0.5;
|
||||
//the actual blurring of the current pixel
|
||||
vec2 offset;
|
||||
for (int i = 0; i < nSamples; ++i)
|
||||
{
|
||||
offset = velocity * (hlim + float(i));
|
||||
result += texture(uTexInput, texture_coordinate + offset);
|
||||
}
|
||||
//average the result
|
||||
result /= float(nSamples);
|
||||
}
|
||||
12
Resources/ThirdParty/MotionBlur/motionBlur_v.glsl
vendored
Normal file
12
Resources/ThirdParty/MotionBlur/motionBlur_v.glsl
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
#version 330 compatibility
|
||||
|
||||
out vec2 texture_coordinate;
|
||||
|
||||
void main()
|
||||
{
|
||||
//set the position of the current vertex
|
||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
|
||||
texture_coordinate = vec2(gl_MultiTexCoord0);
|
||||
}
|
||||
59
Resources/ThirdParty/ProcessingPostFX/shader/blurFrag.glsl
vendored
Normal file
59
Resources/ThirdParty/ProcessingPostFX/shader/blurFrag.glsl
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
// Adapted from:
|
||||
// <a href="http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html" target="_blank" rel="nofollow">http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html</a>
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
#define PROCESSING_TEXTURE_SHADER
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
// The inverse of the texture dimensions along X and Y
|
||||
uniform vec2 texOffset;
|
||||
|
||||
varying vec4 vertColor;
|
||||
varying vec4 vertTexCoord;
|
||||
|
||||
uniform int blurSize;
|
||||
uniform int horizontalPass; // 0 or 1 to indicate vertical or horizontal pass
|
||||
uniform float sigma; // The sigma value for the gaussian function: higher value means more blur
|
||||
// A good value for 9x9 is around 3 to 5
|
||||
// A good value for 7x7 is around 2.5 to 4
|
||||
// A good value for 5x5 is around 2 to 3.5
|
||||
// ... play around with this based on what you need <span class="Emoticon Emoticon1"><span>:)</span></span>
|
||||
|
||||
const float pi = 3.14159265;
|
||||
|
||||
void main() {
|
||||
float numBlurPixelsPerSide = float(blurSize / 2);
|
||||
|
||||
vec2 blurMultiplyVec = 0 < horizontalPass ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
|
||||
|
||||
// Incremental Gaussian Coefficent Calculation (See GPU Gems 3 pp. 877 - 889)
|
||||
vec3 incrementalGaussian;
|
||||
incrementalGaussian.x = 1.0 / (sqrt(2.0 * pi) * sigma);
|
||||
incrementalGaussian.y = exp(-0.5 / (sigma * sigma));
|
||||
incrementalGaussian.z = incrementalGaussian.y * incrementalGaussian.y;
|
||||
|
||||
vec4 avgValue = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
float coefficientSum = 0.0;
|
||||
|
||||
// Take the central sample first...
|
||||
avgValue += texture2D(texture, vertTexCoord.st) * incrementalGaussian.x;
|
||||
coefficientSum += incrementalGaussian.x;
|
||||
incrementalGaussian.xy *= incrementalGaussian.yz;
|
||||
|
||||
// Go through the remaining 8 vertical samples (4 on each side of the center)
|
||||
for (float i = 1.0; i <= numBlurPixelsPerSide; i++) {
|
||||
avgValue += texture2D(texture, vertTexCoord.st - i * texOffset *
|
||||
blurMultiplyVec) * incrementalGaussian.x;
|
||||
avgValue += texture2D(texture, vertTexCoord.st + i * texOffset *
|
||||
blurMultiplyVec) * incrementalGaussian.x;
|
||||
coefficientSum += 2.0 * incrementalGaussian.x;
|
||||
incrementalGaussian.xy *= incrementalGaussian.yz;
|
||||
}
|
||||
|
||||
gl_FragColor = avgValue / coefficientSum;
|
||||
}
|
||||
23
Resources/ThirdParty/ProcessingPostFX/shader/brightPassFrag.glsl
vendored
Normal file
23
Resources/ThirdParty/ProcessingPostFX/shader/brightPassFrag.glsl
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
varying vec4 vertColor;
|
||||
varying vec4 vertTexCoord;
|
||||
|
||||
uniform float brightPassThreshold;
|
||||
|
||||
void main() {
|
||||
vec3 luminanceVector = vec3(0.2125, 0.7154, 0.0721);
|
||||
vec4 c = texture2D(texture, vertTexCoord.st) * vertColor;
|
||||
|
||||
float luminance = dot(luminanceVector, c.xyz);
|
||||
luminance = max(0.0, luminance - brightPassThreshold);
|
||||
c.xyz *= sign(luminance);
|
||||
c.a = 1.0;
|
||||
|
||||
gl_FragColor = c;
|
||||
}
|
||||
38
Resources/ThirdParty/ProcessingPostFX/shader/sobelFrag.glsl
vendored
Executable file
38
Resources/ThirdParty/ProcessingPostFX/shader/sobelFrag.glsl
vendored
Executable file
@@ -0,0 +1,38 @@
|
||||
// Adapted from:
|
||||
// <a href="http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html" target="_blank" rel="nofollow">http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html</a>
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
#define PROCESSING_TEXTURE_SHADER
|
||||
|
||||
uniform sampler2D texture;
|
||||
|
||||
varying vec4 vertColor;
|
||||
varying vec4 vertTexCoord;
|
||||
|
||||
uniform vec2 resolution;
|
||||
|
||||
void main(void) {
|
||||
float x = 1.0 / resolution.x;
|
||||
float y = 1.0 / resolution.y;
|
||||
vec4 horizEdge = vec4( 0.0 );
|
||||
horizEdge -= texture2D( texture, vec2( vertTexCoord.x - x, vertTexCoord.y - y ) ) * 1.0;
|
||||
horizEdge -= texture2D( texture, vec2( vertTexCoord.x - x, vertTexCoord.y ) ) * 2.0;
|
||||
horizEdge -= texture2D( texture, vec2( vertTexCoord.x - x, vertTexCoord.y + y ) ) * 1.0;
|
||||
horizEdge += texture2D( texture, vec2( vertTexCoord.x + x, vertTexCoord.y - y ) ) * 1.0;
|
||||
horizEdge += texture2D( texture, vec2( vertTexCoord.x + x, vertTexCoord.y ) ) * 2.0;
|
||||
horizEdge += texture2D( texture, vec2( vertTexCoord.x + x, vertTexCoord.y + y ) ) * 1.0;
|
||||
vec4 vertEdge = vec4( 0.0 );
|
||||
vertEdge -= texture2D( texture, vec2( vertTexCoord.x - x, vertTexCoord.y - y ) ) * 1.0;
|
||||
vertEdge -= texture2D( texture, vec2( vertTexCoord.x , vertTexCoord.y - y ) ) * 2.0;
|
||||
vertEdge -= texture2D( texture, vec2( vertTexCoord.x + x, vertTexCoord.y - y ) ) * 1.0;
|
||||
vertEdge += texture2D( texture, vec2( vertTexCoord.x - x, vertTexCoord.y + y ) ) * 1.0;
|
||||
vertEdge += texture2D( texture, vec2( vertTexCoord.x , vertTexCoord.y + y ) ) * 2.0;
|
||||
vertEdge += texture2D( texture, vec2( vertTexCoord.x + x, vertTexCoord.y + y ) ) * 1.0;
|
||||
vec3 edge = sqrt((horizEdge.rgb * horizEdge.rgb) + (vertEdge.rgb * vertEdge.rgb));
|
||||
|
||||
gl_FragColor = vec4(edge, texture2D(texture, vertTexCoord.xy).a);
|
||||
}
|
||||
@@ -14,25 +14,25 @@ Size=500,250
|
||||
Collapsed=0
|
||||
|
||||
[Window][DockSpace]
|
||||
Pos=0,21
|
||||
Size=1920,985
|
||||
Pos=0,23
|
||||
Size=1920,983
|
||||
Collapsed=0
|
||||
|
||||
[Window][Viewport]
|
||||
Pos=306,42
|
||||
Size=1265,741
|
||||
Pos=306,46
|
||||
Size=1265,737
|
||||
Collapsed=0
|
||||
DockId=0x00000002,0
|
||||
|
||||
[Window][Hierarchy]
|
||||
Pos=0,42
|
||||
Size=304,741
|
||||
Pos=0,46
|
||||
Size=304,737
|
||||
Collapsed=0
|
||||
DockId=0x00000001,0
|
||||
|
||||
[Window][Inspector]
|
||||
Pos=1573,42
|
||||
Size=347,964
|
||||
Pos=1573,46
|
||||
Size=347,960
|
||||
Collapsed=0
|
||||
DockId=0x00000008,0
|
||||
|
||||
@@ -60,25 +60,31 @@ Size=1000,800
|
||||
Collapsed=0
|
||||
|
||||
[Window][Camera]
|
||||
Pos=0,42
|
||||
Size=304,741
|
||||
Pos=0,46
|
||||
Size=304,737
|
||||
Collapsed=0
|
||||
DockId=0x00000001,1
|
||||
|
||||
[Window][Environment]
|
||||
Pos=1573,42
|
||||
Size=347,964
|
||||
Pos=1573,46
|
||||
Size=347,960
|
||||
Collapsed=0
|
||||
DockId=0x00000008,1
|
||||
|
||||
[Window][Project Manager]
|
||||
Pos=787,785
|
||||
Size=784,221
|
||||
Collapsed=0
|
||||
DockId=0x00000006,1
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0xD71539A0 Window=0x3DA2F1DE Pos=0,42 Size=1920,964 Split=X
|
||||
DockSpace ID=0xD71539A0 Window=0x3DA2F1DE Pos=0,46 Size=1920,960 Split=X
|
||||
DockNode ID=0x00000007 Parent=0xD71539A0 SizeRef=1509,1015 Split=Y
|
||||
DockNode ID=0x00000003 Parent=0x00000007 SizeRef=1858,792 Split=X
|
||||
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=304,758 Selected=0xBABDAE5E
|
||||
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=694,758 CentralNode=1 Selected=0xC450F867
|
||||
DockNode ID=0x00000004 Parent=0x00000007 SizeRef=1858,221 Split=X Selected=0xEA83D666
|
||||
DockNode ID=0x00000005 Parent=0x00000004 SizeRef=929,221 Selected=0xEA83D666
|
||||
DockNode ID=0x00000006 Parent=0x00000004 SizeRef=927,221 Selected=0x9C21DE82
|
||||
DockNode ID=0x00000006 Parent=0x00000004 SizeRef=927,221 Selected=0xDA0DCE3C
|
||||
DockNode ID=0x00000008 Parent=0xD71539A0 SizeRef=347,1015 Selected=0x36DC96AB
|
||||
|
||||
|
||||
Reference in New Issue
Block a user