glsl

Three.js shader pointLight to global position

此生再无相见时 提交于 2019-12-11 05:09:45
问题 All hello, I'm doing a fog shader and trying to add light sources. Recently I asked how to correctly determine the position of the light source, the question was solved, but another problem turned out, for the fog I use the position of the modelMatrix vec3 fogVPosition = (modelMatrix * vec4( position, 1.0 )).xyz To calculate the intensity of light, I use the calculation of the distance from the light source to the point of fog. float diffuseCoefficient = max( 1.0 - (distance(pointLights[i]

Weird behavior of OpenGL / glGetUniformLocation()

旧巷老猫 提交于 2019-12-11 04:48:47
问题 I just wanna do the basics... give the shaders information from my application. I tried everything and nothing worked because I can never figure out what is new and what is deprecated in OpenGL Vertex Shader: #version 420 core layout(location = 0) in vec2 p_rect; layout(location = 1) in vec2 p_clipRect; out vec2 texturePoint; void main() { gl_Position = vec4( p_rect, 0.0, 1.0 ); texturePoint = p_clipRect; } Fragment Shader: #version 420 core uniform sampler2D p_texture; in vec2 texturePoint;

Visualizing a 3D NumPy array with PyOpenGL

折月煮酒 提交于 2019-12-11 04:38:18
问题 I want to create a PyOpenGL/QtOpenGL widget that will allow me to visualize an arbitrary NumPy 3D matrix, not unlike the following Hinton diagram envisioned as a "cube of cubes" instead of a "square of squares": I'm having a bit of a rough time with OpenGL though. Here is my code thus far: from OpenGL.GL import * from OpenGL.GLUT import * from PyQt4 import QtGui, QtOpenGL import numpy as np action_keymap = { # 'a': lambda: glTranslate(-1, 0, 0), # 'd': lambda: glTranslate( 1, 0, 0), # 'w':

Single-pass wireframe issue

拟墨画扇 提交于 2019-12-11 04:16:22
问题 I am trying to implement single-pass wireframe, but I have got couple of issues in the process. Question #1 For some reasons I get only wireframe without (like with glPolygoneMode - lines) filled geometry after my geometry shader worked. ) But if I disable the geometry shader I get my geometry: What I really like to achieve is both geometry and its wireframe. Question #2 Actually, my primitives are triangle strips. I use them to avoid using on quads to improve performance. How can I skip

Drawing circles on a sphere

别说谁变了你拦得住时间么 提交于 2019-12-11 04:07:09
问题 I'm trying to draw lots of circles on a sphere using shaders. The basic alogrith is like this: calculate the distance from the fragment (using it's texture coordinates) to the location of the circle's center (the circle's center is also specified in texture coordinates) calculate the angle from the fragent to the center of the circle. based on the angle, access a texture (which has 360 pixels in it and the red channel specifies a radius distance) and retrieve the radius for the given angle if

GL_CULL_FACE makes all objects disappear

我的梦境 提交于 2019-12-11 04:02:51
问题 I am trying to create some simple polygons in openGL3.3. I have 2 types of objects with the following properties : Object 1 - 10 vertices (listed below, in order) stored in GL_ARRAY_BUFFER and use GL_TRIANGLE_FAN v x y z w v 0.0 0.0 1.0 1.0 v 0.0 1.0 0.1 1.0 v 0.71 0.71 0.1 1.0 v 1.0 0.0 0.1 1.0 v 0.71 -0.71 0.1 1.0 v 0.0 -1.0 0.1 1.0 v -0.71 -0.71 0.1 1.0 v -1.0 0.0 0.1 1.0 v -0.71 0.71 0.1 1.0 v 0.0 1.0 0.1 1.0 Object 2 - 4 vertices (listed below, in order) stored in GL_ARRAY_BUFFER and use

Efficiently Generate a Heat Map Style Histogram using GLSL

北战南征 提交于 2019-12-11 03:49:17
问题 I would like to generate a heat map style histogram using GLSL shaders. Specifically, I have a vector of 2D values that I want to bin into a 2D grid, where each cell is a bin for a specific range of (x,y) values, and it's color is determined by how many values are binned into it. I can easily assign values to cells in the vertex shader, or compute shader. How can I also write to a 2D buffer the frequencies in each bin/cell and then assign color and render to texture accordingly? 来源: https:/

Show half portion of image side by side - OpenGL

假装没事ソ 提交于 2019-12-11 03:04:44
问题 I have created two textures for two images. Now I want to show this textures in opengl in an order that left part of image2, full image1, right part of image2. I have done like below. Image1 shows at the center of opengl screen. But left and right part of screen is not correct (which should show left part of image2 and right part of image2 respectively) Vertex shader: attribute vec3 a_position; varying vec2 vTexCoord; void main() { vTexCoord = (a_position.xy + 1) / 2; gl_Position = vec4(a

Deferred Shadow Mapping GLSL

北城以北 提交于 2019-12-11 03:04:03
问题 Im currently implementing a deferred rendering pipeline and im stuck with shadow mapping. Ive already implemented it succesfully into a forward pipeline. The Steps i do are: Get Position in Light View Convert to light view clip space Get shadow tex coords with * 0.5 + 0.5; check depth Edit: Updated code with new result image: float checkShadow(vec3 position) { // get position in light view mat4 invView = inverse(cameraView); vec4 pEyeDir = sunBias * sunProjection * sunView * invView * vec4

How to create an animated texture in SceneKit? “fallback on default program” error

泄露秘密 提交于 2019-12-11 02:54:35
问题 I would like to use an animated texture in SceneKit, I found this Using shader modifiers to animate texture in SceneKit leads to jittery textures over time , but I have got an error with the same code : C3DResourceManagerMakeProgramResident failed to compile program - fallback on default program I tried to use another file for the shader (New file > Empty > called animated.shader), and use this code instead, but I have got the same error : let fireImage = UIImage(contentsOfFile: "art