chore: format shaders
This commit is contained in:
@@ -9,8 +9,7 @@ uniform mat4 mvp;
|
|||||||
out vec2 fragTexCoord;
|
out vec2 fragTexCoord;
|
||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
|
|
||||||
void main()
|
void main() {
|
||||||
{
|
|
||||||
fragTexCoord = vertexTexCoord;
|
fragTexCoord = vertexTexCoord;
|
||||||
fragColor = vertexColor;
|
fragColor = vertexColor;
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ uniform float shapeInfluence;
|
|||||||
out vec4 finalColor;
|
out vec4 finalColor;
|
||||||
|
|
||||||
float getBallInfluence(vec2 pos, vec2 center, float radius) {
|
float getBallInfluence(vec2 pos, vec2 center, float radius) {
|
||||||
vec2 diff = pos - center;
|
vec2 diff = pos - center;
|
||||||
float distSq = dot(diff, diff);
|
float distSq = dot(diff, diff);
|
||||||
float radiusSq = radius * radius;
|
float radiusSq = radius * radius;
|
||||||
if (distSq > radiusSq) return 0.0;
|
if (distSq > radiusSq) return 0.0;
|
||||||
float dist = sqrt(distSq);
|
float dist = sqrt(distSq);
|
||||||
@@ -25,17 +25,15 @@ float getShapeInfluence(vec2 pos) {
|
|||||||
vec2 uv = pos / resolution;
|
vec2 uv = pos / resolution;
|
||||||
uv.y = 1.0 - uv.y;
|
uv.y = 1.0 - uv.y;
|
||||||
|
|
||||||
if (any(lessThan(uv, vec2(0.0))) || any(greaterThan(uv, vec2(1.0)))) {
|
if (any(lessThan(uv, vec2(0.0))) || any(greaterThan(uv, vec2(1.0)))) return 0.0;
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
float signedDistance = texture(distanceFieldTex, uv).r * 255.0 - 128.0;
|
float signedDistance = texture(distanceFieldTex, uv).r * 255.0 - 128.0;
|
||||||
|
|
||||||
float isInside = step(signedDistance, 0.0);
|
float isInside = step(signedDistance, 0.0);
|
||||||
float isOutside = 1.0 - isInside;
|
float isOutside = 1.0 - isInside;
|
||||||
|
|
||||||
// inside calculation
|
// inside calculation
|
||||||
float normalizedDist = abs(signedDistance) * 0.015625; // 1/64
|
float normalizedDist = abs(signedDistance) * 0.015625; // 1/64
|
||||||
float insideInfluence = shapeInfluence * exp(-normalizedDist * 0.5) * 3.0;
|
float insideInfluence = shapeInfluence * exp(-normalizedDist * 0.5) * 3.0;
|
||||||
|
|
||||||
// outside calculation
|
// outside calculation
|
||||||
@@ -47,11 +45,10 @@ float getShapeInfluence(vec2 pos) {
|
|||||||
return isInside * insideInfluence + isOutside * outsideInfluence;
|
return isInside * insideInfluence + isOutside * outsideInfluence;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main() {
|
||||||
{
|
|
||||||
vec2 pixelPos = fragTexCoord * resolution;
|
vec2 pixelPos = fragTexCoord * resolution;
|
||||||
|
|
||||||
float ballValue = getBallInfluence(pixelPos, mousePos, ballRadius);
|
float ballValue = getBallInfluence(pixelPos, mousePos, ballRadius);
|
||||||
float shapeValue = getShapeInfluence(pixelPos);
|
float shapeValue = getShapeInfluence(pixelPos);
|
||||||
float totalValue = ballValue + shapeValue * 0.01;
|
float totalValue = ballValue + shapeValue * 0.01;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user