Star

Created With

linkArte Ascci - Hardware

linkPlanteamiento del Problema

Realizar la conversion de una imagen a arte ASCII por Hardware.

linkCodigo & Resultados

linkImagen Wolverine Original y en arte ASCII con P5

1link> precision mediump float;

2link>

3link> uniform sampler2D image;

4link>

5link> uniform sampler2D symbol1;

6link> uniform sampler2D symbol2;

7link> uniform sampler2D symbol3;

8link> uniform sampler2D symbol4;

9link> uniform sampler2D symbol5;

10link> uniform sampler2D symbol6;

11link> uniform sampler2D symbol7;

12link> uniform sampler2D symbol8;

13link> uniform sampler2D symbol9;

14link> uniform sampler2D symbol10;

15link> uniform sampler2D symbol11;

16link> uniform sampler2D symbol12;

17link> uniform sampler2D symbol13;

18link> uniform sampler2D symbol14;

19link>

20link> uniform bool debug;

21link>

22link> uniform float resolution;

23link>

24link> varying vec4 vVertexColor;

25link>

26link> varying vec2 vTexCoord;

27link>

28link> void main() {

29link>

30link> vec2 symbolCoord = vTexCoord * resolution;

31link>

32link> vec2 imageCoord = floor(symbolCoord);

33link> symbolCoord = symbolCoord - imageCoord;

34link> vec4 col = texture2D(image, vTexCoord) * vVertexColor;

35link> float grayLuma = dot(col.rgb, vec3(1, 1, 1));

36link>

37link> if(grayLuma > 2.6)

38link> gl_FragColor = texture2D(symbol14, symbolCoord) * vVertexColor;

39link> else if(grayLuma > 2.4)

40link> gl_FragColor = texture2D(symbol13, symbolCoord) * vVertexColor;

41link> else if(grayLuma > 2.2)

42link> gl_FragColor = texture2D(symbol12, symbolCoord) * vVertexColor;

43link> else if(grayLuma > 2.0)

44link> gl_FragColor = texture2D(symbol11, symbolCoord) * vVertexColor;

45link> else if(grayLuma > 1.8)

46link> gl_FragColor = texture2D(symbol10, symbolCoord) * vVertexColor;

47link> else if(grayLuma > 1.6)

48link> gl_FragColor = texture2D(symbol9, symbolCoord) * vVertexColor;

49link> else if(grayLuma > 1.4)

50link> gl_FragColor = texture2D(symbol8, symbolCoord) * vVertexColor;

51link> else if(grayLuma > 1.2)

52link> gl_FragColor = texture2D(symbol7, symbolCoord) * vVertexColor;

53link> else if(grayLuma > 1.0)

54link> gl_FragColor = texture2D(symbol6, symbolCoord) * vVertexColor;

55link> else if(grayLuma > 0.8)

56link> gl_FragColor = texture2D(symbol5, symbolCoord) * vVertexColor;

57link> else if(grayLuma > 0.6)

58link> gl_FragColor = texture2D(symbol4, symbolCoord) * vVertexColor;

59link> else if(grayLuma > 0.4)

60link> gl_FragColor = texture2D(symbol3, symbolCoord) * vVertexColor;

61link> else if(grayLuma > 0.2)

62link> gl_FragColor = texture2D(symbol2, symbolCoord) * vVertexColor;

63link> else

64link> gl_FragColor = texture2D(symbol1, symbolCoord) * vVertexColor;

65link>

66link> }

Arte Ascci - HardwarePlanteamiento del ProblemaCodigo & ResultadosImagen Wolverine Original y en arte ASCII con P5

Home

Workshopschevron_right
Imaging & Videochevron_right
Softwarechevron_right
Hardwarechevron_right
Renderingchevron_right

Algovis Computer Graphics HCI

P5 Code Snippetschevron_right
Memberschevron_right