shader

How can I read float data with glReadPixels

╄→гoц情女王★ 提交于 2019-12-14 02:33:31
问题 I've been trying to read float data for a couple of days with glReadPixels . My cpp code: //expanded to whole screen quad via vertex shader glDrawArrays( GL_TRIANGLES, 0, 3 ); int size = width * height; GLfloat* pixels = new GLfloat[ size ]; glReadPixels( 0, 0, width, height, GL_RED, GL_FLOAT, pixels ); pixelVector.resize( size ); for ( int i = 0; i < size; i++ ) { pixelVector[i] = (float) pixels[i]; } and my shader code: out float data; void main() { data = 0.02; } Strangely I get 0.0196078

How do shader compilers work?

瘦欲@ 提交于 2019-12-14 01:26:15
问题 Does anyone have references to documents and research specific on the inner workings of shader compilers/graphics drivers compilers? 回答1: There's no big difference between writing an ordinary C compiler and writing a shader compiler. The standard book on writing compilers is the so called "Dragon Book": http://www.amazon.com/Compilers-Principles-Techniques-Tools-2nd/dp/0321486811/ref=ntt_at_ep_dpi_1 来源: https://stackoverflow.com/questions/2558974/how-do-shader-compilers-work

Get pixels behind current window without hiding it

≯℡__Kan透↙ 提交于 2019-12-13 22:15:52
问题 I want to take a screenshot of the rectangle where the window is located, but without the window itself, then process that screenshot through filters/shaders and then apply it as a background, making it seem like some sort of glass. (Not aero!) I've been trying to find a way for days. Things I have tried: Hiding the window, taking the screenshot, showing it again. (flickering window, cant really move it as this happens all the time) DX shaders Hooking, all kinds of screenshot approaches I

[Unity Shader] Shader学习笔记2

时光总嘲笑我的痴心妄想 提交于 2019-12-13 21:52:28
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> Unity 有三种编写shader的方式: surface shaders , vertex and fragment shaders , fixed function shaders . fixed function shader (固定功能着色器): 对应于固定管线硬件的操作,最简单的着色器类型,只能使用Unity3D自带的固定语法和提供的方法,适用于任何硬件,使用难度最小。 vertex and fragment shader (顶点片段程序着色器): 顶点和片段着色器,如前所述,是可编程图形管线主要支持的方式。是效果最为丰富的着色器类型,使用Cg/HLSL语言规范,着色器由顶点程序和片段程序组成。所有效果都需要自己编写,使用难度相对较大。 surface shader (表面着色器): Unity推荐的shader类型。同样使用Cg/HLSL语言规范的着色器类型,不过把光照模型提取出来,可以使用Unity3D自带的一些光照模型,也可以自己编写光照模型,着色器同样由顶点程序和片段程序组成,不过本身有默认的程序方法,使用者可以只针对自己关系的效果部分进行编写。由于选择性比较大,所以可以编写出较为丰富的效果,使用难度相对vertex and fragment shader小。 可以理解其是对Vertex 和

OpenGL big projects, VAO-s and more

五迷三道 提交于 2019-12-13 16:11:50
问题 So I've been learning OpenGL 3.3 on https://open.gl/ and I got really confused about some stuff. VAO-s. By my understanding they are used to store the glVertexAttribPointer calls. VBO-s. They store vertecies. So if I am making something with multiple objects do I need a VBO for every object? Shader Programs - Why do we need multiple ones and what exactly do they do ? What exactly does this line do : glBindFragDataLocation(shaderProgram, 0, "outColor"); The most important thing is how does all

OpenGL Shaders. Pass array of float

耗尽温柔 提交于 2019-12-13 14:33:04
问题 On my scene i have many objects that i want to rotate at the same time but on different angles. I have a shader that computes position of each object and draw the whole scene (pass vertex array into the shader with array of vertexes). "uniform float uRotation;" + ... " mat4 mz = mat4(1.0);" + " mz[0][0] = cos(rotation);" + " mz[0][1] = sin(rotation);" + " mz[1][0] = -sin(rotation);" + " mz[1][1] = cos(rotation);" + ... gl_Position = uMVPMatrix * (aPosition *mz); i have all my vertexes,

PyOpenGL cannot compile shader

血红的双手。 提交于 2019-12-13 14:28:53
问题 I'm using Python3, Qt4 and PyOpenGL on Debian testing with the python3-pyside packages. This the minimized example code: #!/bin/env python3 from OpenGL.GL import shaders, GL_VERTEX_SHADER from PySide import QtGui from PySide.QtOpenGL import QGLWidget class MyGLWidget(QGLWidget): def initializeGL(self): self.vertex_shader = shaders.compileShader(""" #version 330 layout(location = 0) in vec4 position; void main() { gl_Position = position; } """, GL_VERTEX_SHADER) if __name__ == '__main__': app

优化

非 Y 不嫁゛ 提交于 2019-12-13 12:41:37
WeTest 导读 做了大概半年多VR应用了,VR由于双眼double渲染的原因,对性能的优化要求比较高,在项目的进展过程中,总结了一些关于移动平台上Unity3D的性能优化经验,供分享。 一、移动平台硬件架构 移动平台无论是Android 还是 IOS 用的都是统一内存架构,GPU和CPU共享一个物理内存,通常我们有“显存”和“内存”两种叫法,可以认为是这块物理内存的所有者不同,当这段映射到cpu,就是通常意义上的内存;当映射到gpu,就是通常意义上的显存。并且同一段物理内存同一时刻只会映射到一个device。 即使是在同一物理内存上 ,之前的openGL ES规范中CPU和GPU之间的内存是不能共享的,vertex和texture的buffer是需要拷贝的。后面出来的vulkan 与IOS的metal 可以共享内存。 了解了移动平台的硬件架构,就知道了 1)CPU 2) 带宽 3) GPU 4) 内存 都有可能成为移动平台3D应用性能瓶颈。 二、移动平台3D应用的画面渲染过程 1、CPU通过调用绘制命令(称为一次Draw Call)来告诉GPU开始进行一个渲染过程的。一个Draw Call命令会指向本次绘制需要渲染的信息,这些信息包括:顶点数据、纹理数据、shader参数(光照模型、法线方向、光照方向等)等,简单地说就 画什么,用什么画,怎么画。 2、GPU接收到Draw

GLSL shader to boost the color

只愿长相守 提交于 2019-12-13 11:11:25
问题 Is their any GLSL shader that can help me to "boost" the color of a texture ? How to write such shader ? I would like to do something like the picture below : 回答1: It seems they are mostly boosting saturation here, so that's what you'd need to do in your fragment shader. To boost saturation, you need to take your data from the RVB color space to the HSL (hue saturation lightness) space. you then need to do: hslColor = vec3(hslCOlor.x, hslColor.y * **boost**, hslCOlor.z); Of course to do that

Android OpenGL ES shader compiler support

可紊 提交于 2019-12-13 10:16:14
问题 The OpenGL ES 2.0 Specs state that "[s]hader compiler support is optional" (see "Notes" here). Are there any Android devices that do not support shader compilation? If so, is there some shader compiler that I can include with my app to generate a binary instead? Or is the format of the binary also standardized so that I can precompile my shaders before hand and ship the binary with my app if needed? Or is there a requirement I can put into my app so that it isn't offered to devices without