a computer program that runs on graphics hardware and provides a high degree of control over how scenes are rendered

learn more… | top users | synonyms (1)

4
votes
2answers
4k views

Basics of drawing in 2d with OpenGL 3 shaders

I am new to OpenGL 3 and graphics programming, and want to create some basic 2d graphics. I have the following scenario of how I might go about drawing a basic (but general) 2d rectangle. I'm not ...
4
votes
2answers
370 views

How can I use shaders to make a square have a waving effect?

I'm new to using shaders to do some fancy effects and I'm struggling with them. I'm using DirectX 11 and HLSL. I have this square in the middle of the screen: It's just a square that I've created ...
4
votes
1answer
969 views

variable number of lights in a glsl shader?

I want to render an arbitrary number of lights in my fragment shader. I do not understand how you can properly pass them into the shader though. For example, I want something like this: uniform int ...
4
votes
1answer
2k views

Access vertex data stored in VBO in the shader

If I wanted to store extra data in a VBO for skinning (indices for indexing into an array of matrices of bones and floats for applying weights to those bones) How would I go about accessing that data ...
4
votes
1answer
1k views

Multiplication for MVP matrices: Any benefits to doing so within the vertex shader?

I'd like to understand under what circumstances (if any) it is worth doing MVP matrix multiplication inside a vertex shader. The vertex shader is run once per vertex, and a single mesh typically ...
4
votes
1answer
603 views

My GLSL shader isn't compiling even though it should. What should I investigate?

I'm porting an iOS game to Android. One of the shaders I'm using wouldn't compile until I reduced the number of uniform variables. Here are the uniform definitions: uniform highp mat4 ...
4
votes
1answer
623 views

Why are my texture coordinates always (0,0) in this shader?

What I'm trying to do is add my depth buffers values to my scene, ie. I'm trying to make objects closer to the camera darker and objects further away lighter. Which should be easy: just render the ...
4
votes
1answer
798 views

Using raw vertex information for sprites rather than SpriteBatch in XNA

I have been wondering whether using SpriteBatch is the best option. Obviously for prototyping or small games it works well. However, I've been wanting to apply techniques such as shaders and lighting ...
4
votes
3answers
3k views

How can I draw the depth value in GLSL?

I want to draw the depth buffer in the fragment shader, I do this: Vertex shader: varying vec4 position_; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; position_ = ...
4
votes
1answer
364 views

Matcap and BRDF Shading

I just would like to know what's the difference between the Matcap shaders used in ZBrush for example and the Bidirectional Radiance Distribution Function shader. Are there two techniques the same ? ...
4
votes
1answer
418 views

How can I emulate point sprites in D3D11?

I have points which I pass to a vertex shader and then to a geometry shader, but now I want to get from the geometry shader a "bigger" point. So the point should get a "dadius" like it was possible in ...
4
votes
3answers
379 views

What techniques make next gen look so realistic [closed]

I have watch several gameplays from upcoming titles for ps4 and xbox one and I must admit that they are breath taking. Of course with new hardware, models will have more polygons and higher texture ...
4
votes
1answer
688 views

OpenGL, fetching the names of all uniform blocks in your program

I want to auto-bind uniform blocks with certain named values to certain binding points when I compile a shader. For example, I have some basic, default fixed binding points that are always used for ...
4
votes
1answer
1k views

Custom shadow mapping in Unity 3D Free Edition

Since real time hard and soft shadows are Unity 3D Pro only features I thought I will learn Cg programming and create my own shadow mapping shader. But after some digging I found that the shadow ...
4
votes
1answer
406 views

Direction vector in raycasting

When I read about how to get the direction vector in raycasting, for example on this site: http://www.daimi.au.dk/~trier/?page_id=98 They first render the mesh with front face culling and then with ...
4
votes
1answer
71 views

Lighting computation viewing direction

This is something that's really cooking my noodle. When I'm computing the light response for a material in my fragment shader, I'm using the standard 3 normalized vectors, in eye space: fragment ...
4
votes
1answer
784 views

Shadow mapping does not work correctly using GLSL shaders

