Hi guys! How is everyone? Can you help me do a basic shader that uses ofLight?
I’m new to openGL. I’ve been playing with post-processing effects (with ofGLProgrammableRenderer and version 150, basically doing 2D fragment shaders) and now I’m starting with 3D vertex shaders. I’ve noticed that ofLight doesn’t work natively with ofGLProgrammableRenderer, so, for now, I’m was thinking of not using that (Stick with version 120).
That being said, I still want to work with lights, but at this point I don’t want to deal with all the crazy shader maths (create my own, that is), so I was thinking I could use ofLights and focus on the vertex shader and object transformations.
The problem is, I don’t know how to use ofLight in a custom shader. I’ve been searching on the web, but all I could find was more advanced stuff. At this point, I can only pass the vertices and colors.
I hope I was clear enough.
Hi hubris, you helped me out earlier today and just now Ive independently found this post via a Google search! Did you ever figure this out? I’m running into the same problem now where I’m not sure if I should use ofGLProgrammableRenderer, or stick with the native one, given I’m not very experienced with lighting in OpenGL. That said, I’d like to learn if you found a clear path!
Did you found a way to do this? Been looking for a easy way to work with lights too. I think in the end you would still need to deal with all the math in your shader but at least you have a easy way to add/remove light on the fly and get their data like position color, etc…
First of all, sorry @jag, I left this tab open but completely forgot to answer you.
You can either go with the new programmable render in the master version of OF or DIY. I decided to do it myself, because I had the time to learn and wanted to have more control. Messing around with shaders is fun!
Any book about GLSL can speed you up. There’s also a lot of stuff in the internet.
I know OF now has a nice shader to deal with lights and materials, but I haven’t had the time to check it in depth. The new areaLightExample may be a good way in to understand how it works. Also check the ofMaterial class. But if you want to know more, maybe ask the big man himself… @arturo !
Great, thanks for the reply hubris. I would love to DIY but Im on pretty strict time budget, working on a project for school. I’m trying to balance learning with producing results, it’s tough. But I will take your advice and check out areaLightExample, thanks man!