Mtg 20/23: Mon-25-Nov-2024

Outline for Today

Reflection Mapping and Working with Framebuffers

Administration

Today

For Next Meeting

Wiki

Link to the UR Courses wiki page for this meeting

Media

Transcript

Audio Transcript

  • anyway.
  • Welcome to
  • so we're At meeting planning today. I
  • so there's a choice in your courses that's available now
  • until the end of the day.
  • I don't know why I can vote on this. Sometimes it tells me for
  • other activities that says I can't. I'm not allowed to vote
  • or give my input,
  • but here I can. I'm just going to turn off the pictures to like
  • and look at the responses so far. Do
  • Is everyone here voted.
  • So we have pointed responses and 240 to keep the due date today,
  • five for Wednesday, Five for Friday, and eight for the
  • following Friday. I
  • so keep an eye on it that it won't be due today.
  • So I asked you a question about colors and
  • reflection.
  • Now let's take a look at this.
  • What's going on in this piece of code?
  • Anyone? Take a look at it?
  • Anyone starting to feel a seizure coming on or I
  • I Don't need to make light
  • of that. Let's do i
  • Does that make it easier to
  • interpret What's going On. I
  • so what do we have? What are you looking at? What's In the scene?
  • Yes, Q, I,
  • so how do we decide the colors that we see on the Cube? I
  • So this is a COVID reflection map. If
  • QC and
  • so the cube we see is reflecting The environment from a cube we
  • don't see the
  • Okay, so the vertex shader, we're getting the position by
  • multiplying the vertex after you get from our buffer by the ball
  • of U and The projection matrix, and then we're getting the eye
  • position.
  • It's not the eye position, it's the position of the vertex in
  • eye coordinates,
  • and then we are transforming the normal and
  • by the normal matrix, which is the matrix that we need to
  • transform normals And object space to normals in our eye
  • space
  • and and then
  • we do
  • make A call to the GL SL function reflect. So that's
  • going to give us the information of where, where the reflection
  • is,
  • where, from? Where are we going to access the texture?
  • So there's no i No no colors assigned. Here, no vertex colors
  • assigned. We're just passing
  • this
  • vec three for R for reflection, and in the fragment shader,
  • we take the reflection R as input and we output the fragment
  • color. So we're going to use a uniform sampler cube, so we have
  • a cube map,
  • and We're determining the fragment color based on the
  • sample And
  • that's returned by the texture function, GLSL, if
  • So how do we specify the texture map to
  • I Don't know that
  • picture helps. Does it help or harm both? Okay,
  • so anyway, that's that's the basic shader, the shaders that
  • are doing reflection maps. So all everything we see on screen
  • is the reflection of the environment map.
  • So
  • here we're defining the
  • red, green, blue, cyan, gent and yellow as a union terrain and
  • so here's the configured texture map. So we're going to create a
  • texture, and then we're binding texture, as we're using a cube
  • map. So
  • create the texture and bind it as a cube map here, and then we
  • specify the images that Go on
  • each side.
  • So we specify the positive x direction,
  • so positive x gets red, negative x gets green, positive y gets
  • blue, negative y gets cyan, positive z is yellow and
  • Negative z Is magenta i
  • So does that picture make more sense? Now? Let's see. So an
  • agenda. I
  • so here We
  • have Green, Yellow and Blue. We
  • so We're seeing we're this
  • corner,
  • In the reflection. So here's a question. It's a little design
  • question, maybe, how do we make this code a little more
  • demonstrative of reflection mapping?
  • This is clear what's going on from looking at the screen and
  • the code and
  • who says it's crystal clear, the textbook author did A great job
  • creating this sample piece of code. I
  • It's okay. I
  • You don't have to You
  • anyway,
  • what's going on. Let's
  • let's do a few more rotations here and see what
  • so There seems to be an awful lot of magenta. I
  • so do you have any questions that that we can discuss before
  • we get To the point of how To improve the code? I
  • should we leave it here? Who thinks this might be a good I it
  • question for The final exam you
  • it. So I mentioned Terminator two already, but I forgot about
  • the abyss. Anyone seen the abyss?
  • Okay? That's a good movie to watch. Lots of interesting
  • special effects. I
  • So similar to Terminator two.
  • I, okay, I don't want to give any spoiler, in case you're
  • going to run out and download not download, but stream or Find
  • a copy of the Abyss to
  • to watch the
  • so the Ideas are reflecting the environment on to the surface
  • and
  • so we have
  • Our view position, a normal and the reflected vector and So
  • WebGL
  • tube has only Q maps to work,
  • so we're determining the
  • where the reflection reflective vector intersects the texture,
  • and then that's how we're determining the frame and color
  • and
  • so we compute reflection as two times n dot v n minus V
  • log. Largest magnitude component of r will determine the face of
  • the cube. The other two components give the texture of
  • coordinates.
  • So that gives a bit of explanation of how the colors
  • are chosen.
  • So we're putting together six different texture maps.
  • This is obviously so you Just use texture in GLSL.
  • So here's The example. Consider to rotate a cube inside a cube
  • that reflects the color of the walls. If
  • so this is a cube, as you may have guessed, but It's using
  • different values of alpha, so The colors of Alpha point five
  • and
  • so how Do we make sense of this? I
  • so that's these are The shaders,
  • fairly standard. And
  • Let's look at The colors and
  • so we have black, red Hill, green, blue agenda, Cyan and
  • white defined. I
  • So to enable to set up blending. So we're using Z buffer, so
  • you've enabled depth test, enable blend, and Then we're
  • doing source alpha One. Minus source alpha one
  • so do all sides look translucent And
  • does this appear like you think it Should? I?
  • Let's turn off in Service removal and
  • and there's No indication of whether the inserts rule is on
  • or off In the interface. That's an issue with sound code and
  • So here's a simple piece
  • of code that uses alpha so the
  • so GL position, again, geo position from the a position and
  • the vertex color from the attribute color, and pass, pass
  • those through to the fragment color In the fragment
  • shader. And you
  • so I've made yellow opaque and cyan opaque, and the Other ones
  • are translucent and
  • so You can see some I
  • So maybe that makes A little more sense. Do
  • I want to show you Another
  • one that's kind
  • of fun. I
  • does it look fun?
  • So here we're using two different texture maps, and
  • we're updating one from the other, and we're flipping back
  • and forth.
  • So this is
  • think of A game of Life. Maybe I
  • so if you can see that
  • this is the picking example that was mentioned earlier. So we can
  • render into an off screen buffer
  • and make it easier to read from that buffer the solid colors,
  • and then we can decide What's going to select. It.
  • Does that make sense? I
  • so here we're doing our laying. We're
  • and our fragment shader we have the
  • we have, first of all, the vertex color that's passed from
  • our vertex shader and
  • and we have the Other face colors, red, green, Blue,
  • yellow,
  • cyan and agenda.
  • So we're using uniform variable u color index.
  • So if we if it's set to zero, it's just going to pass the
  • fragment color to the shader. Otherwise, it's going to
  • the fragment color from the vertex computed by the vertex
  • shader. If it's set to other than zero, then we're going to
  • use the
  • I can explain that better so you color index is an index into the
  • seven to this seven color array. So the computed color is
  • position zero, then one through Seven are the primary colors. So
  • when you color the
  • me. So I'm not sure why the author has made the if statement
  • there. I
  • because we
  • can just use the in depth color New color index to access All
  • the seven Colors And
  • so here we have the List of your mouse down and
  • so We're going to
  • to bind a frame buffer. So we're going to draw the scene in
  • the frame buffer and then read the colors from it.
  • So here's the read pixels command to get the color and
  • So if red, so this is red is set and
  • I always prefer to use braces, so if I
  • if Red is on, if green is on, If
  • that doesn't seem like cyan. I
  • anyway, you can write this more clearly, but the idea is we can
  • draw a simpler version of the cube in the frame buffer read.
  • So then when we interact with the frame buffer, we can read
  • the solid color per face and return that so we know what's
  • been picked and we can perform the interaction we want to do
  • with that without having to deal with the complicated or the
  • complex fragment colors that Come out of the shader. Does
  • that make sense? I
  • any questions About the assignments I
  • any thoughts About that reflection now? I
  • should it be stopped here for today? I
  • thank you for today, see you on Wednesday.
  • Take care. Thank
  • Take care. Thank

Responses

What important concept or perspective did you encounter today?

  • The function of gl.blend
  • Today I learned more about how to map reflections. At first, I thought the program we saw in class was just rotating the outside of a cube while the inside remains at a fixed position. Though I do wonder if that's possible.
  • About Assignment 3 Extension and Quiz questions discussion
  • Blending
  • We looked at the code for reflecting the environment, transparency on a cube, and picking color.
  • went through reflectionmap code
  • Mapping
  • Reflection Map, how reflection maps are being used. Environment mapping, Playing with alpha values of the color in a normal rotating cube example.
  • environmental mapping, and a method of acquiring colors by rendering in a frame buffer
  • The concept of how reflection color is used in the cube involves computing the reflection vector in the vertex shader using the reflect function. In the fragment shader, the texture function samples the cube map texture based on this reflection vector to determine the reflected color.
  • Learn about environment mapping, check reflection map code

Was there anything today that was difficult to understand?

    Was there anything today about which you would like to know more?