shader

Organizing GLSL shaders in OpenGL engine

ぐ巨炮叔叔 提交于 2019-12-04 07:42:16
问题 Which is better ? To have one shader program with a lot of uniforms specifying lights to use, or mappings to do (e.g. I need one mesh to be parallax mapped, and another one parallax/specular mapped). I'd make a cached list of uniforms for lazy transfers, and just change a couple of uniforms for every next mesh if it needs to do so. To have a lot of shader programs for every needed case, each one with small amount of uniforms, and do the lazy bind with glUseProgram for every mesh if it needs

framebuffer and using shaders in opengl

喜欢而已 提交于 2019-12-04 07:25:07
I'm quite a bit confused about framebuffers. What I want to do is using a framebuffer with multiple textures attached, fill every texture and then use a shader to combine (blend) all textures to create a new output. Sounds easy? yeah that's what I thought too, but I don't understand it. How can I pass the currently binded texture to a shader? What you need is to put the texture in a specific slot, then use a sampler to read from it. In your app: GLuint frameBuffer; glGenFramebuffersEXT(1, &frameBuffer); //Create a frame buffer glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameBuffer); //Bind it so

iPhone iOS5 querying OpenGL ES 2.0 pipeline objects if they are hidden in the view or not…“Occlusion”

亡梦爱人 提交于 2019-12-04 07:02:16
EXT_occlusion_query_boolean is new with OS5.0, it looks to me like not a single person on the entire internet has posted about these new extensions nor used this code.... so here they are set up properly...which is not documented anywhere as far as i can tell... you can imagine how they would go in your code from this little sudo code here: import UIKit/UIKit.h import GLKit/GLKit.h import "GLProgram.h" GLuint testBox,hasBeenTested,theParams; //... glGenQueriesEXT(1, &testBox); glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, testBox); //... draw an object ....... glEndQueryEXT(GL_ANY_SAMPLES_PASSED

HLSL branch avoidance

为君一笑 提交于 2019-12-04 06:16:47
I have a shader where I want to move half of the vertices in the vertex shader. I'm trying to decide the best way to do this from a performance standpoint, because we're dealing with well over 100,000 verts, so speed is critical. I've looked at 3 different methods: (pseudo-code, but enough to give you the idea. The <complex formula> I can't give out, but I can say that it involves a sin() function, as well as a function call (just returns a number, but still a function call), as well as a bunch of basic arithmetic on floating point numbers). if (y < 0.5) { x += <complex formula>; } This has

Problems with Shaders in OpenGL

廉价感情. 提交于 2019-12-04 06:11:30
问题 I'm trying to use stuff like glShaderSource in C++. Visual Studio says that functions like glCompileShader or glCreateProgram dont exist. I use FreeGLUT to include OpenGL. Does anybody have an idea how I can fix this? 回答1: On windows, anything beyond GL1.1 must be loaded via the extension mechansim. The most convenient way to do so is by using a GL loader like glew. 来源: https://stackoverflow.com/questions/20722756/problems-with-shaders-in-opengl

texturing using texelFetch()

别等时光非礼了梦想. 提交于 2019-12-04 05:44:16
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; uniform float offset_x; void main() { gl_Position = vec4(a_position.x + offset_x, a_position.y, 1.0, 1

Most Efficient way of Multi-Texturing - iOS, OpenGL ES2, optimization

北战南征 提交于 2019-12-04 05:16:24
I'm trying to find the most efficient way of handling multi-texturing in OpenGL ES2 on iOS. By 'efficient' I mean the fastest rendering even on older iOS devices (iPhone 4 and up) - but also balancing convenience. I've considered (and tried) several different methods. But have run into a couple of problems and questions. Method 1 - My base and normal values are rgb with NO ALPHA. For these objects I don't need transparency. My emission and specular information are each only one channel. To reduce texture2D() calls I figured I could store the emission as the alpha channel of the base, and the

Three.js, custom shader and png texture with transparency

…衆ロ難τιáo~ 提交于 2019-12-04 04:47:58
I have an extremely simple PNG texture: a grey circle with a transparent background. I use it as a uniform map for a THREE.ShaderMaterial : var uniforms = THREE.UniformsUtils.merge( [basicShader.uniforms] ); uniforms['map'].value = THREE.ImageUtils.loadTexture( "img/particle.png" ); uniforms['size'].value = 100; uniforms['opacity'].value = 0.5; uniforms['psColor'].value = new THREE.Color( 0xffffff ); Here is my fragment shader (just part of it): gl_FragColor = vec4( psColor, vOpacity ); gl_FragColor = gl_FragColor * texture2D( map,vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) ); gl_FragColor

Export from Shadertoy to Three.js

主宰稳场 提交于 2019-12-04 04:43:58
问题 I am making my first steps coding. I made some courses on internet, then I played with some three.js experiments, and now I would like to continue learning experimenting with Shaders. I found Shadertoy.com and it's really amazing! There are a lot of difference experiments with incredible effects. I am trying to use one of these shaders in Three.js but is not so easy. The Shaders are already written, it's true. But I don't know what to do with that, I don't know how I can use it. Because it's

Three.js object self shadow itself depending on geometry

坚强是说给别人听的谎言 提交于 2019-12-04 04:08:38
问题 I have playing a little with clara.io and i want to reproduce an image done with it. I have searched the web for days looking up to reproduce what they call "Realistic" rendering. As you can see on the image the six round part have they own shadows on the (one piece) brick from multiple lights sources. I have no idea how they done that, if it is a simple setup, or a complex shader. the best i can do is that and i have no idea how to proceed to make and object shadowing itself depending of it