Tag Info

New answers tagged

1

That would be because the GPU is optimized for massive parallel execution of the same program with multiple data, and accessing a non-constant index of an array in a shader (especially the fragment shader) does not count as "the same program" in GPU terms. If you have seven materials, how about passing an array of seven floats, each defining a weight for ...


0

Because your work would be done on the CPU, and not the GPU your framerates are unaffected. The more calculations you do in the shader, the more the GPU has to work. Some calculations are necessary such as applying transformations, since they can't be done at compile-time, but rather in run-time. If anything, I recommend avoiding the declaration of const ...


0

I checked another simple project where passing array to uniform works and checked what CodeXL is showing. And again only first value was ok. So I believe that this is some kind of bug/limited functionality. Maybe name of uniform which CodeXL shows (kernel[0]) is a hint that only first value is presented.


0

Try using glUniform2fv on threshold.


7

My first thought is the += to an uninitialized outColor. I think it'd be better to do the math on a temporary variable and put it in outColor once it's done.


0

So it turns out that, the solution is to use a TBO for storing the lookup table. The uniform buffer could be faster, but because the uniform buffer can not hold the entire lookup table the added computational cost of the necessary bitwise operations would diminish this advantage. Therefor to my knowledge this would be the fastest solution.


0

You can use two small tables of 16 entries to lookup 4 bits at a time const int table1[16] = { 0x0, 0x2, 0x0, 0x2, 0x1, 0x3, 0x1, 0x3, 0x0, ... }; const int table2[16] = { 0x0 0x0 0x2 0x2 0x0 0x0 0x2 0x2 0x1 ... }; x = table1[gl_VertexID & 0xf] << 8; y = ...


5

You can create two shaders and set the correct one from the application. Use a define to turn on/off features. GLSL both sides of the if-clause is executed Partially true. One core execute a lot of (64) with SIMD paradigms. Think about them as a vector of data and one instruction pointer (IP). In program with a branch the core can't use two IP for ...


2

You can use a Transform Feedback Buffer to output from your vertex shader, your question is not very specific though so I can't be sure if this is truly what you want to do.


1

I'm not very good with English, let's hope that the variable names are clear. float3 half_vector = normalize( eye_dir + light_dir ); float n_dot_l = saturate( dot( normal, light_dir ) ); float n_dot_h = saturate(dot( normal, half_vector ); float h_dot_l = saturate(dot( half_vector, light_dir )); // Amount of reflected energy based on angle // usually is [f0 ...


2

Specifically: blurShadowMap() uses fbo2 which has only one R32F texture set as "color". I want to know if this is necessary or that they are only attaching and blurring the color buffer because they are storing their depth values in it. Correct; depth is encoded into a "color" and stored in the color buffer In other words, I would like to know if ...


0

I use XNA, so even looking at GL code makes my head hurt. On top of that, your variable names do not indicate anything obvious. How does "aVP" represent a worldCoordinate? Anyway... I can't tell if you've done this in the posted code, or elsewhere: Since you are inside the skybox, all of its triangles are counter-clockwise from the camera's perspective so ...


2

Normalizing would simply divide those combined values by their magnitude. You just need to find the mean, of which you can add each individual component and thereafter divide by the total number of overlapping vertices. (v.t + v1.t + v2.t) / 3


4

The return value is computed as x*(1−a)+y*a. in other words if a is -1 then the result will be 2*x-y


0

Try to declare your float variables outside of the loop. It doesn't make sense to declare them in each run of the loop. Let me know, how many frames you could gain. Regards, M



Top 50 recent answers are included