glsl

GLSL Tessellation shader number of triangles/faces?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-30 14:46:13
问题 I have implemented a triangle tessellation shader as shown in the example on this website. How can I determine the total number of faces that would be output for defined inter and outer tessellation factors? - It doesn't effect my program in any way I would just like to know my poly/face count. 回答1: The number of triangles for the barycentric subdivision of a single triangle (where the inner and outer subdivision is equal) can be found using a simple recursion: // Calculate number of

glsl refraction getting mapped upside down

一个人想着一个人 提交于 2019-12-30 03:21:05
问题 I am implementing refraction in glsl. I am using the refract function provided in frag shader to get the desired effect. But the refraction I am getting, its upside down. I think this is wrong.. any idea why is it so? This is what I do in vertex shader: vec3 worldView = normalize(vec3(WorldCameraPosition-worldPos)); refractor = refract(-worldView, worldNorm, Eta); // eta = 0.66; and then frag shader I do: vec4 refractColor = textureCube(cubeMap, refractor); http://www.cse.ohio-state.edu/

Why does barrier synchronize shared memory when memoryBarrier doesn't?

做~自己de王妃 提交于 2019-12-30 03:02:07
问题 The following GLSL compute shader simply copies inImage to outImage . It is derived from a more complex post-processing pass. In the first several lines of main() , a single thread loads 64 pixels of data into the shared array. Then, after synchronizing, each of the 64 threads writes one pixel to the output image. Depending on how I synchronize, I get different results. I originally thought memoryBarrierShared() would be the correct call, but it produces the following result: which is the

OpenGL: How to render perfect rectangular gradient?

允我心安 提交于 2019-12-30 00:41:05
问题 I can render triangular gradient with simply just one triangle and using glColor for each corner. But how to render perfect rectangular gradient? I tried with one quad, but the middle will get ugly seam. I also tried with texture of 2x2 size, it was like it should be done: proper blending from each corner, but the texture sampling precision becomes unprecise when stretched too much (i started to see pixels bigger than 1x1 size). Is there some way of calculating this in a shader perhaps? --

WebGL/GLSL - How does a ShaderToy work?

◇◆丶佛笑我妖孽 提交于 2019-12-29 10:09:11
问题 I've been knocking around Shadertoy - https://www.shadertoy.com/ - recently, in an effort to learn more about OpenGL and GLSL in particular. From what I understand so far, the OpenGL user first has to prepare all the geometry to be used and configure the OpenGL server (number of lights allowed, texture storage, etc). Once that's done, the user then has to provide at least one vertex shader program, and one fragment shader program before an OpenGL program compiles. However, when I look at the

WebGL/GLSL - How does a ShaderToy work?

萝らか妹 提交于 2019-12-29 10:09:08
问题 I've been knocking around Shadertoy - https://www.shadertoy.com/ - recently, in an effort to learn more about OpenGL and GLSL in particular. From what I understand so far, the OpenGL user first has to prepare all the geometry to be used and configure the OpenGL server (number of lights allowed, texture storage, etc). Once that's done, the user then has to provide at least one vertex shader program, and one fragment shader program before an OpenGL program compiles. However, when I look at the

Issue when porting from OpenGL 1.1 to OpenGL-ES 2.0

浪子不回头ぞ 提交于 2019-12-29 09:42:20
问题 this is my opengl-es 2.0 code : { for (surfnum=0;surfnum<surftotal;surfnum++){ for (i=0;i<triNum[surfnum];i++){ GLfloat *Vertices[] = { triArray[surfnum][i].normpt1, triArray[surfnum][i].normpt2,triArray[surfnum][i].normpt3}; glGenBuffers(1, &ui32Vbo); glBindBuffer(GL_ARRAY_BUFFER, ui32Vbo); unsigned int uiSize = 3 * (sizeof(GLfloat) * 1); glBufferData(GL_ARRAY_BUFFER, uiSize,*Vertices, GL_STATIC_DRAW); } } } for(int i = 0; i < 80000; ++i) { glClear(GL_COLOR_BUFFER_BIT); int i32Location =

How to do a shader to convert to azimuthal_equidistant

南笙酒味 提交于 2019-12-29 09:26:10
问题 I have a 360 texture in Equirectangular Projection. With what GLSL shader can I convert it into a azimuthal equidistant projection? See also: http://earth.nullschool.net/#current/wind/isobaric/500hPa/azimuthal_equidistant=24.64,98.15,169 回答1: I would do it in Fragment shader. bind Equirectangular texture as 2D texture bind projection shader draw Quad covering the screen or target texture store or use the result. In Vertex shader I would: Just pass the vertex coordinates as varying to fragment

What version of GLSL is used in the iPhone(s)?

我与影子孤独终老i 提交于 2019-12-29 08:30:15
问题 I know that iPhone uses OpenGL ES 2.0, but I don't know the version of the underlying language GLSL. Is it 1.3, 1.4, 2.0, or other? 回答1: Ok, I found it myself, thanks to the _____VERSION_____ predefined macro. The GLSL ES specification used is the 1.0, which is based on the GLSL version 1.20. The OpengGL ES 2.0 and GLSL ES 1.0 specifications are available for download at http://www.khronos.org/registry/gles/. 回答2: printf("GLSL Version = %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); printf

correct glsl affine texture mapping

主宰稳场 提交于 2019-12-29 07:53:09
问题 i'm trying to code correct 2D affine texture mapping in GLSL. Explanation: ...NONE of this images is correct for my purposes. Right (labeled Correct) has perspective correction which i do not want. So this: Getting to know the Q texture coordinate solution (without further improvements) is not what I'm looking for. I'd like to simply "stretch" texture inside quadrilateral, something like this: but composed from two triangles. Any advice (GLSL) please? 回答1: This works well as long as you have