FAQ Database Discussion Community


webgl lighting shader working with firefox but not with chrome

google-chrome,firefox,glsl,webgl,shader
I am currently developing a 3D engine using WebGL, and I encountered a problem with the lighting shader. I am using an array of structure in order to pass the light parameters to the vertex and fragment shaders (with the same array passed as "uniform"). It actualy works very well...

Reading a shader from a .txt file using a structure

c++,opengl,struct,shader
I've started learning how to use OpenGL and I absolutely hate having my shaders declared as global variables before my main(). I thought it would be cool to make a structure or class that would read the shader from a file in my project directory. The file reading works perfectly...

Simple GLSL Shader (Light) causes flickering

opengl,glsl,shader,lighting
I'm trying to implement some basic lighting and shading following the tutorial over here and here. Everything is more or less working but I get some kind of strange flickering on object surfaces due to the shading. I have two images attached to show you guys how this problem looks....

Bloom effect using downscaling (downsampling) technique using OpenGL/GLSL

opengl,glsl,shader
Hello I'm trying to implement Bloom effect in my program. In fact, I've already implemented the effect using a highlight pass and a separate gaussian blur pass. Here's an example: Bright pass texture: Gaussian blur render pass (2 internal passes for this effect): And finally the final pass (brightPass +...

Three.js setting each pointCloud's color with Shader Material

