glsl

Text2DEntity renders opaque and hides other entities behind it

一个人想着一个人 提交于 2020-01-02 07:19:30
问题 I draw some 2d text entities in a Qt3D QML scene but some of the texts always render opaque , i.e hide the contents behind them. When looking at the scene from behind ( changing the position of the camera to Qt.vector3d(0,0,-40) ) all texts render OK. The following image shows the wrong behaviour, I would expect the text "AAARGH" not to be rendered on a white background, but the green text shining through. Platform is Windows 64-bit, Qt5.13.0, and Visual Studio 2019. See the following small

Uniform vertex displacement for skinned mesh shader (Animated outline, Three.js)

孤街浪徒 提交于 2020-01-02 04:07:28
问题 I think I've solved implementation of rendering borders/outlines over meshes in Three.js, a technique many games use for highlighting objects/characters. Diablo 1 and 3 for example Here are details and demo of my solution. Now what remains to be done are animated meshes (for characters etc). The problem is, skinned mesh is animated with a vertex shader and I also used a shader to scale (displace) the mesh out along the normals. It might be pretty straight-forward but unfortunately my math

Hide faces with GLSL shader

五迷三道 提交于 2020-01-01 22:29:12
问题 I'm trying to wright a shader to work with three.js. Which is a javascript library for WebGL. I just started reading up on GLSL so there are some thing i'm having trouble with. Basically I want reveal and hide faces of a geometry. I have cloned my geometry's face array and reordered it. The reordered array has the faces in the order I would like to reveal/hide them. I have read that Uniforms can be access from anywhere within the pipeline. Can I just declare the array as a Uniform and access

Is it safe to use the block index as the binding point for UniformBufferObject, ShaderStorageBufferObjects, etc?

空扰寡人 提交于 2020-01-01 11:32:52
问题 I'm curious about the *BlockBinding argument used in several of OpenGLs buffer object related functions. For example the uniformBlockBinding parameter in glUniformBlockBinding , storageBlockBinding​ in glShaderStorageBlockBinding , and the corresponding index parameter in glBindBufferRange and glBindBufferBase . I know that calls to glUniformBlockBinding and glShaderStorageBlockBinding aren't necessary if binding points are set in the shaders using layout qualifiers such as: layout (binding =

GLSL Fragment Position

末鹿安然 提交于 2020-01-01 10:14:14
问题 Sorry I will rewrite the question hoping to be clear. In my .cpp code I create a list of quads, a few of them have a flag, in the pixel shader I check if this flag is set or not, if the flag is not set, the quad gets colored in red for example, if the flag is set, I want to decide the color of every single pixel, so if I need to colour half of the flagged quad in red and the other half in blue I can simply do something like : if coordinate in quad < something color = red else colour = blue;

Transpose a mat4 in OpenGL ES 2.0 GLSL

孤人 提交于 2020-01-01 03:14:13
问题 I'd like to transpose a matrix in my OpenGL ES 2.0 vertex shader, but apparently my iPad 3 doesn't support GLSL #version 120 , which is needed for the built-in function transpose(mat4) . I know there are options to work around that, like transposing the matrix on the CPU before passing it to the graphics chip, but it would make my shader a lot simpler if I could transpose it there. So, is there an option to transpose a mat4 in a shader on an iOS 6 device? Another thing: The question What

“flat” qualifier in glsl?

主宰稳场 提交于 2020-01-01 02:40:16
问题 So I was reading "The Official OpenGL Guide" and in a section where they taught material lighting, they suddenly used the "flat" qualifier for an input variable in the fragment shader. I google'd the matter and all I came up with was "flat shading" and "smooth shading" and the differences between them, which I cannot understand how it is related to a simple "MatIndex" variable. here's the example code from the book: struct MaterialProperties { vec3 emission; vec3 ambient; vec3 diffuse; vec3

texture vs texture2D in GLSL

僤鯓⒐⒋嵵緔 提交于 2019-12-31 10:44:23
问题 When sampling a 2D texture in GLSL (a uniform sampler2D ), the texture function is used and the dimension is inferred from the sampler (2D in this case). This is the modern way of sampling a texture in the GLSL since 1.30 (GLSL Reference Pages). However you can also use the texture2D function. Is the texture2D function deprecated and if so, will support for the texture2D function be removed (or has been removed) in some version of GLSL? 回答1: Yes, texture2D() is deprecated as of (at least)

Differences between GLSL and GLSL ES 2

会有一股神秘感。 提交于 2019-12-31 08:45:32
问题 Two questions really... Is GLSL ES 2 a totally separate language, or a special version of GLSL? What are the differences between them, in terms of "standard library" functions, syntax and capabilities? I am writing shaders for an application targeted at Windows, Mac and iPad and I would prefer not to have to add more versions of each shader - well simpler shaders anyway. 回答1: Is GLSL ES 2 a totally separate language, or a special version of GLSL? Every version of GLSL is ultimately a "totally

OpenGL / GLSL - Uniform block data values incorrect

五迷三道 提交于 2019-12-31 04:17:10
问题 My shader has a uniform block as such: layout (std140) uniform LightSourceBlock { vec3 test; vec3 color; } LightSources; The data for this block is supposed to come from a buffer object which is created like so: GLuint buffer; glGenBuffers(1,&buffer); GLfloat data[6] = { 0,0,0, 0,0,1 }; glBindBuffer(GL_UNIFORM_BUFFER,buffer); glBufferData(GL_UNIFORM_BUFFER,sizeof(data),&data[0],GL_DYNAMIC_DRAW); The buffer is linked to the uniform block before rendering: unsigned int locLightSourceBlock =