Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: how to create light source(like a bulb) that can move around in a window  (Read 2047 times)

0 Members and 1 Guest are viewing this topic.

theakhilarya

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Hi! I am new to SMFL and learning. I have created a map till now on a black background. No i wish a bulb like light source to move around and create shadows from the object.

So how do i create light source?  i read some forum and know about blender and texture, but not able to understand it very much. is their simple way or easy tutorial page where i can learn.

Kanoha

  • Newbie
  • *
  • Posts: 19
    • View Profile
    • Email
Re: how to create light source(like a bulb) that can move around in a window
« Reply #1 on: November 29, 2018, 03:25:38 pm »
Hi, unfortunatly, in SFML there isn't any built-in classes you can use for lighting, so you should probably use GLSL shaders. I don't know any tutorials right now, but you should find some if you sesrch a bit. I believe SFML only supports shaders up to the version 1.2 of GLSL (#version 120). Also, it is kind of though to implement shadows without a proper understanding on how lightmaps and shadowmaps work, so inform yourself well.

Alternatively, you can use the Let There Be Light 2 (LTBL2) libraby for SFML that is easy to use and really powerful for handling lighting systems with shadow casting. I hope that helped!

Sent from my SM-G950F using Tapatalk


ZeroZ30o

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: how to create light source(like a bulb) that can move around in a window
« Reply #2 on: November 29, 2018, 10:01:16 pm »
You need to do it yourself with custom vertex arrays and shaders.

Look more into 2d shadows



The basic idea is you draw the light (white zone) first, and then draw the black shadows on top.
« Last Edit: November 30, 2018, 12:28:57 pm by ZeroZ30o »

 

anything