glsl

webgl: fastest approach to drawing many circles

為{幸葍}努か 提交于 2020-12-04 11:39:34
问题 I'm currently drawing thousands of circles, instancing a circle geometry (many triangles). alternatively, I could simply instance a quad (2 triangles), but cut out a circle in the fragment shader, using a distance function and discard . which approach would be faster? -- is drawing many triangles more expensive than the calculations done in the fragment shader? 回答1: The fastest way might depend on the GPU and lots of other factors like how you're drawing the circles, 2D, 3D, are you blending

Working around gl_PointSize limitations in three.js / webGL

假装没事ソ 提交于 2020-12-01 07:18:50
问题 I'm using three.js to create an interactive data visualisation. This visualisation involves rendering 68000 nodes, where each different node has a different size and color. Initially I tried to do this by rendering meshes, but that proved to be very expensive. My current attempt is to use a three.js particle system, with each point being a node in the visualisation. I can control the color * size of the point, but only to a certain point. On my card, the maximum size for a gl point seems to

Working around gl_PointSize limitations in three.js / webGL

血红的双手。 提交于 2020-12-01 07:18:01
问题 I'm using three.js to create an interactive data visualisation. This visualisation involves rendering 68000 nodes, where each different node has a different size and color. Initially I tried to do this by rendering meshes, but that proved to be very expensive. My current attempt is to use a three.js particle system, with each point being a node in the visualisation. I can control the color * size of the point, but only to a certain point. On my card, the maximum size for a gl point seems to

Drawing a triangle in OpenGL fragment shader

不问归期 提交于 2020-11-29 23:50:37
问题 I'm trying to draw a triangle using an OpenGL fragment shader. I succeeded in drawing a circle but I have a problem with handling the equation/logic or the code to draw a triangle. draw_triangle(vec2 v1 , vec2 v2, vec2 v3) Here is the fragment shader: #version 330 core out vec4 frag_color; void draw_circle(vec2 shift_val, int radius,int color) { vec2 res = vec2(1280,720); vec2 norm_cord = gl_FragCoord.xy; float dist = length(norm_cord - (res*shift_val)); if( dist < radius ) { if( color ==1 )

Drawing a triangle in OpenGL fragment shader

淺唱寂寞╮ 提交于 2020-11-29 23:46:23
问题 I'm trying to draw a triangle using an OpenGL fragment shader. I succeeded in drawing a circle but I have a problem with handling the equation/logic or the code to draw a triangle. draw_triangle(vec2 v1 , vec2 v2, vec2 v3) Here is the fragment shader: #version 330 core out vec4 frag_color; void draw_circle(vec2 shift_val, int radius,int color) { vec2 res = vec2(1280,720); vec2 norm_cord = gl_FragCoord.xy; float dist = length(norm_cord - (res*shift_val)); if( dist < radius ) { if( color ==1 )

Drawing a triangle in OpenGL fragment shader

笑着哭i 提交于 2020-11-29 23:43:16
问题 I'm trying to draw a triangle using an OpenGL fragment shader. I succeeded in drawing a circle but I have a problem with handling the equation/logic or the code to draw a triangle. draw_triangle(vec2 v1 , vec2 v2, vec2 v3) Here is the fragment shader: #version 330 core out vec4 frag_color; void draw_circle(vec2 shift_val, int radius,int color) { vec2 res = vec2(1280,720); vec2 norm_cord = gl_FragCoord.xy; float dist = length(norm_cord - (res*shift_val)); if( dist < radius ) { if( color ==1 )

Drawing a triangle in OpenGL fragment shader

有些话、适合烂在心里 提交于 2020-11-29 23:42:47
问题 I'm trying to draw a triangle using an OpenGL fragment shader. I succeeded in drawing a circle but I have a problem with handling the equation/logic or the code to draw a triangle. draw_triangle(vec2 v1 , vec2 v2, vec2 v3) Here is the fragment shader: #version 330 core out vec4 frag_color; void draw_circle(vec2 shift_val, int radius,int color) { vec2 res = vec2(1280,720); vec2 norm_cord = gl_FragCoord.xy; float dist = length(norm_cord - (res*shift_val)); if( dist < radius ) { if( color ==1 )

Drawing a triangle in OpenGL fragment shader

我们两清 提交于 2020-11-29 23:42:40
问题 I'm trying to draw a triangle using an OpenGL fragment shader. I succeeded in drawing a circle but I have a problem with handling the equation/logic or the code to draw a triangle. draw_triangle(vec2 v1 , vec2 v2, vec2 v3) Here is the fragment shader: #version 330 core out vec4 frag_color; void draw_circle(vec2 shift_val, int radius,int color) { vec2 res = vec2(1280,720); vec2 norm_cord = gl_FragCoord.xy; float dist = length(norm_cord - (res*shift_val)); if( dist < radius ) { if( color ==1 )

Draw a simple dotted line or dashed line in OpenGL GLES20 android using fragment shader and GL_LINE_STRIP

こ雲淡風輕ζ 提交于 2020-11-29 03:31:10
问题 I went through different sources and seen that we could draw a dotted line using a fragment shader. Because I am new to OpenGL I couldn't able to understand. Can anyone share some code sample that plot dotted or dashed line using fragment shader and GL_LINE_STRIP in Android. References: Dashed line in OpenGL3? Dotted back edges of object 回答1: Line stipple is not supported in OpenGL ES. If you use OpenGL ES 1.00, then you can use the approach which is presented in the answers to OpenGL ES -