glsl

GLSL SpinLock only Mostly Works

☆樱花仙子☆ 提交于 2019-12-29 07:18:22
问题 I have implemented a depth peeling algorithm using a GLSL spinlock (inspired by this). In the following visualization, notice how overall the depth peeling algorithm functions correctly (first layer top left, second layer top right, third layer bottom left, fourth layer bottom right). The four depth layers are stored into a single RGBA texture. Unfortunately, the spinlock sometimes fails to prevent errors--you can see little white speckles, particularly in the fourth layer. There's also one

Using a matrix as vertex attribute in OpenGL3 Core Profile

不问归期 提交于 2019-12-29 06:20:31
问题 I am using OpenGL3.2 Core Profile on OSX. And I want to do instanced drawing (glDrawArraysInstanced), where I pass a matrix for each instance. My vertex shader builds just fine: #version 150 in mediump vec4 position; in mediump mat4 trf; in lowp vec4 rgb; out lowp vec4 colour; uniform highp mat4 modelcamviewprojmat; void main() { mediump vec4 tpos = trf * position; gl_Position = modelcamviewprojmat * tpos; colour = rgb; } The binding of 'trf' went fine: glBindAttribLocation(program, ATTRIB

Issue Understanding Lighting in OpenGL

最后都变了- 提交于 2019-12-29 02:06:38
问题 I am having some problems understanding how lighting works in OpenGL (especially understanding the pre-defined variables. is there a list of them somewhere?). I have been messing around in my Vertex Shader file to shade my shpere. So I managed to shade it but I don't know what I did. Here is the code: Vertex Shader: #version 330 precision highp float; in vec3 in_Position; //declare position in vec3 in_Color; //color passed from the cpp file //mycode in vec3 in_Normal; // mvpmatrix is the

How do you pack one 32bit int Into 4, 8bit ints in glsl / webgl?

眉间皱痕 提交于 2019-12-28 01:56:14
问题 I'm looking to parallelize some complex math, and webgl looks like the perfect way to do it. The problem is, you can only read 8 bit integers from textures. I would ideally like to get 32 bit numbers out of the texture. I had the idea of using the 4 color channels to get 32 bits per pixel, instead of 4 times 8 bits. My problem is, glsl doesn't have a "%" operator or any bitwise operator! TLDR: How do I convert a 32bit number to 4 8bit numbers by using the operators in glsl. Some extra info on

OpenGL 3D texture “shine through”

半世苍凉 提交于 2019-12-25 18:48:09
问题 For testing purposes I want to display the first slice of a 3D texture. However it seems that the other slices are also displayed. My vertex shader: #version 130 attribute vec4 position; varying vec2 texcoord; void main() { gl_Position = position; texcoord = position.xy * vec2(0.5) + vec2(0.5); } The fragment shader: #version 130 uniform sampler3D textures[1]; varying vec2 texcoord; void main() { gl_FragColor = texture3D(textures[0], vec3(texcoord.x, texcoord.y, 0)); } I bind the texture from

Explanation of working principle of openGL [closed]

十年热恋 提交于 2019-12-25 18:39:47
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I'm trying to understand how coding in openGL works. I found this code on the internet and I want to understand it clearly. For my vertex shader I have: Vertex uniform vec3 fvLightPosition; varying vec2 Texcoord; varying vec2 Texcoordcut; varying vec3 ViewDirection; varying vec3

Silhouette-Outlined shader

一个人想着一个人 提交于 2019-12-25 11:59:30
问题 I'm trying to implement GLSL shader which would highlight the outer edges of rendered 3D mesh. The problem is that I do not have access to the OpenGL client side code so this must be done only in GLSL shaders. My first attempt was to use/adopt this shader from Unity and do it in OpenGL GLSL . Here how it should look: And here is what I got: I'm not sure If I compute the stuff correctly but as you can see the output is nowhere near my expectations. Here is the ogre material material Chassis {

calculate light volume radius from intensity

江枫思渺然 提交于 2019-12-25 09:42:08
问题 i am currently having a problem with calculating the light volume radius for a deferred renderer. On low light intensities the volume size looks correct but when the light intensity (and therefore the radius) increases, the light volume seems to be more and more too small. I am calculating the light volume radius (in world space) like this: const float LIGHT_CUTOFF_DEFAULT = 50; mRadius = sqrt(color.length() * LIGHT_CUTOFF_DEFAULT); I then use this value to scale a box. In my shader i then

Formula to determine if an infinite line and a line segment intersect?

▼魔方 西西 提交于 2019-12-25 09:32:07
问题 Given a point on a line and that line's slope how would one determine if the line, extending in each direction infinitely, intersects with a line segment (x1,y1) , (x2,y2) and, if so, the point at which the intersection occurs? I found this, but I'm unsure if it's helpful here. If someone wants to help me understand "rays", that's alright with me. http://www.realtimerendering.com/intersections.html I'm sorry that I'm an idiot. 回答1: Arbitrary point on the first line has parametric equation dx

How to figure out which GLSL (ESSL) version Qt uses on my PC?

只谈情不闲聊 提交于 2019-12-25 09:18:31
问题 I'm using ESSL (OpenGL ES Shading language) via Canvas3D in Qt. On my machine I run Windows and have set the following: QGuiApplication::setAttribute(Qt::AA_UseOpenGLES); in main() , which means that GL calls get translated by Qt to GL ES calls, which get translated by ANGLE to Direct3D calls. At least I believe that's what it means. I'm using the following test QML code to see what OpenGL version is used: Text { text: OpenGLInfo.majorVersion + "." + OpenGLInfo.minorVersion } This displays "2