Giter Site home page Giter Site logo

Comments (4)

jonathanhogg avatar jonathanhogg commented on May 29, 2024

Have been thinking about how to do this off-and-on and wondering about the following:

  • Reflect the view ray off the surface normal to get a (normalised) reflection direction
  • Calculate closest point on this ray to the position of the light: dot product of fragment-to-light vector and reflection direction, multiplied by reflection direction, plus fragment position
  • Offset light along vector towards closest point by a maximum of the light radius
  • Attenuate light by some amount based on offset (not sure what the calculation for this should be)

This ought to give more believable specular reflections while not being too complicated to calculate.

from flitter.

jonathanhogg avatar jonathanhogg commented on May 29, 2024

A second possibility is just offsetting the light by its radius towards the fragment. Might be worth trying this first to see what that looks like…

from flitter.

jonathanhogg avatar jonathanhogg commented on May 29, 2024

A second possibility is just offsetting the light by its radius towards the fragment. Might be worth trying this first to see what that looks like…

OK, yeah, tried that. It doesn't work.

from flitter.

jonathanhogg avatar jonathanhogg commented on May 29, 2024

The winning solution was the second comment above: offsetting the point towards the reflection ray by up to radius. I am not attenuating the light at all, however, as I realised this doesn't make any sense. It would affect all light falling on objects from point lights and mess up the diffuse calculations as well. At the moment this means that reflections of ball lights off of shiny surfaces are a little crisp – I can revisit perhaps in the future.

from flitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.