I'm a beginner in shadow mapping. I have in my scene two meshes : a cube and a floor. The scene is lighted by a single point light. Here's for the following display the light properties : ...
4
votes
2answers
277 views

Refractive blur in XNA?

I'm writing a 2D hack-and-slash game using XNA. I really want to implement the blur-like, refractive effect of a sword or such moving really quickly, seen in such games as Dust: An Elysian Tail and ...
4
votes
1answer
628 views

Can I use the default depth buffer when drawing to FBO?

How to attach default depth buffer to FBO? How to use depth renderbuffer buffer attached to FBO (after drawing to it) as a default depth buffer? Basically I want to use the same depth buffer for both ...
4
votes
4answers
743 views

Enconding/Decoding bit value in Texture Alpha Channel

I am Rendering to a SurfaceFormat.Color. (R8G8B8A8) The alpha of this format has 8 bits and I want to be able to use those 8 bits as a bit field. For example, in one pass of my render, I want to save ...
4
votes
2answers
3k views

Changing the color of some fragment of a texture using shaders

Declarative programming language QML allows to connect the elements, their properties with universal variables in shader programs description. For these purposes there is such elements as ...
4
votes
2answers
949 views

Real time reflections

I just had a quick look at the new Crysis 2 DX11 update, and was quite surprised by some of the new features, especially the real time reflections on moving models. From what I could gather, there are ...
4
votes
3answers
1k views

BlitzMax - generating 2D neon glowing line effect to png file

Originally asked on StackOverflow, but it became tumbleweed. I'm looking to create a glowing line effect in BlitzMax, something like a Star Wars lightsaber or laserbeam. Doesn't have to be realtime, ...
4
votes
2answers
118 views

Should I use different input layout for meshes (vertices) with and without normal maps?

I'm writing an DirectX11 game. About 60% of my game models (or "of my vertices") have: Position Texture coordinate Some of them use: Position Texture coordinate Normals And few of them: ...
4
votes
1answer
135 views

PCF shadow shader math causing artifacts

For a while now I used PCSS for my shadow technique of choice until I discovered a type of percentage closer filtering. This method creates really smooth shadows and with hopes of improving ...
4
votes
1answer
248 views

How can I handle the combination of multiple shader effects?

To be able to work efficiently with effects, is there a good way to combine multiple reusable "base" effects to achieve a more complex final result? For example, say I have an effect that handles ...
4
votes
1answer
224 views

Premultiplied Alpha And Alpha Testing

I have a shader that is supposed to work with either alpha blending or alpha testing, but the color values being passed in are premultiplied alpha values. Is there an easy/standard way to have it ...
4
votes
2answers
1k views

XNA 4.0 - Normal mapping shader - strange texture artifacts

I recently started using custom shader. Shader can do diffuse and specular lighting and normal mapping. But normal mapping is causing really ugly artifacts (some sort of pixeling noise) for textures ...
4
votes
1answer
1k views

OpenGL ES 2 shaders for drawing buildings and roads like Google Maps does

I'm trying to create a shader that'll give me an effect similar to what buildings and roads look like on 3D Google Maps. You can see the effect interactively if you enable WebGL at maps.google.com, ...
4
votes
4answers
1k views

From camera coordinates to world coordinates

I want to calculate world coordinates from camera coordinates. However, I seem to have problems with my understandings of how matrices in HLSL work. From world to camera is clear: cameraPosition = ...
4
votes
1answer
1k views

Faking 2d light using shader (Unity, Shaderlab)

Since the concept was difficult to explain in words for someone who's not quite familiar with shader, I described it in pictures. I'm currently using Unity and it seems Shaderlab is the best choice ...
4
votes
2answers
329 views

Calculate mipmap level in a loop with varying iteration?

How can I calculate the correct mipmap level in a shader? It needs to be used in a loop which runs a variable number of times so the compiler will not allow me to use Sample or the derivative ...
4
votes
1answer
609 views

Material System

I'm designing Material/Shader System (target API DX10+ and may be OpenGL3+, now only DX10). I know, there was a lot of topics about this, but i can't find what i need. I don't want to do some kind of ...
4
votes
2answers
326 views

Geometry shader worldviewprojection

I'm writing a simple geometry shader to create 3D "primitives" in place of a single point. I am performing all of the world-view-projection conversions within the geometry shader after creating the ...
4
votes
3answers
572 views

OpenGL ES 2.0 - How to batch draw particles that have unique translations, rotations, scales, and alphas?

I've combined all of my vertex data for many particles into a single array. How would I batch draw all of those particles in a manner that preserves their unique translations? Any code examples ...
4
votes
1answer
1k views

GLSL Editor and Debugger for MacOSX with ES2 support

is there a GLSL editor for the mac? I need it for iOS OpenGLES2 shader. How do you best debug shader? Regards
4
votes
2answers
529 views

Reflections based on distance from plane

Let's consider, for example, a surface like the volleyball court, we can see that legs and shoes of the players are reflected, with a blur effect, but body and stadium don't (as each object not near ...
4
votes
1answer
489 views

Phone complains that identical GLSL struct definition differs in vert/frag programs

When I provide the following struct definition in linked frag and vert shaders, my phone (Samsung Vibrant / Android 2.2) complains that the definition differs. struct Light { mediump vec3 ...
3
votes
3answers
2k views

How can I make a shader effect that looks like a lightly shaded pencil drawing?

I want to make a shader effect using OpenGL ES 2.0 that looks like this image: I'm not sure if this image was painted or is the result of some filter, but I want to create a shader that produces ...
3
votes
4answers
6k views

How do multipass shaders work in OpenGL?

In Direct3D, multipass shaders are simple to use because you can literally define passes within a program. In OpenGL, it seems a bit more complex because it is possible to give a shader program as ...
3
votes
2answers
1k views

Which is worst: Too many VertexShader instructions, or FragmentShader instructions?

I want to have a better understanding of how to create shaders with optimal performance and realize where some bottlenecks can occur. Is it usually favorable (when possible) to delegate most of the ...
3
votes
2answers
391 views

When is the Z coordinate normalized in GLSL?

I thought that whenever you transform an object to world space, then view space and finally screen space, the last matrix you apply(the projection matrix) normalizes the z values between 0 and 1. ...
3
votes
1answer
303 views

How to achieve animated glow

I am trying to achieve something I've seen numerous times, but I don't know where to start from. I've come across numerous old effects, which I can't recreate. The said effects are the glow animations ...
3
votes
1answer
184 views

What is the maximum number of shaders I can have in OpenGL 4?

What is the maximum limit of shaders I can have on the GPU? With 1000 different objects, I might have 1000 * 5 shaders (vertex, tcs, tes, geo, frag) on the GPU at a time. Though only one will be ...
3
votes
1answer
724 views

Multiple Textures in Shader?

I have this (pseudo) code: unsigned int TextureLoc = glGetUniformLocation(programID, "objectTexture"); for(int i = 0; i < object->texturesCount; i++) { glActivateTexture(GL_TEXTURE0); ...
3
votes
1answer
466 views

Rendering different materials in a voxel terrain

Each voxel datapoint in my terrain model is made up of two properties: density and material type. Each is stored as an unsigned integer value (but the density is interpreted as a decimal value ...
3
votes
2answers
1k views

Learning OpenGL GLSL - VAO buffer problems?

I've just started digging through OpenGL and GLSL, and now stumbled on something I can't get my head around this one!? I've stepped back to loading a simple cube and using a simple shader on it, but ...
3
votes
2answers
140 views

How to implement color changing fragment shader?

I have a background of a given size and filled with a given color. I want to change it with an animation effect, starting from the center and spread out until it extends the whole background. The new ...
3
votes
1answer
209 views

How can I determine the extreme color values in a texture?

I am looking for a way to determine the most extreme color values for all of the texels in a texture. So for a texture consisting only of black and white texels, the extreme values should be (0,0,0) ...
3
votes
1answer
685 views

Issue with interpolation on a burn shader (lerp and smoothstep)

I'm trying to create a simple burn shader. See here for more info on the method I'm using. However, I don't get why replacing the smoothstep with a lerp results in completely different results. Am I ...