three.js,shader,point-clouds
What I'm trying to do is create multiple PointCloud's, and assign each of them a different color. With the PointCloudMaterial, it had a color property that seemed to do the trick, but since I'm using a ShaderMaterial I can't seem to figure out how to achieve similar results. [Edit: added...

three.js webgl custom shader sharing texture with new offset

three.js,webgl,shader,vertex-shader
I am splitting a texture 1024 x 1024 over 32x32 tiles * 32, Im not sure if its possible to share the texture with an offset or would i need to create a new texture for each tile with the offset.. to create the offset i am using a uniform...

Issue with using Sampler2D with a Shader

opengl,shader,lwjgl,fbo
! I am aware that there are easier ways to draw to the screen than this, but i need to do it this specific way ! I am drawing to a texture through a fbo. I am then using a shader to re-draw it onto the screen, doing so with...

OpenGL unwanted transparency with deferred shading

opengl,shader,transparency,blending
I'm trying to implement deferred shading using the OpenGL, I render positions and normals to the textures. When I use only 1 light source without blending everything works well, but after I turn on blending, so the other light sources could contribute, I get a transparency. Does anyone had the...

Android: What is meaning of Uniform, mat4 and vec4 in Open GL ES?

android,opengl-es,embedded,shader
In this code (from Android Developer website): private final String vertexShaderCode = "uniform mat4 uMVPMatrix; \n" "attribute vec4 vPosition; \n" + "void main(){ \n" + " gl_Position = uMVPMatrix * vPosition; \n" + "} \n"; What is meaning of uniform and mat 4? and What is meaning of attribute and...

GLSL works weirdly for creating depth G-Buffer

glsl,shader,depth
Following pictures is geometry rendering result. Jesus! I have no enough reputation. Then i can't attach my picture. I describe the geometry, instead attach my picture. geometry is flat rectangle. Then following code is glsl source for creating depth g-buffer. --- Vertex Shader --- varying float uv_depth; void main (void)...

How do you update a uniform In Three.js?

javascript,three.js,shader
I had to re-write my question because I was asking the wrong thing before. I meant to ask, how do you update a uniform in three.js?...

Shader - Simple SSS lighting issue

opengl,directx,glsl,shader,hlsl
I am trying to create a simple subsurface scattering effect using a shader but I am facing a small issue. Look at those screenshots. The three images represents three lighting states (above surface, really close to surface, subsurface) with various lighting colors (red and blue) and always the same subsurface...

Can I load a shader into My JavaScript code from an external text file?

webgl,shader,fragment-shader,vertex-shader
I learn WebGL. I see the tutorial has the code of shaders inside of JavaScript code as a usual string. For example: var VSHADER_SOURCE = 'void main(){\n' + ' gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n' + ' gl_PointSize = 10.0;\n' + '}\n'; I want to place the code of my...

Can't set line color while drawing

c++,opengl,shader,lines,fragment-shader
In my application, I can't explicitly set the color of the lines that I draw, as they will either be black, or they mimic the color of the last object I have rendered in the scene. This is quite a bit of a problem, because I want to put a...

mat4 type in attribute shader

opengl-es,webgl,shader
how to send to a shader attribute with the MAT4 type? attribute mat4 attr; ... JS: var attr=gl.getAttribLocation(_program,"attr"); ...

unity3d, multiple render targets - different behavior in Direct3D/OpenGl

opengl,unity3d,directx,shader,cg
I'm writing shader for unity3d. The shader uses multiple render targets to render post processing effect. However, I've run into interesting issue. When Unity3d runs in direct3d mode, by default all standard shaders write data only into first color buffer (i.e. with index 0). I.e. if I attach 3 color...

Updating float4 declaration from dx9 to dx11

directx,shader
There's a shader which was given which I'm trying to update to be compatible with the newest Unity 5 (presumably dx11). I don't understand how float4 basic instantiation from dx9 was working. Can someone help me understand the following syntax and then provide an equivalent dx11 syntax? I understand that...

OpenGL ES 2.0 on Android: Cannot load Textures

java,android,opengl-es,textures,shader
I'm a fixed-function pipeline guy getting used to the newfangled shader stuff. I'm trying to extend the Android OpenGL ES example to texture a square shape. If the last line of my shader is gl_Fragcolor = vColor; I get a white square. If it is gl_FragColor = vColor * texture2D(u_Texture,...

How to draw each a vertex of a mesh as a circle

ios,unity3d,shader,mesh,particle
How to draw each a vertex of a mesh as a circle?

syntax error on #pragma kernal Main

unity3d,syntax-error,shader,compute-shader
I have the following shader: #pragma kernal Main [email protected]<float4>Reult; [numthreads(8,8,1)] void Main (uint3 id:SV_DispatchThreadID) { Result[id,xy]=float4(id.x & id.y, (id.x & 15)/15.0, (id.y & 15)/15.0, 0.0); } in unity. However this creates the error "Shader error in ":Parse error: syntax error at line 1" //that is #pragma kernal Main I have...

QOpenGLShader Can't Compile GLSL 120 On Android

qt,opengl-es-2.0,shader
I have programed OpenGL code on Qt5 for Mac OS 10.10. The GLSL version is 120 and there is no problem to run. #version 120 attribute highp vec4 vVertex; attribute vec3 vNormal; uniform mat4 mvpMatrix; uniform mat4 mvMatrix; uniform mat4 normalMatrix; uniform vec3 vLightPosition; varying vec3 vVaryingNormal; varying vec3 vVaryingLightDir;...

Is there an accurate approximation of the acos() function?

opengl,glsl,shader,trigonometry,double-precision
I need an acos() function with double precision within a compute shader. Since there is no built-in function of acos() in GLSL with double precision, I tried to implement my own. At first, I implemented a Taylor series like the equation from Wiki - Taylor series with precalculated faculty values....

What are the semantics in CG programming?

shader
msdn stated A semantic is a string attached to a shader input or output that conveys information about the intended use of a parameter unity stated Semantics is a special clause of Cg to define the default input values of a fragment/vertex Shader What are the actually semantics? why do...

What means this texture.zzzz, texture.xy, texture.xz etc

shader,cg
I stumbled upon on this coordinates texture.zzzz, texture.xy, texture.xz etc What do this means or give reference?...

OpenGL lights and deferred shading

opengl,shader,fragment-shader,light,deferred-rendering
Is it fair to say that the only difference between directional lights and point lights is that directional lights have no attenuation factor? Also, do most games use deferred shading? Should I implement deferred shading in my application if I use say less than 10 lights overall?

Why it is necessary to set precision for the fragment shader?

opengl-es,webgl,shader,precision
I learn WebGL. Next shaders work fine: // vertex.shader // precision mediump float; attribute vec4 a_Position; attribute float a_PointSize; void main(){ gl_Position = a_Position; gl_PointSize = a_PointSize; } and // fragment.shader precision mediump float; uniform vec4 u_FragColor; void main(){ gl_FragColor = u_FragColor; } Why it is necessary to set precission...

OpenGL ES 2.0 GLSL Barrel Distortion Shader not working

opengl-es,glsl,shader,distortion
i took the code from the OpenGL ES 2.0 Tutorial from : github.com/learnopengles/Learn-OpenGLES-Tutorials and customized the class "LessonOneRenderer" to test a barrel distortin Shader like mentioned on this site: www.geeks3d.com/20140213/glsl-shader-library-fish-eye-and-dome-and-barrel-distortion-post-processing-filters/2/ This is the "untouched" Result without calling the distort() function: http://fs1.directupload.net/images/150125/hw746rcn.png and the result calling the function : http://fs2.directupload.net/images/150125/f84arxoj.png /**...

Back face culling for linestrips

opengl,directx,shader,linear-algebra
I have circle in 3D space (red on image) with normals (white) This circle is being drawn as linestrip. Problem is: i need to draw only those pixels whose normals directed into camera (angle between normal and camera vector is < 90) using discard in fragment shader code. Like backface...

Shader - Performance and functions

opengl,directx,glsl,shader,hlsl
I am creating vertex and fragment shaders and I would like to know if using functions inside my shader, for better readability, could have an impact on performance and optimisation.

Water rendering in opengl [duplicate]

opengl,glsl,shader
This question already has an answer here: How to render ocean wave using opengl in 3D? [closed] 2 answers I have absolutely no idea how to render water sources (ocean, lake, etc). It's like every tutorial I come across assumes I have the basic knowledge in this subject, and...

Share a function between two passes inside CG Shader for unity3d

function,unity3d,shader
I'm writing a shader in CG language for Unity3d. If you make a shader for transparent object you need to create two similar passes in SubShader. The first one to render only back faces (with Cull Front) and the second one to render only front faces (with Cull Back). But...

HDR Bloom effect rendering pipeline using OpenGL/GLSL

opengl,glsl,shader
I have integrated bloom HDR rendering using OpenGL and GLSL... At least I think! I'm not really sure about the result. I followed a tutorial from intel website: https://software.intel.com/en-us/articles/compute-shader-hdr-and-bloom And about Gaussian blur effect I follow scrupulously all the advices concerning the performance on the following website: https://software.intel.com/en-us/blogs/2014/07/15/an-investigation-of-fast-real-time-gpu-based-image-blur-algorithms According to...

WebGl scanner effect

javascript,three.js,webgl,shader
Hey I have just seen this short video: https://vine.co/v/hxHz5H2Q07q and I am wondering how to achieve this scanning effect. For start there are 2 groups needed: one holding cubes with material and a corresponding one with the same cubes but just wireframed, so it is possible to get these layers....

libgdx - blendFunc for brush line drawing? (additive/non-additive mixture)

opengl,libgdx,shader,brush,glblendfunc
I am drawing sprites to the framebuffer at each pixel for every step in a line between two points, but I have an issue with the blending: I am currently using: (GL_ONE, GL_ONE_MINUS_SRC_ALPHA); Then, in my shader I do: if( color.a == 0 ) color.rgb = 0; However, if you...

Libgdx - map shader to world

java,opengl,libgdx,shader,mesh
I have a 2d level with box2d doing the physics. I have implemented the following water effect described in this tutorial. I am using one OrthographicCamera which is centred on the main character sprite. The camera follows the sprite and as it reaches the edges of the level the camera...

MeshNormalMaterial color

three.js,shader,mesh,fragment-shader,material
In default MeshNormalMaterial example, the color of cube wall is changing because it uses this THREE.ShaderLib[ 'normal' ] shader. This shader sets gl_FragColor by this gl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );. Can anyone explain me this formula? which vector of cube is normalized? Are...

Issue with threejs and shaders showing an sphere glow

three.js,shader
I am working on a 3d visualization. I need to show a world with its atmosphere and I based on an example that was with threejs r40 but mine is r71. When I try to add the atmosphere (kind of a glow to the sphere that represents the world) I...

Problems passing OpenGL 3.0 uniforms through multiple classes

c++,opengl,shader,opengl-3,light
I'm loosely following the tutorial on www.learnopengl.com, I'm currently passing multiple lights into my fragmentshader. For that I've got multiple lightclasses and one class that acts as a container to be able to pass my lights uniforms into the shader. The shader is set up correctly. However when I call...

THREEJS Shader Material overwritten

javascript,three.js,textures,webgl,shader
I have a shader material that works as expected. This shader has a texture attached. I want to create 2 meshes using this shader material, with a different texture for each mesh. Problem is that if I try to render my 2 meshes in the scene, the first object's material...

Weighted, blended order independent transparency

opengl,graphics,shader,transparency
I want to use Meshkin method described here http://jcgt.org/published/0002/02/09/paper-lowres.pdf page 5 in order to obtain a basic weighted, blended order independent transparency. I don't understand who is Ci and ai. Also, what is "Multiple render targets"....

Normals are inverted

opengl,glsl,shader,opentk
I am computing my modelview matrix, and normal matrix in my main program: private void setMV() { modelViewMat = Matrix4.Mult(modelMat,viewMat); // model * view because opentk is row major order GL.UniformMatrix4(uModelViewIndex, false, ref modelViewMat); // normal matrix = transpose(inverse(modelView)) normalMat = Matrix4.Invert(modelViewMat); normalMat = Matrix4.Transpose(normalMat); GL.UniformMatrix4(uNormalIndex, false, ref normalMat); }...

Passing texture to shader in OpenGL

c++,opengl,textures,shader
I'm working on some examples, and I was trying to pass a texture to a shader. To build a VAO, I have this piece of code: void PlaneShaderProgram::BuildVAO() { // Generate and bind the vertex array object glGenVertexArrays(1, &_vao); glBindVertexArray(_vao); // Generate and bind the vertex buffer object glGenBuffers(1, &_vbo);...

DirectX - Pixel Shader 3.0 doesn't work

c#,directx,shader
I’ve been working on a 3D project for quite some time now, to display model files from a engine. I wrote it in C# and using the Managed DirectX wrapper (I know it is old and deprecated, but I have my own reasons to use it). I needed to write...

Should Meshes with and without Skeleton use different Shaders?

c++,opengl,glsl,shader,vertex-shader
Should Meshes with and without Skeleton use different Shaders? Background: Right now my shader is constructed to handle meshes with skeletons. Each vertex takes 3 bone IDs, with respective bone weight. This works well for models with skeletons that I wish to animate, but I feel that it is a...

Porting GL ES 2.0 shaders to desktop GLSL (should I?)

opengl,opengl-es,glsl,shader,glsles
I'm developing a cross-platform game, for iOS, Windows, and OS X. Right now I'm at the point where I'm writing all my shaders for my graphics. So here's the question: If I have working GL ES 2.0 shaders (#version 100) for the mobile version of the game (which I developed...

Can't link shaders to program object in OpenGL, can't debug

c++,opengl,shader
I attach a vertex and fragment shader to a program object, then attempt to link the said program. GL_LINK_STATUS returns false. I check the info log, it's a bunch of gibberish characters. I check GL_INFO_LOG_LENGTH, it's 0. How do I debug this situation? //this is the end of my LoadBasicShaders...

How pick geometries in OpenGL with multisample framebuffer?

opengl,shader,multisampling,mouse-picking
(Edit) I made working geometry picking with framebuffer. My goal is draw huge scene in one draw call, but I need to draw to multisample color texture attachment (GL_COLOR_ATTACHMENT0) and draw to (eddited) non-multisample picking texture attachment (GL_COLOR_ATTACHMENT1). The problem is if I use multisample texture to pick, picking is...

In OpenGL is it possible for one shader program, in one draw call, to render to both an FBO and the default framebuffer?

opengl,shader,fbo
I would like to draw a scene to the default framebuffer, while also drawing some auxiliary data related to some of my drawn models to an offscreen buffer with the same image dimensions as the default framebuffer. I understand I can do these two things separately, in two glDraw* calls...

can I send an array of data as a vertex attribute?

three.js,glsl,webgl,shader
I have a PointCloud in which I am using to visualize some time-related data points. For each vertex in the PointCloud.Geometry, I'd like to assign an attribute which is an array of epoch times. These epoch times are ints, an example would be: epochTimes = [1432314839, 1432314840, 1432314841]; the custom...

Why do we compile shaders at runtime in OpenGL 2?

android,opengl-es,glsl,shader
I have been trying to learn OpenGL, specifically for Android. I have seen various tutorials online, and I noticed that many of the tutorials for OpenGL 1.0, or 1.2 do not require compilation of shader programs, while the only tutorials I could find for OpenGL 2.0 all involve creating a...

How to translate using shaders and matrices?

opengl,matrix,glsl,shader,lwjgl
I'm am using LWJGL and shaders to try and translate everything I'm drawing within my shader program. I am using a 4 by 4 matrix 1,0,0,x, 0,1,0,y, 0,0,1,z, 0,0,0,1 Where x,y,z are the values I am using to translate. Then I use gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex * transformMatrix Where...

Fresh Qt installation does not run Qt projects, including many of Qt Example projects, says “shader program not linked”

qt,opengl,shader,pyqt5
Yesterday I installed Qt 5.4 on my windows 7 PC. But I can not build and run any Qt project including those given in Examples section on the Welcome page of Qt Creator 3.3 except for a few. Also, I can’t run any qml file either using this command from...

How it is possible to get rid of spurious artifacts of Shadow Mapping?

javascript,webgl,shader,shadow
Spurious artifacts in case of creation of shadows through shadow mapping. I can't understand why many shadows are drawn, and from where they originate? example: example...

Efficient way to generate normal map (from height) for all 360 degrees of a rotated image

opengl,glsl,shader,hlsl,normals
I already have a shader that generates a normal map from a height map. Now I need to apply the effect to all 360 degrees of the rotated heightmap. Of coarse I could just apply the effect 360 times to each heighmap, but if I have already done it once...

OpenGL es 2, Shaders not compiling

java,android,opengl-es-2.0,shader
I'm trying to make a very simple point light and I'm failing miserably. All I know is that my shaders doesn't compile correctly (I don't seem to get much error information). My shaders are: Vertex Shader Code "uniform mat4 u_MVPMatrix;" + "uniform mat4 u_MVMatrix;" + "attribute vec4 a_Position;" + "varying...

Phone unable to compile shader

java,android,opengl-es,libgdx,shader
I have a project I'm working on in libGDX. I'm running tests on a distance field font and I've run into issues while compiling the shader on my Android phone (Galaxy Core 2 4.4.2). When deployed on my phone I get errors while the desktop app works fine (mostly -...

Unity | 'gameobject.renderer.material.color' in version 5.x

unity3d,shader,crop,mask,renderer
I want to make a portion of the gameObject(guiTexture or sprite) as transparent color like "SpriteMask" which is in asset store. https://www.assetstore.unity3d.com/kr/#!/content/27642 Let me explain in more detail. For example, there are two gameObject in the scene. One is the background of the scene and the other one is just...

Using a FrameBufferObject with several Color Texture attachments

opengl-es,opengl-es-2.0,shader,fbo
I'm implementing in my program the gaussian blur effect. To do the job I need to render the first blur information (the one on Y axis) in a specific texture (let's call it tex_1) and use this same information contained in tex_1 as input information for a second render pass...

QOpenGLShaderProgram: is possible to make error output nice?

qt,opengl,error-handling,shader,gpu
I'm implementing some numerical algorithms on GPU via OpenGL and Qt. But i am not very familiar with it. I want to extract some functions from my current shader to some "shader library" and use it in my other shaders by string interpolation. It not hard to implement but i...

Constant buffer is empty when passed HLSL C++

c++,directx,shader,hlsl
So I moved from this problem: Previous problem to this one :). I made 2 constant buffers in C++ which I'm passing to my HLSL Shader but when I debug and look into the buffers they are just filled with zeros except the last 3 numbers (which are -572662307). I...

