Home Technical Talk

GLSL Rim Highlighting

I've given myself a massive headache over the past few months with trying to get GLSL to work and I'm finally ready to ask for help.

I am using vertex brightness to darken the models based on what room they are in, so each vertex is darkened to room[x].light if model is within boundaries of room[x].

The goal is to apply the original, full bright texture to the outline of the model.

What I want are fixed shader programs, not dynamic light or anything fancy, so far I can deduce that I need edge detection for finding the edges of the models and then reading the original texture's fragment data and writing over the top of the darkened fragment data.

This is the effect I'm trying to achieve:
v6okzn.jpg

Here's a diagram:
lighting_shader.jpg

The rendering path I'm trying to get is:
  • Render 3D model darkened to light level of room
  • Find direction of nearest light source
  • If light source is not in-front
  • Start shader program[light_direction] to highlight the model rim with original, undarkened texture

Ideally I want this to be 3 shader programs, one for behind, one for the left, one for the right so I can select which one to use out of 4 states, no program, left program, right program, behind program.

Thanks if anyone can help, I'm pulling my hair out over this one as the massive lack of GLSL tutorials in the world has finally stunted my project's development.

Edit:

I've had a second go at this and at the moment I have this based on vertex normals:
lighting_test.png

Just ignore that poser on the far right!

Replies

  • Drew++
    Offline / Send Message
    Drew++ polycounter lvl 14
    Do you have access to normals and light positions in your vertex program? There's some ideas I have but they are more of a dynamic style. You can still do lighting and whatnot in the vertex program and pass that off as color, but I'm not sure if you want to do that.

    But due to the low polygon count of the models using interpolated normals might not be the best idea for calculating rim terms...
  • xilefian
    Yes I do however I do not want to use the light positions as I just want fixed lights that are offset to the model mesh along the camera plane directions, something that's proving very difficult.
Sign In or Register to comment.