stackgl / shader-school

:mortar_board: A workshopper for GLSL shaders and graphics programming
Other
4.28k stars 254 forks source link

Course Review #159

Open krzychukula opened 8 years ago

krzychukula commented 8 years ago

Exercise 4

There was no info about "&&" in the previous lessons.

I would start with information that you can use && like in JS (preferably with short code sample)

for example: a < b == lessThan(a, b)

In my opinion shuld be extended with something like:

for example: a < b == lessThan(a, b) == bvec(bool, bool)

to make sure it's obvious what is the type of the result.

Then in "boolean vectors" I would appreciate if it would be explained when and why should I use all/any functions.

Something like: "Instead of writing p.x && p.y && p.z on bvec3 you can use handy function: all(p) that will do the same thing.

I may add feedback to other lessons here but feel free to close it earlier.

Exercise 5

float x = 0.0;
for(int i=0; i<100; ++i) {
  x += i;   //Executes 100 times
}

Actually I had to change it to i<=100 to make it work and I wasn't something I was expecting:

float x = 0.0;
for(int i=0; i<=100; ++i) {
  x += i;   //Executes 100 times
}

Exercise 6

It would be great to have a reminder somewhere that I can't use n in for(int i = 0; i < N; i++) and I have to use static number for(int i = 0; i < 16; i++) https://github.com/stackgl/shader-school/issues/104 helped a lot :)

Exercise 7

Something about length or distance or just link to the documentation would help a lot.

Exercise 8

frag-2 There is no info which color to set if fragments is not discarded, but the only one that worked was: gl_FragColor = vec4(1,1,1,1);

Exercise 10

I had no idea how to solve it. I would say this one is really to hard, even looking at the result it's not clear what really happens here or why multiplication is the same as rotation... Really confusing.

  //this matrix is really magical for me, how am I supposed to know
  //that I have to create rotation matrix and even then
  //how am I supposed to figure out the order of cos and sin not to mention
  //the signs...
  mat2 rot = mat2(c, s, -s, c);

Exercise 13 geom-2

  1. The test passes without any changes - that's probably a bug :)
  2. Is there anywhere mentioned what different position in matrix do? I don't think so, yet user has to know magical positions in the matrix to do the translation.
  3. Translate function - I can't see how this code sample with vector is supposed to be helpful? It adds up to the confusion in my opinion.
  4. At the end I have noticed the link to wikipedia. This one was helpful, I just didn't notice it at first...

    Exercise 14 geom-3

Link to https://en.wikipedia.org/wiki/Scaling_(geometry) would be helpful

Exercise 15 geom-4

No idea where where to get this:

n = normalize(n);
  return mat4(1.0-2.0*n.x*n.x,    -2.0*n.y*n.x,    -2.0*n.z*n.x, 0,
                 -2.0*n.y*n.x, 1.0-2.0*n.y*n.y,    -2.0*n.z*n.y, 0, 
                 -2.0*n.z*n.x,    -2.0*n.y*n.z, 1.0-2.0*n.z*n.z, 0,
                            0,               0,               0, 1);

If it's obvious easy to find then maybe there should be some required reding before?

Light 1

"That is, there is some parameter called kA which just determines the color of each fragment." ambient parameter is supposed to determine color.

Light 2

  1. No idea what lamber weight code is for.
  2. Reflected light code - useful
  3. Parallel distance - no idea how to use All in all fragment shader was pretty easy but I had no idea how to create fragNormal and that I needed worldNormal not to menion how to create it.

    Light 3

Just to hard for me :(

javbit commented 8 years ago

NPR 1

The instructions provided don't lead to the target shader.

Following the instructions leads to the answer found here; however, the target shader on the left does not match. It seems that on the left the light source moves with the cursor, but on the right the shader obtained by following the exercise directions has the light source fixed. Visually, the "edges" formed between two bands looks like it stays in the same position on the dragon model.

taseenb commented 8 years ago

I really like the course. Congratulations to the authors!! I'm not sure what the goal and the target audience are, so ignore my comment if it's inappropriate.

Maybe the course could be even greater if you added a couple of hints or exercises with the most common mathematical solutions used in shaders (that in most cases appear to be taken for granted). At least those a bit more advanced than the absolute basics.

For example, expecting a beginner to know about rotation matrices (i guess that's a quaternion?) in the first vertex shader exercise (ironically called "The Basics" :) is a bit ambitious. That was impossible for me and i suppose it could be the same for many computer graphics beginners.

But that was great for me to learn (watching the answer). At the end of the day, i think that maybe 90% of CG problems are solved with a limited combination of trigonometry functions. Personally, i'd really like to see those strategies (and others) explicitly exposed in a course on shaders.

fczuardi commented 7 years ago

Exercise 15 geom-4 was a very hard jump for me too, and I gave up and cheated :( Maybe to follow the pattern of the 2 previous lessons, this one could also include a wikipedia article with hints / explanation / answer, maybe this one: https://en.wikipedia.org/wiki/Transformation_matrix (https://en.wikipedia.org/wiki/Transformation_matrix#Reflection_2 )

ohookins commented 6 years ago

I'm only up to exercise 11 now, but I'll agree with @krzychukula on exercise 10. I ended up making all of the trigonometry calculations manually. Is there really a rot() function??? Anyway, the materials don't really guide towards the desired solution.

Exercise 12 I've gotten working by just making another varying vec for color and then assigning it in both shaders. Basically 3 lines of additional code - although my initial solutions involved actual calculation of the vertices and setting appropriate formulas for calculating the colour at any given point. Neither of these seems correct, although the first one does pass.

ohookins commented 6 years ago

To further clarify on what I pointed out above, from Exercise 12:

Hint : The triangles' 3 corners are the only vertices used, so you (a) need to figure out their coordinates, and (b) construct an expression that colors each vertex correctly.

The solution requires neither of these to be done, as long as you have the color attribute, fragColor varying and then set that automatically interpolated value in the fragment shader. No calculation of vertices or colours is required since it is done automatically.

61315 commented 2 years ago

I find the following articles helpful for the exercise 15 geom-4.

https://math.stackexchange.com/questions/2235997/reflecting-ray-on-triangle-in-3d-space https://en.wikipedia.org/wiki/Vector_projection

nUDxp