Attribute Variable not found in OpenGL, possible optimization

opengl,optimization,glsl,shader
I'm currently working in a deferred shading and I created a class which manages the FBOs and draw the buffers on the screen. This is how it looks so far: FBORender::FBORender(float screenWidth, float screenHeight) : _screenWidth(screenWidth), _screenHeight(screenHeight), ProgramManager("defVertexShader.txt", "defFragShader.txt") { CreateProgram(); _vbo[0] = 0; _vbo[1] = 0; _vao = 0;...

is early exit of loops on GPU worth doing?

opengl-es,glsl,webgl,shader,gpu
We've written GLSL shader code to do ray tracing visualisation using the GPU. It seems to be pretty standard to put an early exit break in the ray marching loop, so if the light is extinguished, the loop breaks. But from what I know about GPU code, each render will...

Setting fontColor for ImageTextButton works in one screen but not on another - LIBGDX Scene2D

java,libgdx,shader,fragment-shader
I have two ImageTextbuttons and this is how I set them up in my MainMenu screen and in the Game screen: ImageTextButton.ImageTextButtonStyle ibs = new ImageTextButton.ImageTextButtonStyle(); ibs.font = skin.getFont("scorescombo3-font160"); ibs.fontColor = new Color(1.0f, 0.6f, 0.0f, 0.65f); ibs.up = new TextureRegionDrawable(skin.getRegion("level_name")); level_no_button = new ImageTextButton("button", ibs); I use the same font...

