Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17560

GLSL: 9-slicing

$
0
0

I have a 9-slice shader working mostly nicely:

9-slice.png.231188fe8ce59a994fa693ec76675036.png

slice-scifi.png.461bcea84f60a33e3ac0fa1672f3b05a.png     slice-dashed.png.d215b7f9bf17f71a0c232b646f75c3b2.png

Here, both the sprites are separate images, so the shader code works well:

varying vec4 color;
varying vec2 texCoord;

uniform sampler2D tex;

uniform vec2 u_dimensions;
uniform vec2 u_border;floatmap(float value,float originalMin,float originalMax,float newMin,float newMax){return(value - originalMin)/(originalMax - originalMin)*(newMax - newMin)+ newMin;}// Helper function, because WET code is bad code// Takes in the coordinate on the …

Viewing all articles
Browse latest Browse all 17560

Latest Images

Trending Articles



Latest Images