A programming language for OpenGL shaders.

learn more… | top users | synonyms

0
votes
1answer
59 views

Fragment Shader output type error

StackExchange! I've been working with opengl for a bit and I'm trying to finally load the shaders instead of having them inline. I'm having a ton of issues, though. As soon as I solve one, another ...
2
votes
1answer
33 views

Failing to move exponential depth term to depth shader in exponential shadow mapping

I'm playing around in my little toy project to see if I can understand how exponential shadow mapping works. To begin, I have the following two fragment shaders: Light depth texture shader ...
-1
votes
1answer
39 views

how to turn (or solidify) water or fuild into solid material (Renderring Effect)

i want to implement an effect like this. for example, let's assume the clay are made of particles. liquids of clay flows for a while, then it becomes dry and rest.finally those particles becomes only ...
4
votes
1answer
260 views

C++ OpenGL ShadowMap Issue/Artifacts

I am currently implementing basic shadow mapping in my C++ Custom Engine using GLSL 4.10. It is currently working with basic PCF anti-aliasing and very minimal reduction for unwanted artifacts. Here ...
0
votes
1answer
62 views

Reconstruct shader vertices in OpenGL

I'm not sure if 'reconstruct' is the correct term for this but essentially what I am trying to do is calculate vertex positions (that are already calculated via shader) on the CPU for the purpose of ...
0
votes
0answers
30 views

Grayscale and 2D lighting using cocos-2dx

I want to create a lighting effect on a gray-scaled world using cocos2d-x. What I've done is creating a layer which runs a shader program that receives light positions and radiuses as input and ...
0
votes
2answers
48 views

Overload how an object instance of a class is treated when used

So I've made this struct that encapsulates a glm::vec4. This is because vec3s are treated as 16-byte in GLSL, but I don't want to assign a vec4 if I only really need 3 components. Anyway, my question ...
0
votes
1answer
50 views

Ray casting problem using JOGL

I'm trying to port an old perfectly functioning ray casting implementation from my lwjgl project (FF pipeline) to a new project using JOGL and shaders. My problem is that my ray no longer intersects ...
0
votes
0answers
56 views

Artifacts rendering high-poly procedural meshes with OpenGL

I am having some issues when rendering some procedural generated meshes. There are some really wierd artifacts when rendering high-poly count meshes (not that much actualy). I have been able to ...
3
votes
1answer
318 views

I want to render some surfaces in GLSL with normal maps, and some without