How do I send a uniform matrix to a shader in Haskell?

opengl,haskell,shader,vertices
Trying to do essentially do matrix multiplication on vertices in shaders for transformations and it's uh, not having it. At the moment, I've got this: curMatrix <- get ((matrix $ Just $ Modelview 0)::StateVar(GLmatrix GLfloat)) mc <- getMatrixComponents ColumnMajor curMatrix setUniform p "uModelViewMatrix" mc setUniform being a function in the...

Rendering a circle with a Vertex shader in DirectX

shader,hlsl,directx-9
I am trying to draw a simple 2D circle by manipulating texcoord coordinates inside a vertex shader. This is the code: float2 uv2 = 2.0 * (TextureCoordinate.xy - 0.5); float tnm = 1.0 - length(uv2); In pixel shader, this draws a circle. The same code inside the vertex shader would...

Colored Vignette Shader (the outer part) - LIBGDX

opengl-es,libgdx,opengl-es-2.0,shader,vertex-shader
I've seen lots of tutorials on vignette shaders just like these but none of them say how to change the color of the vignette, they only talk about applying sepia or grey shaders to the whole composite image. For example the video above gives the below code for the vignette...

How to use a huge array in HLSL (error X4505)

arrays,directx,shader,hlsl
When I try to compile I get the error: X4505: sum of temp register and indexable temp registers exceeds limit of 4096. However my shader does work in FX Composer. The reason it crashes is probably because I use a very large array since I'm using marching cubes. const static...

