glsl

Change the intensity of an image by comparing intensity of another image - OpenTK

孤街浪徒 提交于 2019-12-23 18:09:40
问题 I have two images. I have to found the points of first image which have intensity greater than 0.8. At the same time I have to found the intensity of second image on same points and need to adjust the light on second image on same points with a threshold/slider value(ranges from 0 to 1). I have done like below. Getting black or dark area on points have intensity greater than 0.8. I'm trying with z value of HSV. But instead of this black area I should be able to adjust the light on image2. How

Writing the correct value in the depth buffer when using ray-casting

守給你的承諾、 提交于 2019-12-23 15:27:53
问题 I am doing a ray-casting in a 3d texture until I hit a correct value. I am doing the ray-casting in a cube and the cube corners are already in world coordinates so I don't have to multiply the vertices with the modelviewmatrix to get the correct position. Vertex shader world_coordinate_ = gl_Vertex; Fragment shader vec3 direction = (world_coordinate_.xyz - cameraPosition_); direction = normalize(direction); for (float k = 0.0; k < steps; k += 1.0) { .... pos += direction*delta_step; float

Can I avoid texture gradient calculations in webgl?

孤街醉人 提交于 2019-12-23 14:53:38
问题 We have a webgl/three.js application that makes extensive use of texture buffers for passing data between passes and for storing arrays of data. None of these has any use for mipmaps. We are easily able to prevent mipmap generation: at the three.js level we set min and mag filters to NearestFilter, and set generateMipmaps false. However, the shaders do not know at compile time that there is no mipmapping. When compiled using ANGLE we get a lot of warning messages: warning X4121: gradient

Odd behavior of GLSL switch statement

女生的网名这么多〃 提交于 2019-12-23 13:59:08
问题 I want to draw a cube with a different texture on each side. I pass Textnum parameter containing the number of the texture to use through my vertex shader to my fragment shader, then use a switch statement to choose appropriate sampler2D based on its value: #version 150 in float Shade; in vec2 Textcoord; in uint Textnum; out vec4 outColor; uniform sampler2D tex0; uniform sampler2D tex1; uniform sampler2D tex2; uniform sampler2D tex3; uniform sampler2D tex4; uniform sampler2D tex5; void main()

Three.js/GLSL - Convert Pixel Coordinate to World Coordinate

流过昼夜 提交于 2019-12-23 12:46:59
问题 I have a simple shader in my Three.js application that colors the screen red. However, I want to color all pixels to the right of a given world position to to a different color. I have seen some answers that suggest using varying vec4 worldCoord = gl_ModelViewMatrix * gl_Vertex; , but since WebGL using GLSLES, variables like gl_Vertex are not available to me. Vertex Shader <script type="x-shader/x-vertex" id="vertexshader"> #ifdef GL_ES precision highp float; #endif void main() { gl_Position

Can you use glVertexAttribPointer to assign a smaller vector to a larger one?

倖福魔咒の 提交于 2019-12-23 09:59:39
问题 From section 5.8 of The OpenGL® ES Shading Language (v1.00, r17) [PDF] (emphasis mine): The assignment operator stores the value of the rvalue-expression into the l-value and returns an r-value with the type and precision of the lvalue-expression. The lvalue-expression and rvalue-expression must have the same type. All desired type-conversions must be specified explicitly via a constructor. So it sounds like doing something like this would not be legal: vec3 my_vec3 = vec3(1, 2, 3); vec4 my

sampler1D not supported in nVidia GLSL?

守給你的承諾、 提交于 2019-12-23 09:18:33
问题 In the GLSL spec, and other sources about GLSL, sampler types are available in 3 dimensions: sampler1D , sampler2D , and sampler3D . However when I try to compile GLSL programs using WebGL in Chrome (both regular, and also in Canary), sampler2D and sampler3D are accepted but sampler1D gives a syntax error. Code: uniform sampler1D tex1; Error: FS ERROR: ERROR: 0:9: 'sampler1D' : syntax error This error occurs even if I give Canary the command line argument --use-gl=desktop . I am running

Selecting the face of a Cubemap in GLSL

冷暖自知 提交于 2019-12-23 08:27:05
问题 Ok, I'm trying to understand how the face of a cubemap is selected using the coordinates supplied to textureCube() . From the spec, I gather the coord with the biggest magnitude defines the face. For example these coords (-0.2, 0.7, 0.65) would select the Y+ face of the cube map, but these (0.2, 0.3, -0.8) would select the Z- face. Am I right in my understanding? 回答1: Indeed you are. This is the simplemost way to select the face of a cube, given a direction from the center. 来源: https:/

Selecting the face of a Cubemap in GLSL

淺唱寂寞╮ 提交于 2019-12-23 08:26:01
问题 Ok, I'm trying to understand how the face of a cubemap is selected using the coordinates supplied to textureCube() . From the spec, I gather the coord with the biggest magnitude defines the face. For example these coords (-0.2, 0.7, 0.65) would select the Y+ face of the cube map, but these (0.2, 0.3, -0.8) would select the Z- face. Am I right in my understanding? 回答1: Indeed you are. This is the simplemost way to select the face of a cube, given a direction from the center. 来源: https:/

Using different push-constants in different shader stages

一个人想着一个人 提交于 2019-12-23 07:03:48
问题 I have a vertex shader with a push-constant block containing one float: layout(push_constant) uniform pushConstants { float test1; } u_pushConstants; And a fragment shader with another push-constant block with a different float value: layout(push_constant) uniform pushConstants { float test2; } u_pushConstants; test1 and test2 are supposed to be different. The push-constant ranges for the pipeline layout are defined like this: std::array<vk::PushConstantRange,2> ranges = { vk: