Tag Info

Hot answers tagged

8

Vertex and fragment shaders run concurrently, not sequentially, and the GPU automatically load-balances between them, so it's not possible to meaningfully assign specific timings like 7 ms for one and 1 ms for the other. However, you can do a simple experiment to measure where the bottleneck lies: set the view-projection matrix to all zeros for all your ...


5

The task is actually highly parallelisable on the GPU. Here is an algorithm that should work, assuming e.g. a 1024×1024 source texture ST. create a 256×256 render target, RT1 run a fragment shader that reads from ST and writes to RT1 and does the following: for each fragment in the render target get the (x,y) fragment coordinates sample 16 pixels from ...


5

You tell the GPU how to produce triangles from the input data. You specify vertex buffers containing all your vertex data, you also specify a primitive topology (lines, triangles, et cetera) and an optional index buffer. The topology tells the GPU how many and what pattern to take the indices in (for example, in sets of three for a triangle list). The ...


3

Another way to do this is to make a texture that maps each RGB to a colour on the palette, an image like this (from the NES colours): Then in a post processing shader you can the RGB colour from your regular image in a way like this: uniform sampler2d paletteMapping; vec3 mapColor( vec3 realColor ) { vec3 mappedColors = floor( realColor * 16 ); ...


3

This effect can be achieved by drawing the blood in two layers. The bottom layer is the black border and the top layer is the red blood. Note that actual "layers" are not required, as long as the drops can draw in two phases, all black, followed by all red. Each droplet draws its shape as a black sprite. Then after all black shapes are drawn, they each draw ...


2

Texture Coordinates are usually expressed in the range between [0,1]. Each (textured) vertex will have these coordinates. These coordinates are mapped to texels in the actual texture. [0,0] is the top left corner, [1,1] the bottom-right corner. When the coordinates are in a range that is multiple of 1, the texture will repeat itself. For example, for a ...


2

mental ray is a stand-alone 3D renderer. It's primarily application domain is film and TV. As a renderer, it supports a concept of "shaders" as functions that compute lighting effects. However, these are not mechanically the same shaders that you'd use in OpenGL or D3D. They are built in their own language, tied to the mental ray lighting and renderer ...


2

They are not equivalent. In the GLSL shader you use the same texture coordinate for your diffuse and normal map (gl_TexCoord[0]). In the CG shader you use separate ones (TEXCOORD0 and TEXCOORD1, which is presumably not set).


1

So the short answer is to turn on the debug layer. Thanks to @Nathan Reed for pointing that out. I tested it out and verified that it does indeed detect when shader signatures are incompatible. I also verified that new SV inputs to a shader stage must come last in the list of inputs.


1

If you look closer - it is not border of(each) blood drops - it is a border of all blood-red area. And I think the border was added actually after rendering blood to look cartoonish. This could be post processing effect just as well as shader. It should not be difficult to implement edge-detection algorithm (plus you know the color you are looking for).


1

To do this, you must sample your alpha texture in the depth buffer creation fragment shader, which is ShadowCasterFP in your code. When you sampled the texture, you should discard pixels below a certain alpha level, or do a clip: if( color.a<0.1 ) discard; clip( color.a<0.1?-1:1 ); //where color is your sampled texture at the current fragment ...


1

After you compile and link the shader program you should validate and check the compile and link status'. Anyway, you don't even seem to be compiling the shader sources. Do that and make the checks and it should work. The Compile() function should look more like this: public void Compile() { programId = GL.CreateProgram(); for (int i = 0; i < ...



Only top voted, non community-wiki answers of a minimum length are eligible