Need advice on how to best use multiple light sources with sdl2 texture and opengl (example link included)

lets say I do this
http://www.ronfrazier.net/apparition/ (Multi-Light scene)
How do I get sdl2 to use it? Like I have to get sdl2 made with the same stuff? I don’t know the 3d terms. I will be stacking several layers of textures on top of each other to get a product texture. With overhead camera I want to put that texture on the floor and light it up with several lights. They share a context is that what you say? I have never needed help from this community like now. Can you toss a few bones? Am I even on the right track? Can I do this?

For rendering a 3D scene, you can open up a window with an OpenGL
context (SDL_WINDOW_OPENGL) and draw into it with OpenGL. Any kind of
interesting lighting effects will require you to learn how to use
GLSL, OpenGL’s shader language. To make your life easier or help with
complex scenes you can also use a high-level rendering engine. For my
game I used OpenSceneGraph which wraps OpenGL, but there are a lot of
other rendering engines out there.

Does any of this help? I’m not sure I understand the specifics of what
you are trying to do.–
Terry Welsh
http://www.reallyslick.com

I certainly don’t understand the specifics of what I want to do. I do know
that there would be no shading on a two-dimensional surface. I just need
the lights . I did link to an OpenGL code example that has lights on a
surface just like I want. It’s the one with the camera looks directly down
at the floor or maybe it’s directly sideways at a wall and there is a light
on that surface. Some people are saying its not worth using OpenGL to do a
light effect but there’s no other way to get that kind of quality than
going 3d on a 2d texture. It’s kind of like the blizzard game hearthstone
where they use 3d but its really used in a two-dimensional way with the
flat cards and the lighting effects on the flat part of the game board

I did not link that correctly at all it’s a different page on that
web-site.i wanted but you get the idea of what I’m talking about now
probably

Okay, I understand a little better. That link you included made me
think you wanted to do something completely 3D. I’m afraid I’m not the
best one to advise you on the 2D rendering portion of SDL since I
haven’t used it. However, it has multiple backends including OpenGL
with simple shaders because it’s a stinking fast way to render. I
still think shaders are a good option for your lighting effects, even
in 2D. They will also give you the flexibility to make things fancier
later on if you want to.

If you want to know more it would help to figure out the specifics of
what you want to do. Specific questions are a lot easier to answer.–
Terry Welsh
http://www.reallyslick.com

I did not link that correctly at all it’s a different page on that
web-site.i wanted but you get the idea of what I’m talking about now
probably

Yeah , I thought I was asking specific questions but I guess each of my
questions represented like a bunch of questions. Imagine there is a ring of
9 candles and a spot in the middle with all of the lights circles
intersect. I don’t want a bleached out blinding white spot in the middle. I
don’t so don’t want objects that have a light circle intersection not to be
lit like they should . At some point I’m going to have lightning bolts and
explosions and being a dark cave with torches & lanterns and all kinds of
cool stuff. I don’t want my cool lighting all the sudden look Dumpy

The SDL drawing api is fundamentally not appropriate for your task; it
doesn’t support shaders or lighting.

You’ll want to use either opengl directly, or look at a wrapper like
sdl_gpu.~
Doug.

On Wed, Mar 19, 2014 at 7:24 AM, R Manard wrote:

Yeah , I thought I was asking specific questions but I guess each of my
questions represented like a bunch of questions. Imagine there is a ring of
9 candles and a spot in the middle with all of the lights circles
intersect. I don’t want a bleached out blinding white spot in the middle. I
don’t so don’t want objects that have a light circle intersection not to be
lit like they should . At some point I’m going to have lightning bolts and
explosions and being a dark cave with torches & lanterns and all kinds of
cool stuff. I don’t want my cool lighting all the sudden look Dumpy


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

    sources with sdl2 texture and opengl (example link included)

Message-ID:

Content-Type: text/plain; charset=“utf-8”

The SDL drawing api is fundamentally not appropriate for your task; it
doesn’t support shaders or lighting.

You’ll want to use either opengl directly, or look at a wrapper like
sdl_gpu.

Actually, now that I have a bit of time to type it out, I think I know
how he can do it with the SDL2 api: it’s just that the performance
with shaders would be better.

At the end of the day, what I think that he wants can be implemented
in the form of rendering the scene as if everything was fully lit, and
THEN rendering a “shading map” (which in this case is really just a
texture the size of the window, with an alpha channel) on top. The
"shading map" (there’s probably a proper name for this) can be
implemented by the following “three piece” procedure:

  1. create a SECOND renderer the size of the window with render-to-texture
    enabled,

  2. create textures for that renderer that correspond to the lighting
    effects, with
    transparency representing dark & opacity representing light,

  3. clear the second renderer to the desired color & alpha,

  4. render the desired lighting effects to the appropriate positions,

  5. copy the resulting texture to CPU memory,

  6. “flip” the alpha channel to it’s complement: 0 to 255, 1 to 254, 8 to 247,
    246 to 9, etc.,

  7. load the now-edited texture to your “display” renderer,

  8. render your “full lighting” display scene,

  9. render your “shading map” over the top of the scene resulting from 8.

This basic concept can be taken in various other directions as well
(e.g. with transparency as “light” and skipping step 6, you’ve got a
fog engine; for a swords’n’sorcery game you might want a “darkness
map” that allows spells to increase the shadows between steps 6 and 7;
etc.). However for fancy stuff like colored lighting you’re back into
image-processing stuff, which means either shaders or doing step 9 in
CPU-space.

Remember that if the window size changes, then the size of BOTH
renderers has to change, not just one!> Date: Wed, 19 Mar 2014 12:46:10 +0800

From: Doug <douglas.linder at gmail.com>
To: SDL Development List
Subject: Re: [SDL] Need advice on how to best use multiple light

No need for a second renderer or copying to CPU memory, you can accomplish the same thing with much better performance and architecture if you just use a single render-texture.

Draw the scene as normal to the main screen, draw the lights with additive blending to the render target, and then draw the render target to the main screen with the modulate blendmode.On Mar 19, 2014, at 3:16 AM, Jared Maddox wrote:

Actually, now that I have a bit of time to type it out, I think I know
how he can do it with the SDL2 api: it’s just that the performance
with shaders would be better.
[?]


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

what? lol
"draw the lights with additive blending to the render target, and then draw
the render target to the main screen with the modulate blendmode."
I see

SDL_SetTextureBlendMode with

SDL_BLENDMODE_MOD as something I can put in it so maybe I get the last
part, maybe…

Is additive blending where I take the light map and the regular
texture both with half alpha and then put the result on the screen?On Wed, Mar 19, 2014 at 1:22 AM, Alex Szpakowski wrote:

No need for a second renderer or copying to CPU memory, you can accomplish
the same thing with much better performance and architecture if you just
use a single render-texture.

Draw the scene as normal to the main screen, draw the lights with additive
blending to the render target, and then draw the render target to the main
screen with the modulate blendmode.

On Mar 19, 2014, at 3:16 AM, Jared Maddox wrote:

Actually, now that I have a bit of time to type it out, I think I know
how he can do it with the SDL2 api: it’s just that the performance
with shaders would be better.
[…]


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org