Spotlight with shadows becomes square-like

c++,opengl,graphics,shader,shadow
I've been following a two part tutorial on shadow mapping from OGLDev (part 1, part 2) for a couple of days now, and I've nearly finished implementing it. My problem is that when I enable shadow maps the illuminated region which shadows appear in appears as a "strip" and I'm...

How can I make this spherical gradient in an OpenGL fragment shader?

c++,opengl,shader
I'm new to OpenGL. I'd like my background to look as if the player is inside the sphere pictured below. White as the player looks up, black as the player looks down, and a gradient along the way. I tried enclosing the camera in a diamond shaped prism and assigning...

What is texture downsampling (downscaling) using OpenGL?

opengl,glsl,shader
I did not found any tutorial that explains how to downscale a texture using OpenGL. For example if I have a 1024x720 texture and I want to generate downscale by the factor 1/4 how to do it? Here's a tutorial talking about downsampling. UPDATE I tried the following filtering code...

Geometry shader output filling Z-Buffer with closest value possible? (DirectX)

c++,directx,shader,hlsl
I need lines of a certain thickness in my CAD viewer and found out that I should use a geometry shader to accomplish this. I then went ahead and found demo code of a geometry shader that creates lines at a given thickness. Here: https://github.com/paulhoux/Cinder-Samples/blob/master/GeometryShader/assets/shaders/lines1.geom Discussion about it here: https://forum.libcinder.org/topic/smooth-thick-lines-using-geometry-shader...

