glsl

OpenGL: debugging “Single-pass Wireframe Rendering”

旧城冷巷雨未停 提交于 2019-12-21 20:45:11
问题 I'm trying to implement the paper "Single-Pass Wireframe Rendering", which seems pretty simple, but it's giving me what I'd expect as far as thick, dark values. The paper didn't give the exact code to figure out the altitudes, so I did it as I thought fit. The code should project the three vertices into viewport space, get their "altitudes" and send them to the fragment shader. The fragment shader determines the distance of the closest edge and generates an edgeIntensity. I'm not sure what I

Strange alpha blending results with ShaderEffectItem

余生长醉 提交于 2019-12-21 20:33:16
问题 I'm trying to apply a simple alpha mask on a QML item using ShaderEffectItem . Here is a minimal (non-)working example: I have a red-to-white gradient as the background and want to draw a green 200x200 square on top of it. The alpha mask for this square should be 0.0 at the left and 1.0 at the right border, so it should be transparent at the left border. import QtQuick 1.1 import Qt.labs.shaders 1.0 Rectangle { width: 300 height: 300 id: wrapper gradient: Gradient { GradientStop { position: 0

How to write a fragment shader in GLSL to sort an array of 9 floating point numbers

风格不统一 提交于 2019-12-21 20:19:17
问题 I am writing a fragment shader in order to median 9 images together. I have never worked with GLSL before, but it seemed like the right tool for the job, as OpenCL isn't available on iOS and medianing on the CPU is inefficient. Here's what I have so far: uniform sampler2D frames[9]; uniform vec2 wh; void main(void) { vec4 sortedFrameValues[9]; float sortedGrayScaleValues[9]; for (int i = 0; i < 9; i++) { sortedFrameValues[i] = texture2D(frames[i], -gl_FragCoord.xy / wh); sortedGrayScaleValues

How to express tetration function, for complex numbers

吃可爱长大的小学妹 提交于 2019-12-21 19:56:33
问题 There do exists so-called hyperoperation sequence. It works like you construct multiplication a*b=a+a+a+a...+a with many additions of a repeated b times. Then there goes exponentiation a^b = a*a*a*a*...*a with many multiplicaitions of a repeated b times. Then, there goes tetration, expressed as a tower of exponentiations, same like a^^b == a^a^a^...^a , repeated b times. I am interested how to write this function, for floating point and complex numbers? I've alredy wrote multiplication and

Synchronisation in OpenGL [closed]

戏子无情 提交于 2019-12-21 19:54:11
问题 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 7 days ago . I have just spent around five hours studying parts of the OpenGL 4.5 specification found here (or a slightly earlier version of it): https://www.khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf Unfortunately, I seem to be getting mixed messages. In section 5.3.1 “Determining

Creating a Gradient Color in Fragment Shader

[亡魂溺海] 提交于 2019-12-21 19:47:02
问题 I'm trying to achieve making a gradient color as the design apps (Photoshop for example) does, but can't get the exact result i want. My shader creates very nice 'gradients' but also contains other colors that are different from the colors I want to switch in. It looks nice but, my aim is adding blending functions later and make a kind of color correction shader. but first of all I have to get the right colors. Here is my fragment shader http://player.thebookofshaders.com/?log=171119111216

How to send multiple textures to a fragment shader in WebGL?

家住魔仙堡 提交于 2019-12-21 13:11:22
问题 So in the javascript portion of my code, here is the snippet that actually sends an array of pixels to the vertex and fragment shaders- but I am only working with 1 texture when I get to those shaders- is there anyway that I can send two textures at a time? if so, how would I 'catch' both of them on the GLSL side of the codee? if (it > 0){ gl.activeTexture(gl.TEXTURE1); gl.bindTexture(gl.TEXTURE_2D, texture); gl.activeTexture(gl.TEXTURE0); gl.bindFramebuffer(gl.FRAMEBUFFER, FBO2);} else{ gl

texturing using texelFetch()

旧巷老猫 提交于 2019-12-21 12:15:03
问题 When I pass non max values into texture buffer, while rendering it draws geometry with colors at max values. I found this issue while using glTexBuffer() API. E.g. Let’s assume my texture data is GLubyte, when I pass any value less than 255, then the color is same as that of drawn with 255, instead of mixture of black and that color. I tried on AMD and nvidia card, but the results are same. Can you tell me where could be going wrong? I am copying my code here: Vert shader: in vec2 a_position;

Enabling an extension on a Three.js shader

假如想象 提交于 2019-12-21 07:48:11
问题 How can I enable an extension on a Three.js shader? My code so far: getting extension: var domElement = document.createElement( 'canvas' ); var gl = domElement.getContext('webgl') || domElement.getContext('experimental-webgl'); gl.getExtension('OES_standard_derivatives'); on my shader: fragmentShader: [ "#extension GL_OES_standard_derivatives : enable", "code..." ]... The console output: WARNING: 0:26: extension 'GL_OES_standard_derivatives' is not supported ERROR: 0:32: 'dFdx' : no matching

three.js / webGL / GLSL - utilizing random math

不羁的心 提交于 2019-12-21 06:05:03
问题 I am using three.js to call a fragment shader - that shader specifies a color for my material, broken out into rgb - and I want to see if I can multiply those colors by a random value. This is the code I'm using so far: gl_FragColor = vec4( color.r*.5, color.g, color.b, smoothstep( 8000.0, -8000.0, gl_FragCoord.z / gl_FragCoord.w ) ); //MH - creates colors by multiplying color values and this is what I'd want to do if it were javascript, though obviously this doesn't work inside a GLSL shader