glsl

Bind multiple Uniform Buffer Objects

只谈情不闲聊 提交于 2020-04-16 03:32:51
问题 With WebGL 2 we now can play with Uniform Buffer Objects. They look like a great idea, not having to attach common uniforms to every single program (like projection and view matrices that are common to every object being rendered). I created an helper class which I call every time I want to bind a uniform buffer object. class UniformBuffer { constructor(gl, data, boundLocation = 0) { this.boundLocation = boundLocation; this.data = new Float32Array(data); this.buffer = gl.createBuffer(); gl

Bind multiple Uniform Buffer Objects

 ̄綄美尐妖づ 提交于 2020-04-16 03:32:37
问题 With WebGL 2 we now can play with Uniform Buffer Objects. They look like a great idea, not having to attach common uniforms to every single program (like projection and view matrices that are common to every object being rendered). I created an helper class which I call every time I want to bind a uniform buffer object. class UniformBuffer { constructor(gl, data, boundLocation = 0) { this.boundLocation = boundLocation; this.data = new Float32Array(data); this.buffer = gl.createBuffer(); gl

Showing Point Cloud Structure using Lighting in Three.js

喜夏-厌秋 提交于 2020-04-14 08:33:27
问题 I am generating a point cloud representing a rock using Three.js, but am facing a problem with visualizing its structure clearly. In the second screenshot below I would like to be able to denote the topography of the rock, like the corner (shown better in the third screenshot) of the structure, in a more explicit way, as I want to be able to maneuver around the rock and select different points. I have rocks that are more sparse (harder to see structure as points very far away) and more dense

GLSL Geometry shader to replace glLineWidth

喜欢而已 提交于 2020-04-14 04:11:48
问题 I'm trying to write a geometry shader to replace glLineWidth behavior. I want to draw lines with a customizable width (doing this with a uniform suffices for now). The lines should always have the same thickness, regardless of the camera projection or distance to where the lines are. Based on a lot of googling, I've come up with the following geometry shader: #version 330 layout (lines) in; layout (triangle_strip, max_vertices = 4) out; uniform mat4 u_model_matrix; uniform mat4 u_view_matrix;

GLSL Geometry shader to replace glLineWidth

拜拜、爱过 提交于 2020-04-14 04:09:17
问题 I'm trying to write a geometry shader to replace glLineWidth behavior. I want to draw lines with a customizable width (doing this with a uniform suffices for now). The lines should always have the same thickness, regardless of the camera projection or distance to where the lines are. Based on a lot of googling, I've come up with the following geometry shader: #version 330 layout (lines) in; layout (triangle_strip, max_vertices = 4) out; uniform mat4 u_model_matrix; uniform mat4 u_view_matrix;

How to get a bit from a integer using GLSL and OpenGL ES 2.0

两盒软妹~` 提交于 2020-04-11 17:27:56
问题 I have an integer value and want to get the Bit which is placed on a special location. I'm working with GLSL for OpenGL ES 2.0 Something like this: GetBitOnLocation(int value, int location) { bit myBit = value[location]; if (myBit == 0) return 0; if (myBit == 1) return 1; } 回答1: As per the previous comments, don't do this. ES 2 hardware needn't natively support integers; it is permitted to emulate them as floating point. To permit that, direct bit tests aren't defined. If you're absolutely

How to get a bit from a integer using GLSL and OpenGL ES 2.0

半世苍凉 提交于 2020-04-11 17:26:33
问题 I have an integer value and want to get the Bit which is placed on a special location. I'm working with GLSL for OpenGL ES 2.0 Something like this: GetBitOnLocation(int value, int location) { bit myBit = value[location]; if (myBit == 0) return 0; if (myBit == 1) return 1; } 回答1: As per the previous comments, don't do this. ES 2 hardware needn't natively support integers; it is permitted to emulate them as floating point. To permit that, direct bit tests aren't defined. If you're absolutely

Not working OpenGL ES shader, call glLinkProgram every frame?

时光总嘲笑我的痴心妄想 提交于 2020-03-25 19:07:26
问题 I'm trying to make transparent object in OpenGL ES 2.0. It's a live wallpaper, I'm using GLWallpaperService as a base class for this. I'm setting up OpenGL in this way: GLES20.glEnable(GLES20.GL_DEPTH_TEST); GLES20.glDepthFunc(GLES20.GL_GEQUAL); GLES20.glClearDepthf(0.0f); GLES20.glClearColor(0.0f, 0.0f, 1.0f, 1.0f); Shaders I use are taken from PowerVR sample OGLES2AlphaTest for alpha testing, which works fine on my HTC Desire device. Here is the code for shaders: private final String

GLSL语言基础

江枫思渺然 提交于 2020-03-19 17:19:02
from http://www.kankanews.com/ICkengine/archives/120870.shtml 变量 GLSL的变量命名方式与C语言类似。变量的名称可以使用字母,数字以及下划线,但变量名不能以数字开头,还有变量名不能以gl_作为前缀,这个是GLSL保留的前缀,用于GLSL的内部变量。当然还有一些GLSL保留的名称是不能够作为变量的名称的。 基本类型 除了布尔型,整型,浮点型基本类型外,GLSL还引入了一些在着色器中经常用到的类型作为基本类型。这些基本类型都可以作为结构体内部的类型。如下表: 类型 描述 void 跟C语言的void类似,表示空类型。作为函数的返回类型,表示这个函数不返回值。 bool 布尔类型,可以是true 和false,以及可以产生布尔型的表达式。 int 整型 代表至少包含16位的有符号的整数。可以是十进制的,十六进制的,八进制的。 float 浮点型 bvec2 包含2个布尔成分的向量 bvec3 包含3个布尔成分的向量 bvec4 包含4个布尔成分的向量 ivec2 包含2个整型成分的向量 ivec3 包含3个整型成分的向量 ivec4 包含4个整型成分的向量 mat2 或者 mat2x2 2×2的浮点数矩阵类型 mat3或者mat3x3 3×3的浮点数矩阵类型 mat4x4 4×4的浮点矩阵 mat2x3 2列3行的浮点矩阵

Correspondance between texture units and sampler uniforms in opengl

大城市里の小女人 提交于 2020-03-16 07:04:44
问题 The correspondence between sampler uniforms and texture units used by glActiveTexture apparently can't be queried with opengl, and I can't find good documentation on how to find which texture unit is mapped to which sampler uniform. Here is what I have been able to find: If there is only sampler uniform in a program, then it is mapped to gl_TEXTURE0 If there are multiple sampler uniforms in a single program stage, then they are mapped in the order they are declared in the shader. If the