Giter VIP home page Giter VIP logo

Comments (3)

discosultan avatar discosultan commented on May 24, 2024

Each light is essentially a quad. Origin is the anchor point which marks the (0; 0) point on that quad (in local space). Depending if you are operating in SpriteBatch's screen space (y-axis runs from top to bottom) origin (0; 0) represents the light quad's top left corner while (1; 1) represents the bottom right corner. The reason its normalized to [0..1] is so that if you change the scale of your light, you wouldn't need to change the origin: an origin (0.5; 0.5) would still mark the center of the light. I see a source of confusion here because SpriteBatch's origin is not normalized. Perhaps an anchor would be a better name...

When it comes to the setter, there is no automatic normalization being done: it is expected to be set in its normalized form. The reason values outside [0..1] range are allowed is that it might be desirable for some weird rotation scenarios, though such usage should be rather uncommon.

Usually, for PointLight and Spotlight the default values are sufficient.

(0.5; 0.5) marks the origin for point light (since it emanates from the quad's center):
Point light

(0.0; 0.5) marks the origin for spotlight:
Spotlight

Main usage for the property is when you use a TexturedLight with a custom texture where the light may emanate from whichever point on that texture (quad). For example, for the following texture you would set the origin to (0.5; 0.0):
Textured light

I hope that helps :) Let me know if anything is still unclear.

from penumbra.

InfiniteProductions avatar InfiniteProductions commented on May 24, 2024

Thanks, it's clearer now :).
I don't think there were any details about how default spotlight are made (not as crystal clear as here at least), so the confusion.
I suggest to add some words and rephrasing a bit maybe as from my point of view, origin or anchor is very close to UV coordinates inside the texture. Example(s) with some random textured light, with screen capture of paint program showing light point and origin value used in code may be very helpful.
(Also, what could be done with textured light if origin is not on any of the edges).

from penumbra.

discosultan avatar discosultan commented on May 24, 2024

origin or anchor is very close to UV coordinates inside the texture

UV coordinates are a good analogy. In case of using the same transform as SpriteBatch (penumbra.SpriteBatchTransformEnabled = true;), they match exactly. Otherwise it depends on the penumbra.Transform being used: if the world's y-coordinate runs from bottom to top, then that is also the case for Origin.

Also, what could be done with textured light if origin is not on any of the edges

I guess you would just need to try out different origins until you find the sweet spot.

from penumbra.

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.