Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Lighting with shaders

$
0
0

@aceslowman wrote:

I've made a simple displacement map shader, and now I'm looking to shade it. From what I can tell, I can't use the typical ofEasyCam and ofLight combination without actually calculating the shading myself.

I would imagine I can at least use the position of the ofLight, as well as the position of the ofEasyCam, and calculate my lighting using these two. This comes with a few new questions for me though:

  1. Should I be writing the lighting calculations in my displacement map shader? Or should I nest them? I've never tried nesting shaders so forgive me if that is misinformed.

    cam.begin();

    shader_shading.begin();
        shader_displacement.begin();
            shader_displacement.setUniformTexture("displacementMap", video.getTexture(), 1);
            plane_displacement.draw();
        shader_displacement.end();
    shader_shading.end();

    cam.end();
  1. How do I retrieve the relevant normals and positions from the camera and from the light?

I've been reading this openGL shading tutorial, but between GLM and the differences in built-in uniform variables, I've become overwhelmed trying to figure out what is right in oF. http://www.opengl-tutorial.org/beginners-tutorials/tutorial-8-basic-shading/

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles