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
1answer
453 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
3answers
2k 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
371 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
2answers
226 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
519 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
630 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
884 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
1answer
261 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
185 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
213 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
835 views

ConsumeStructuredBuffer, what am I doing wrong?

I'm trying to implement the 3rd exercise in chapter 12 of Introduction to 3D Game Programming with DirectX 11, that is: Implement a Compute Shader to calculate the length of 64 vectors. Previous ...
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
990 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
793 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
266 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
521 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
297 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
500 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
782 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
502 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 ...
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
5k 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
877 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
224 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
218 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
449 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
382 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
978 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
1answer
189 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 ...
3
votes
1answer
363 views

Matrix in constant buffer on the GPU contains NaNs but not on the CPU

I've got a shader with the following constant buffer: cbuffer ShaderParameters { matrix inverseViewProjectionMatrix; float4 cameraPosition; }; When using Visual Studio 2012's graphic ...
3
votes
1answer
2k views

GLSL if-else statement unexpected behaviour

This question is related to this other one I asked a few days ago. Because I have finally get to the bottom of the issue, I have rather preferred to open a new question with a more detailed ...
3
votes
2answers
6k views

Can't update DirectX11 shader constant buffer [closed]

Alright, I'm currently making the transition from DirectX 10 to DirectX 11 (with very little help from the MSDN documention) and recently ran into a snag with updating a shader's constant buffer. My ...
3
votes
2answers
59 views

Local shape color blending

I am trying to implement this in Unity 4 Pro. But I am stuck in the blending part. I don't understand how you could blend multiples textures/colors using multiples volumes on an object. How could you ...
3
votes
1answer
192 views

Using a switch command in one shader vs multiple shaders

If you have multiple shaders, could you instead of switching between shaders all the time just have one shader with a switch and each case will send you along to another shader function which you ...
3
votes
1answer
115 views

Do I need Texture Units when NOT using shaders?

Does calling glActiveTexture() even make sense when not using shaders? I only have to switch the textures before drawing a buffer with glBindTexture(), right?
3
votes
2answers
180 views

Shaders and Performance

I'm coding my first Shader in my little game engine, and I have some questions about it's performance and common approaches. Is the Shader code processed by the video card instead of the PC ...
3
votes
1answer
479 views

Is the series of books “GPU Gems” still good for a modern OpenGL 3.0+ approach?

I noticed that this series of free books from Nvidia is really popular and well know in the devs world, the problem is that is simply old; you would recommend to read those 3 books to a developer that ...
3
votes
1answer
402 views

Complex shading using one single (small) texture

Recently I stumbled upon a demo reel in UDK about how one can attain beautiful results using just one (rather tiny) texture that's being sent to the shader pipeline. The famous link is this one. ...
3
votes
1answer
3k views

Simple GLSL example to render a 2d textured quad?

I would really love to add shader support in my game , although i can't seem to find a SIMPLE example on how to setup opengl for using shaders. So i would like to ask : Does anyone knows if there are ...
3
votes
1answer
59 views

Why does my PixelShader ignore color but respond to alpha changes?

I started teaching myself some DirectX a short time ago and found something I'm confused about. For some reason, I can only get the color of the model I'm drawing to vary between black and white, ...
3
votes
1answer
117 views

When are HLSL literals taken as a float and integer?

float2 uv = float2(fX % 1, fY % 1) * 1/16; In the above example 1/16 is treated as a float, multiplying the float2 by 0.0625, but in: float2 uv = float2(fX % 1, fY % 1) * 1/16 + float2(1/16,0); ...
3
votes
2answers
142 views

Opengl shader questions

I'm currently building a shader that takes a 2D texture sampler and uses UV coordinates to map it. This works fine for all textured objects. However, I'm having a bit of a problem as I'm trying to ...
3
votes
1answer
356 views

How do I render a filled and stroked path using OpenGL?

I want to render a 2-dimensional geometric path consisting of Bézier curves and straight lines. Paths can be concave. What is the most efficient way to draw this using modern OpenGL? Can I do this ...
3
votes
1answer
186 views

Why are some objects not rendering properly?

Here's a button I exported from Blender into a .x format: Now here it is in the game with BasicEffect applied to everything: And now with my custom shader: And there's the problem. While the ...
3
votes
1answer
315 views

How do I make a more or less realistic water surface?

I want to make a similar water surface like in this picture: I need the water surface in the same view than in the picture. Is it possible to work without shaders? I want to develop a little game ...
3
votes
2answers
239 views

Which will be faster? Switching shaders or ignore that some cases don't need full code?

I have two types of 2d objects: In first case (for about 70% of objects), I need that code in the shader: float2 texCoord = input.TexCoord + textureCoord.xy But in the second case I have to use: ...
3
votes
1answer
566 views

Spherical fractal noise generator in shader

I have a growing sphere in space, and I thought of having a procedural generated texture over it. Since it is growing, I thought a fractal would be a great choice, because more details would be ...
3
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, ...