I have normal mapping working in my game, but I want to only use normal mapping for some surfaces, and not others. Right now, as far as I can tell, my shader is applying an incorrect normal of (0, 0, ...
0
votes
0answers
34 views

Dynamic VBO update possibly corrupting data?

I want to draw a line between two vertices. On a mouseclick the vertex data will change and I want to update the line to use the new values. I am using a VBO for this and it looks like the update ...
1
vote
1answer
59 views

How do I convert from rectangular to spherical coordinates?

This seems like a fairly basic and common problem. Is there a builtin way to achieve it or do I have to write the algorithm on my own? If I do, how should it work?
0
votes
2answers
117 views

Combine flat and smooth shading with a single model geometry

I need to be able to switch between smooth and flat shading interactively. Is there a way to do this efficiently with a single geometry? For example, smooth shading does not require duplicate ...
0
votes
0answers
56 views

Tessellation shader pass-through : Nothing displayed

I am trying to set a pass-through tessellation shader and then build on top of that while learning. From what I found/read I need to do in the TE shader everything that was done in the vertex shader ...
1
vote
1answer
48 views

Is it possible to look up a texel from a texture in GLES2 GLSL framgent shader without using sampler?

Is there some way I can directly access texture memory from fragment shader in GLES2 GLSL? I don't need the sampler to be involved since I am just using it as a look-up table.
1
vote
0answers
28 views

Is it possible to use unnormalized texture coordinates from a GLES2 GLSL fragment shader?

I want to look up a texel from my GLES2 GLSL fragment shader using un-normalized texture coordinates (0-w, 0-h instead of 0-1, 0-1). The reason is that this texture is used as a look up table and I ...
0
votes
1answer
67 views

Uniform Block solve padding/alignment for vec3 in CPU struct

I have a struct on the CPU which I'm sending to a uniform block in my shader. After a bit frustration I finally got it to work. The problem I had was that vec3s are actually treated as 16-bytes, or in ...
1
vote
1answer
45 views

What is the fastest way to know if the current coordinate in screen-space is odd or even in GLSL/GLES2 frag shader?

I want to make a post-effect where every second column of pixels is colored differently, and I want to implement this as a GLSL fragment shader on GLES2. The question is what is the most effective way ...
1
vote
1answer
112 views

Basic terrain shader without using external texture

I have this: (Right now I have the height map in a x*x size 2D array and a 1D vector too.) What I am trying to achieve is something like this: Without using any textures, only plain colors. So ...
0
votes
0answers
20 views

Artefact in VSM as if GL_DEPTH_TEST disabled

I am trying to implement VSM and I incurred in a strange issue. I render them as follow: glUseProgram(shadowMapProgramID); glEnableVertexAttribArray(0); glBindFramebuffer(GL_FRAMEBUFFER, ...
0
votes
0answers
12 views

Transform screenquad around object's view space boundaries (GLSL)

Im not sure how to ask this, but essentially I am looking for a way to optimize rendering screen quad lights per object. I have a deferred renderer that draws directional lights onto a screen quad. ...
1
vote
2answers
127 views

How can I pass a std::vector<Vector3f> to my shader?

I have a Vector3f type which has x, y, and z properties. I have a std::vector of these vertices which describe my terrain. I would like to pass these values to a vertex shader through a uniform ...
2
votes
1answer
111 views

Shader - Transmittance or Absorption

I am trying to create a transmittance or absorption shader (glsl, hlsl, cg, etc...) in realtime but I don't find any good tutorial or white paper about this subject. I only find offline rendering ...
1
vote
1answer
99 views

Is it possible to calculate the TBN matrix in the fragment shader?

Just from model position, model normal and texture uv?
0
votes
1answer
60 views

How to load and render PhysX 3.3 heightfield

I'm trying to load a PhysX 3.3 heightmap and render it with OpenGL using glm and glfw, but so far it doesn't seem to be working. I'm basing my code on the PhysX samples, and am also using FreeImage to ...
0
votes
1answer
81 views

Per vertex diffuse lighting not propogating across entire model

I'm not sure how to describe this problem so I've added a picture. When I add per vertex diffuse lighting to my model (just a field of cubes for simplicity) the lighting effect applies to each ...
1
vote
1answer
126 views

What is the relationship between glVertexAttribPointer index and GLSL location?

I've been getting some strange results when trying to implement a normals buffer for the purpose of rendering lighting. It seems to be related to the indexes for glEnableVertexAttribArray, ...
2
votes
1answer
111 views

How to share values between different shader programs?

I am using Unity but this might concerns all type of shaders. I would like to know if this is possible to share values between different shader pass.Let's imagine that I am computing something in the ...
3
votes
2answers
172 views

Shader - Calculate depth relative to Object

I am trying to calculate depth relative to the object.Here is a good solution to retrieve depth relative to camera : Depth as distance to camera plane in GLSL varying float distToCamera; void main() ...
0
votes
1answer
81 views

GLSL: Vertex attribute to int

I'm trying to write a shader which renders a multitextured geometry wihout rerendering the geometry with each texture. In my test I'm not using textures, I just convert the texture index to a color ...
1
vote
1answer
159 views

Problem with uniforms in OpenGL

I have a strange problem I can't figure out. On the CPU I have class that handles the material properties for a model. material = new Material(); material->Emissive = vec3(0.1, 0.0, 0.0); ...
0
votes
3answers
73 views

Arbitrary number of VBO to Vertex Shader

I am currently using standard modern OpenGL way to render a mesh via VBO and attributes glEnableVertexAttribArray(aVertexPosition); glBindBuffer(GL_ARRAY_BUFFER, VBO); ...
0
votes
1answer
73 views

Why does my vertex shader produce no output until I add some arbitrary value to the position attribute?

I want to draw a textured quad but there is nothing drawn and the setup should be right. This is my vertex shader: #version 330 in vec2 position; in vec2 texel; out vec2 texCoord; void main() { ...
2
votes
0answers
168 views

Skybox rendering

I am sorry if this is trivial, but I got into OpenGL just very very recently. I am trying to render skybox (with cubemaps) and this is what I have done: Created a VBO with vertices positions (36 ...
-2
votes
1answer
148 views

GLSL- How to change a certain color of a sprite, to another color passed into the shader?

I have been googling for over an hour, trying to find out how to do something very simple, which I see in tons of games. I tried to understand GLSL, but it seems like a ton of learning for a single, ...
0
votes
0answers
121 views

Problems texturing a sphere using a cubemap

I have a single problem which I've attempted two methods to resolve. Neither is giving me 100% results. I've read about 100 tutorials and looked at code but it's just not working out for me; I believe ...
2
votes
1answer
120 views

OpenTK GL.DrawElements is never called

I found this C++ code here. It draws simple rectangle. Works great. #define GLEW_STATIC #include <iostream> #include <glew.h> #include <freeglut.h> const GLchar* vertexSource = ...
0
votes
0answers
57 views

Is it possible to loop over an array of samplerCube/samplerCubeShadow using OpenGL/GLSL?

I try to manage a scene with several point lights. For the moment my program works perfectly with just one point light. So I have in my fragment shader the following uniform declaration: uniform ...
6
votes
1answer
207 views

Why does accessing a uniform float make my shader more than twice as slow?

My fragment shader was significantly slowed down by a recent change, and I've been trying to understand why. I isolated the main slow-down to accessing a single particular uniform float. If I include ...
0
votes
1answer
140 views

3D position of an arbitrary UV coordinate

I have a UV map for a 3D mesh that encodes "links" between pairs of UV coordinates. I have previously defined this links (or pairs), one to one. The links are enconded using the function rgb_color(u1, ...
1
vote
2answers
72 views

Vertex Skinning Looks Messy on Real Android Device using Monodroid

I have no problem doing the "vertex skinning" for three-dimensional animation. All goes well when using the emulator (and genymotion). However, when run on a real device (such as Samsung and Lenovo) ...
2
votes
1answer
59 views

How to know when graphics driver or card changes

I'm about to start work on implementing GLSL binary shader compilation and I was curious how to handle the cases when the shaders need to be recompiled, such as when the driver (or perhaps even the ...
0
votes
1answer
93 views

Blurring part of the screen - optimisation

I develop 3d menu and sometimes I need to blur only part of the screen. I use a forward rendering. I create a frame buffer object with 3 color attachments. Rendering looks like this: bind fbo ...
1
vote
1answer
33 views

Only affect pixels in buffer with alpha 0

I'm working on a transition effect where I have a texture and simply draw that as a pattern to my buffer. Here is a demo, use "e" to start the effect again. This looks fine but it won't work if the ...
1
vote
0answers
170 views

Is it reasonable to use a 2D texture as a lookup table in GLSL

I need a lookup table in a shader. The input values would be color values and the output other color values. Something like: uniform float lut[256]; color = vec3(lut[int(color.r*255.)], ...
1
vote
1answer
129 views

Vertex shader in OpenGL/GLSL - transformation of the interior of a textured quad

I have a LWJGL project and ran into a problem with a vertex shader I wrote. In my scene I am rendering a map whose ground consists of rectangular tiles. On top of that there are other objects (I used ...
0
votes
1answer
73 views

Proper way to encapsulate a Shader into different modules

I am planning to build a Shader system which can be accessed through different components/modules in C++. Each component has its own functionality like transform-relevated stuff (handle the MVP ...
0
votes
2answers
65 views

Best way to detect if vec3 is between vec3(x) and vec3(y) in glsl

As titled I am sampling from a texture and if the color is somehow gray [vec3(.8), vec3(.9)] and an uniform is 1 I need to substitute that color with another one I am not a glsl veteran but I am ...
0
votes
0answers
39 views

GLSL 150 (or upper) per pixel lighting base code

I'm looking for a working example of smooth per pixel shading for one directional light I've seen this example http://www.opengl.org/sdk/docs/tutorials/ClockworkCoders/lighting.php but its old GLSL ...
5
votes
1answer
323 views

How can glass breaking effect from Smash Hit be achieved? [duplicate]

I saw Smash Hit the other day and was amazed by the physics of the game, specially the shattered glass effect: I've read other posts about this subject but I still feel that they don't share enough ...