Image atomic addition in a compute shader

opengl,shader,compute-shader
I have the following compute shader: #version 430 layout(std430, binding=0) buffer wks{ ivec2 w[]; }; layout(r32i, binding=1) uniform writeonly iimage2D pathTex; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; void main(){ imageAtomicAdd(pathTex, w[0], 1); // line 12 } That gives me this error: 0(12) : error C1317: qualified...

Render camera preview on a Texture with target GL_TEXTURE_2D

android,opengl-es,android-camera,shader,render-to-texture
I'm trying to render the camera preview on an OpenGL Texture with target GL_TEXTURE_2D. I'm very well aware of SurfaceTexture but I cannot use it because it only works with GL_TEXTURE_EXTERNAL_OES. In the documentation of SurfaceTexture, it's written : Each time the texture is bound it must be bound to...

OpenGL ES: define triangles color in shader?

android,opengl-es,opengl-es-2.0,shader
I'm making an Android game using OpenGL ES 2.0, and I have a question on what would be the best strategy: I want to have a plane (the ground) made of multiple triangles (like a chessboard, with each case as 2 triangles), and I want each triangle to have a...

OpenGL reading from unbound texture unit

opengl,textures,shader
Does the OpenGL standard mandate what the result of a texture2d operation should be given a uniform sampler2D that the program hasn't bound to a texture unit? For example in the pixel shader: layout(binding=0) uniform sampler2D Map_Diffuse; ... texture2D(Map_Diffuse, attrib_Fragment_Texture) Where in the program: ::glActiveTexture(GL_TEXTURE0); ::glBindTexture(GL_TEXTURE_2D, 0); For context I'm...

GLSL offsetting multitexture

opengl,glsl,shader,vertex-shader
How can I do something like this in GLSL shaders? vec2 attribute texture_sky; vec2 attribute texture_floor; if(texture_sky) gl_position = position+Xoffset; else gl_position = position; I want to move one texture over the other. Is it possible to do with the vertex shaders?...

Why does this call of glEnableVertexPointer and glVertexPointer cause InvalidValue?

c#,opengl,shader,game-engine,opentk
I am creating a game engine that includes basic game needs. Using glslDevil, it turns out my bind VBO method throws an InvalidValue error. A call of glVertexPointer and a call of glEnableVertexPointer cause the issue. The vertex attribute index is causing the issue. The index is 4294967295 which is...

Issues refactoring GLES30 shader?

opengl-es,textures,glsl,shader,hlsl
I'm currently rewriting a shader written in GLES30 for the GLES20 shader language. I've hit a snag where the shader I need to convert makes a call to the function textureLod, which samples the currently bound texture using a specific level-of-detail. This call is made within the fragment shader, which...

How to rotate a THREE.PlaneBufferGeometry with THREE.WaterShader and MirrorMesh

rotation,three.js,shader
In this example we have a THREE.PlaneBufferGeometry with WaterShader and Water Normals texture. If you try to delete the rotation at line 119, the plane rotates as expected but the Shader and the normals aren't working correct anymore but they are distorted. How can you rotate without distortion?Is it something...

Why the CPU compiles the GPU shader?

caching,compilation,shader,gpu,cpu
To understand in general how GPU's cache support work, I read some information and understood this: CPU compiles shader and transmit resulting code of shader to GPU to execute and also save it to the disk. If necessary to execute the same shader, GPU get it saved binary code directly...

Visual debugging for Direct3D/OpenGL/unity3d applications on windows 7

debugging,opengl,unity3d,directx,shader
I need to visually debug scene rendering (step-by-step frame rendering) in unity3d (version 5) on Windows 7 64bit. "Visually debug" means that I need to walk through rendering process step-by-step and see what unity does to framebuffer at each step. Which tools are currently available for that? Few years ago...

What is the difference between glUseProgram() and glUseShaderProgram()?

c++,c,opengl,shader
In OpenGL what is the difference between glUseProgram() and glUseShaderProgram()? It seems in MESA and Nvidia provided glext.h, and in GLEW, both are defined, and both seem to do basically the same thing. I find documentation for glUseProgram() but not for glUseShaderProgram(). Are they truly interchangeable?...

Cant understand CG semantic

unity3d,shader,cg
I am beginner in CG and do simple shader. I can't understand what means this code float4 vert(float4 vertexPos : POSITION) : SV_POSITION { ... } Rather this moment: We announced parameter with type float4.Question: what do this ": POSITION" and this ": SV_POSITION" Or give reference for this Thanks...

Why are shaders and programs stored as integers in OpenGL?

c++,opengl,opengl-es,integer,shader
I'm following the "OpenGL Superbible" book and I can't help but notice that when we create a shader and create the program that we attach the shaders to, we store them as GLuint which are unsigned integers. Why are they stored as numbers? What does the value of the number...

Shader's function parameters performance

opengl,directx,glsl,shader,hlsl
I'm trying to understand how passing parameters is implemented in shader languages. I've read several articles and documentation, but still I have some doubts. In particular I'm trying to understand the differences with a C++ function call, with a particular emphasis on performances. There are slightly differences between HSLS,Cg and...

Multiple [in] attributes in shader - OpenGL

c++,opengl,textures,shader
I'm to learn OpenGL 4 and now I working with textures. I would like to apply a texture to a sphere, and my vertex shader looks like this: #version 410 in vec4 vPosition; in vec2 texCoord; uniform mat4 mvpMatrix; uniform mat4 mvMatrix; uniform mat3 normalMatrix; uniform vec3 vLightPosition; smooth out...

OpenglES 2.0 Vertex Shader Attributes

c++,opengl-es,shader,vertex
I've read in tutorials that the bare minimum a vertex shader needs is define below: attribute vec3 v3_variable; attribute vec3 v3Pos; void main() { gl_Position = v3Pos; } OpenglES passes to the shader vertex data to v3Pos but the name of this variable can actually be anything, other tutorials name...

Billboarded sprites intersecting 3D objects

opengl,shader,quad
I'm using spherically billboarded sprites along with 3D objects. Because the quad leans backwards to match the camera angle, it intersects with 3D objects immediately behind it. It is more noticeable when the camera angle is very large.The following link provides a very clear visual. Is there an efficient way...

Transparent shader allows the objects below to show on top

unity3d,shader,transparent
In my scene, the smileys(Quad with png image) are placed at Y:0 and the dots(Quad with tiling 3X3) are placed at Y: -0.25. The shader I need to use for the smileys is Transparent-Diffuse as I am using a circle png image. But the dots I use below are showing...

Draw a sphere on a billboard with world normal from a pointlist

3d,directx,shader,hlsl
I am drawing spheres on billboards by passing center world positions via a StructuredBuffer and use the geometry shader to build a billboard facing the camera. The sphere is drawn correctly and I can figure out the UVs. Now I would like to light it but I cannot figure how...

Retrieve Vertices Data in THREE.js

three.js,textures,webgl,shader,vertex-shader
I'm creating a mesh with a custom shader. Within the vertex shader I'm modifying the original position of the geometry vertices. Then I need to access to this new vertices position from outside the shader, how can I accomplish this?

Tessellation shader drawing issues

glsl,shader,tessellation
I am currently trying to add tessellation shaders to my program and I feel as though I'm at my wit's end. I have gone through several tutorials and delved into a lot of the questions here as well. Unfortunately I still do not understand what I am doing wrong after...

OpenGL Shader Compiles on Desktop, But Not Android

java,android,opengl-es,shader
I recently started learning opengl and still don't know very much about it. I was following a tutorial and wrote these two shaders: Vertex Shader: #version 400 in vec4 s_vPosition; in vec4 s_vColor; out vec4 color; void main() { color = s_vColor; gl_Position = s_vPosition; } Fragment Shader: #version 400...

Copying data from one texture to another - opengl

android,opengl-es,shader,render-to-texture
I'm rendering my camera preview in android on a SurfaceTexure. This SurfaceTexture is bound to target GL_TEXTURE_EXTERNAL_OES. I want to copy the texture data from this SurfaceTexture object to my custom OpenGL texture which is bound to GL_TEXTURE_2D. My onFrameAvailable callback is as follows : @Override public void onFrameAvailable(final SurfaceTexture...

OpenGL 3.3 lighting gives really strange disortions

c++,opengl,3d,shader,lighting
I've, the last month, been following tutorials on a various pages (learnopengl.com) amongst others. I got to the lighting section (I created a loader to load meshes with Assimp first), my fragmentshader code is pretty much the same as the tutorials lighting ( learnopengl.com/basic_lighting). Frag code: #version 130 out vec4...