Good points. Parts of the example was copied from another projects and I didn’t consider some of the settings. Pushed some changes. Thanks!
Thanks for the example @britzl.
I dont understand the mechanics at all and the example looks a little bit to complicated to explain
Maybe I have to dive much deeper in it. Never worked with the render and the materials in that way.
Your example works fine and I fooled around a bit to get into it
But do you understand the basic principle behind it? One image with everything fully lit. One image with a semi transparent black/grey (ambient light) with the areas around the lights transparent. Overlay the image with the lights on the normal one to compose the final image with everything dark except around the lights.
This effect is achieved through some renderscript and shader “magic” that might seem very hard to understand in the beginning. But playing around with different examples might help you understand.
Hi.
Sure, its kind of layering / masking.
I started a new project to reproduce it and dupilicated materials etc. but… you use a complete different render-script and an orthographic camera & Script (Helper).
Isnt it possible to “more simpify” the demo? Without any external scripts? Just to have the real bone basics for a better understanding? Maybe some comments or maybe with screenshots or whatever . including - or special - the render-script.
I think there arejust a few changes / additions to the standard-render-script.
Are really 3 materials needed? and a mesh (quad)?
what about the quad scripts (.vp and .fp)? which content?
How can I get this result:
front sprite should not be transparent
he should be black
How can I do it?
One solution could be to draw the background to one render target, the player to a second and the lava to a third render target. You render the player and the lava render targets onto the background and either draw as is from the player target or with rgb set to 0.0 depending on lava or not. And finally you apply the lights.
add some flicker to the light,
not all objects of light (selectively)
how to do it?
I don’t really understand your question. Could you please elaborate?
If you mean something like flickering light from e.g. fire, there is no problem - you have a game object with a sprite that has a light material, right? Then animate GO’s scale up and down relatively quick
I mean this piece of code:
function update(self) ... -- draw lights render_to_rt(self, self.light_rt, function(self) clear(AMBIENT_LIGHT, nil, nil) -- add some flicker to the light local constants = render.constant_buffer() constants.time = vmath.vector4(math.random(90, 100) / 100) render_to_world(self, { self.light_pred }, constants) end) end
Yes it adds some variation. Do you wish to disable it?
I would like to be able to disable it on some game objects.
for example, create new material light2.material, and it will not flicker
but I don’t know how I can correctly specify this new material in postprocess.render_script.
I would appreciate the help… thanks!
Looks like the simple lighting example no longer works, any ideas on what has changed to cause these errors?
ERROR:CRASH: CALL STACK:
# 0 pc 0x3e0a85bd SharedFileList _sigtramp+29
# 1 pc 0x10eba8 dmengine _ZN8dmRender4DrawEPNS_13RenderContextEPNS_9PredicateEPNS_19NamedConstantBufferE+392
# 2 pc 0x10e6e1 dmengine _ZN8dmRender14DrawRenderListEPNS_13RenderContextEPNS_9PredicateEPNS_19NamedConstantBufferE+2545
# 3 pc 0x1135dd dmengine _ZN8dmRender13ParseCommandsEPNS_13RenderContextEPNS_7CommandEj+733
# 4 pc 0x11807a dmengine _ZN8dmRender26UpdateRenderScriptInstanceEPNS_20RenderScriptInstanceEf+170
# 5 pc 0x4aff dmengine _ZN8dmEngine4StepEPNS_6EngineE+975
# 6 pc 0x7d946 dmengine _ZN10dmGraphicsL24OpenGLRunApplicationLoopEPvPFvS0_EPFiS0_E+38
# 7 pc 0x58f1 dmengine _ZN8dmEngine6LaunchEiPPcPFvPNS_6EngineEPvES6_S4_+177
# 8 pc 0x5d1f dmengine _Z11engine_mainiPPc+143
Strange, I don’t know that we’ve changed anything that should make it crash. I’ll take look.
I tested the example simple_lights and it worked for me on my mac, using 1.2.170.
What project did you run? What platform are you on?
Here isa partial error log; (includes system info)
Process: dmengine [8612]
Path: /Applications/Defold.app/Contents/MacOS/Defold
Identifier: com.defold.editor
Version: 2.0 (2.0)
Code Type: X86-64 (Native)
Parent Process: java [8590]
Responsible: Defold [8588]
User ID: 501
OS Version: Mac OS X 10.15
System Integrity Protection: enabled
Crashed Thread: 0 engine_main Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: EXC_I386_GPFLT
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [8612]
Thread 0 Crashed:: engine_main Dispatch queue: com.apple.main-thread
0 dmengine 0x000000010673db83 dmRender::Draw(dmRender::RenderContext*, dmRender::Predicate*, dmRender::NamedConstantBuffer*) + 355
1 dmengine 0x000000010673d6e1 dmRender::DrawRenderList(dmRender::RenderContext*, dmRender::Predicate*, dmRender::NamedConstantBuffer*) + 2545
2 dmengine 0x00000001067425dd dmRender::ParseCommands(dmRender::RenderContext*, dmRender::Command*, unsigned int) + 733
3 dmengine 0x000000010674707a dmRender::UpdateRenderScriptInstance(dmRender::RenderScriptInstance*, float) + 170
4 dmengine 0x0000000106633aff dmEngine::Step(dmEngine::Engine*) + 975
5 dmengine 0x00000001066ac946 dmGraphics::OpenGLRunApplicationLoop(void*, void (*)(void*), int (*)(void*)) + 38
6 dmengine 0x00000001066348f1 dmEngine::Launch(int, char**, void (*)(dmEngine::Engine*, void*), void (*)(dmEngine::Engine*, void*), void*) + 177
7 dmengine 0x0000000106634d1f engine_main(int, char**) + 143
8 dmengine 0x0000000106630674 start + 52
Model: MacBookPro16,1, BootROM 1517.0.0.115.1 (iBridge: 18.16.10310.5.15,0), 8 processors, 8-Core Intel Core i9, 2.3 GHz, 16 GB, SMC
Graphics: kHW_IntelUHDGraphics630Item, Intel UHD Graphics 630, spdisplays_builtin
Graphics: kHW_AMDRadeonPro5500MItem, AMD Radeon Pro 5500M, spdisplays_pcie_device, 4 GB
I just tested, it works fine when I build it first, then run the build. It only fails when loading from debug.
What do you mean by this?