glsl

How to convert large arrays of quad primitives to triangle primitives?

梦想的初衷 提交于 2020-01-15 20:23:13
问题 The bounty expires in 4 days . Answers to this question are eligible for a +100 reputation bounty. Rabbid76 wants to reward an existing answer . I have an existing system, which provides 3D meshes. The provided data are an array of vertex coordinates with 3 components (x, y, z) and an index list. The issue is that the index list is a consecutive array of quad primitives. The system has to be make runnable with a core profile OpenGL Context first, and later with OpenGL ES 3.x, too. I know that

SSBO hash table, missing values

有些话、适合烂在心里 提交于 2020-01-15 09:24:26
问题 I am trying to run a little data compression experiment. I am trying to compress 3D textures into hash tables to avoid storing empty volume information. To this effect I wrote the hashing function and retreiving function (they are in different shaders): struct Voxel { int filled; ivec4 position; vec4 normal; vec4 color; }; layout(std430, binding = 0) buffer voxel_buffer { uint index; Voxel voxels[]; }; // Data storing shader int a_size = 10000000; void insert(vec3 pos, Voxel value) { ivec3

Initializing structures from arrays in GLSL

对着背影说爱祢 提交于 2020-01-15 07:53:44
问题 Suppose I have an array variable in a shader, declared in a shader storage block: layout(std430, binding = 2) buffer MyBuffer { float lotsOfFloats[]; }; and a struct: struct myStruct { float f1; vec3 vf1; }struct1; Is there a way to "quickly" initialize an object of this structure in a shader using the values in the array in a buffer storage block ( in the lotsOfFloats array in this example)? Say, in C++ one can copy memory from the array to the object: memcpy(&struct1, &lotsOfFloats[0],

GLSL ES fragment shader produces very different results on different devices

删除回忆录丶 提交于 2020-01-14 18:45:53
问题 I am developing a game for Android using OpenGL ES 2.0 and have a problem with a fragment shader for drawing stars in the background. I've got the following code: precision mediump float; varying vec2 transformed_position; float rand(vec2 co) { return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } void main(void) { float distance = 10.0; float quantization_strength = 4.0; vec3 background_color = vec3(0.09, 0.0, 0.288); vec2 zero = vec2(0.0, 0.0); vec2 distance_vec = vec2

GLSL ES fragment shader produces very different results on different devices

不羁岁月 提交于 2020-01-14 18:44:31
问题 I am developing a game for Android using OpenGL ES 2.0 and have a problem with a fragment shader for drawing stars in the background. I've got the following code: precision mediump float; varying vec2 transformed_position; float rand(vec2 co) { return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } void main(void) { float distance = 10.0; float quantization_strength = 4.0; vec3 background_color = vec3(0.09, 0.0, 0.288); vec2 zero = vec2(0.0, 0.0); vec2 distance_vec = vec2

OpenGL/GLSL - implementation of texture filtering

淺唱寂寞╮ 提交于 2020-01-14 11:45:19
问题 I would like to implement texture filtering (min and magfilter) myself in a GLSL shader (as i want to use image_load_and_store and not a sampler, and also I want to handle undefined pixels in a special way) and I'm looking for an article or so that discusses the filtering process. I can recall on how to implement texturefiltering from a raytracer I once wrote - I think you need to take into consideration the UV gradients at each pixel and depending on the length of those somehow scale your

OpenGL/GLSL - implementation of texture filtering

我们两清 提交于 2020-01-14 11:44:32
问题 I would like to implement texture filtering (min and magfilter) myself in a GLSL shader (as i want to use image_load_and_store and not a sampler, and also I want to handle undefined pixels in a special way) and I'm looking for an article or so that discusses the filtering process. I can recall on how to implement texturefiltering from a raytracer I once wrote - I think you need to take into consideration the UV gradients at each pixel and depending on the length of those somehow scale your

How to add fog to texture in shader (THREE.JS R76)

情到浓时终转凉″ 提交于 2020-01-14 03:55:35
问题 So firstly, I am aware of this post: ShaderMaterial fog parameter does not work My question is a bit different... I am trying to apply the fog in my three.js scene to a shader thats using a TEXTURE and I can't figure it out. My best guess as to what is supposed to go into the frag was: resultingColor = mix(texture2D(glowTexture, vUv), fogColor, fogFactor); This works when the texture2D part is just a normal color but as a texture it doesn't render. THREE.glowShader = { vertexShader: [ `

My OpenGL QQuickItem won't have the size I want

主宰稳场 提交于 2020-01-14 03:14:15
问题 I'm drawing with OpenGL on Qtquick and no matter what size I put on my OpenGlVideoQtQuick on QML, it always occupies the entire space of the window. I want to be able to control its size. I created this minimal example which draws a green screen with OpenGL. I should be able to control the size of QQuickItem and thus control the size of the green screen to occupy, for example, 1/4 of the screen. You can see that I even tried (and commented) the setWidth and setHeight methods on the QQuickItem

Which GLSL ES extensions are available on various iOS devices?

别来无恙 提交于 2020-01-13 20:29:23
问题 I'm looking for a list of all extensions available on any iOS devices (and which are available on which device). I haven't found the right page in the apple docs despite a lot of searching, but I'm sure it's there somewhere. Any pointers? 回答1: This code should print out all extensions: NSString *extensionString = [NSString stringWithUTF8String:(char *)glGetString(GL_EXTENSIONS)]; NSArray *extensions = [extensionString componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet