defold / examples

Defold examples for the Learn section of the site
https://www.defold.com/examples/
109 stars 28 forks source link

Add "Unlit" material example #43

Closed aglitchman closed 1 month ago

aglitchman commented 1 month ago

In industry-established terms, a material that is not affected by lighting is called ‘unlit’ or ‘non-lit’. It is used to create retro-style graphics or for effects that should not depend on lighting (headlights, lamps). This PR adds an example of ‘unlit’ material for 3D models.

It also adds a ‘nobg’ option to temporarily remove the background sprite for 3D examples.

image

I don't know how the example will look on the site - I hope I've got it right!

britzl commented 1 month ago

Thanks! I wonder if it wouldn't make sense to have model-unlit.material in builtins too?

aglitchman commented 1 month ago

I wonder if it wouldn't make sense to have model-unlit.material in builtins too?

More like the base model material should have been like this, i.e. which just displays the model as is, without light sources. But backwards compatibility should not be broken.

I have a question. I added the ‘nobg’ parameter to turn off the background (sprite) for 3d examples. It turns out that on the site the examples run differently, directly, and the background is displayed again. I can't figure out how to tweak the project so that the 2d examples have the background, but the 3d examples don't. Maybe remove my ‘nobg’ parameter and just add a separate list of examples that should have no background?

image

britzl commented 1 month ago

Oh, yeah, that's not good. I didn't test it like that either and didn't think of it! I'll fix it!

britzl commented 1 month ago

Additional info:

The examples on the defold.com/examples page are loaded by specifying additional engine arguments:

CUSTOM_PARAMETERS.engine_arguments = [ '--config=examples.start=material/unlit', '--verify-graphics-calls=false' ];

The examples.start argument is checked in loader.script.