shader

Setting up and using OpenGL 3.0+ with Mac OSX Lion(10.7)

一世执手 提交于 2019-12-21 02:34:16
问题 I am trying to set up an OpenGL 3.0+ context within XCode 4. As you can see talking about shaders here at the developer website the example it uses is OpenGL 2.0. In Appendix B it does talk about updating for 3.2 but just shows you function name changes and what only applies to the core, yet there is no example of actually setting up an OpenGL context. This has changed greatly since the fixed function pipeline being that you can no longer do things like glMatrixMode(...).. etc etc...i.e.

Shader optimization: Is a ternary operator equivalent to branching?

心已入冬 提交于 2019-12-20 16:27:32
问题 I'm working on a vertex shader in which I want to conditionally drop some vertices: float visible = texture(VisibleTexture, index).x; if (visible > threshold) gl_Vertex.z = 9999; // send out of frustum I know that branches kill performance when there's little commonality between neighboring data. In this case, every other vertex may get a different 'visible' value, which would be bad for the performance of the local shader core cluster (from my understanding). To my question: Is a ternary

OpenGL 资源汇编

泪湿孤枕 提交于 2019-12-20 13:49:33
本文收集和汇总了 OpenGL 的文档、教程和在线书籍,供学习和开发者參考。 OPENGL开发教程: http://www.linuxgraphics.cn/opengl/index.html OpenGL 教程 大名鼎鼎的 Nehe 教程: http://nehe.gamedev.net/ OpenGL 入门学习系列讲的很清楚,推荐。 OpenGL入门学习之中的一个——编写第一个OpenGL程序 OpenGL入门学习之二——绘制几何图形 OpenGL入门学习之三——绘制几何图形的一些细节问题 OpenGL入门学习之四——颜色的选择 OpenGL入门学习之五——三维的空间变换 OpenGL入门学习之六——动画的制作 OpenGL入门学习之七——使用光照来表现立体感 OpenGL入门学习之八——使用显示列表 OpenGL入门学习之九——使用混合来实现半透明效果 OpenGL入门学习之十——BMP文件与像素操作 OpenGL入门学习之十一——纹理的使用入门 OpenGL入门学习之十二——OpenGL片断測试 OpenGL入门学习之十三——OpenGL是一个状态机 OpenGL入门学习之十四——OpenGL版本号和OpenGL扩展 OpenGL入门学习之十五——从“绘制一个立方体”来看OpenGL的进化过程 OpenGL入门学习之十六——在Windows系统中显示文字 ZwqXin博客

Unity Shader highlighting overlaps

纵然是瞬间 提交于 2019-12-20 10:20:57
问题 I am trying to write a shader for unity that will highlight the overlapping fragments of meshes. It should work for one object overlapping itself as well as multiple objects. The result should look like an attached image. First I tried to accomplish this with collision detection but I think that the best way is writing a shader. I'm not very familiar with shaders so if anyone could help me I would be grateful. I think that it can be done by using stencil shaders like here http://docs.unity3d

RGB filters for different forms of color blindness

谁都会走 提交于 2019-12-20 08:49:32
问题 My father is color blind and given that I work in games where the visuals are important, I've always wanted to write a filter for screen shots (or even some type of shader) that emulated different forms of color blindness. I've seen plenty of references but never have been able to track down algorithms. Any algorithms would be appreciated. 回答1: My Google search came up with this one, which appears to be exactly what you're looking for. Eight different versions of color blindness are simulated

In OpenGL is there a way to get a list of all uniforms & attribs used by a shader program?

北战南征 提交于 2019-12-20 07:58:35
问题 I'd like to get a list of all the uniforms & attribs used by a shader program object. glGetAttribLocation() & glGetUniformLocation() can be used to map a string to a location, but what I would really like is the list of strings without having to parse the glsl code. Note: In OpenGL 2.0 glGetObjectParameteriv() is replaced by glGetProgramiv() . And the enum is GL_ACTIVE_UNIFORMS & GL_ACTIVE_ATTRIBUTES . 回答1: Variables shared between both examples: GLint i; GLint count; GLint size; // size of

Outline shader unity similar to the gizmo Editor

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 07:56:41
问题 I wonder if I can get the same outline as in the Editor. Like this I tried to use this script https://github.com/michaelcurtiss/UnityOutlineFX And get this as a result 回答1: I'm not sure how you applied the scripts in the Github repo you linked to. It looks like the outline shader is only applied to the leaf material on the 3D model you posted, however I believe that this outline effect is meant to run as a post processing or replacement shader. I think that you're attaching a script or

Fragment shader on plane with modified vertices

冷暖自知 提交于 2019-12-20 06:57:51
问题 I have a PlaneGeometry and I'm randomly animating the vertices in order to create random spikes. I use this FragmentShader : void main() { vec3 light = vec3(cos(time),sin(time),1.0); light = normalize(light); float dProd = max(0.0, dot(vNormal, light)); gl_FragColor = vec4(dProd,dProd,dProd,1.0); } I expected to have some faces of each spike colored in black, but instead I got a solid color. I placed a Sphere on my plane and applied the same shader: When I turn the wireframe OFF : Not sure I

Fragment shader on plane with modified vertices

一曲冷凌霜 提交于 2019-12-20 06:57:33
问题 I have a PlaneGeometry and I'm randomly animating the vertices in order to create random spikes. I use this FragmentShader : void main() { vec3 light = vec3(cos(time),sin(time),1.0); light = normalize(light); float dProd = max(0.0, dot(vNormal, light)); gl_FragColor = vec4(dProd,dProd,dProd,1.0); } I expected to have some faces of each spike colored in black, but instead I got a solid color. I placed a Sphere on my plane and applied the same shader: When I turn the wireframe OFF : Not sure I

Fragment shader on plane with modified vertices

核能气质少年 提交于 2019-12-20 06:56:55
问题 I have a PlaneGeometry and I'm randomly animating the vertices in order to create random spikes. I use this FragmentShader : void main() { vec3 light = vec3(cos(time),sin(time),1.0); light = normalize(light); float dProd = max(0.0, dot(vNormal, light)); gl_FragColor = vec4(dProd,dProd,dProd,1.0); } I expected to have some faces of each spike colored in black, but instead I got a solid color. I placed a Sphere on my plane and applied the same shader: When I turn the wireframe OFF : Not sure I