a computer program that runs on graphics hardware and provides a high degree of control over how scenes are rendered
4
votes
3answers
3k views
What happened to .fx files in D3D11?
It seems they completely ruined .fx file loading / parsing in D3D11.
In D3D9, loading an entire effect file was D3DXCreateEffectFromFile( .. ), and you got a ID3DXEffect9, which had great methods ...
4
votes
1answer
220 views
Where to store shaders
I have an OpenGL renderer which has a Scene member variable. The Scene object can contain N SceneObjects. I use these SceneObjects for storing the vertex position and any transforms. My question is, ...
4
votes
2answers
415 views
Programatically replace color gradient on sprite
Say I have the following image:
I want to tint the yellow parts on this sprites shoulder/arms by a random color. In other questions on this site, they suggest using a chroma key and replacing the ...
4
votes
1answer
546 views
Shader effect similar to Metro 2033 gasmask
I was thinking about effects in games the other day and I was reminded of the Gasmask effect from Metro 2033. Once you put the gasmask on it blurred a bit in the corners and could ice up and even get ...
4
votes
1answer
382 views
Bitwise operators in DX9 ps_2_0 shader
I've got the following code in a shader:
// v & y are both uints
nPixel = v;
nPixel << 8;
nPixel |= y;
and this gives me the following error in compilation:
shader.fx(80,10): error ...
4
votes
1answer
1k 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
511 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
2answers
824 views
Should the modelview and projection matrices be calculated in the shader or on the CPU?
At minimum I would have a camera with rotation and world position; projections parameters such as angle of view and perspective vs. orthographic; and meshes with scale, angle, and world position.
...
4
votes
1answer
442 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
987 views
How to invert background pixel's color
I'm writing a game and map editor using Java and jMonkeyEngine. In the map editor, I've got a brush done by wireframed sphere. My problem is: I want to make it visible everywhere, so I want to invert ...
4
votes
3answers
1k views
Loading and using an HLSL shader?
I've been looking everywhere and all I can find are tutorials on writing the shaders. None of them showed me how to incorporate them into my scene.
So essentially:
Given an hlsl shader, if I were to ...
4
votes
3answers
4k views
shader tutorial for unity
I would like to start developing my own shaders within unity.
For starters I would like to do a screen spaced blur.
Are there any good tutorials to learn shader development besides the official ...
4
votes
1answer
137 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
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
304 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
674 views
GLSL shader without a vertex array
Ok so I have a idea for a neat GPU driven curve renderer, and I realised that the vertex shader can be hardwired to generate points of the curve segment (to be rendered as a line strip) without ...
4
votes
1answer
717 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
380 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
2answers
798 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
147 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
2answers
266 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
1answer
754 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
922 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
2answers
216 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
394 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
2answers
645 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
2answers
339 views
Detect Mip mapping level in the shader?
Is there a way to do this in pixel shader 2.0/3.0? I've got on or off transparency so when the mipmapping level is different the transparency can take up too much of the texture and make it ...
4
votes
1answer
252 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
401 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
0answers
178 views
+50
Optimizing performance of a heavy fragment shader
I need help optimizing the following set of shaders:
Vertex:
precision mediump float;
uniform vec2 rubyTextureSize;
attribute vec4 vPosition;
attribute vec2 a_TexCoordinate;
varying vec2 tc;
...
4
votes
0answers
114 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 ...
3
votes
3answers
876 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
3k 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
444 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
75 views
What is a Fragment Pipe?
I remember someone saying "24 fragment pipes on nVidia 7800" in a presentation.
Am I correct in saying that a fragment is the data that can generate a pixel in the frame buffer? Or are fragments the ...
3
votes
1answer
95 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
167 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
1k 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
1answer
464 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 ...
3
votes
2answers
4k 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
1answer
89 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
1answer
131 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 ...
3
votes
2answers
139 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
273 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
277 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
2answers
2k 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 ...
3
votes
1answer
697 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 ...
3
votes
1answer
157 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
164 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
2answers
172 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:
...
