#
source:
orange/orange/OrangeWidgets/plot/generator.gs
@
8786:5625ec1ac9e6

Revision 8786:5625ec1ac9e6, 3.0 KB checked in by matejd <matejd@…>, 3 years ago (diff) |
---|

Line | |
---|---|

1 | #version 150 |

2 | |

3 | layout(points) in; |

4 | layout(triangle_strip, max_vertices=144) out; |

5 | |

6 | uniform int x_index; |

7 | uniform int y_index; |

8 | uniform int z_index; |

9 | uniform int color_index; |

10 | uniform int symbol_index; |

11 | uniform int size_index; |

12 | |

13 | uniform bool use_2d_symbols; |

14 | |

15 | uniform float jitter_size; |

16 | uniform bool jitter_continuous; |

17 | uniform bool x_discrete; |

18 | uniform bool y_discrete; |

19 | uniform bool z_discrete; |

20 | |

21 | uniform samplerBuffer symbol_buffer; |

22 | uniform samplerBuffer data_buffer; |

23 | |

24 | uniform int num_symbols_used; |

25 | uniform int[20] symbols_indices; |

26 | uniform int[20] symbols_sizes; |

27 | uniform int example_size; |

28 | |

29 | // Colors are specified in case of a discrete attribute. |

30 | uniform int num_colors; |

31 | uniform vec3[50] colors; |

32 | |

33 | out vec3 out_position; |

34 | out vec3 out_offset; |

35 | out vec3 out_color; |

36 | out vec3 out_normal; |

37 | out float out_index; |

38 | |

39 | // http://stackoverflow.com/questions/4200224/random-noise-functions-for-glsl |

40 | // Should return pseudo-random value [-0.5, 0.5] |

41 | float rand(vec3 co){ |

42 | return fract(sin(dot(co.xyz, vec3(12.9898, 78.233, 42.42))) * 43758.5453) - 0.5; |

43 | } |

44 | |

45 | void main() |

46 | { |

47 | vec4 position = gl_in[0].gl_Position; |

48 | const float scale = 0.001; |

49 | |

50 | out_index = position.x; |

51 | int index = int(out_index * example_size); |

52 | |

53 | out_position = vec3(texelFetch(data_buffer, index+x_index).x, |

54 | texelFetch(data_buffer, index+y_index).x, |

55 | texelFetch(data_buffer, index+z_index).x); |

56 | |

57 | if (x_discrete || jitter_continuous) |

58 | out_position.x += rand(out_position * out_index) * jitter_size / 100.; |

59 | if (y_discrete || jitter_continuous) |

60 | out_position.y += rand(out_position * out_index) * jitter_size / 100.; |

61 | if (z_discrete || jitter_continuous) |

62 | out_position.z += rand(out_position * out_index) * jitter_size / 100.; |

63 | |

64 | int symbol = 0; |

65 | if (num_symbols_used > 1 && symbol_index > -1) |

66 | symbol = clamp(int(texelFetch(data_buffer, index+symbol_index).x * num_symbols_used), 0, 9); |

67 | if (!use_2d_symbols) |

68 | symbol += 10; |

69 | |

70 | float size = texelFetch(data_buffer, index+size_index).x; |

71 | if (size_index < 0 || size < 0.) |

72 | size = 1.; |

73 | |

74 | float color = texelFetch(data_buffer, index+color_index).x; |

75 | if (num_colors > 0) |

76 | out_color = colors[int(color*num_colors)]; |

77 | else if (color_index > -1) |

78 | out_color = vec3(0., 0., color); |

79 | else |

80 | out_color = vec3(0., 0., 0.8); |

81 | |

82 | for (int i = 0; i < symbols_sizes[symbol]; ++i) |

83 | { |

84 | out_offset = texelFetch(symbol_buffer, symbols_indices[symbol]+i*6+0).xyz * size * scale; |

85 | out_normal = texelFetch(symbol_buffer, symbols_indices[symbol]+i*6+3).xyz; |

86 | EmitVertex(); |

87 | out_offset = texelFetch(symbol_buffer, symbols_indices[symbol]+i*6+1).xyz * size * scale; |

88 | out_normal = texelFetch(symbol_buffer, symbols_indices[symbol]+i*6+4).xyz; |

89 | EmitVertex(); |

90 | out_offset = texelFetch(symbol_buffer, symbols_indices[symbol]+i*6+2).xyz * size * scale; |

91 | out_normal = texelFetch(symbol_buffer, symbols_indices[symbol]+i*6+5).xyz; |

92 | EmitVertex(); |

93 | |

94 | EndPrimitive(); |

95 | } |

96 | } |

**Note:**See TracBrowser for help on using the repository browser.