├── assets ├── props │ ├── common.go │ ├── tiles │ │ ├── f3.go │ │ ├── f4.go │ │ └── grig10x10.go │ └── coin.go ├── dice │ ├── die.glb │ └── dice.png ├── docs │ ├── dof.jpg │ ├── fow.png │ ├── fr1.jpg │ ├── fun.png │ ├── low.png │ ├── sun.png │ ├── blur.png │ ├── bulb.png │ ├── fr03.jpg │ ├── render.png │ ├── repeat.png │ ├── sun2.png │ ├── title.png │ ├── render2.png │ ├── bootstrap.png │ ├── example_low.png │ ├── lightsetting.png │ ├── USE_FLAT_SHADOW.png │ ├── USE_PCF_SHADOW.png │ ├── example_standart.png │ └── USE_PCF_POISSON_SHADOW.png ├── images │ ├── tip.png │ ├── Button.png │ ├── empty.png │ ├── noname.png │ ├── shadow.png │ ├── Arrow-up.png │ ├── Icon-coin.png │ ├── Icon-gear.png │ ├── light_a.png │ ├── noname4.png │ ├── tiles │ │ ├── b1.png │ │ ├── b2.png │ │ ├── bg.png │ │ ├── c1.png │ │ ├── c2.png │ │ ├── d1.png │ │ ├── d2.png │ │ ├── e1.png │ │ ├── e2.png │ │ ├── e3.png │ │ ├── e4.png │ │ ├── e5.png │ │ ├── e6.png │ │ ├── e7.png │ │ ├── e8.png │ │ ├── e9.png │ │ ├── h1.png │ │ ├── h2.png │ │ ├── h3.png │ │ ├── h4.png │ │ ├── h5.png │ │ ├── r1.png │ │ ├── r2.png │ │ ├── t1.png │ │ ├── t2.png │ │ ├── t3.png │ │ ├── t4.png │ │ ├── t5.png │ │ ├── t6.png │ │ ├── t7.png │ │ ├── t8.png │ │ ├── t8_.png │ │ ├── tr1.png │ │ ├── tr2.png │ │ ├── tr3.png │ │ ├── tr4.png │ │ ├── tr5.png │ │ ├── tr6.png │ │ ├── tr7.png │ │ ├── w1.png │ │ ├── w2.png │ │ ├── w3.png │ │ ├── w4.png │ │ ├── w5.png │ │ ├── w6.png │ │ ├── w7.png │ │ ├── Char1.png │ │ ├── Char2.png │ │ ├── Char3.png │ │ ├── Char4.png │ │ ├── Char5.png │ │ ├── Ogre.png │ │ ├── halo.png │ │ ├── candle.png │ │ └── AttentionIcon.png │ ├── Arrow-left.png │ ├── Arrow-right.png │ ├── fire │ │ ├── fire1.png │ │ ├── fire10.png │ │ ├── fire2.png │ │ ├── fire3.png │ │ ├── fire4.png │ │ ├── fire5.png │ │ ├── fire6.png │ │ ├── fire7.png │ │ ├── fire8.png │ │ └── fire9.png │ ├── windowlight.png │ ├── lightaura_blue.png │ ├── lightaura_red.png │ └── Rounded Rectangle.png ├── ogg │ └── navigate_36.ogg ├── fnt │ ├── Exo2-ExtraBold.ttf │ └── cardfont.font ├── models │ └── gltf │ │ ├── Atlas.png │ │ ├── tower.glb │ │ ├── tower2.glb │ │ ├── Blocks_PixelArt.png │ │ └── License.txt ├── meshes │ ├── quad.buffer │ ├── quad2.buffer │ ├── quad3.buffer │ └── quad_bottom.buffer └── custom.texture_profiles ├── helper ├── print_url.script ├── breathing.script ├── moving.script ├── prettify.lua └── mouse_movement_controller.script ├── examples ├── tinyworld │ ├── images │ │ ├── tw.png │ │ ├── gear.png │ │ ├── moon.png │ │ ├── move.png │ │ ├── sun.png │ │ ├── button.png │ │ ├── button2.png │ │ ├── button3.png │ │ ├── button_.png │ │ ├── grass1.png │ │ ├── house.png │ │ ├── tree1.png │ │ ├── tree2.png │ │ ├── tree3.png │ │ ├── tree4.png │ │ ├── tree5.png │ │ ├── tree6.png │ │ ├── tw.aseprite │ │ ├── src │ │ │ ├── fire1.png │ │ │ ├── fire2.png │ │ │ ├── fire3.png │ │ │ ├── fire4.png │ │ │ ├── fire5.png │ │ │ ├── fire6.png │ │ │ ├── fire7.png │ │ │ ├── fire8.png │ │ │ ├── heart.png │ │ │ ├── heart_.png │ │ │ ├── light_a.png │ │ │ ├── point1.png │ │ │ ├── point2.png │ │ │ ├── point3.png │ │ │ ├── point4.png │ │ │ ├── point5.png │ │ │ ├── point6.png │ │ │ ├── pointg1.png │ │ │ ├── pointg2.png │ │ │ ├── pointg3.png │ │ │ ├── pointg4.png │ │ │ ├── pointg5.png │ │ │ ├── pointg6.png │ │ │ ├── shadow.png │ │ │ ├── shadow2.png │ │ │ └── sunlight.png │ │ ├── chars │ │ │ ├── boy_idle1.png │ │ │ ├── boy_idle2.png │ │ │ ├── boy_idle3.png │ │ │ ├── boy_idle4.png │ │ │ └── boy_idle5.png │ │ └── tw.tilesource │ ├── models │ │ ├── edg32.ase │ │ ├── texture.png │ │ ├── texture_.png │ │ └── decor1.gltf │ ├── 3D │ │ ├── shad.sprite │ │ ├── shad2.sprite │ │ ├── b1.go │ │ ├── b1_.go │ │ ├── b2_.go │ │ ├── b3.go │ │ ├── b4.go │ │ ├── b5.go │ │ ├── b6.go │ │ ├── b7.go │ │ ├── lamp.go │ │ ├── tower.go │ │ ├── tree1.go │ │ ├── tree5.go │ │ ├── decor1.go │ │ ├── tower2.go │ │ ├── tower_wall.go │ │ ├── tower_bridge.go │ │ ├── tower_bridge_.go │ │ ├── tree_bill.go │ │ ├── tree_bill1.go │ │ ├── tree_bill2.go │ │ ├── tree_bill3.go │ │ ├── tree_bill4.go │ │ ├── tree_bill5.go │ │ ├── tree_bill6.go │ │ ├── wagon1.go │ │ └── b2.go │ ├── props │ │ ├── point.go │ │ ├── billboard.go │ │ ├── billboard2.go │ │ ├── billboard3.go │ │ ├── billboard4.go │ │ ├── billboard5.go │ │ ├── billboard6.go │ │ └── boy.go │ └── materials │ │ ├── gui_nearest.material │ │ ├── shadow_mesh │ │ ├── model3.fp │ │ ├── model3.vp │ │ └── model3.material │ │ ├── fog_sprite_nearest.material │ │ ├── billboard_particlefx_nearest.material │ │ ├── model_instanced.vp │ │ ├── rgss.glsl │ │ ├── tilemap.material │ │ ├── billboard_model_instanced_nearest.material │ │ ├── model_instanced_nearest.material │ │ ├── billboard_light_sprite_nearest.material │ │ └── model_emissive.fp ├── example2 │ └── player │ │ └── player.collection ├── example1 │ ├── coin.script │ ├── ui.gui │ └── manager.script ├── example4 │ ├── model_tint_blend_yellow.material │ ├── model_alpha_blend.material │ ├── model_skinned_instanced_no_shadow.material │ └── model_skinned_instanced_nearest.material ├── main.script └── example3 │ └── die.go ├── light_and_shadows ├── props │ ├── shpere.glb │ ├── bulb_dir.glb │ ├── render_target_quad.go │ ├── bulb.go │ └── sun.go ├── render │ ├── upscale.render_target │ ├── shadowmap.render_target │ └── default.render ├── materials │ ├── hidden_model │ │ ├── model.fp │ │ ├── model.vp │ │ ├── white.material │ │ └── yellow.material │ ├── shadow │ │ ├── shadow_instanced.vp │ │ ├── shadow_instanced.material │ │ ├── shadow_instanced_textured.vp │ │ ├── shadow.vp │ │ ├── shadow_model.fp │ │ ├── shadow_local.material │ │ ├── shadow.fp │ │ ├── skinned │ │ │ ├── shadow_skinned.vp │ │ │ ├── shadow_skinned_instanced.vp │ │ │ ├── shadow_skinned.material │ │ │ └── shadow_skinned_instanced.material │ │ ├── shadow_instanced_textured.material │ │ ├── shadow.material │ │ ├── shadow_instanced_billboard.material │ │ └── shadow_instanced_billboard.vp │ ├── copy │ │ ├── copy.fp │ │ ├── copy.vp │ │ └── copy.material │ ├── hidden_label.material │ ├── post │ │ ├── mix │ │ │ ├── mix.vp │ │ │ ├── mix.material │ │ │ └── mix.fp │ │ └── blur_horizontal │ │ │ ├── blur_horizontal.vp │ │ │ ├── blur_horizontal.material │ │ │ └── blur_vertical.material │ ├── sprite │ │ ├── billboard │ │ │ ├── billboard.script │ │ │ ├── billboard_sprite.vp │ │ │ └── billboard_light_sprite.material │ │ ├── parallax │ │ │ ├── bg_sprite.vp │ │ │ ├── bg_sprite.fp │ │ │ └── bg_parallax_sprite.material │ │ ├── sprite.vp │ │ ├── repeat │ │ │ ├── sprite_repeat.script │ │ │ ├── repeat_sprite.vp │ │ │ └── repeat_sprite_nocast.material │ │ ├── light_sprite_back.material │ │ ├── light_sprite_up.material │ │ ├── light_sprite.material │ │ └── sprite.fp │ ├── hidden_sprite.material │ ├── fog_sprite │ │ ├── sprite.vp │ │ ├── fog_sprite.material │ │ ├── sprite.fp │ │ └── billboard │ │ │ ├── sprite.fp │ │ │ ├── billboard_sprite.vp │ │ │ ├── billboard_fog_sprite_linear.material │ │ │ └── billboard_fog_sprite_nearest.material │ ├── fog_particle │ │ ├── particlefx.vp │ │ ├── fog_particlefx.material │ │ └── particlefx.fp │ ├── fog_fun.glsl │ ├── fog_label │ │ ├── fog_label.material │ │ ├── font.vp │ │ └── font.fp │ ├── billboard_particle │ │ ├── billboard_particlefx.vp │ │ └── billboard_particlefx.material │ ├── spine │ │ ├── spine.vp │ │ └── light_spine.material │ ├── model │ │ ├── model_local.vp │ │ ├── model_instanced.vp │ │ ├── model_world.vp │ │ ├── skinned │ │ │ ├── model_skinned.vp │ │ │ ├── model_skinned_instanced.vp │ │ │ ├── model_skinned_instanced.material │ │ │ └── model_skinned.material │ │ ├── model_world.material │ │ ├── model_instanced_nocast.material │ │ ├── model_instanced.material │ │ ├── model_world_nocast.material │ │ ├── billboard │ │ │ ├── billboard_model_instanced.material │ │ │ └── billboard_model_instanced.vp │ │ ├── model.fp │ │ └── model_local.material │ └── mesh │ │ ├── mesh.vp │ │ ├── mesh.material │ │ └── mesh.fp ├── constants.lua ├── sun.script └── light_setting.script ├── .gitignore ├── input └── game.input_binding ├── LICENSE └── game.project /assets/props/common.go: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/dice/die.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/dice/die.glb -------------------------------------------------------------------------------- /assets/docs/dof.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/dof.jpg -------------------------------------------------------------------------------- /assets/docs/fow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/fow.png -------------------------------------------------------------------------------- /assets/docs/fr1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/fr1.jpg -------------------------------------------------------------------------------- /assets/docs/fun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/fun.png -------------------------------------------------------------------------------- /assets/docs/low.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/low.png -------------------------------------------------------------------------------- /assets/docs/sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/sun.png -------------------------------------------------------------------------------- /assets/dice/dice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/dice/dice.png -------------------------------------------------------------------------------- /assets/docs/blur.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/blur.png -------------------------------------------------------------------------------- /assets/docs/bulb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/bulb.png -------------------------------------------------------------------------------- /assets/docs/fr03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/fr03.jpg -------------------------------------------------------------------------------- /assets/docs/render.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/render.png -------------------------------------------------------------------------------- /assets/docs/repeat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/repeat.png -------------------------------------------------------------------------------- /assets/docs/sun2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/sun2.png -------------------------------------------------------------------------------- /assets/docs/title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/title.png -------------------------------------------------------------------------------- /assets/images/tip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tip.png -------------------------------------------------------------------------------- /helper/print_url.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | print("Hello:", msg.url(), go.get_id()) 3 | end 4 | 5 | 6 | -------------------------------------------------------------------------------- /assets/docs/render2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/render2.png -------------------------------------------------------------------------------- /assets/images/Button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/Button.png -------------------------------------------------------------------------------- /assets/images/empty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/empty.png -------------------------------------------------------------------------------- /assets/images/noname.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/noname.png -------------------------------------------------------------------------------- /assets/images/shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/shadow.png -------------------------------------------------------------------------------- /assets/docs/bootstrap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/bootstrap.png -------------------------------------------------------------------------------- /assets/docs/example_low.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/example_low.png -------------------------------------------------------------------------------- /assets/images/Arrow-up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/Arrow-up.png -------------------------------------------------------------------------------- /assets/images/Icon-coin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/Icon-coin.png -------------------------------------------------------------------------------- /assets/images/Icon-gear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/Icon-gear.png -------------------------------------------------------------------------------- /assets/images/light_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/light_a.png -------------------------------------------------------------------------------- /assets/images/noname4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/noname4.png -------------------------------------------------------------------------------- /assets/images/tiles/b1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/b1.png -------------------------------------------------------------------------------- /assets/images/tiles/b2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/b2.png -------------------------------------------------------------------------------- /assets/images/tiles/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/bg.png -------------------------------------------------------------------------------- /assets/images/tiles/c1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/c1.png -------------------------------------------------------------------------------- /assets/images/tiles/c2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/c2.png -------------------------------------------------------------------------------- /assets/images/tiles/d1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/d1.png -------------------------------------------------------------------------------- /assets/images/tiles/d2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/d2.png -------------------------------------------------------------------------------- /assets/images/tiles/e1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/e1.png -------------------------------------------------------------------------------- /assets/images/tiles/e2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/e2.png -------------------------------------------------------------------------------- /assets/images/tiles/e3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/e3.png -------------------------------------------------------------------------------- /assets/images/tiles/e4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/e4.png -------------------------------------------------------------------------------- /assets/images/tiles/e5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/e5.png -------------------------------------------------------------------------------- /assets/images/tiles/e6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/e6.png -------------------------------------------------------------------------------- /assets/images/tiles/e7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/e7.png -------------------------------------------------------------------------------- /assets/images/tiles/e8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/e8.png -------------------------------------------------------------------------------- /assets/images/tiles/e9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/e9.png -------------------------------------------------------------------------------- /assets/images/tiles/h1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/h1.png -------------------------------------------------------------------------------- /assets/images/tiles/h2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/h2.png -------------------------------------------------------------------------------- /assets/images/tiles/h3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/h3.png -------------------------------------------------------------------------------- /assets/images/tiles/h4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/h4.png -------------------------------------------------------------------------------- /assets/images/tiles/h5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/h5.png -------------------------------------------------------------------------------- /assets/images/tiles/r1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/r1.png -------------------------------------------------------------------------------- /assets/images/tiles/r2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/r2.png -------------------------------------------------------------------------------- /assets/images/tiles/t1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/t1.png -------------------------------------------------------------------------------- /assets/images/tiles/t2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/t2.png -------------------------------------------------------------------------------- /assets/images/tiles/t3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/t3.png -------------------------------------------------------------------------------- /assets/images/tiles/t4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/t4.png -------------------------------------------------------------------------------- /assets/images/tiles/t5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/t5.png -------------------------------------------------------------------------------- /assets/images/tiles/t6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/t6.png -------------------------------------------------------------------------------- /assets/images/tiles/t7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/t7.png -------------------------------------------------------------------------------- /assets/images/tiles/t8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/t8.png -------------------------------------------------------------------------------- /assets/images/tiles/t8_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/t8_.png -------------------------------------------------------------------------------- /assets/images/tiles/tr1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/tr1.png -------------------------------------------------------------------------------- /assets/images/tiles/tr2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/tr2.png -------------------------------------------------------------------------------- /assets/images/tiles/tr3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/tr3.png -------------------------------------------------------------------------------- /assets/images/tiles/tr4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/tr4.png -------------------------------------------------------------------------------- /assets/images/tiles/tr5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/tr5.png -------------------------------------------------------------------------------- /assets/images/tiles/tr6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/tr6.png -------------------------------------------------------------------------------- /assets/images/tiles/tr7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/tr7.png -------------------------------------------------------------------------------- /assets/images/tiles/w1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/w1.png -------------------------------------------------------------------------------- /assets/images/tiles/w2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/w2.png -------------------------------------------------------------------------------- /assets/images/tiles/w3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/w3.png -------------------------------------------------------------------------------- /assets/images/tiles/w4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/w4.png -------------------------------------------------------------------------------- /assets/images/tiles/w5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/w5.png -------------------------------------------------------------------------------- /assets/images/tiles/w6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/w6.png -------------------------------------------------------------------------------- /assets/images/tiles/w7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/w7.png -------------------------------------------------------------------------------- /assets/ogg/navigate_36.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/ogg/navigate_36.ogg -------------------------------------------------------------------------------- /assets/docs/lightsetting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/lightsetting.png -------------------------------------------------------------------------------- /assets/fnt/Exo2-ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/fnt/Exo2-ExtraBold.ttf -------------------------------------------------------------------------------- /assets/images/Arrow-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/Arrow-left.png -------------------------------------------------------------------------------- /assets/images/Arrow-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/Arrow-right.png -------------------------------------------------------------------------------- /assets/images/fire/fire1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/fire/fire1.png -------------------------------------------------------------------------------- /assets/images/fire/fire10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/fire/fire10.png -------------------------------------------------------------------------------- /assets/images/fire/fire2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/fire/fire2.png -------------------------------------------------------------------------------- /assets/images/fire/fire3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/fire/fire3.png -------------------------------------------------------------------------------- /assets/images/fire/fire4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/fire/fire4.png -------------------------------------------------------------------------------- /assets/images/fire/fire5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/fire/fire5.png -------------------------------------------------------------------------------- /assets/images/fire/fire6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/fire/fire6.png -------------------------------------------------------------------------------- /assets/images/fire/fire7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/fire/fire7.png -------------------------------------------------------------------------------- /assets/images/fire/fire8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/fire/fire8.png -------------------------------------------------------------------------------- /assets/images/fire/fire9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/fire/fire9.png -------------------------------------------------------------------------------- /assets/images/tiles/Char1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/Char1.png -------------------------------------------------------------------------------- /assets/images/tiles/Char2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/Char2.png -------------------------------------------------------------------------------- /assets/images/tiles/Char3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/Char3.png -------------------------------------------------------------------------------- /assets/images/tiles/Char4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/Char4.png -------------------------------------------------------------------------------- /assets/images/tiles/Char5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/Char5.png -------------------------------------------------------------------------------- /assets/images/tiles/Ogre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/Ogre.png -------------------------------------------------------------------------------- /assets/images/tiles/halo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/halo.png -------------------------------------------------------------------------------- /assets/images/windowlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/windowlight.png -------------------------------------------------------------------------------- /assets/models/gltf/Atlas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/models/gltf/Atlas.png -------------------------------------------------------------------------------- /assets/models/gltf/tower.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/models/gltf/tower.glb -------------------------------------------------------------------------------- /assets/models/gltf/tower2.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/models/gltf/tower2.glb -------------------------------------------------------------------------------- /assets/docs/USE_FLAT_SHADOW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/USE_FLAT_SHADOW.png -------------------------------------------------------------------------------- /assets/docs/USE_PCF_SHADOW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/USE_PCF_SHADOW.png -------------------------------------------------------------------------------- /assets/docs/example_standart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/example_standart.png -------------------------------------------------------------------------------- /assets/images/lightaura_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/lightaura_blue.png -------------------------------------------------------------------------------- /assets/images/lightaura_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/lightaura_red.png -------------------------------------------------------------------------------- /assets/images/tiles/candle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/candle.png -------------------------------------------------------------------------------- /examples/tinyworld/images/tw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/tw.png -------------------------------------------------------------------------------- /examples/tinyworld/images/gear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/gear.png -------------------------------------------------------------------------------- /examples/tinyworld/images/moon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/moon.png -------------------------------------------------------------------------------- /examples/tinyworld/images/move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/move.png -------------------------------------------------------------------------------- /examples/tinyworld/images/sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/sun.png -------------------------------------------------------------------------------- /light_and_shadows/props/shpere.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/light_and_shadows/props/shpere.glb -------------------------------------------------------------------------------- /assets/images/Rounded Rectangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/Rounded Rectangle.png -------------------------------------------------------------------------------- /assets/images/tiles/AttentionIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/images/tiles/AttentionIcon.png -------------------------------------------------------------------------------- /examples/tinyworld/images/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/button.png -------------------------------------------------------------------------------- /examples/tinyworld/images/button2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/button2.png -------------------------------------------------------------------------------- /examples/tinyworld/images/button3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/button3.png -------------------------------------------------------------------------------- /examples/tinyworld/images/button_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/button_.png -------------------------------------------------------------------------------- /examples/tinyworld/images/grass1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/grass1.png -------------------------------------------------------------------------------- /examples/tinyworld/images/house.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/house.png -------------------------------------------------------------------------------- /examples/tinyworld/images/tree1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/tree1.png -------------------------------------------------------------------------------- /examples/tinyworld/images/tree2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/tree2.png -------------------------------------------------------------------------------- /examples/tinyworld/images/tree3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/tree3.png -------------------------------------------------------------------------------- /examples/tinyworld/images/tree4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/tree4.png -------------------------------------------------------------------------------- /examples/tinyworld/images/tree5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/tree5.png -------------------------------------------------------------------------------- /examples/tinyworld/images/tree6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/tree6.png -------------------------------------------------------------------------------- /examples/tinyworld/images/tw.aseprite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/tw.aseprite -------------------------------------------------------------------------------- /examples/tinyworld/models/edg32.ase: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/models/edg32.ase -------------------------------------------------------------------------------- /examples/tinyworld/models/texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/models/texture.png -------------------------------------------------------------------------------- /light_and_shadows/props/bulb_dir.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/light_and_shadows/props/bulb_dir.glb -------------------------------------------------------------------------------- /assets/docs/USE_PCF_POISSON_SHADOW.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/docs/USE_PCF_POISSON_SHADOW.png -------------------------------------------------------------------------------- /assets/models/gltf/Blocks_PixelArt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/assets/models/gltf/Blocks_PixelArt.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/fire1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/fire1.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/fire2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/fire2.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/fire3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/fire3.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/fire4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/fire4.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/fire5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/fire5.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/fire6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/fire6.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/fire7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/fire7.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/fire8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/fire8.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/heart.png -------------------------------------------------------------------------------- /examples/tinyworld/models/texture_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/models/texture_.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/heart_.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/heart_.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/light_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/light_a.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/point1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/point1.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/point2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/point2.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/point3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/point3.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/point4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/point4.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/point5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/point5.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/point6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/point6.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/pointg1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/pointg1.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/pointg2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/pointg2.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/pointg3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/pointg3.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/pointg4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/pointg4.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/pointg5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/pointg5.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/pointg6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/pointg6.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/shadow.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/shadow2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/shadow2.png -------------------------------------------------------------------------------- /examples/tinyworld/images/src/sunlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/src/sunlight.png -------------------------------------------------------------------------------- /examples/tinyworld/images/chars/boy_idle1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/chars/boy_idle1.png -------------------------------------------------------------------------------- /examples/tinyworld/images/chars/boy_idle2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/chars/boy_idle2.png -------------------------------------------------------------------------------- /examples/tinyworld/images/chars/boy_idle3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/chars/boy_idle3.png -------------------------------------------------------------------------------- /examples/tinyworld/images/chars/boy_idle4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/chars/boy_idle4.png -------------------------------------------------------------------------------- /examples/tinyworld/images/chars/boy_idle5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Dragosha/defold-light-and-shadows/HEAD/examples/tinyworld/images/chars/boy_idle5.png -------------------------------------------------------------------------------- /examples/example2/player/player.collection: -------------------------------------------------------------------------------- 1 | name: "player" 2 | instances { 3 | id: "player" 4 | prototype: "/examples/example2/player/player.go" 5 | } 6 | scale_along_z: 0 7 | -------------------------------------------------------------------------------- /light_and_shadows/render/upscale.render_target: -------------------------------------------------------------------------------- 1 | color_attachments { 2 | width: 1600 3 | height: 900 4 | } 5 | depth_stencil_attachment { 6 | width: 1600 7 | height: 900 8 | } 9 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/shad.sprite: -------------------------------------------------------------------------------- 1 | default_animation: "shadow" 2 | material: "/examples/tinyworld/materials/fog_sprite_nearest.material" 3 | textures { 4 | sampler: "texture_sampler" 5 | texture: "/examples/tinyworld/tiles.atlas" 6 | } 7 | -------------------------------------------------------------------------------- /examples/tinyworld/images/tw.tilesource: -------------------------------------------------------------------------------- 1 | image: "/examples/tinyworld/images/tw.png" 2 | tile_width: 16 3 | tile_height: 16 4 | collision_groups: "default" 5 | animations { 6 | id: "anim" 7 | start_tile: 1 8 | end_tile: 1 9 | } 10 | extrude_borders: 1 11 | -------------------------------------------------------------------------------- /light_and_shadows/materials/hidden_model/model.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | out vec4 out_fragColor; 4 | 5 | uniform fs_uniforms 6 | { 7 | mediump vec4 tint; 8 | }; 9 | 10 | void main() 11 | { 12 | out_fragColor = vec4(tint.xyz * tint.w, tint.w); 13 | } 14 | 15 | -------------------------------------------------------------------------------- /light_and_shadows/render/shadowmap.render_target: -------------------------------------------------------------------------------- 1 | color_attachments { 2 | width: 2048 3 | height: 2048 4 | format: TEXTURE_FORMAT_RGBA 5 | } 6 | depth_stencil_attachment { 7 | width: 2048 8 | height: 2048 9 | format: DEPTH_STENCIL_FORMAT_D24U_S8U 10 | texture_storage: false 11 | } 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.internal 2 | /build 3 | .externalToolBuilders 4 | .DS_Store 5 | Thumbs.db 6 | .lock-wscript 7 | *.pyc 8 | .project 9 | .cproject 10 | builtins 11 | manifest.private.der 12 | manifest.public.der 13 | *.blend1 14 | *.blend 15 | *.afphoto 16 | *.psd 17 | *.mdp 18 | /.editor_settings 19 | /.obsidian -------------------------------------------------------------------------------- /examples/example1/coin.script: -------------------------------------------------------------------------------- 1 | local broadcast = require 'helper.broadcast' 2 | function init(self) 3 | -- Since we don't grant that the others scripts are activated: skip 1 frame. 4 | timer.delay(0, false, function() 5 | broadcast.send("coin_register", {id = go.get_id()} ) 6 | end) 7 | end 8 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/shad2.sprite: -------------------------------------------------------------------------------- 1 | default_animation: "shadow2" 2 | material: "/light_and_shadows/materials/fog_sprite/fog_sprite.material" 3 | size { 4 | x: 19.0 5 | y: 11.0 6 | } 7 | size_mode: SIZE_MODE_MANUAL 8 | textures { 9 | sampler: "texture_sampler" 10 | texture: "/examples/tinyworld/tiles.atlas" 11 | } 12 | -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/shadow_instanced.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in highp vec4 position; 4 | in highp mat4 mtx_world; 5 | 6 | uniform vs_uniforms 7 | { 8 | highp mat4 mtx_viewproj; 9 | }; 10 | 11 | void main() 12 | { 13 | gl_Position = mtx_viewproj * mtx_world * vec4(position.xyz, 1.0); 14 | } 15 | 16 | -------------------------------------------------------------------------------- /helper/breathing.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.scale = go.get_scale() 3 | local time = 1 + math.random() 4 | go.animate(".", "scale.y", go.PLAYBACK_LOOP_PINGPONG, self.scale.y*1.1, go.EASING_INOUTSINE, time) 5 | --go.animate(".", "scale.x", go.PLAYBACK_LOOP_PINGPONG, self.scale.x*1.025, go.EASING_INEXPO, time) 6 | end 7 | 8 | -------------------------------------------------------------------------------- /light_and_shadows/materials/copy/copy.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in mediump vec2 var_texcoord0; 4 | uniform mediump sampler2D tex0; 5 | 6 | out vec4 out_fragColor; 7 | 8 | void main() 9 | { 10 | vec3 color = texture(tex0, var_texcoord0).rgb; 11 | // color = floor(color * 3.) / 3.; // zx spectrum 12 | out_fragColor = vec4(color, 1.); 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /helper/moving.script: -------------------------------------------------------------------------------- 1 | go.property("value", 1) 2 | go.property("time", 2) 3 | go.property("delay", 0) 4 | go.property("prop", hash("euler.z")) 5 | go.property("playback", 6) -- go.PLAYBACK_LOOP_PINGPONG 6 | go.property("easing", 19) -- EASING_INOUTSINE 7 | 8 | function init(self) 9 | go.animate(".", self.prop, self.playback, self.value, self.easing, self.time, self.delay) 10 | end 11 | 12 | -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/shadow_instanced.material: -------------------------------------------------------------------------------- 1 | name: "shadow_instanced" 2 | tags: "shadow_instanced" 3 | vertex_program: "/light_and_shadows/materials/shadow/shadow_instanced.vp" 4 | fragment_program: "/light_and_shadows/materials/shadow/shadow_model.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_viewproj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | -------------------------------------------------------------------------------- /assets/models/gltf/License.txt: -------------------------------------------------------------------------------- 1 | 2 | Cube World Kit 3 | 4 | Get the full package: https://quaternius.com/packs/cubeworldkit.html 5 | 6 | Created by Quaternius 7 | 8 | ------------------------------ 9 | 10 | License: (Creative Commons Zero, CC0) 11 | https://creativecommons.org/publicdomain/zero/1.0/ 12 | 13 | This content is free to use in personal, educational and commercial projects. 14 | 15 | -------------------------------------------------------------------------------- /light_and_shadows/materials/hidden_label.material: -------------------------------------------------------------------------------- 1 | name: "label" 2 | tags: "htile" 3 | vertex_program: "/builtins/fonts/font-df.vp" 4 | fragment_program: "/builtins/fonts/font-df.fp" 5 | vertex_space: VERTEX_SPACE_WORLD 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | value { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 0.0 14 | } 15 | } 16 | max_page_count: 0 17 | -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/shadow_instanced_textured.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in highp vec4 position; 4 | in highp vec2 texcoord0; 5 | in highp mat4 mtx_world; 6 | 7 | out highp vec2 var_texcoord0; 8 | 9 | uniform vs_uniforms 10 | { 11 | highp mat4 mtx_viewproj; 12 | }; 13 | 14 | void main() 15 | { 16 | gl_Position = mtx_viewproj * mtx_world * vec4(position.xyz, 1.0); 17 | var_texcoord0 = texcoord0; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /light_and_shadows/materials/copy/copy.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // positions are in world space 4 | in mediump vec4 position; 5 | in mediump vec2 texcoord0; 6 | in mediump vec3 normal; 7 | 8 | out mediump vec2 var_texcoord0; 9 | 10 | uniform vs_uniforms 11 | { 12 | mediump mat4 mtx_viewproj; 13 | }; 14 | 15 | void main() 16 | { 17 | gl_Position = mtx_viewproj * vec4(position.xyz, 1.0); 18 | var_texcoord0 = texcoord0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/shadow.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // positions are in world/local space depends material settings 4 | in highp vec4 position; 5 | in highp vec2 texcoord0; 6 | 7 | out highp vec2 var_texcoord0; 8 | 9 | uniform vs_uniforms 10 | { 11 | highp mat4 mtx_viewproj; 12 | }; 13 | 14 | void main() 15 | { 16 | gl_Position = mtx_viewproj * vec4(position.xyz, 1.0); 17 | var_texcoord0 = texcoord0; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /light_and_shadows/materials/post/mix/mix.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // positions are in world space 4 | in mediump vec4 position; 5 | in mediump vec2 texcoord0; 6 | in mediump vec3 normal; 7 | 8 | out mediump vec2 var_texcoord0; 9 | 10 | uniform vs_uniforms 11 | { 12 | mediump mat4 mtx_viewproj; 13 | }; 14 | 15 | void main() 16 | { 17 | gl_Position = mtx_viewproj * vec4(position.xyz, 1.0); 18 | var_texcoord0 = texcoord0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /light_and_shadows/materials/post/blur_horizontal/blur_horizontal.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // positions are in world space 4 | in mediump vec4 position; 5 | in mediump vec2 texcoord0; 6 | in mediump vec3 normal; 7 | 8 | uniform vs_uniforms 9 | { 10 | mediump mat4 mtx_viewproj; 11 | }; 12 | out mediump vec2 var_texcoord0; 13 | 14 | void main() 15 | { 16 | var_texcoord0 = texcoord0; 17 | gl_Position = mtx_viewproj * vec4(position.xyz, 1.0); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /light_and_shadows/materials/sprite/billboard/billboard.script: -------------------------------------------------------------------------------- 1 | go.property("sprite_url", msg.url("#sprite")) 2 | function init(self) 3 | -- Setup local attribute 'sprite_scale' in the vertex shader 4 | -- It needs to correct calcule billboarding 5 | -- you may use this small script or set this value manually in the sprite properties panel. 6 | local scale = vmath.mul_per_elem(go.get(self.sprite_url, "scale"), go.get_scale()) 7 | go.set(self.sprite_url, "sprite_scale", scale) 8 | end 9 | -------------------------------------------------------------------------------- /examples/tinyworld/props/point.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "sprite" 3 | type: "sprite" 4 | data: "default_animation: \"pointg\"\n" 5 | "material: \"/light_and_shadows/materials/fog_sprite/fog_sprite.material\"\n" 6 | "textures {\n" 7 | " sampler: \"texture_sampler\"\n" 8 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 9 | "}\n" 10 | "" 11 | position { 12 | y: 0.1 13 | } 14 | rotation { 15 | x: 0.70710677 16 | w: 0.70710677 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/b1.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/block.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/b1_.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/block.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/b2_.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/block2.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/b3.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/block3.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/b4.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/block4.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/b5.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/block5.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/b6.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/block6.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/b7.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/block7.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/lamp.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/lamp.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/tower.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/tower.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/tree1.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/tree1.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/tree5.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/tree5.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/shadow_model.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | out vec4 out_fragColor; 4 | 5 | vec4 float_to_rgba( float v ) 6 | { 7 | vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v; 8 | enc = fract(enc); 9 | enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0); 10 | return enc; 11 | } 12 | // For model shadow casting we are don't use a texture sampler. 13 | void main() 14 | { 15 | out_fragColor = float_to_rgba(gl_FragCoord.z); 16 | } 17 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/decor1.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/decor1.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/tower2.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/tower2.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/materials/gui_nearest.material: -------------------------------------------------------------------------------- 1 | name: "gui" 2 | tags: "gui" 3 | vertex_program: "/builtins/materials/gui.vp" 4 | fragment_program: "/builtins/materials/gui.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | samplers { 10 | name: "texture_sampler" 11 | wrap_u: WRAP_MODE_REPEAT 12 | wrap_v: WRAP_MODE_REPEAT 13 | filter_min: FILTER_MODE_MIN_NEAREST 14 | filter_mag: FILTER_MODE_MAG_NEAREST 15 | max_anisotropy: 0.0 16 | } 17 | -------------------------------------------------------------------------------- /examples/tinyworld/props/billboard.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "sprite" 3 | type: "sprite" 4 | data: "default_animation: \"tree1\"\n" 5 | "material: \"/examples/tinyworld/materials/billboard_light_sprite_nearest.material\"\n" 6 | "textures {\n" 7 | " sampler: \"tex0\"\n" 8 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 9 | "}\n" 10 | "textures {\n" 11 | " sampler: \"tex1\"\n" 12 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/tower_wall.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/tower_wall.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/props/billboard2.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "sprite" 3 | type: "sprite" 4 | data: "default_animation: \"tree2\"\n" 5 | "material: \"/examples/tinyworld/materials/billboard_light_sprite_nearest.material\"\n" 6 | "textures {\n" 7 | " sampler: \"tex0\"\n" 8 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 9 | "}\n" 10 | "textures {\n" 11 | " sampler: \"tex1\"\n" 12 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/props/billboard3.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "sprite" 3 | type: "sprite" 4 | data: "default_animation: \"tree3\"\n" 5 | "material: \"/examples/tinyworld/materials/billboard_light_sprite_nearest.material\"\n" 6 | "textures {\n" 7 | " sampler: \"tex0\"\n" 8 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 9 | "}\n" 10 | "textures {\n" 11 | " sampler: \"tex1\"\n" 12 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/props/billboard4.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "sprite" 3 | type: "sprite" 4 | data: "default_animation: \"tree4\"\n" 5 | "material: \"/examples/tinyworld/materials/billboard_light_sprite_nearest.material\"\n" 6 | "textures {\n" 7 | " sampler: \"tex0\"\n" 8 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 9 | "}\n" 10 | "textures {\n" 11 | " sampler: \"tex1\"\n" 12 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/props/billboard5.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "sprite" 3 | type: "sprite" 4 | data: "default_animation: \"tree5\"\n" 5 | "material: \"/examples/tinyworld/materials/billboard_light_sprite_nearest.material\"\n" 6 | "textures {\n" 7 | " sampler: \"tex0\"\n" 8 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 9 | "}\n" 10 | "textures {\n" 11 | " sampler: \"tex1\"\n" 12 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/props/billboard6.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "sprite" 3 | type: "sprite" 4 | data: "default_animation: \"tree6\"\n" 5 | "material: \"/examples/tinyworld/materials/billboard_light_sprite_nearest.material\"\n" 6 | "textures {\n" 7 | " sampler: \"tex0\"\n" 8 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 9 | "}\n" 10 | "textures {\n" 11 | " sampler: \"tex1\"\n" 12 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/tower_bridge.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/tower_bridge.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/tower_bridge_.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/tower_bridge.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | -------------------------------------------------------------------------------- /assets/meshes/quad.buffer: -------------------------------------------------------------------------------- 1 | [{"name":"position","type":"float32","count":3,"data":[-1.0,-1.0,0.0,1.0,-1.0,0.0,1.0,1.0,0.0,-1.0,-1.0,0.0,1.0,1.0,0.0,-1.0,1.0,0.0]},{"name":"normal","type":"float32","count":3,"data":[0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,-0.0,0.0,1.0,-0.0,0.0,1.0,-0.0,0.0,1.0]},{"name":"texcoord0","type":"float32","count":2,"data":[0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0]},{"name":"color0","type":"float32","count":4,"data":[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]}] -------------------------------------------------------------------------------- /assets/meshes/quad2.buffer: -------------------------------------------------------------------------------- 1 | [{"name":"position","type":"float32","count":3,"data":[-1.0,-1.0,0.0,1.0,-1.0,0.0,1.0,1.0,0.0,-1.0,-1.0,0.0,1.0,1.0,0.0,-1.0,1.0,0.0]},{"name":"normal","type":"float32","count":3,"data":[0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,-0.0,0.0,1.0,-0.0,0.0,1.0,-0.0,0.0,1.0]},{"name":"texcoord0","type":"float32","count":2,"data":[0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0]},{"name":"color0","type":"float32","count":4,"data":[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]}] -------------------------------------------------------------------------------- /assets/meshes/quad3.buffer: -------------------------------------------------------------------------------- 1 | [{"name":"position","type":"float32","count":3,"data":[-1.0,-1.0,0.0,1.0,-1.0,0.0,1.0,1.0,0.0,-1.0,-1.0,0.0,1.0,1.0,0.0,-1.0,1.0,0.0]},{"name":"normal","type":"float32","count":3,"data":[0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,-0.0,0.0,1.0,-0.0,0.0,1.0,-0.0,0.0,1.0]},{"name":"texcoord0","type":"float32","count":2,"data":[0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0]},{"name":"color0","type":"float32","count":4,"data":[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]}] -------------------------------------------------------------------------------- /assets/meshes/quad_bottom.buffer: -------------------------------------------------------------------------------- 1 | [{"name":"position","type":"float32","count":3,"data":[-1.0,0.0,0.0, 1.0,0.0,0.0, 1.0,2.0,0.0, -1.0,0.0,0.0, 1.0,2.0,0.0, -1.0,2.0,0.0]},{"name":"normal","type":"float32","count":3,"data":[0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,-0.0,0.0,1.0,-0.0,0.0,1.0,-0.0,0.0,1.0]},{"name":"texcoord0","type":"float32","count":2,"data":[0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0]},{"name":"color0","type":"float32","count":4,"data":[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]}] -------------------------------------------------------------------------------- /light_and_shadows/props/render_target_quad.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/builtins/assets/meshes/quad_2x2.dae\"\n" 5 | "material: \"/light_and_shadows/materials/copy/copy.material\"\n" 6 | "skeleton: \"\"\n" 7 | "animations: \"\"\n" 8 | "default_animation: \"\"\n" 9 | "name: \"unnamed\"\n" 10 | "" 11 | position { 12 | x: 0.0 13 | y: 0.0 14 | z: 0.0 15 | } 16 | rotation { 17 | x: 0.0 18 | y: 0.0 19 | z: 0.0 20 | w: 1.0 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /light_and_shadows/materials/copy/copy.material: -------------------------------------------------------------------------------- 1 | name: "copy" 2 | tags: "upscale" 3 | vertex_program: "/light_and_shadows/materials/copy/copy.vp" 4 | fragment_program: "/light_and_shadows/materials/copy/copy.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_viewproj" 8 | type: CONSTANT_TYPE_WORLDVIEWPROJ 9 | } 10 | samplers { 11 | name: "tex0" 12 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 13 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 14 | filter_min: FILTER_MODE_MIN_DEFAULT 15 | filter_mag: FILTER_MODE_MAG_DEFAULT 16 | } 17 | -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/shadow_local.material: -------------------------------------------------------------------------------- 1 | name: "shadow_local" 2 | tags: "shadow_local" 3 | vertex_program: "/light_and_shadows/materials/shadow/shadow.vp" 4 | fragment_program: "/light_and_shadows/materials/shadow/shadow.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_viewproj" 8 | type: CONSTANT_TYPE_WORLDVIEWPROJ 9 | } 10 | samplers { 11 | name: "tex0" 12 | wrap_u: WRAP_MODE_REPEAT 13 | wrap_v: WRAP_MODE_REPEAT 14 | filter_min: FILTER_MODE_MIN_NEAREST 15 | filter_mag: FILTER_MODE_MAG_NEAREST 16 | } 17 | -------------------------------------------------------------------------------- /light_and_shadows/materials/hidden_sprite.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "htile" 3 | vertex_program: "/builtins/materials/sprite.vp" 4 | fragment_program: "/builtins/materials/sprite.fp" 5 | vertex_space: VERTEX_SPACE_WORLD 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | value { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 0.0 14 | } 15 | } 16 | fragment_constants { 17 | name: "tint" 18 | type: CONSTANT_TYPE_USER 19 | value { 20 | x: 1.0 21 | y: 1.0 22 | z: 1.0 23 | w: 1.0 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/tinyworld/props/boy.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "sprite" 3 | type: "sprite" 4 | data: "default_animation: \"boyidle\"\n" 5 | "material: \"/examples/tinyworld/materials/billboard_light_sprite_nearest.material\"\n" 6 | "textures {\n" 7 | " sampler: \"tex0\"\n" 8 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 9 | "}\n" 10 | "textures {\n" 11 | " sampler: \"tex1\"\n" 12 | " texture: \"/examples/tinyworld/tiles.atlas\"\n" 13 | "}\n" 14 | "" 15 | position { 16 | x: -18.699322 17 | y: 9.0 18 | z: 75.04193 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /light_and_shadows/materials/hidden_model/model.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // Positions can be world or local space, since world and normal 4 | // matrices are identity for world vertex space materials. 5 | // If world vertex space is selected, you can remove the 6 | // normal matrix multiplication for optimal performance. 7 | 8 | in highp vec4 position; 9 | 10 | uniform vs_uniforms 11 | { 12 | mediump mat4 mtx_worldview; 13 | mediump mat4 mtx_proj; 14 | }; 15 | 16 | void main() 17 | { 18 | vec4 p = mtx_worldview * vec4(position.xyz, 1.0); 19 | gl_Position = mtx_proj * p; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /light_and_shadows/materials/fog_sprite/sprite.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // positions are in world space 4 | in highp vec4 position; 5 | in mediump vec2 texcoord0; 6 | 7 | uniform vs_uniforms 8 | { 9 | highp mat4 view_proj; 10 | highp mat4 mtx_view; 11 | }; 12 | 13 | out mediump vec2 var_texcoord0; 14 | out highp vec4 var_position; 15 | out highp vec4 var_view_position; 16 | 17 | void main() 18 | { 19 | 20 | gl_Position = view_proj * vec4(position.xyz, 1.0); 21 | var_texcoord0 = texcoord0; 22 | 23 | var_position = vec4(position.xyz, 1.0); 24 | var_view_position = mtx_view * position; 25 | } -------------------------------------------------------------------------------- /examples/example4/model_tint_blend_yellow.material: -------------------------------------------------------------------------------- 1 | name: "model" 2 | tags: "model_alpha_blend" 3 | vertex_program: "/light_and_shadows/materials/hidden_model/model.vp" 4 | fragment_program: "/light_and_shadows/materials/hidden_model/model.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_worldview" 8 | type: CONSTANT_TYPE_WORLDVIEW 9 | } 10 | vertex_constants { 11 | name: "mtx_proj" 12 | type: CONSTANT_TYPE_PROJECTION 13 | } 14 | fragment_constants { 15 | name: "tint" 16 | type: CONSTANT_TYPE_USER 17 | value { 18 | x: 1.0 19 | y: 1.0 20 | z: 0.1 21 | w: 0.8 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /light_and_shadows/materials/hidden_model/white.material: -------------------------------------------------------------------------------- 1 | name: "model" 2 | tags: "hiddenmodel" 3 | vertex_program: "/light_and_shadows/materials/hidden_model/model.vp" 4 | fragment_program: "/light_and_shadows/materials/hidden_model/model.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_worldview" 8 | type: CONSTANT_TYPE_WORLDVIEW 9 | } 10 | vertex_constants { 11 | name: "mtx_proj" 12 | type: CONSTANT_TYPE_PROJECTION 13 | } 14 | fragment_constants { 15 | name: "tint" 16 | type: CONSTANT_TYPE_USER 17 | value { 18 | x: 1.0 19 | y: 1.0 20 | z: 1.0 21 | w: 0.8 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /light_and_shadows/materials/hidden_model/yellow.material: -------------------------------------------------------------------------------- 1 | name: "model" 2 | tags: "hiddenmodel" 3 | vertex_program: "/light_and_shadows/materials/hidden_model/model.vp" 4 | fragment_program: "/light_and_shadows/materials/hidden_model/model.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_worldview" 8 | type: CONSTANT_TYPE_WORLDVIEW 9 | } 10 | vertex_constants { 11 | name: "mtx_proj" 12 | type: CONSTANT_TYPE_PROJECTION 13 | } 14 | fragment_constants { 15 | name: "tint" 16 | type: CONSTANT_TYPE_USER 17 | value { 18 | x: 1.0 19 | y: 1.0 20 | z: 0.1 21 | w: 0.8 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/shadow.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in highp vec2 var_texcoord0; 4 | uniform highp sampler2D tex0; 5 | 6 | out vec4 out_fragColor; 7 | 8 | vec4 float_to_rgba( float v ) 9 | { 10 | vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v; 11 | enc = fract(enc); 12 | enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0); 13 | return enc; 14 | } 15 | 16 | void main() 17 | { 18 | vec4 color = texture(tex0, var_texcoord0.xy); 19 | if(color.a < 0.1) discard; 20 | out_fragColor = float_to_rgba(gl_FragCoord.z); 21 | // out_fragColor = vec4(gl_FragCoord.z); 22 | } 23 | -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/skinned/shadow_skinned.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in highp vec4 position; 4 | in mediump vec4 bone_weights; 5 | in mediump vec4 bone_indices; 6 | in mediump vec4 animation_data; 7 | in highp vec2 texcoord0; 8 | 9 | uniform vs_uniforms 10 | { 11 | highp mat4 mtx_worldviewproj; 12 | }; 13 | out highp vec2 var_texcoord0; 14 | 15 | #include "/builtins/materials/skinning.glsl" 16 | 17 | void main() 18 | { 19 | vec4 skinned_position = get_skinned_position(position); 20 | gl_Position = mtx_worldviewproj * vec4(skinned_position.xyz, 1.0); 21 | var_texcoord0 = texcoord0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/shadow_instanced_textured.material: -------------------------------------------------------------------------------- 1 | name: "shadow_instanced_textured" 2 | tags: "shadow_instanced_textured" 3 | vertex_program: "/light_and_shadows/materials/shadow/shadow_instanced_textured.vp" 4 | fragment_program: "/light_and_shadows/materials/shadow/shadow.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_viewproj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | samplers { 11 | name: "tex0" 12 | wrap_u: WRAP_MODE_REPEAT 13 | wrap_v: WRAP_MODE_REPEAT 14 | filter_min: FILTER_MODE_MIN_NEAREST 15 | filter_mag: FILTER_MODE_MAG_NEAREST 16 | max_anisotropy: 0.0 17 | } 18 | -------------------------------------------------------------------------------- /light_and_shadows/materials/fog_particle/particlefx.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | uniform vs_uniforms 4 | { 5 | highp mat4 view_proj; 6 | highp mat4 proj; 7 | }; 8 | 9 | // positions are in world space 10 | in highp vec4 position; 11 | in mediump vec2 texcoord0; 12 | in mediump vec4 color; 13 | 14 | out mediump vec2 var_texcoord0; 15 | out mediump vec4 var_color; 16 | out highp vec4 var_view_position; 17 | 18 | void main() 19 | { 20 | gl_Position = view_proj * vec4(position.xyz, 1.0); 21 | var_texcoord0 = texcoord0; 22 | var_color = vec4(color.rgb * color.a, color.a); 23 | var_view_position = vec4(position.xyz, 1.0); 24 | } 25 | -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/shadow.material: -------------------------------------------------------------------------------- 1 | name: "shadow" 2 | tags: "shadow" 3 | vertex_program: "/light_and_shadows/materials/shadow/shadow.vp" 4 | fragment_program: "/light_and_shadows/materials/shadow/shadow.fp" 5 | vertex_space: VERTEX_SPACE_WORLD 6 | vertex_constants { 7 | name: "mtx_viewproj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | value { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 0.0 14 | } 15 | } 16 | samplers { 17 | name: "tex0" 18 | wrap_u: WRAP_MODE_REPEAT 19 | wrap_v: WRAP_MODE_REPEAT 20 | filter_min: FILTER_MODE_MIN_NEAREST 21 | filter_mag: FILTER_MODE_MAG_NEAREST 22 | max_anisotropy: 1.0 23 | } 24 | -------------------------------------------------------------------------------- /light_and_shadows/materials/fog_fun.glsl: -------------------------------------------------------------------------------- 1 | // Put functions in this file to use them in shaders 2 | // To get access to the functions, you need to put: 3 | // #include "/my-folder/my-file.glsl" 4 | // in any script using the functions. 5 | // Please consult the manual on how to use this feature! 6 | 7 | #ifndef LS_FOGFUN 8 | #define LS_FOGFUN 9 | 10 | // Fog 11 | vec3 add_fog(vec3 frag_color, float dist, float fog_min, float fog_max, vec3 fog_color, float density) 12 | { 13 | float fog_factor = clamp((fog_max - abs(dist)) / (fog_max - fog_min) + density, 0.0, 1.0 ); 14 | return mix(fog_color, frag_color, fog_factor); 15 | } 16 | 17 | #endif // LS_FOGFUN -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/skinned/shadow_skinned_instanced.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in highp vec4 position; 4 | in highp mat4 mtx_world; 5 | in mediump vec4 bone_weights; 6 | in mediump vec4 bone_indices; 7 | in mediump vec4 animation_data; 8 | in highp vec2 texcoord0; 9 | 10 | uniform vs_uniforms 11 | { 12 | highp mat4 mtx_viewproj; 13 | }; 14 | out highp vec2 var_texcoord0; 15 | 16 | #include "/builtins/materials/skinning.glsl" 17 | 18 | void main() 19 | { 20 | vec4 skinned_position = get_skinned_position(position); 21 | gl_Position = mtx_viewproj * mtx_world * vec4(skinned_position.xyz, 1.0); 22 | var_texcoord0 = texcoord0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /light_and_shadows/materials/fog_label/fog_label.material: -------------------------------------------------------------------------------- 1 | name: "label" 2 | tags: "tile" 3 | vertex_program: "/light_and_shadows/materials/fog_label/font.vp" 4 | fragment_program: "/light_and_shadows/materials/fog_label/font.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "mtx_view" 11 | type: CONSTANT_TYPE_VIEW 12 | } 13 | fragment_constants { 14 | name: "fog_color" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 1.0 18 | y: 1.0 19 | z: 1.0 20 | w: 1.0 21 | } 22 | } 23 | fragment_constants { 24 | name: "fog" 25 | type: CONSTANT_TYPE_USER 26 | value { 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /input/game.input_binding: -------------------------------------------------------------------------------- 1 | key_trigger { 2 | input: KEY_LEFT 3 | action: "left" 4 | } 5 | key_trigger { 6 | input: KEY_RIGHT 7 | action: "right" 8 | } 9 | key_trigger { 10 | input: KEY_UP 11 | action: "up" 12 | } 13 | key_trigger { 14 | input: KEY_DOWN 15 | action: "down" 16 | } 17 | mouse_trigger { 18 | input: MOUSE_BUTTON_1 19 | action: "touch" 20 | } 21 | mouse_trigger { 22 | input: MOUSE_WHEEL_UP 23 | action: "wup" 24 | } 25 | mouse_trigger { 26 | input: MOUSE_WHEEL_DOWN 27 | action: "wdown" 28 | } 29 | mouse_trigger { 30 | input: MOUSE_BUTTON_RIGHT 31 | action: "right_click" 32 | } 33 | touch_trigger { 34 | input: TOUCH_MULTI 35 | action: "touch_multi" 36 | } 37 | -------------------------------------------------------------------------------- /helper/prettify.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | 4 | function M.prettify(t, indentation) 5 | indentation = indentation or "" 6 | local s = "" 7 | local keys = {} 8 | for k,v in pairs(t) do 9 | keys[#keys + 1] = k 10 | end 11 | for i=1,#keys do 12 | local k = keys[i] 13 | local v = t[k] 14 | local last = (i == #keys) and "" or ",\n" 15 | if type(v) == "table" then 16 | s = s .. ("%s%s = {\n%s\n}%s"):format(indentation, k, M.prettify(v, indentation .. " "), last) 17 | else 18 | s = s .. ("%s%s = %s%s"):format(indentation, k, tostring(v), last) 19 | end 20 | end 21 | return s 22 | end 23 | 24 | 25 | return setmetatable(M, { 26 | __call = function(t, ...) 27 | return M.prettify(...) 28 | end 29 | }) -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/shadow_instanced_billboard.material: -------------------------------------------------------------------------------- 1 | name: "shadow_instanced_billboard" 2 | tags: "shadow_instanced_billboard" 3 | vertex_program: "/light_and_shadows/materials/shadow/shadow_instanced_billboard.vp" 4 | fragment_program: "/light_and_shadows/materials/shadow/shadow.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_viewproj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "mtx_proj" 12 | type: CONSTANT_TYPE_PROJECTION 13 | } 14 | samplers { 15 | name: "tex0" 16 | wrap_u: WRAP_MODE_REPEAT 17 | wrap_v: WRAP_MODE_REPEAT 18 | filter_min: FILTER_MODE_MIN_NEAREST 19 | filter_mag: FILTER_MODE_MAG_NEAREST 20 | max_anisotropy: 0.0 21 | } 22 | -------------------------------------------------------------------------------- /assets/custom.texture_profiles: -------------------------------------------------------------------------------- 1 | path_settings { 2 | path: "/assets/rgba/*" 3 | profile: "Default" 4 | } 5 | path_settings { 6 | path: "/examples/tinyworld/*" 7 | profile: "uncompressed" 8 | } 9 | profiles { 10 | name: "Default" 11 | platforms { 12 | os: OS_ID_GENERIC 13 | formats { 14 | format: TEXTURE_FORMAT_RGBA 15 | compressor: "BasisU" 16 | compressor_preset: "BASISU_HIGH" 17 | } 18 | mipmaps: false 19 | } 20 | } 21 | profiles { 22 | name: "uncompressed" 23 | platforms { 24 | os: OS_ID_GENERIC 25 | formats { 26 | format: TEXTURE_FORMAT_RGBA 27 | compressor: "Uncompressed" 28 | compressor_preset: "UNCOMPRESSED" 29 | } 30 | mipmaps: false 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /light_and_shadows/materials/billboard_particle/billboard_particlefx.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | uniform vs_uniforms 4 | { 5 | highp mat4 view_proj; 6 | highp mat4 proj; 7 | }; 8 | 9 | // positions are in world space 10 | in highp vec3 local_position; 11 | in highp vec4 position; 12 | in mediump vec2 texcoord0; 13 | in mediump vec4 color; 14 | 15 | out mediump vec2 var_texcoord0; 16 | out mediump vec4 var_color; 17 | out highp vec4 var_view_position; 18 | 19 | void main() 20 | { 21 | gl_Position = (view_proj * vec4(position.xyz - local_position.xyz, 1.0)) + (proj * vec4(local_position.xy, 0.0, 0.0)); 22 | var_texcoord0 = texcoord0; 23 | var_color = vec4(color.rgb * color.a, color.a); 24 | var_view_position = vec4(position.xyz, 1.0); 25 | } 26 | -------------------------------------------------------------------------------- /light_and_shadows/props/bulb.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "bulb" 3 | component: "/light_and_shadows/bulb.script" 4 | position { 5 | x: 0.0 6 | y: 0.0 7 | z: 0.0 8 | } 9 | rotation { 10 | x: 0.0 11 | y: 0.0 12 | z: 0.0 13 | w: 1.0 14 | } 15 | } 16 | embedded_components { 17 | id: "model" 18 | type: "model" 19 | data: "mesh: \"/light_and_shadows/props/lamp.dae\"\n" 20 | "material: \"/light_and_shadows/materials/hidden_model/white.material\"\n" 21 | "skeleton: \"\"\n" 22 | "animations: \"\"\n" 23 | "default_animation: \"\"\n" 24 | "name: \"unnamed\"\n" 25 | "" 26 | position { 27 | x: 0.0 28 | y: 0.0 29 | z: 0.0 30 | } 31 | rotation { 32 | x: 0.0 33 | y: 0.0 34 | z: 0.0 35 | w: 1.0 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /light_and_shadows/materials/sprite/parallax/bg_sprite.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // positions are in world space 4 | in highp vec4 position; 5 | in highp vec3 parallax; 6 | in mediump vec2 texcoord0; 7 | 8 | uniform vs_uniforms 9 | { 10 | highp mat4 view_proj; 11 | highp mat4 mtx_view; 12 | highp vec4 cam_look_at_position; 13 | }; 14 | 15 | out mediump vec2 var_texcoord0; 16 | out highp vec4 var_position; 17 | out highp vec4 var_view_position; 18 | 19 | void main() 20 | { 21 | 22 | vec3 offset = vec3(cam_look_at_position.xyz * parallax); 23 | gl_Position = view_proj * vec4(position.xyz + offset, 1.0); 24 | var_texcoord0 = texcoord0; 25 | 26 | var_position = vec4(position.xyz, 1.0); 27 | var_view_position = mtx_view * vec4(position.xyz + offset, 1.0); 28 | } -------------------------------------------------------------------------------- /examples/tinyworld/3D/tree_bill.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/tree_bill.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/billboard_model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "materials {\n" 15 | " name: \"material_1\"\n" 16 | " material: \"/examples/tinyworld/materials/shadow_mesh/model3.material\"\n" 17 | " textures {\n" 18 | " sampler: \"tex0\"\n" 19 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 20 | " }\n" 21 | "}\n" 22 | "" 23 | } 24 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/tree_bill1.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/tree_bill1.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/billboard_model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "materials {\n" 15 | " name: \"material_1\"\n" 16 | " material: \"/examples/tinyworld/materials/shadow_mesh/model3.material\"\n" 17 | " textures {\n" 18 | " sampler: \"tex0\"\n" 19 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 20 | " }\n" 21 | "}\n" 22 | "" 23 | } 24 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/tree_bill2.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/tree_bill2.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/billboard_model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "materials {\n" 15 | " name: \"material_1\"\n" 16 | " material: \"/examples/tinyworld/materials/shadow_mesh/model3.material\"\n" 17 | " textures {\n" 18 | " sampler: \"tex0\"\n" 19 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 20 | " }\n" 21 | "}\n" 22 | "" 23 | } 24 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/tree_bill3.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/tree_bill3.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/billboard_model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "materials {\n" 15 | " name: \"material_1\"\n" 16 | " material: \"/examples/tinyworld/materials/shadow_mesh/model3.material\"\n" 17 | " textures {\n" 18 | " sampler: \"tex0\"\n" 19 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 20 | " }\n" 21 | "}\n" 22 | "" 23 | } 24 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/tree_bill4.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/tree_bill4.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/billboard_model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "materials {\n" 15 | " name: \"material_1\"\n" 16 | " material: \"/examples/tinyworld/materials/shadow_mesh/model3.material\"\n" 17 | " textures {\n" 18 | " sampler: \"tex0\"\n" 19 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 20 | " }\n" 21 | "}\n" 22 | "" 23 | } 24 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/tree_bill5.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/tree_bill5.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/shadow_mesh/model3.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "materials {\n" 15 | " name: \"material_1\"\n" 16 | " material: \"/examples/tinyworld/materials/billboard_model_instanced_nearest.material\"\n" 17 | " textures {\n" 18 | " sampler: \"tex0\"\n" 19 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 20 | " }\n" 21 | "}\n" 22 | "" 23 | } 24 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/tree_bill6.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/tree_bill6.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/billboard_model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "materials {\n" 15 | " name: \"material_1\"\n" 16 | " material: \"/examples/tinyworld/materials/shadow_mesh/model3.material\"\n" 17 | " textures {\n" 18 | " sampler: \"tex0\"\n" 19 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 20 | " }\n" 21 | "}\n" 22 | "" 23 | } 24 | -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/shadow_instanced_billboard.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in highp vec4 position; 4 | in highp vec2 texcoord0; 5 | in highp mat4 mtx_world; 6 | 7 | out highp vec2 var_texcoord0; 8 | 9 | uniform vs_uniforms 10 | { 11 | highp mat4 mtx_viewproj; 12 | highp mat4 mtx_proj; 13 | }; 14 | 15 | void main() 16 | { 17 | vec4 pw = mtx_world * vec4(position.xyz, 1.0); 18 | vec3 axis_factor = vec3(1.0, 0.0, 1.0); // which axis should use to toward the camera 19 | float scaling_factor = mtx_world[0].x; // ger model scale 20 | vec3 model_scale = axis_factor * scaling_factor; 21 | gl_Position = (mtx_viewproj * vec4(pw.xyz - position.xyz * model_scale, 1.0)) + (mtx_proj * vec4(position.xy * model_scale.xy, 0.0, 0.0)); 22 | var_texcoord0 = texcoord0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /light_and_shadows/materials/fog_particle/fog_particlefx.material: -------------------------------------------------------------------------------- 1 | name: "particle" 2 | tags: "tile" 3 | vertex_program: "/light_and_shadows/materials/fog_particle/particlefx.vp" 4 | fragment_program: "/light_and_shadows/materials/fog_particle/particlefx.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | fragment_constants { 10 | name: "tint" 11 | type: CONSTANT_TYPE_USER 12 | value { 13 | x: 1.0 14 | y: 1.0 15 | z: 1.0 16 | w: 1.0 17 | } 18 | } 19 | fragment_constants { 20 | name: "fog_color" 21 | type: CONSTANT_TYPE_USER 22 | value { 23 | x: 0.9 24 | y: 0.9 25 | z: 0.9 26 | w: 1.0 27 | } 28 | } 29 | fragment_constants { 30 | name: "fog" 31 | type: CONSTANT_TYPE_USER 32 | value { 33 | x: 10.0 34 | y: 1000.0 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /light_and_shadows/materials/sprite/sprite.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // positions are in world space 4 | in highp vec4 position; 5 | in mediump vec2 texcoord0; 6 | 7 | uniform vs_uniforms 8 | { 9 | highp mat4 view_proj; 10 | highp mat4 mtx_view; 11 | highp vec4 normal; 12 | highp mat4 mtx_light; 13 | }; 14 | 15 | out mediump vec2 var_texcoord0; 16 | out highp vec4 var_position; 17 | out highp vec4 var_view_position; 18 | out highp vec3 var_normal; 19 | out highp vec4 var_texcoord0_shadow; 20 | 21 | void main() 22 | { 23 | gl_Position = view_proj * vec4(position.xyz, 1.0); 24 | var_texcoord0 = texcoord0; 25 | var_texcoord0_shadow = mtx_light * position; 26 | var_position = vec4(position.xyz, 1.0); 27 | var_view_position = mtx_view * position; 28 | var_normal = normalize(normal.xyz); 29 | 30 | } -------------------------------------------------------------------------------- /light_and_shadows/materials/spine/spine.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // positions are in world space 4 | in highp vec4 position; 5 | in mediump vec2 texcoord0; 6 | 7 | uniform vs_uniforms 8 | { 9 | highp mat4 world_view_proj; 10 | highp mat4 mtx_view; 11 | highp vec4 normal; 12 | highp mat4 mtx_light; 13 | }; 14 | 15 | out mediump vec2 var_texcoord0; 16 | out highp vec4 var_position; 17 | out highp vec4 var_view_position; 18 | out highp vec3 var_normal; 19 | out highp vec4 var_texcoord0_shadow; 20 | 21 | void main() 22 | { 23 | gl_Position = world_view_proj * vec4(position.xyz, 1.0); 24 | var_texcoord0 = texcoord0; 25 | var_texcoord0_shadow = mtx_light * position; 26 | var_position = vec4(position.xyz, 1.0); 27 | var_view_position = mtx_view * position; 28 | var_normal = normalize(normal.xyz); 29 | 30 | } -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/skinned/shadow_skinned.material: -------------------------------------------------------------------------------- 1 | name: "shadow_skinned" 2 | tags: "shadow_skinned" 3 | vertex_program: "/light_and_shadows/materials/shadow/skinned/shadow_skinned.vp" 4 | fragment_program: "/light_and_shadows/materials/shadow/shadow.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_worldviewproj" 8 | type: CONSTANT_TYPE_WORLDVIEWPROJ 9 | } 10 | samplers { 11 | name: "tex0" 12 | wrap_u: WRAP_MODE_REPEAT 13 | wrap_v: WRAP_MODE_REPEAT 14 | filter_min: FILTER_MODE_MIN_NEAREST 15 | filter_mag: FILTER_MODE_MAG_NEAREST 16 | max_anisotropy: 0.0 17 | } 18 | samplers { 19 | name: "pose_matrix_cache" 20 | wrap_u: WRAP_MODE_REPEAT 21 | wrap_v: WRAP_MODE_REPEAT 22 | filter_min: FILTER_MODE_MIN_NEAREST 23 | filter_mag: FILTER_MODE_MAG_NEAREST 24 | max_anisotropy: 0.0 25 | } 26 | -------------------------------------------------------------------------------- /examples/main.script: -------------------------------------------------------------------------------- 1 | local monarch = require "monarch.monarch" 2 | local broadcast = require 'helper.broadcast' 3 | go.property("first", 5) 4 | go.property("total", 5) 5 | 6 | local function on_window(self, event, data) 7 | if event == window.WINDOW_EVENT_RESIZED then 8 | if data.width == 0 or data.height == 0 then 9 | return 10 | end 11 | broadcast.send("WINDOW_RESIZED", data) 12 | end 13 | 14 | end 15 | local SFS = hash("show_first_screen") 16 | function init(self) 17 | msg.post("#", SFS) 18 | if window then 19 | window.set_listener(on_window) 20 | end 21 | end 22 | 23 | function on_message(self, message_id, message, sender) 24 | if message_id == SFS then 25 | broadcast.send("SHOW", {first = self.first, total = self.total}) -- send to /examples/ui/next.gui_script 26 | end 27 | end -------------------------------------------------------------------------------- /light_and_shadows/props/sun.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "sun" 3 | component: "/light_and_shadows/sun.script" 4 | } 5 | embedded_components { 6 | id: "label" 7 | type: "label" 8 | data: "size {\n" 9 | " x: 50.0\n" 10 | " y: 32.0\n" 11 | "}\n" 12 | "text: \"Sun\"\n" 13 | "font: \"/builtins/fonts/default.font\"\n" 14 | "material: \"/light_and_shadows/materials/hidden_label.material\"\n" 15 | "" 16 | position { 17 | y: 7.385 18 | } 19 | scale { 20 | x: 0.4 21 | y: 0.4 22 | z: 0.4 23 | } 24 | } 25 | embedded_components { 26 | id: "model" 27 | type: "model" 28 | data: "mesh: \"/light_and_shadows/props/bulb_dir.glb\"\n" 29 | "name: \"unnamed\"\n" 30 | "materials {\n" 31 | " name: \"material_0\"\n" 32 | " material: \"/light_and_shadows/materials/hidden_model/yellow.material\"\n" 33 | "}\n" 34 | "" 35 | } 36 | -------------------------------------------------------------------------------- /light_and_shadows/materials/shadow/skinned/shadow_skinned_instanced.material: -------------------------------------------------------------------------------- 1 | name: "shadow_skinned_instanced" 2 | tags: "shadow_skinned_instanced" 3 | vertex_program: "/light_and_shadows/materials/shadow/skinned/shadow_skinned_instanced.vp" 4 | fragment_program: "/light_and_shadows/materials/shadow/shadow.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_viewproj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | samplers { 11 | name: "tex0" 12 | wrap_u: WRAP_MODE_REPEAT 13 | wrap_v: WRAP_MODE_REPEAT 14 | filter_min: FILTER_MODE_MIN_NEAREST 15 | filter_mag: FILTER_MODE_MAG_NEAREST 16 | max_anisotropy: 0.0 17 | } 18 | samplers { 19 | name: "pose_matrix_cache" 20 | wrap_u: WRAP_MODE_REPEAT 21 | wrap_v: WRAP_MODE_REPEAT 22 | filter_min: FILTER_MODE_MIN_NEAREST 23 | filter_mag: FILTER_MODE_MAG_NEAREST 24 | max_anisotropy: 0.0 25 | } 26 | -------------------------------------------------------------------------------- /light_and_shadows/materials/fog_sprite/fog_sprite.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | vertex_program: "/light_and_shadows/materials/fog_sprite/sprite.vp" 4 | fragment_program: "/light_and_shadows/materials/fog_sprite/sprite.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "mtx_view" 11 | type: CONSTANT_TYPE_VIEW 12 | } 13 | fragment_constants { 14 | name: "tint" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 1.0 18 | y: 1.0 19 | z: 1.0 20 | w: 1.0 21 | } 22 | } 23 | fragment_constants { 24 | name: "fog_color" 25 | type: CONSTANT_TYPE_USER 26 | value { 27 | x: 0.5 28 | y: 0.5 29 | z: 0.5 30 | w: 1.0 31 | } 32 | } 33 | fragment_constants { 34 | name: "fog" 35 | type: CONSTANT_TYPE_USER 36 | value { 37 | x: 1000.0 38 | y: 1000.0 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /light_and_shadows/materials/sprite/repeat/sprite_repeat.script: -------------------------------------------------------------------------------- 1 | -- More info: https://github.com/Dragosha/defold-sprite-repeat 2 | 3 | go.property("url", msg.url("#sprite")) 4 | go.property("repeat_x", 2) 5 | go.property("repeat_y", 2) 6 | go.property("auto_tiling", false) 7 | 8 | go.property("repeat_material", resource.material("/light_and_shadows/materials/sprite/repeat/repeat_sprite_nocast.material")) 9 | 10 | local sprite_repeat = require('light_and_shadows.materials.sprite.repeat.sprite_repeat') 11 | 12 | function init(self) 13 | if self.auto_tiling then 14 | local scale = go.get(self.url, "scale") 15 | self.repeat_x = scale.x 16 | self.repeat_y = scale.y 17 | end 18 | 19 | go.set(self.url, "material", self.repeat_material) 20 | 21 | local sr = sprite_repeat.create(self.url) 22 | sr.animate(self.repeat_x, self.repeat_y) 23 | 24 | end 25 | 26 | function final(self) 27 | end 28 | -------------------------------------------------------------------------------- /light_and_shadows/materials/post/blur_horizontal/blur_horizontal.material: -------------------------------------------------------------------------------- 1 | name: "blur_horizontal" 2 | tags: "lowrez" 3 | vertex_program: "/light_and_shadows/materials/post/blur_horizontal/blur_horizontal.vp" 4 | fragment_program: "/light_and_shadows/materials/post/blur_horizontal/blur_horizontal.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_viewproj" 8 | type: CONSTANT_TYPE_WORLDVIEWPROJ 9 | } 10 | fragment_constants { 11 | name: "resolution" 12 | type: CONSTANT_TYPE_USER 13 | value { 14 | x: 1280.0 15 | y: 720.0 16 | w: 1.0 17 | } 18 | } 19 | fragment_constants { 20 | name: "direct" 21 | type: CONSTANT_TYPE_USER 22 | value { 23 | x: 1.0 24 | } 25 | } 26 | samplers { 27 | name: "DIFFUSE_TEXTURE" 28 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 29 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 30 | filter_min: FILTER_MODE_MIN_LINEAR 31 | filter_mag: FILTER_MODE_MAG_LINEAR 32 | } 33 | -------------------------------------------------------------------------------- /light_and_shadows/materials/post/blur_horizontal/blur_vertical.material: -------------------------------------------------------------------------------- 1 | name: "blur_vertical" 2 | tags: "lowrez" 3 | vertex_program: "/light_and_shadows/materials/post/blur_horizontal/blur_horizontal.vp" 4 | fragment_program: "/light_and_shadows/materials/post/blur_horizontal/blur_horizontal.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_viewproj" 8 | type: CONSTANT_TYPE_WORLDVIEWPROJ 9 | } 10 | fragment_constants { 11 | name: "resolution" 12 | type: CONSTANT_TYPE_USER 13 | value { 14 | x: 1280.0 15 | y: 720.0 16 | w: 1.0 17 | } 18 | } 19 | fragment_constants { 20 | name: "direct" 21 | type: CONSTANT_TYPE_USER 22 | value { 23 | y: 1.0 24 | } 25 | } 26 | samplers { 27 | name: "DIFFUSE_TEXTURE" 28 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 29 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 30 | filter_min: FILTER_MODE_MIN_LINEAR 31 | filter_mag: FILTER_MODE_MAG_LINEAR 32 | } 33 | -------------------------------------------------------------------------------- /light_and_shadows/materials/fog_sprite/sprite.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in mediump vec2 var_texcoord0; 4 | 5 | out vec4 out_fragColor; 6 | 7 | uniform mediump sampler2D texture_sampler; 8 | uniform fs_uniforms 9 | { 10 | mediump vec4 tint; 11 | mediump vec4 fog_color; 12 | mediump vec4 fog; 13 | }; 14 | 15 | 16 | in highp vec4 var_position; 17 | in highp vec4 var_view_position; 18 | 19 | #include "/light_and_shadows/materials/fog_fun.glsl" 20 | 21 | void main() 22 | { 23 | // Pre-multiply alpha since all runtime textures already are 24 | mediump vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 25 | vec4 color = texture(texture_sampler, var_texcoord0.xy)*tint_pm; 26 | 27 | vec3 frag_color = color.rgb; 28 | // Add the fog 29 | frag_color = add_fog(frag_color, var_view_position.z, fog.x, fog.y, fog_color.rgb*color.a, fog_color.a); 30 | 31 | out_fragColor = vec4(frag_color, color.a); 32 | } 33 | -------------------------------------------------------------------------------- /light_and_shadows/materials/fog_particle/particlefx.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in mediump vec2 var_texcoord0; 4 | in mediump vec4 var_color; 5 | in highp vec4 var_view_position; 6 | 7 | out vec4 out_fragColor; 8 | 9 | uniform mediump sampler2D texture_sampler; 10 | uniform fs_uniforms 11 | { 12 | mediump vec4 tint; 13 | mediump vec4 fog_color; 14 | mediump vec4 fog; 15 | }; 16 | 17 | 18 | #include "/light_and_shadows/materials/fog_fun.glsl" 19 | 20 | void main() 21 | { 22 | // Pre-multiply alpha since all runtime textures already are 23 | mediump vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 24 | vec4 color = texture(texture_sampler, var_texcoord0.xy) * var_color * tint_pm; 25 | 26 | vec3 frag_color = color.rgb; 27 | 28 | // Add the fog 29 | frag_color = add_fog(frag_color, var_view_position.z, fog.x, fog.y, fog_color.rgb*color.a, fog_color.a); 30 | 31 | out_fragColor = vec4(frag_color, color.a); 32 | } 33 | -------------------------------------------------------------------------------- /assets/fnt/cardfont.font: -------------------------------------------------------------------------------- 1 | font: "/assets/fnt/Exo2-ExtraBold.ttf" 2 | material: "/builtins/fonts/font.material" 3 | size: 34 4 | antialias: 1 5 | alpha: 1.0 6 | outline_alpha: 1.0 7 | outline_width: 2.0 8 | shadow_alpha: 0.0 9 | shadow_blur: 0 10 | shadow_x: 0.0 11 | shadow_y: 0.0 12 | extra_characters: "\320\260\320\261\320\262\320\263\320\264\320\265\321\221\320\266\320\267\320\270\320\271\320\272\320\273\320\274\320\275\320\276\320\277\321\200\321\201\321\202\321\203\321\204\321\205\321\206\321\207\321\210\321\211\321\212\321\213\321\214\321\215\321\216\321\217\320\220\320\221\320\222\320\223\320\224\320\225\320\201\320\226\320\227\320\230\320\231\320\232\320\233\320\234\320\235\320\236\320\237\320\240\320\241\320\242\320\243\320\244\320\245\320\246\320\247\320\250\320\251\320\252\320\253\320\254\320\255\320\256\320\257\304\253" 13 | output_format: TYPE_BITMAP 14 | all_chars: false 15 | cache_width: 0 16 | cache_height: 0 17 | render_mode: MODE_SINGLE_LAYER 18 | -------------------------------------------------------------------------------- /light_and_shadows/materials/fog_sprite/billboard/sprite.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in mediump vec2 var_texcoord0; 4 | in highp vec4 var_color; 5 | 6 | out vec4 out_fragColor; 7 | 8 | uniform mediump sampler2D texture_sampler; 9 | uniform fs_uniforms 10 | { 11 | mediump vec4 tint; 12 | mediump vec4 fog_color; 13 | mediump vec4 fog; 14 | }; 15 | 16 | 17 | in highp vec4 var_position; 18 | in highp vec4 var_view_position; 19 | 20 | #include "/light_and_shadows/materials/fog_fun.glsl" 21 | 22 | void main() 23 | { 24 | // Pre-multiply alpha since all runtime textures already are 25 | mediump vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 26 | vec4 color = texture(texture_sampler, var_texcoord0.xy) * tint_pm * var_color; 27 | 28 | vec3 frag_color = color.rgb; 29 | // Add the fog 30 | frag_color = add_fog(frag_color, var_view_position.z, fog.x, fog.y, fog_color.rgb*color.a, fog_color.a); 31 | 32 | out_fragColor = vec4(frag_color, color.a); 33 | } 34 | -------------------------------------------------------------------------------- /light_and_shadows/materials/fog_sprite/billboard/billboard_sprite.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // positions are in world space 4 | in highp vec4 position; 5 | in mediump vec2 texcoord0; 6 | in highp vec3 local_position; 7 | in highp vec3 sprite_scale; 8 | in highp vec4 color; 9 | 10 | uniform vs_uniforms 11 | { 12 | highp mat4 view_proj; 13 | highp mat4 proj; 14 | highp mat4 mtx_view; 15 | highp vec4 cam_pos; 16 | }; 17 | 18 | out mediump vec2 var_texcoord0; 19 | out highp vec4 var_position; 20 | out highp vec4 var_view_position; 21 | out highp vec3 var_normal; 22 | out highp vec4 var_color; 23 | 24 | 25 | void main() 26 | { 27 | gl_Position = (view_proj * vec4(position.xyz - local_position.xyz * sprite_scale, 1.0)) + (proj * vec4(local_position.xy * sprite_scale.xy, 0.0, 0.0)); 28 | var_texcoord0 = texcoord0; 29 | var_color = color; 30 | var_position = vec4(position.xyz, 1.0); 31 | var_view_position = mtx_view * position; 32 | var_normal = normalize((cam_pos - position).xyz); 33 | 34 | } -------------------------------------------------------------------------------- /light_and_shadows/materials/sprite/parallax/bg_sprite.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in mediump vec2 var_texcoord0; 4 | in highp vec4 var_position; 5 | in highp vec4 var_view_position; 6 | 7 | uniform mediump sampler2D texture_sampler; 8 | uniform fs_uniforms 9 | { 10 | mediump vec4 tint; 11 | mediump vec4 ambient; 12 | mediump vec4 color0; 13 | mediump vec4 fog_color; 14 | mediump vec4 fog; 15 | }; 16 | 17 | out vec4 out_fragColor; 18 | #include "/light_and_shadows/materials/fog_fun.glsl" 19 | 20 | void main() 21 | { 22 | // Pre-multiply alpha since all runtime textures already are 23 | mediump vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 24 | vec4 color = texture(texture_sampler, var_texcoord0.xy)*tint_pm; 25 | 26 | vec3 frag_color = color.rgb * (ambient.xyz + color0.xyz); 27 | // Add the fog 28 | frag_color = add_fog(frag_color, var_view_position.z, fog.x, fog.y, fog_color.rgb*color.a, fog_color.a); 29 | 30 | out_fragColor = vec4(frag_color, color.a); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /examples/tinyworld/3D/wagon1.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/wagon1.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | embedded_components { 17 | id: "model1" 18 | type: "model" 19 | data: "mesh: \"/examples/tinyworld/models/lamp.gltf\"\n" 20 | "name: \"unnamed\"\n" 21 | "materials {\n" 22 | " name: \"material_0\"\n" 23 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 24 | " textures {\n" 25 | " sampler: \"tex0\"\n" 26 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 27 | " }\n" 28 | "}\n" 29 | "" 30 | position { 31 | x: 0.214 32 | y: 0.184 33 | z: 0.227 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /examples/tinyworld/materials/shadow_mesh/model3.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in highp vec4 var_position; 4 | in highp vec4 var_view_position; 5 | in mediump vec2 var_texcoord0; 6 | 7 | out vec4 out_fragColor; 8 | 9 | uniform mediump sampler2D tex0; 10 | 11 | uniform fs_uniforms 12 | { 13 | mediump vec4 tint; 14 | mediump vec4 fog_color; 15 | mediump vec4 fog; 16 | mediump vec4 ambient; 17 | mediump vec4 color0; 18 | }; 19 | 20 | #include "/light_and_shadows/materials/fog_fun.glsl" 21 | 22 | void main() 23 | { 24 | // Pre-multiply alpha since all runtime textures already are 25 | vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 26 | vec4 color = texture(tex0, var_texcoord0.xy) * tint_pm; 27 | if(color.a < 0.2) discard; 28 | vec3 frag_color = color.rgb * (ambient.xyz + color0.xyz) * .5; 29 | 30 | // Add the fog 31 | frag_color = add_fog(frag_color, var_view_position.z, fog.x, fog.y, fog_color.rgb*color.a, fog_color.a); 32 | 33 | out_fragColor = vec4(frag_color, color.a); 34 | } 35 | 36 | -------------------------------------------------------------------------------- /light_and_shadows/materials/sprite/billboard/billboard_sprite.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // positions are in world space 4 | in highp vec4 position; 5 | in mediump vec2 texcoord0; 6 | in highp vec3 local_position; 7 | in highp vec3 sprite_scale; 8 | 9 | uniform vs_uniforms 10 | { 11 | highp mat4 view_proj; 12 | highp mat4 proj; 13 | highp mat4 mtx_view; 14 | highp mat4 mtx_light; 15 | highp vec4 cam_pos; 16 | }; 17 | 18 | out mediump vec2 var_texcoord0; 19 | out highp vec4 var_position; 20 | out highp vec4 var_view_position; 21 | out highp vec3 var_normal; 22 | out highp vec4 var_texcoord0_shadow; 23 | 24 | void main() 25 | { 26 | gl_Position = (view_proj * vec4(position.xyz - local_position.xyz * sprite_scale, 1.0)) + (proj * vec4(local_position.xy * sprite_scale.xy, 0.0, 0.0)); 27 | var_texcoord0 = texcoord0; 28 | var_texcoord0_shadow = mtx_light * position; 29 | var_position = vec4(position.xyz, 1.0); 30 | var_view_position = mtx_view * position; 31 | var_normal = normalize((cam_pos - position).xyz); 32 | 33 | } -------------------------------------------------------------------------------- /light_and_shadows/materials/billboard_particle/billboard_particlefx.material: -------------------------------------------------------------------------------- 1 | name: "particle" 2 | tags: "tile" 3 | vertex_program: "/light_and_shadows/materials/billboard_particle/billboard_particlefx.vp" 4 | fragment_program: "/light_and_shadows/materials/fog_particle/particlefx.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "proj" 11 | type: CONSTANT_TYPE_PROJECTION 12 | } 13 | fragment_constants { 14 | name: "tint" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 1.0 18 | y: 1.0 19 | z: 1.0 20 | w: 1.0 21 | } 22 | } 23 | fragment_constants { 24 | name: "fog_color" 25 | type: CONSTANT_TYPE_USER 26 | value { 27 | x: 0.9 28 | y: 0.9 29 | z: 0.9 30 | w: 1.0 31 | } 32 | } 33 | fragment_constants { 34 | name: "fog" 35 | type: CONSTANT_TYPE_USER 36 | value { 37 | x: 10.0 38 | y: 1000.0 39 | } 40 | } 41 | attributes { 42 | name: "local_position" 43 | semantic_type: SEMANTIC_TYPE_POSITION 44 | vector_type: VECTOR_TYPE_VEC3 45 | } 46 | -------------------------------------------------------------------------------- /light_and_shadows/materials/fog_label/font.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // positions are in world space 4 | in mediump vec4 position; 5 | in mediump vec2 texcoord0; 6 | in mediump vec4 face_color; 7 | in mediump vec4 outline_color; 8 | in mediump vec4 shadow_color; 9 | in mediump vec3 layer_mask; 10 | 11 | out mediump vec2 var_texcoord0; 12 | out mediump vec4 var_face_color; 13 | out mediump vec4 var_outline_color; 14 | out mediump vec4 var_shadow_color; 15 | out mediump vec4 var_layer_mask; 16 | out mediump float var_is_single_layer; 17 | 18 | uniform vs_uniforms 19 | { 20 | highp mat4 view_proj; 21 | highp mat4 mtx_view; 22 | }; 23 | 24 | out highp vec4 var_view_position; 25 | 26 | void main() 27 | { 28 | var_texcoord0 = texcoord0; 29 | var_face_color = face_color; 30 | var_outline_color = outline_color; 31 | var_layer_mask.rgb = layer_mask; 32 | var_layer_mask.a = var_layer_mask.x * var_layer_mask.y * var_layer_mask.z; 33 | var_shadow_color = shadow_color; 34 | gl_Position = view_proj * vec4(position.x, position.y, position.z, 1.0); 35 | var_view_position = mtx_view * position; 36 | } 37 | -------------------------------------------------------------------------------- /helper/mouse_movement_controller.script: -------------------------------------------------------------------------------- 1 | local common = require 'helper.common' 2 | 3 | go.property("obj", msg.url()) 4 | go.property("action_id", hash("touch")) 5 | 6 | 7 | function init(self) 8 | self.touch_down = false 9 | msg.post(".","acquire_input_focus") 10 | end 11 | 12 | function final(self) 13 | end 14 | 15 | local root = vmath.vector3(0, 0, 0) 16 | local up = vmath.vector3(0, 1, 0) 17 | function on_input(self, action_id, action) 18 | if action_id == self.action_id then 19 | self.touch_down = true 20 | 21 | if action.pressed then 22 | self.start_p = common.screen_to_world_plane(action.x, action.y, self.camera_id, up, root) 23 | end 24 | 25 | if action.released then 26 | self.touch_down = false 27 | end 28 | end 29 | 30 | if self.touch_down and action_id == nil then 31 | local p = common.screen_to_world_plane(action.x, action.y, self.camera_id, up, root) 32 | local position = go.get_position(self.obj) - (p - self.start_p) 33 | go.set_position(position, self.obj) 34 | end 35 | 36 | end 37 | -------------------------------------------------------------------------------- /examples/tinyworld/materials/fog_sprite_nearest.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "atile" 3 | vertex_program: "/light_and_shadows/materials/fog_sprite/sprite.vp" 4 | fragment_program: "/light_and_shadows/materials/fog_sprite/sprite.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "mtx_view" 11 | type: CONSTANT_TYPE_VIEW 12 | } 13 | fragment_constants { 14 | name: "tint" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 1.0 18 | y: 1.0 19 | z: 1.0 20 | w: 1.0 21 | } 22 | } 23 | fragment_constants { 24 | name: "fog_color" 25 | type: CONSTANT_TYPE_USER 26 | value { 27 | x: 0.5 28 | y: 0.5 29 | z: 0.5 30 | w: 1.0 31 | } 32 | } 33 | fragment_constants { 34 | name: "fog" 35 | type: CONSTANT_TYPE_USER 36 | value { 37 | x: 1000.0 38 | y: 10000.0 39 | w: 1.0 40 | } 41 | } 42 | samplers { 43 | name: "texture_sampler" 44 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 45 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 46 | filter_min: FILTER_MODE_MIN_LINEAR 47 | filter_mag: FILTER_MODE_MAG_LINEAR 48 | max_anisotropy: 0.0 49 | } 50 | -------------------------------------------------------------------------------- /light_and_shadows/materials/post/mix/mix.material: -------------------------------------------------------------------------------- 1 | name: "copy" 2 | tags: "upscale" 3 | vertex_program: "/light_and_shadows/materials/post/mix/mix.vp" 4 | fragment_program: "/light_and_shadows/materials/post/mix/mix.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_viewproj" 8 | type: CONSTANT_TYPE_WORLDVIEWPROJ 9 | } 10 | fragment_constants { 11 | name: "dof" 12 | type: CONSTANT_TYPE_USER 13 | value { 14 | x: 10.0 15 | y: 100.0 16 | } 17 | } 18 | samplers { 19 | name: "tex0" 20 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 21 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 22 | filter_min: FILTER_MODE_MIN_DEFAULT 23 | filter_mag: FILTER_MODE_MAG_DEFAULT 24 | } 25 | samplers { 26 | name: "tex1" 27 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 28 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 29 | filter_min: FILTER_MODE_MIN_DEFAULT 30 | filter_mag: FILTER_MODE_MAG_DEFAULT 31 | max_anisotropy: 0.0 32 | } 33 | samplers { 34 | name: "depth" 35 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 36 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 37 | filter_min: FILTER_MODE_MIN_NEAREST 38 | filter_mag: FILTER_MODE_MAG_NEAREST 39 | max_anisotropy: 0.0 40 | } 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 - 2025 Igor Suntsev 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /light_and_shadows/materials/sprite/repeat/repeat_sprite.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // positions are in world space 4 | in highp vec4 position; 5 | in mediump vec2 texcoord0; 6 | in highp vec3 lp; 7 | 8 | uniform vs_uniforms 9 | { 10 | highp mat4 view_proj; 11 | highp mat4 mtx_view; 12 | highp vec4 normal; 13 | highp mat4 mtx_light; 14 | highp vec4 uv_coord; 15 | highp vec4 uv_repeat; 16 | }; 17 | 18 | out mediump vec2 var_texcoord0; 19 | out highp vec4 var_position; 20 | out highp vec4 var_view_position; 21 | out highp vec3 var_normal; 22 | out highp vec4 var_texcoord0_shadow; 23 | 24 | out highp vec2 var_boo; 25 | out highp vec4 var_uv; 26 | out highp vec4 var_repeat; 27 | 28 | void main() 29 | { 30 | gl_Position = view_proj * vec4(position.xyz, 1.0); 31 | var_texcoord0 = texcoord0; 32 | var_texcoord0_shadow = mtx_light * position; 33 | var_position = vec4(position.xyz, 1.0); 34 | var_view_position = mtx_view * position; 35 | var_normal = normalize(normal.xyz); 36 | var_boo = vec2(lp.x / uv_repeat.z + 0.5, lp.y / uv_repeat.w + 0.5); 37 | var_uv = uv_coord; 38 | var_repeat = uv_repeat; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /light_and_shadows/materials/model/model_local.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // Positions can be world or local space, since world and normal 4 | // matrices are identity for world vertex space materials. 5 | // If world vertex space is selected, you can remove the 6 | // normal matrix multiplication for optimal performance. 7 | 8 | in highp vec4 position; 9 | in mediump vec2 texcoord0; 10 | in highp vec3 normal; 11 | 12 | uniform vs_uniforms 13 | { 14 | highp mat4 mtx_world; 15 | highp mat4 mtx_normal; 16 | highp mat4 mtx_view; 17 | highp mat4 mtx_proj; 18 | highp mat4 mtx_light; 19 | }; 20 | 21 | out highp vec4 var_view_position; 22 | out highp vec4 var_position; 23 | out highp vec3 var_normal; 24 | out mediump vec2 var_texcoord0; 25 | out highp vec4 var_texcoord0_shadow; 26 | 27 | void main() 28 | { 29 | vec4 pw = mtx_world * vec4(position.xyz, 1.0); 30 | vec4 p = mtx_view * pw; 31 | var_view_position = p; 32 | var_position = pw; 33 | var_texcoord0 = texcoord0; 34 | var_texcoord0_shadow = mtx_light * pw; 35 | var_normal = normalize((mtx_world * vec4(normal, 0.0)).xyz); 36 | gl_Position = mtx_proj * p; 37 | 38 | } 39 | 40 | -------------------------------------------------------------------------------- /examples/tinyworld/materials/shadow_mesh/model3.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // Positions can be world or local space, since world and normal 4 | // matrices are identity for world vertex space materials. 5 | // If world vertex space is selected, you can remove the 6 | // normal matrix multiplication for optimal performance. 7 | 8 | in highp vec4 position; 9 | in mediump vec2 texcoord0; 10 | in highp vec3 normal; 11 | 12 | // When 'mtx_world' and 'mtx_normal' is specified as attributes, 13 | // instanced rendering is automatically triggered. 14 | #ifndef EDITOR 15 | in highp mat4 mtx_world; 16 | in highp mat4 mtx_normal; 17 | #endif 18 | 19 | uniform vs_uniforms 20 | { 21 | #ifdef EDITOR 22 | highp mat4 mtx_world; 23 | #endif 24 | highp mat4 mtx_view; 25 | highp mat4 mtx_proj; 26 | }; 27 | 28 | out highp vec4 var_view_position; 29 | out highp vec4 var_position; 30 | out mediump vec2 var_texcoord0; 31 | 32 | void main() 33 | { 34 | vec4 pw = mtx_world * vec4(position.xyz, 1.0); 35 | vec4 p = mtx_view * pw; 36 | var_view_position = p; 37 | var_position = pw; 38 | var_texcoord0 = texcoord0; 39 | gl_Position = mtx_proj * p; 40 | 41 | } 42 | 43 | -------------------------------------------------------------------------------- /examples/example3/die.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/assets/dice/die.glb\"\n" 5 | "name: \"{{NAME}}\"\n" 6 | "materials {\n" 7 | " name: \"Material\"\n" 8 | " material: \"/light_and_shadows/materials/model/model_instanced.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/assets/dice/dice.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | embedded_components { 17 | id: "collisionobject" 18 | type: "collisionobject" 19 | data: "type: COLLISION_OBJECT_TYPE_DYNAMIC\n" 20 | "mass: 1.0\n" 21 | "friction: 0.5\n" 22 | "restitution: 0.5\n" 23 | "group: \"unit\"\n" 24 | "mask: \"default\"\n" 25 | "mask: \"unit\"\n" 26 | "embedded_collision_shape {\n" 27 | " shapes {\n" 28 | " shape_type: TYPE_BOX\n" 29 | " position {\n" 30 | " }\n" 31 | " rotation {\n" 32 | " }\n" 33 | " index: 0\n" 34 | " count: 3\n" 35 | " }\n" 36 | " data: 1.0\n" 37 | " data: 1.0\n" 38 | " data: 1.0\n" 39 | "}\n" 40 | "linear_damping: 0.8\n" 41 | "angular_damping: 0.8\n" 42 | "event_contact: false\n" 43 | "event_trigger: false\n" 44 | "" 45 | } 46 | -------------------------------------------------------------------------------- /game.project: -------------------------------------------------------------------------------- 1 | [bootstrap] 2 | main_collection = /examples/main.collectionc 3 | render = /light_and_shadows/render/default.renderc 4 | 5 | [script] 6 | shared_state = 1 7 | 8 | [display] 9 | width = 1600 10 | height = 900 11 | high_dpi = 1 12 | 13 | [project] 14 | title = Light and Shadows 15 | version = 0.84 16 | developer = Igor Suntsev 17 | dependencies#0 = https://github.com/britzl/defold-input/archive/master.zip 18 | dependencies#1 = https://github.com/britzl/monarch/archive/refs/tags/3.4.6.zip 19 | 20 | [physics] 21 | type = 3D 22 | gravity_y = -90.0 23 | max_collisions = 128 24 | max_contacts = 256 25 | use_fixed_timestep = 1 26 | 27 | [html5] 28 | show_fullscreen_button = 0 29 | show_made_with_defold = 0 30 | scale_mode = stretch 31 | cssfile = /builtins/manifests/web/dark_theme.css 32 | 33 | [graphics] 34 | texture_profiles = /assets/custom.texture_profiles 35 | max_debug_vertices = 60000 36 | 37 | [input] 38 | game_binding = /builtins/input/all.input_bindingc 39 | 40 | [sprite] 41 | max_count = 8192 42 | 43 | [library] 44 | include_dirs = light_and_shadows 45 | 46 | [model] 47 | max_count = 8192 48 | 49 | [tilemap] 50 | max_tile_count = 16384 51 | 52 | [collection] 53 | max_instances = 16384 54 | 55 | -------------------------------------------------------------------------------- /light_and_shadows/materials/mesh/mesh.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // Positions can be world or local space, since world and normal 4 | // matrices are identity for world vertex space materials. 5 | // If world vertex space is selected, you can remove the 6 | // normal matrix multiplication for optimal performance. 7 | 8 | in highp vec4 position; 9 | in mediump vec2 texcoord0; 10 | in highp vec3 normal; 11 | in mediump vec4 color0; 12 | 13 | uniform vs_uniforms 14 | { 15 | highp mat4 mtx_view; 16 | highp mat4 mtx_proj; 17 | highp mat4 mtx_normal; 18 | highp mat4 mtx_light; 19 | }; 20 | 21 | out highp vec4 var_view_position; 22 | out highp vec4 var_position; 23 | out highp vec3 var_normal; 24 | out mediump vec2 var_texcoord0; 25 | out mediump vec4 var_color0; 26 | out highp vec4 var_texcoord0_shadow; 27 | 28 | void main() 29 | { 30 | vec4 p = mtx_view * vec4(position.xyz, 1.0); 31 | var_view_position = p; 32 | var_color0 = color0; 33 | var_position = position; 34 | var_texcoord0 = texcoord0; 35 | var_texcoord0_shadow = mtx_light * position; 36 | 37 | var_normal = normalize(normal); 38 | // var_normal = normalize((mtx_normal * vec4(normal, 0.0)).xyz); 39 | gl_Position = mtx_proj * p; 40 | 41 | } 42 | 43 | 44 | -------------------------------------------------------------------------------- /assets/props/tiles/f3.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "collisionobject" 3 | type: "collisionobject" 4 | data: "type: COLLISION_OBJECT_TYPE_STATIC\n" 5 | "mass: 0.0\n" 6 | "friction: 0.1\n" 7 | "restitution: 0.5\n" 8 | "group: \"default\"\n" 9 | "mask: \"default\"\n" 10 | "mask: \"unit\"\n" 11 | "mask: \"bullet\"\n" 12 | "mask: \"bullet2\"\n" 13 | "embedded_collision_shape {\n" 14 | " shapes {\n" 15 | " shape_type: TYPE_BOX\n" 16 | " position {\n" 17 | " y: -0.8\n" 18 | " }\n" 19 | " rotation {\n" 20 | " }\n" 21 | " index: 0\n" 22 | " count: 3\n" 23 | " }\n" 24 | " data: 2.5\n" 25 | " data: 0.8\n" 26 | " data: 2.5\n" 27 | "}\n" 28 | "" 29 | } 30 | embedded_components { 31 | id: "model" 32 | type: "model" 33 | data: "mesh: \"/assets/images/tiles/base.dae\"\n" 34 | "name: \"unnamed\"\n" 35 | "materials {\n" 36 | " name: \"default\"\n" 37 | " material: \"/light_and_shadows/materials/model/model_world.material\"\n" 38 | " textures {\n" 39 | " sampler: \"tex0\"\n" 40 | " texture: \"/assets/images/tiles/bg.png\"\n" 41 | " }\n" 42 | " textures {\n" 43 | " sampler: \"tex1\"\n" 44 | " texture: \"/assets/images/tiles/bg.png\"\n" 45 | " }\n" 46 | "}\n" 47 | "" 48 | } 49 | -------------------------------------------------------------------------------- /assets/props/tiles/f4.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "collisionobject" 3 | type: "collisionobject" 4 | data: "type: COLLISION_OBJECT_TYPE_STATIC\n" 5 | "mass: 0.0\n" 6 | "friction: 0.1\n" 7 | "restitution: 0.5\n" 8 | "group: \"default\"\n" 9 | "mask: \"default\"\n" 10 | "mask: \"unit\"\n" 11 | "mask: \"bullet\"\n" 12 | "mask: \"bullet2\"\n" 13 | "embedded_collision_shape {\n" 14 | " shapes {\n" 15 | " shape_type: TYPE_BOX\n" 16 | " position {\n" 17 | " y: -0.8\n" 18 | " }\n" 19 | " rotation {\n" 20 | " }\n" 21 | " index: 0\n" 22 | " count: 3\n" 23 | " }\n" 24 | " data: 5.0\n" 25 | " data: 0.8\n" 26 | " data: 5.0\n" 27 | "}\n" 28 | "" 29 | } 30 | embedded_components { 31 | id: "model" 32 | type: "model" 33 | data: "mesh: \"/assets/images/tiles/base4.dae\"\n" 34 | "name: \"unnamed\"\n" 35 | "materials {\n" 36 | " name: \"default\"\n" 37 | " material: \"/light_and_shadows/materials/model/model_world.material\"\n" 38 | " textures {\n" 39 | " sampler: \"tex0\"\n" 40 | " texture: \"/assets/images/tiles/bg.png\"\n" 41 | " }\n" 42 | " textures {\n" 43 | " sampler: \"tex1\"\n" 44 | " texture: \"/assets/images/tiles/bg.png\"\n" 45 | " }\n" 46 | "}\n" 47 | "" 48 | } 49 | -------------------------------------------------------------------------------- /examples/tinyworld/materials/billboard_particlefx_nearest.material: -------------------------------------------------------------------------------- 1 | name: "particle" 2 | tags: "tile" 3 | vertex_program: "/light_and_shadows/materials/billboard_particle/billboard_particlefx.vp" 4 | fragment_program: "/light_and_shadows/materials/fog_particle/particlefx.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "proj" 11 | type: CONSTANT_TYPE_PROJECTION 12 | } 13 | fragment_constants { 14 | name: "tint" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 1.0 18 | y: 1.0 19 | z: 1.0 20 | w: 1.0 21 | } 22 | } 23 | fragment_constants { 24 | name: "fog_color" 25 | type: CONSTANT_TYPE_USER 26 | value { 27 | x: 0.9 28 | y: 0.9 29 | z: 0.9 30 | w: 1.0 31 | } 32 | } 33 | fragment_constants { 34 | name: "fog" 35 | type: CONSTANT_TYPE_USER 36 | value { 37 | x: 10.0 38 | y: 1000.0 39 | } 40 | } 41 | samplers { 42 | name: "texture_sampler" 43 | wrap_u: WRAP_MODE_REPEAT 44 | wrap_v: WRAP_MODE_REPEAT 45 | filter_min: FILTER_MODE_MIN_NEAREST 46 | filter_mag: FILTER_MODE_MAG_NEAREST 47 | max_anisotropy: 0.0 48 | } 49 | attributes { 50 | name: "local_position" 51 | semantic_type: SEMANTIC_TYPE_POSITION 52 | vector_type: VECTOR_TYPE_VEC3 53 | } 54 | -------------------------------------------------------------------------------- /light_and_shadows/materials/model/model_instanced.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // Positions can be world or local space, since world and normal 4 | // matrices are identity for world vertex space materials. 5 | // If world vertex space is selected, you can remove the 6 | // normal matrix multiplication for optimal performance. 7 | 8 | in highp vec4 position; 9 | in mediump vec2 texcoord0; 10 | in highp vec3 normal; 11 | 12 | // When 'mtx_world' and 'mtx_normal' is specified as attributes, 13 | // instanced rendering is automatically triggered. 14 | in highp mat4 mtx_world; 15 | in highp mat4 mtx_normal; 16 | 17 | uniform vs_uniforms 18 | { 19 | highp mat4 mtx_view; 20 | highp mat4 mtx_proj; 21 | highp mat4 mtx_light; 22 | }; 23 | 24 | out highp vec4 var_view_position; 25 | out highp vec4 var_position; 26 | out highp vec3 var_normal; 27 | out mediump vec2 var_texcoord0; 28 | out highp vec4 var_texcoord0_shadow; 29 | 30 | void main() 31 | { 32 | vec4 pw = mtx_world * vec4(position.xyz, 1.0); 33 | vec4 p = mtx_view * pw; 34 | var_view_position = p; 35 | var_position = pw; 36 | var_texcoord0 = texcoord0; 37 | var_texcoord0_shadow = mtx_light * pw; 38 | var_normal = normalize((mtx_world * vec4(normal, 0.0)).xyz); 39 | gl_Position = mtx_proj * p; 40 | 41 | } 42 | 43 | -------------------------------------------------------------------------------- /light_and_shadows/materials/model/model_world.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // Positions can be world or local space, since world and normal 4 | // matrices are identity for world vertex space materials. 5 | // If world vertex space is selected, you can remove the 6 | // normal matrix multiplication for optimal performance. 7 | 8 | in highp vec4 position; 9 | in mediump vec2 texcoord0; 10 | in highp vec3 normal; 11 | 12 | uniform vs_uniforms 13 | { 14 | highp mat4 mtx_normal; 15 | highp mat4 mtx_view; 16 | highp mat4 mtx_proj; 17 | highp mat4 mtx_light; 18 | }; 19 | 20 | out highp vec4 var_view_position; 21 | out highp vec4 var_position; 22 | out highp vec3 var_normal; 23 | out mediump vec2 var_texcoord0; 24 | out highp vec4 var_texcoord0_shadow; 25 | 26 | void main() 27 | { 28 | vec4 pw = vec4(position.xyz, 1.0); 29 | vec4 p = mtx_view * pw; 30 | var_view_position = p; 31 | var_position = pw; 32 | var_texcoord0 = texcoord0; 33 | var_texcoord0_shadow = mtx_light * pw; 34 | // If world vertex space is selected, you can remove the 35 | // normal matrix multiplication for optimal performance. 36 | // var_normal = normalize(normal); 37 | var_normal = normalize((mtx_normal * vec4(normal, 0.0)).xyz); 38 | gl_Position = mtx_proj * p; 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /assets/props/coin.go: -------------------------------------------------------------------------------- 1 | components { 2 | id: "coin" 3 | component: "/examples/example1/coin.script" 4 | } 5 | embedded_components { 6 | id: "collisionobject" 7 | type: "collisionobject" 8 | data: "type: COLLISION_OBJECT_TYPE_KINEMATIC\n" 9 | "mass: 0.0\n" 10 | "friction: 0.9\n" 11 | "restitution: 0.5\n" 12 | "group: \"coin\"\n" 13 | "mask: \"default\"\n" 14 | "mask: \"unit\"\n" 15 | "embedded_collision_shape {\n" 16 | " shapes {\n" 17 | " shape_type: TYPE_SPHERE\n" 18 | " position {\n" 19 | " }\n" 20 | " rotation {\n" 21 | " }\n" 22 | " index: 0\n" 23 | " count: 1\n" 24 | " }\n" 25 | " data: 2.5\n" 26 | "}\n" 27 | "linear_damping: 0.9\n" 28 | "locked_rotation: true\n" 29 | "" 30 | } 31 | embedded_components { 32 | id: "sprite" 33 | type: "sprite" 34 | data: "default_animation: \"Icon-coin\"\n" 35 | "material: \"/light_and_shadows/materials/sprite/light_sprite.material\"\n" 36 | "textures {\n" 37 | " sampler: \"tex0\"\n" 38 | " texture: \"/assets/rgba/tiles.atlas\"\n" 39 | "}\n" 40 | "textures {\n" 41 | " sampler: \"tex1\"\n" 42 | " texture: \"/assets/rgba/tiles.atlas\"\n" 43 | "}\n" 44 | "" 45 | rotation { 46 | x: -0.23004974 47 | w: 0.97317886 48 | } 49 | scale { 50 | x: 0.04 51 | y: 0.04 52 | z: 0.04 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /assets/props/tiles/grig10x10.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "collisionobject" 3 | type: "collisionobject" 4 | data: "type: COLLISION_OBJECT_TYPE_STATIC\n" 5 | "mass: 0.0\n" 6 | "friction: 0.1\n" 7 | "restitution: 0.5\n" 8 | "group: \"default\"\n" 9 | "mask: \"default\"\n" 10 | "mask: \"unit\"\n" 11 | "mask: \"bullet\"\n" 12 | "mask: \"bullet2\"\n" 13 | "embedded_collision_shape {\n" 14 | " shapes {\n" 15 | " shape_type: TYPE_BOX\n" 16 | " position {\n" 17 | " y: -0.5\n" 18 | " }\n" 19 | " rotation {\n" 20 | " }\n" 21 | " index: 0\n" 22 | " count: 3\n" 23 | " }\n" 24 | " data: 25.0\n" 25 | " data: 0.5\n" 26 | " data: 25.0\n" 27 | "}\n" 28 | "" 29 | } 30 | embedded_components { 31 | id: "model" 32 | type: "model" 33 | data: "mesh: \"/assets/images/tiles/grid10x10.dae\"\n" 34 | "name: \"unnamed\"\n" 35 | "materials {\n" 36 | " name: \"default\"\n" 37 | " material: \"/light_and_shadows/materials/model/model_instanced_nocast.material\"\n" 38 | " textures {\n" 39 | " sampler: \"tex0\"\n" 40 | " texture: \"/assets/images/tiles/bg.png\"\n" 41 | " }\n" 42 | " textures {\n" 43 | " sampler: \"tex1\"\n" 44 | " texture: \"/assets/images/tiles/bg.png\"\n" 45 | " }\n" 46 | "}\n" 47 | "" 48 | position { 49 | y: -0.01 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /examples/tinyworld/materials/model_instanced.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // Positions can be world or local space, since world and normal 4 | // matrices are identity for world vertex space materials. 5 | // If world vertex space is selected, you can remove the 6 | // normal matrix multiplication for optimal performance. 7 | 8 | in highp vec4 position; 9 | in mediump vec2 texcoord0; 10 | in highp vec3 normal; 11 | 12 | // When 'mtx_world' and 'mtx_normal' is specified as attributes, 13 | // instanced rendering is automatically triggered. 14 | #ifndef EDITOR 15 | in highp mat4 mtx_world; 16 | in highp mat4 mtx_normal; 17 | #endif 18 | 19 | uniform vs_uniforms 20 | { 21 | #ifdef EDITOR 22 | highp mat4 mtx_world; 23 | #endif 24 | highp mat4 mtx_view; 25 | highp mat4 mtx_proj; 26 | highp mat4 mtx_light; 27 | }; 28 | 29 | out highp vec4 var_view_position; 30 | out highp vec4 var_position; 31 | out highp vec3 var_normal; 32 | out mediump vec2 var_texcoord0; 33 | out highp vec4 var_texcoord0_shadow; 34 | 35 | void main() 36 | { 37 | vec4 pw = mtx_world * vec4(position.xyz, 1.0); 38 | vec4 p = mtx_view * pw; 39 | var_view_position = p; 40 | var_position = pw; 41 | var_texcoord0 = texcoord0; 42 | var_texcoord0_shadow = mtx_light * pw; 43 | var_normal = normalize((mtx_world * vec4(normal, 0.0)).xyz); 44 | gl_Position = mtx_proj * p; 45 | 46 | } 47 | 48 | -------------------------------------------------------------------------------- /light_and_shadows/materials/model/skinned/model_skinned.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // Positions can be world or local space, since world and normal 4 | // matrices are identity for world vertex space materials. 5 | // If world vertex space is selected, you can remove the 6 | // normal matrix multiplication for optimal performance. 7 | 8 | in highp vec4 position; 9 | in mediump vec2 texcoord0; 10 | in highp vec3 normal; 11 | in mediump vec4 bone_weights; 12 | in mediump vec4 bone_indices; 13 | 14 | uniform vs_uniforms 15 | { 16 | highp mat4 mtx_world; 17 | highp mat4 mtx_normal; 18 | highp mat4 mtx_view; 19 | highp mat4 mtx_proj; 20 | highp mat4 mtx_light; 21 | mediump vec4 animation_data; 22 | }; 23 | 24 | out highp vec4 var_view_position; 25 | out highp vec4 var_position; 26 | out highp vec3 var_normal; 27 | out mediump vec2 var_texcoord0; 28 | out highp vec4 var_texcoord0_shadow; 29 | 30 | #include "/builtins/materials/skinning.glsl" 31 | 32 | void main() 33 | { 34 | vec4 skinned_position = get_skinned_position(position); 35 | vec4 pw = mtx_world * vec4(skinned_position.xyz, 1.0); 36 | vec4 p = mtx_view * pw; 37 | var_view_position = p; 38 | var_position = pw; 39 | var_texcoord0 = texcoord0; 40 | var_texcoord0_shadow = mtx_light * pw; 41 | var_normal = normalize((mtx_world * vec4(normal, 0.0)).xyz); 42 | gl_Position = mtx_proj * p; 43 | 44 | } 45 | 46 | -------------------------------------------------------------------------------- /examples/tinyworld/materials/shadow_mesh/model3.material: -------------------------------------------------------------------------------- 1 | name: "model3" 2 | tags: "model3" 3 | vertex_program: "/examples/tinyworld/materials/shadow_mesh/model3.vp" 4 | fragment_program: "/examples/tinyworld/materials/shadow_mesh/model3.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_view" 8 | type: CONSTANT_TYPE_VIEW 9 | } 10 | vertex_constants { 11 | name: "mtx_proj" 12 | type: CONSTANT_TYPE_PROJECTION 13 | } 14 | vertex_constants { 15 | name: "mtx_world" 16 | type: CONSTANT_TYPE_WORLD 17 | } 18 | fragment_constants { 19 | name: "tint" 20 | type: CONSTANT_TYPE_USER 21 | value { 22 | x: 1.0 23 | y: 1.0 24 | z: 1.0 25 | w: 1.0 26 | } 27 | } 28 | fragment_constants { 29 | name: "ambient" 30 | type: CONSTANT_TYPE_USER 31 | value { 32 | x: 0.8 33 | y: 0.8 34 | z: 0.8 35 | w: 1.0 36 | } 37 | } 38 | fragment_constants { 39 | name: "fog_color" 40 | type: CONSTANT_TYPE_USER 41 | value { 42 | x: 0.5 43 | y: 0.5 44 | z: 0.5 45 | w: 1.0 46 | } 47 | } 48 | fragment_constants { 49 | name: "fog" 50 | type: CONSTANT_TYPE_USER 51 | value { 52 | x: 1000.0 53 | y: 10000.0 54 | } 55 | } 56 | samplers { 57 | name: "tex0" 58 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 59 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 60 | filter_min: FILTER_MODE_MIN_NEAREST 61 | filter_mag: FILTER_MODE_MAG_NEAREST 62 | max_anisotropy: 0.0 63 | } 64 | -------------------------------------------------------------------------------- /light_and_shadows/materials/post/mix/mix.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in mediump vec2 var_texcoord0; 4 | uniform mediump sampler2D tex0; 5 | uniform mediump sampler2D tex1; 6 | uniform mediump sampler2D depth; 7 | 8 | uniform fs_uniforms 9 | { 10 | highp vec4 dof; 11 | }; 12 | 13 | out vec4 out_fragColor; 14 | 15 | void main() 16 | { 17 | // regular color texture (render target) 18 | vec3 color = texture(tex0, var_texcoord0).rgb; 19 | // blured render target 20 | vec3 blured = texture(tex1, var_texcoord0).rgb; 21 | // depth buffer texture 22 | float z = texture(depth, var_texcoord0).r; 23 | float near_z = dof.x; 24 | float far_z = dof.y; 25 | float cam_z = dof.z; 26 | float _focus_range = dof.w; 27 | float coef = cam_z / (far_z - near_z); // normalize focus distance 28 | 29 | // Linearized Depth Buffer Values for Depth of Field 30 | float d = (2.0 * near_z) / (far_z + near_z - z * (far_z - near_z)); 31 | 32 | // Circle of Confusion 33 | float focus_distance = coef * 1.75; 34 | float focus_range = coef * _focus_range; 35 | float coc = (d - focus_distance) / focus_range; 36 | coc = abs(clamp(coc, -1, 1)); 37 | 38 | // d = abs(d*d -.5) * 2. - coef; 39 | 40 | // DEBUG: 41 | // if (var_texcoord0.x > 0.75) 42 | // out_fragColor = vec4(vec3(coc), 1.); 43 | // else 44 | out_fragColor = vec4(mix(color, blured, clamp(coc, 0., 1.0)), 1.); 45 | 46 | 47 | } 48 | 49 | -------------------------------------------------------------------------------- /light_and_shadows/materials/sprite/parallax/bg_parallax_sprite.material: -------------------------------------------------------------------------------- 1 | name: "bg_parallax_sprite" 2 | tags: "tile" 3 | vertex_program: "/light_and_shadows/materials/sprite/parallax/bg_sprite.vp" 4 | fragment_program: "/light_and_shadows/materials/sprite/parallax/bg_sprite.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "mtx_view" 11 | type: CONSTANT_TYPE_VIEW 12 | } 13 | fragment_constants { 14 | name: "tint" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 1.0 18 | y: 1.0 19 | z: 1.0 20 | w: 1.0 21 | } 22 | } 23 | fragment_constants { 24 | name: "fog" 25 | type: CONSTANT_TYPE_USER 26 | value { 27 | x: 1000.0 28 | y: 1000.0 29 | } 30 | } 31 | fragment_constants { 32 | name: "ambient" 33 | type: CONSTANT_TYPE_USER 34 | value { 35 | x: 1.0 36 | y: 1.0 37 | z: 1.0 38 | } 39 | } 40 | fragment_constants { 41 | name: "fog_color" 42 | type: CONSTANT_TYPE_USER 43 | value { 44 | x: 0.8 45 | y: 0.8 46 | z: 0.8 47 | } 48 | } 49 | samplers { 50 | name: "texture_sampler" 51 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 52 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 53 | filter_min: FILTER_MODE_MIN_DEFAULT 54 | filter_mag: FILTER_MODE_MAG_DEFAULT 55 | max_anisotropy: 0.0 56 | } 57 | attributes { 58 | name: "parallax" 59 | double_values { 60 | v: 0.5 61 | v: 0.0 62 | v: 0.9 63 | } 64 | vector_type: VECTOR_TYPE_VEC3 65 | } 66 | -------------------------------------------------------------------------------- /light_and_shadows/constants.lua: -------------------------------------------------------------------------------- 1 | local clear_color = vmath.vector4(0.1, 0.1, 0.5, 1) 2 | local fog_color = vmath.vector4(0.1, 0.1, 0.5, 1) 3 | local fog = vmath.vector4(20, 120, 1, 0) 4 | local ambient_default = vmath.vector4(0.1, 0.1, 0.1, 1) 5 | 6 | -- Special module to access light options in renderscript. 7 | -- Renderscript is going to forward this values into shader uniform constants. 8 | return { 9 | clear_color = clear_color, 10 | fog = fog, 11 | ambient = ambient_default, 12 | fog_color = fog_color, 13 | -- List of light sources. Their world position and colors. 14 | -- v0 is a zero vector4. This value will be assigned in case if there are no sources, or amount of sources less 16 (max in demo). 15 | -- "Lights" is an indices array. Only first 16 (max in this demo) sources will be used in shader. 16 | lights = { 17 | -- {position = v0, color = v0, distance = 1, power = 1}, 18 | }, 19 | 20 | cam_position = vmath.vector4(0, 0, 0, 0), 21 | cam_look_at_position = vmath.vector3(0, 0, 0), 22 | sun_position = vmath.vector4(-10, 10, 9, 0), 23 | sun_color = vmath.vector4(0.75, 0.75, 0.5, 0), 24 | sun_dir = vmath.vector3(.1, -10, .1 ), 25 | shadow_color = vmath.vector4(0.25, 0.25, 0.5, 0), 26 | cam_z = 100, -- camera Z coord (a distance from focus point) 27 | focus_range = 1.2, -- how wide is a focus zone 28 | near_z = 10, -- camera near Z plane 29 | far_z = 1000 -- camera far Z plane 30 | } -------------------------------------------------------------------------------- /examples/tinyworld/3D/b2.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "model" 3 | type: "model" 4 | data: "mesh: \"/examples/tinyworld/models/block2.gltf\"\n" 5 | "name: \"unnamed\"\n" 6 | "materials {\n" 7 | " name: \"material_0\"\n" 8 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 9 | " textures {\n" 10 | " sampler: \"tex0\"\n" 11 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 12 | " }\n" 13 | "}\n" 14 | "" 15 | } 16 | embedded_components { 17 | id: "model1" 18 | type: "model" 19 | data: "mesh: \"/examples/tinyworld/models/block.gltf\"\n" 20 | "name: \"unnamed\"\n" 21 | "materials {\n" 22 | " name: \"material_0\"\n" 23 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 24 | " textures {\n" 25 | " sampler: \"tex0\"\n" 26 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 27 | " }\n" 28 | "}\n" 29 | "" 30 | position { 31 | y: 1.0 32 | } 33 | } 34 | embedded_components { 35 | id: "model2" 36 | type: "model" 37 | data: "mesh: \"/examples/tinyworld/models/block4.gltf\"\n" 38 | "name: \"unnamed\"\n" 39 | "materials {\n" 40 | " name: \"material_0\"\n" 41 | " material: \"/examples/tinyworld/materials/model_instanced_nearest.material\"\n" 42 | " textures {\n" 43 | " sampler: \"tex0\"\n" 44 | " texture: \"/examples/tinyworld/models/texture.png\"\n" 45 | " }\n" 46 | "}\n" 47 | "" 48 | position { 49 | y: 2.0 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /light_and_shadows/materials/mesh/mesh.material: -------------------------------------------------------------------------------- 1 | name: "mesh" 2 | tags: "model" 3 | tags: "shadow" 4 | vertex_program: "/light_and_shadows/materials/mesh/mesh.vp" 5 | fragment_program: "/light_and_shadows/materials/mesh/mesh.fp" 6 | vertex_constants { 7 | name: "mtx_view" 8 | type: CONSTANT_TYPE_VIEW 9 | } 10 | vertex_constants { 11 | name: "mtx_proj" 12 | type: CONSTANT_TYPE_PROJECTION 13 | } 14 | vertex_constants { 15 | name: "mtx_normal" 16 | type: CONSTANT_TYPE_NORMAL 17 | } 18 | fragment_constants { 19 | name: "tint" 20 | type: CONSTANT_TYPE_USER 21 | value { 22 | x: 1.0 23 | y: 1.0 24 | z: 1.0 25 | w: 1.0 26 | } 27 | } 28 | fragment_constants { 29 | name: "ambient" 30 | type: CONSTANT_TYPE_USER 31 | value { 32 | x: 0.8 33 | y: 0.8 34 | z: 0.8 35 | w: 1.0 36 | } 37 | } 38 | fragment_constants { 39 | name: "fog_color" 40 | type: CONSTANT_TYPE_USER 41 | value { 42 | x: 0.5 43 | y: 0.5 44 | z: 0.5 45 | w: 1.0 46 | } 47 | } 48 | fragment_constants { 49 | name: "fog" 50 | type: CONSTANT_TYPE_USER 51 | value { 52 | x: 1000.0 53 | y: 10000.0 54 | w: 1.0 55 | } 56 | } 57 | samplers { 58 | name: "tex0" 59 | wrap_u: WRAP_MODE_REPEAT 60 | wrap_v: WRAP_MODE_REPEAT 61 | filter_min: FILTER_MODE_MIN_DEFAULT 62 | filter_mag: FILTER_MODE_MAG_DEFAULT 63 | } 64 | samplers { 65 | name: "tex1" 66 | wrap_u: WRAP_MODE_REPEAT 67 | wrap_v: WRAP_MODE_REPEAT 68 | filter_min: FILTER_MODE_MIN_NEAREST 69 | filter_mag: FILTER_MODE_MAG_NEAREST 70 | } 71 | -------------------------------------------------------------------------------- /light_and_shadows/materials/model/model_world.material: -------------------------------------------------------------------------------- 1 | name: "model_world" 2 | tags: "model" 3 | tags: "shadow" 4 | vertex_program: "/light_and_shadows/materials/model/model_world.vp" 5 | fragment_program: "/light_and_shadows/materials/model/model.fp" 6 | vertex_constants { 7 | name: "mtx_view" 8 | type: CONSTANT_TYPE_VIEW 9 | } 10 | vertex_constants { 11 | name: "mtx_proj" 12 | type: CONSTANT_TYPE_PROJECTION 13 | } 14 | fragment_constants { 15 | name: "tint" 16 | type: CONSTANT_TYPE_USER 17 | value { 18 | x: 1.0 19 | y: 1.0 20 | z: 1.0 21 | w: 1.0 22 | } 23 | } 24 | fragment_constants { 25 | name: "ambient" 26 | type: CONSTANT_TYPE_USER 27 | value { 28 | x: 0.8 29 | y: 0.8 30 | z: 0.8 31 | w: 1.0 32 | } 33 | } 34 | fragment_constants { 35 | name: "fog_color" 36 | type: CONSTANT_TYPE_USER 37 | value { 38 | x: 0.5 39 | y: 0.5 40 | z: 0.5 41 | w: 1.0 42 | } 43 | } 44 | fragment_constants { 45 | name: "fog" 46 | type: CONSTANT_TYPE_USER 47 | value { 48 | x: 1000.0 49 | y: 10000.0 50 | } 51 | } 52 | samplers { 53 | name: "tex0" 54 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 55 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 56 | filter_min: FILTER_MODE_MIN_DEFAULT 57 | filter_mag: FILTER_MODE_MAG_DEFAULT 58 | max_anisotropy: 0.0 59 | } 60 | samplers { 61 | name: "tex1" 62 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 63 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 64 | filter_min: FILTER_MODE_MIN_NEAREST 65 | filter_mag: FILTER_MODE_MAG_NEAREST 66 | max_anisotropy: 0.0 67 | } 68 | -------------------------------------------------------------------------------- /examples/tinyworld/materials/rgss.glsl: -------------------------------------------------------------------------------- 1 | // Rotated Grid Super-Sampling (RGSS) 2 | 3 | #ifdef GL_OES_standard_derivatives 4 | #extension GL_OES_standard_derivatives : enable 5 | #endif 6 | 7 | // Derivative functions are available on: 8 | // - OpenGL (desktop). 9 | // - OpenGL ES 3.0, WebGL 2.0. 10 | // - OpenGL ES 2.0, WebGL 1.0, if the extension GL_OES_standard_derivatives is enabled. 11 | #if !defined(GL_ES) || __VERSION__ >= 300 || defined(GL_OES_standard_derivatives) 12 | // Rotated grid UV offsets 13 | const mediump vec2 rgss_uv_offsets = vec2(0.125, 0.375); 14 | 15 | mediump vec4 rgss_tex2D(mediump sampler2D texture_sampler, highp vec2 uv, mediump float bias) 16 | { 17 | // Per pixel partial derivatives 18 | mediump vec2 dx = dFdx(uv); 19 | mediump vec2 dy = dFdy(uv); 20 | 21 | // Supersampled using 2x2 rotated grid 22 | mediump vec4 col = texture(texture_sampler, vec2(uv + rgss_uv_offsets.x * dx + rgss_uv_offsets.y * dy), bias); 23 | col += texture(texture_sampler, vec2(uv - rgss_uv_offsets.x * dx - rgss_uv_offsets.y * dy), bias); 24 | col += texture(texture_sampler, vec2(uv + rgss_uv_offsets.y * dx - rgss_uv_offsets.x * dy), bias); 25 | col += texture(texture_sampler, vec2(uv - rgss_uv_offsets.y * dx + rgss_uv_offsets.x * dy), bias); 26 | 27 | col *= 0.25; 28 | 29 | return col; 30 | } 31 | #else 32 | // A fallback in the case of derivatives lack 33 | mediump vec4 rgss_tex2D(mediump sampler2D texture_sampler, highp vec2 uv, mediump float bias) 34 | { 35 | return texture(texture_sampler, uv, bias); 36 | } 37 | #endif -------------------------------------------------------------------------------- /light_and_shadows/materials/model/model_instanced_nocast.material: -------------------------------------------------------------------------------- 1 | name: "model_instanced" 2 | tags: "model" 3 | vertex_program: "/light_and_shadows/materials/model/model_instanced.vp" 4 | fragment_program: "/light_and_shadows/materials/model/model.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_view" 8 | type: CONSTANT_TYPE_VIEW 9 | } 10 | vertex_constants { 11 | name: "mtx_proj" 12 | type: CONSTANT_TYPE_PROJECTION 13 | } 14 | fragment_constants { 15 | name: "tint" 16 | type: CONSTANT_TYPE_USER 17 | value { 18 | x: 1.0 19 | y: 1.0 20 | z: 1.0 21 | w: 1.0 22 | } 23 | } 24 | fragment_constants { 25 | name: "ambient" 26 | type: CONSTANT_TYPE_USER 27 | value { 28 | x: 0.8 29 | y: 0.8 30 | z: 0.8 31 | w: 1.0 32 | } 33 | } 34 | fragment_constants { 35 | name: "fog_color" 36 | type: CONSTANT_TYPE_USER 37 | value { 38 | x: 0.5 39 | y: 0.5 40 | z: 0.5 41 | w: 1.0 42 | } 43 | } 44 | fragment_constants { 45 | name: "fog" 46 | type: CONSTANT_TYPE_USER 47 | value { 48 | x: 1000.0 49 | y: 10000.0 50 | } 51 | } 52 | samplers { 53 | name: "tex0" 54 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 55 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 56 | filter_min: FILTER_MODE_MIN_DEFAULT 57 | filter_mag: FILTER_MODE_MAG_DEFAULT 58 | max_anisotropy: 0.0 59 | } 60 | samplers { 61 | name: "tex1" 62 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 63 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 64 | filter_min: FILTER_MODE_MIN_NEAREST 65 | filter_mag: FILTER_MODE_MAG_NEAREST 66 | max_anisotropy: 0.0 67 | } 68 | -------------------------------------------------------------------------------- /light_and_shadows/materials/model/model_instanced.material: -------------------------------------------------------------------------------- 1 | name: "model_instanced" 2 | tags: "model" 3 | tags: "shadow_instanced" 4 | vertex_program: "/light_and_shadows/materials/model/model_instanced.vp" 5 | fragment_program: "/light_and_shadows/materials/model/model.fp" 6 | vertex_space: VERTEX_SPACE_LOCAL 7 | vertex_constants { 8 | name: "mtx_view" 9 | type: CONSTANT_TYPE_VIEW 10 | } 11 | vertex_constants { 12 | name: "mtx_proj" 13 | type: CONSTANT_TYPE_PROJECTION 14 | } 15 | fragment_constants { 16 | name: "tint" 17 | type: CONSTANT_TYPE_USER 18 | value { 19 | x: 1.0 20 | y: 1.0 21 | z: 1.0 22 | w: 1.0 23 | } 24 | } 25 | fragment_constants { 26 | name: "ambient" 27 | type: CONSTANT_TYPE_USER 28 | value { 29 | x: 0.8 30 | y: 0.8 31 | z: 0.8 32 | w: 1.0 33 | } 34 | } 35 | fragment_constants { 36 | name: "fog_color" 37 | type: CONSTANT_TYPE_USER 38 | value { 39 | x: 0.5 40 | y: 0.5 41 | z: 0.5 42 | w: 1.0 43 | } 44 | } 45 | fragment_constants { 46 | name: "fog" 47 | type: CONSTANT_TYPE_USER 48 | value { 49 | x: 1000.0 50 | y: 10000.0 51 | } 52 | } 53 | samplers { 54 | name: "tex0" 55 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 56 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 57 | filter_min: FILTER_MODE_MIN_DEFAULT 58 | filter_mag: FILTER_MODE_MAG_DEFAULT 59 | max_anisotropy: 0.0 60 | } 61 | samplers { 62 | name: "tex1" 63 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 64 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 65 | filter_min: FILTER_MODE_MIN_NEAREST 66 | filter_mag: FILTER_MODE_MAG_NEAREST 67 | max_anisotropy: 0.0 68 | } 69 | -------------------------------------------------------------------------------- /light_and_shadows/materials/model/model_world_nocast.material: -------------------------------------------------------------------------------- 1 | name: "model_world" 2 | tags: "model" 3 | vertex_program: "/light_and_shadows/materials/model/model_world.vp" 4 | fragment_program: "/light_and_shadows/materials/model/model.fp" 5 | vertex_constants { 6 | name: "mtx_view" 7 | type: CONSTANT_TYPE_VIEW 8 | } 9 | vertex_constants { 10 | name: "mtx_proj" 11 | type: CONSTANT_TYPE_PROJECTION 12 | } 13 | vertex_constants { 14 | name: "mtx_normal" 15 | type: CONSTANT_TYPE_NORMAL 16 | } 17 | fragment_constants { 18 | name: "tint" 19 | type: CONSTANT_TYPE_USER 20 | value { 21 | x: 1.0 22 | y: 1.0 23 | z: 1.0 24 | w: 1.0 25 | } 26 | } 27 | fragment_constants { 28 | name: "ambient" 29 | type: CONSTANT_TYPE_USER 30 | value { 31 | x: 0.8 32 | y: 0.8 33 | z: 0.8 34 | w: 1.0 35 | } 36 | } 37 | fragment_constants { 38 | name: "fog_color" 39 | type: CONSTANT_TYPE_USER 40 | value { 41 | x: 0.5 42 | y: 0.5 43 | z: 0.5 44 | w: 1.0 45 | } 46 | } 47 | fragment_constants { 48 | name: "fog" 49 | type: CONSTANT_TYPE_USER 50 | value { 51 | x: 1000.0 52 | y: 10000.0 53 | } 54 | } 55 | samplers { 56 | name: "tex0" 57 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 58 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 59 | filter_min: FILTER_MODE_MIN_DEFAULT 60 | filter_mag: FILTER_MODE_MAG_DEFAULT 61 | max_anisotropy: 0.0 62 | } 63 | samplers { 64 | name: "tex1" 65 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 66 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 67 | filter_min: FILTER_MODE_MIN_NEAREST 68 | filter_mag: FILTER_MODE_MAG_NEAREST 69 | max_anisotropy: 0.0 70 | } 71 | -------------------------------------------------------------------------------- /examples/tinyworld/materials/tilemap.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "bgtile" 3 | vertex_program: "/light_and_shadows/materials/sprite/sprite.vp" 4 | fragment_program: "/light_and_shadows/materials/sprite/sprite.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "mtx_view" 11 | type: CONSTANT_TYPE_VIEW 12 | } 13 | vertex_constants { 14 | name: "normal" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | y: 1.0 18 | } 19 | } 20 | fragment_constants { 21 | name: "tint" 22 | type: CONSTANT_TYPE_USER 23 | value { 24 | x: 1.0 25 | y: 1.0 26 | z: 1.0 27 | w: 1.0 28 | } 29 | } 30 | fragment_constants { 31 | name: "ambient" 32 | type: CONSTANT_TYPE_USER 33 | value { 34 | x: 0.8 35 | y: 0.8 36 | z: 0.8 37 | w: 1.0 38 | } 39 | } 40 | fragment_constants { 41 | name: "fog_color" 42 | type: CONSTANT_TYPE_USER 43 | value { 44 | x: 0.5 45 | y: 0.5 46 | z: 0.5 47 | w: 1.0 48 | } 49 | } 50 | fragment_constants { 51 | name: "fog" 52 | type: CONSTANT_TYPE_USER 53 | value { 54 | x: 1000.0 55 | y: 10000.0 56 | w: 1.0 57 | } 58 | } 59 | samplers { 60 | name: "tex0" 61 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 62 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 63 | filter_min: FILTER_MODE_MIN_NEAREST 64 | filter_mag: FILTER_MODE_MAG_NEAREST 65 | max_anisotropy: 0.0 66 | } 67 | samplers { 68 | name: "tex1" 69 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 70 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 71 | filter_min: FILTER_MODE_MIN_NEAREST 72 | filter_mag: FILTER_MODE_MAG_NEAREST 73 | max_anisotropy: 0.0 74 | } 75 | -------------------------------------------------------------------------------- /examples/tinyworld/materials/billboard_model_instanced_nearest.material: -------------------------------------------------------------------------------- 1 | name: "model_instanced" 2 | tags: "model2" 3 | tags: "shadow_instanced_billboard" 4 | vertex_program: "/light_and_shadows/materials/model/billboard/billboard_model_instanced.vp" 5 | fragment_program: "/examples/tinyworld/materials/model_emissive.fp" 6 | vertex_space: VERTEX_SPACE_LOCAL 7 | vertex_constants { 8 | name: "mtx_view" 9 | type: CONSTANT_TYPE_VIEW 10 | } 11 | vertex_constants { 12 | name: "mtx_proj" 13 | type: CONSTANT_TYPE_PROJECTION 14 | } 15 | fragment_constants { 16 | name: "tint" 17 | type: CONSTANT_TYPE_USER 18 | value { 19 | x: 1.0 20 | y: 1.0 21 | z: 1.0 22 | w: 1.0 23 | } 24 | } 25 | fragment_constants { 26 | name: "ambient" 27 | type: CONSTANT_TYPE_USER 28 | value { 29 | x: 0.8 30 | y: 0.8 31 | z: 0.8 32 | w: 1.0 33 | } 34 | } 35 | fragment_constants { 36 | name: "fog_color" 37 | type: CONSTANT_TYPE_USER 38 | value { 39 | x: 0.5 40 | y: 0.5 41 | z: 0.5 42 | w: 1.0 43 | } 44 | } 45 | fragment_constants { 46 | name: "fog" 47 | type: CONSTANT_TYPE_USER 48 | value { 49 | x: 1000.0 50 | y: 10000.0 51 | } 52 | } 53 | samplers { 54 | name: "tex0" 55 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 56 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 57 | filter_min: FILTER_MODE_MIN_NEAREST 58 | filter_mag: FILTER_MODE_MAG_NEAREST 59 | max_anisotropy: 0.0 60 | } 61 | samplers { 62 | name: "tex1" 63 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 64 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 65 | filter_min: FILTER_MODE_MIN_NEAREST 66 | filter_mag: FILTER_MODE_MAG_NEAREST 67 | max_anisotropy: 0.0 68 | } 69 | -------------------------------------------------------------------------------- /light_and_shadows/materials/sprite/light_sprite_back.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "atile" 3 | vertex_program: "/light_and_shadows/materials/sprite/sprite.vp" 4 | fragment_program: "/light_and_shadows/materials/sprite/sprite.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "mtx_view" 11 | type: CONSTANT_TYPE_VIEW 12 | } 13 | vertex_constants { 14 | name: "normal" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | y: 1.0 18 | } 19 | } 20 | fragment_constants { 21 | name: "tint" 22 | type: CONSTANT_TYPE_USER 23 | value { 24 | x: 1.0 25 | y: 1.0 26 | z: 1.0 27 | w: 1.0 28 | } 29 | } 30 | fragment_constants { 31 | name: "ambient" 32 | type: CONSTANT_TYPE_USER 33 | value { 34 | x: 0.8 35 | y: 0.8 36 | z: 0.8 37 | w: 1.0 38 | } 39 | } 40 | fragment_constants { 41 | name: "fog_color" 42 | type: CONSTANT_TYPE_USER 43 | value { 44 | x: 0.5 45 | y: 0.5 46 | z: 0.5 47 | w: 1.0 48 | } 49 | } 50 | fragment_constants { 51 | name: "fog" 52 | type: CONSTANT_TYPE_USER 53 | value { 54 | x: 1000.0 55 | y: 10000.0 56 | w: 1.0 57 | } 58 | } 59 | samplers { 60 | name: "tex0" 61 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 62 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 63 | filter_min: FILTER_MODE_MIN_DEFAULT 64 | filter_mag: FILTER_MODE_MAG_DEFAULT 65 | max_anisotropy: 0.0 66 | } 67 | samplers { 68 | name: "tex1" 69 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 70 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 71 | filter_min: FILTER_MODE_MIN_NEAREST 72 | filter_mag: FILTER_MODE_MAG_NEAREST 73 | max_anisotropy: 0.0 74 | } 75 | -------------------------------------------------------------------------------- /light_and_shadows/materials/model/billboard/billboard_model_instanced.material: -------------------------------------------------------------------------------- 1 | name: "billboard_model_instanced" 2 | tags: "model2" 3 | tags: "shadow_instanced_billboard" 4 | vertex_program: "/light_and_shadows/materials/model/billboard/billboard_model_instanced.vp" 5 | fragment_program: "/light_and_shadows/materials/model/model.fp" 6 | vertex_space: VERTEX_SPACE_LOCAL 7 | vertex_constants { 8 | name: "mtx_view" 9 | type: CONSTANT_TYPE_VIEW 10 | } 11 | vertex_constants { 12 | name: "mtx_proj" 13 | type: CONSTANT_TYPE_PROJECTION 14 | } 15 | fragment_constants { 16 | name: "tint" 17 | type: CONSTANT_TYPE_USER 18 | value { 19 | x: 1.0 20 | y: 1.0 21 | z: 1.0 22 | w: 1.0 23 | } 24 | } 25 | fragment_constants { 26 | name: "ambient" 27 | type: CONSTANT_TYPE_USER 28 | value { 29 | x: 0.8 30 | y: 0.8 31 | z: 0.8 32 | w: 1.0 33 | } 34 | } 35 | fragment_constants { 36 | name: "fog_color" 37 | type: CONSTANT_TYPE_USER 38 | value { 39 | x: 0.5 40 | y: 0.5 41 | z: 0.5 42 | w: 1.0 43 | } 44 | } 45 | fragment_constants { 46 | name: "fog" 47 | type: CONSTANT_TYPE_USER 48 | value { 49 | x: 1000.0 50 | y: 10000.0 51 | } 52 | } 53 | samplers { 54 | name: "tex0" 55 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 56 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 57 | filter_min: FILTER_MODE_MIN_DEFAULT 58 | filter_mag: FILTER_MODE_MAG_DEFAULT 59 | max_anisotropy: 0.0 60 | } 61 | samplers { 62 | name: "tex1" 63 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 64 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 65 | filter_min: FILTER_MODE_MIN_NEAREST 66 | filter_mag: FILTER_MODE_MAG_NEAREST 67 | max_anisotropy: 0.0 68 | } 69 | -------------------------------------------------------------------------------- /light_and_shadows/materials/spine/light_spine.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | tags: "shadow" 4 | vertex_program: "/light_and_shadows/materials/spine/spine.vp" 5 | fragment_program: "/light_and_shadows/materials/sprite/sprite.fp" 6 | vertex_constants { 7 | name: "mtx_view" 8 | type: CONSTANT_TYPE_VIEW 9 | } 10 | vertex_constants { 11 | name: "normal" 12 | type: CONSTANT_TYPE_USER 13 | value { 14 | z: 1.0 15 | } 16 | } 17 | vertex_constants { 18 | name: "world_view_proj" 19 | type: CONSTANT_TYPE_WORLDVIEWPROJ 20 | } 21 | fragment_constants { 22 | name: "tint" 23 | type: CONSTANT_TYPE_USER 24 | value { 25 | x: 1.0 26 | y: 1.0 27 | z: 1.0 28 | w: 1.0 29 | } 30 | } 31 | fragment_constants { 32 | name: "ambient" 33 | type: CONSTANT_TYPE_USER 34 | value { 35 | x: 0.8 36 | y: 0.8 37 | z: 0.8 38 | w: 1.0 39 | } 40 | } 41 | fragment_constants { 42 | name: "fog_color" 43 | type: CONSTANT_TYPE_USER 44 | value { 45 | x: 0.5 46 | y: 0.5 47 | z: 0.5 48 | w: 1.0 49 | } 50 | } 51 | fragment_constants { 52 | name: "fog" 53 | type: CONSTANT_TYPE_USER 54 | value { 55 | x: 1000.0 56 | y: 10000.0 57 | } 58 | } 59 | samplers { 60 | name: "tex0" 61 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 62 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 63 | filter_min: FILTER_MODE_MIN_DEFAULT 64 | filter_mag: FILTER_MODE_MAG_DEFAULT 65 | max_anisotropy: 0.0 66 | } 67 | samplers { 68 | name: "tex1" 69 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 70 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 71 | filter_min: FILTER_MODE_MIN_NEAREST 72 | filter_mag: FILTER_MODE_MAG_NEAREST 73 | max_anisotropy: 0.0 74 | } 75 | -------------------------------------------------------------------------------- /light_and_shadows/materials/sprite/light_sprite_up.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | tags: "shadow" 4 | vertex_program: "/light_and_shadows/materials/sprite/sprite.vp" 5 | fragment_program: "/light_and_shadows/materials/sprite/sprite.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "mtx_view" 12 | type: CONSTANT_TYPE_VIEW 13 | } 14 | vertex_constants { 15 | name: "normal" 16 | type: CONSTANT_TYPE_USER 17 | value { 18 | y: 1.0 19 | } 20 | } 21 | fragment_constants { 22 | name: "tint" 23 | type: CONSTANT_TYPE_USER 24 | value { 25 | x: 1.0 26 | y: 1.0 27 | z: 1.0 28 | w: 1.0 29 | } 30 | } 31 | fragment_constants { 32 | name: "ambient" 33 | type: CONSTANT_TYPE_USER 34 | value { 35 | x: 0.8 36 | y: 0.8 37 | z: 0.8 38 | w: 1.0 39 | } 40 | } 41 | fragment_constants { 42 | name: "fog_color" 43 | type: CONSTANT_TYPE_USER 44 | value { 45 | x: 0.5 46 | y: 0.5 47 | z: 0.5 48 | w: 1.0 49 | } 50 | } 51 | fragment_constants { 52 | name: "fog" 53 | type: CONSTANT_TYPE_USER 54 | value { 55 | x: 1000.0 56 | y: 10000.0 57 | } 58 | } 59 | samplers { 60 | name: "tex0" 61 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 62 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 63 | filter_min: FILTER_MODE_MIN_DEFAULT 64 | filter_mag: FILTER_MODE_MAG_DEFAULT 65 | max_anisotropy: 0.0 66 | } 67 | samplers { 68 | name: "tex1" 69 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 70 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 71 | filter_min: FILTER_MODE_MIN_NEAREST 72 | filter_mag: FILTER_MODE_MAG_NEAREST 73 | max_anisotropy: 0.0 74 | } 75 | -------------------------------------------------------------------------------- /light_and_shadows/materials/model/skinned/model_skinned_instanced.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // Positions can be world or local space, since world and normal 4 | // matrices are identity for world vertex space materials. 5 | // If world vertex space is selected, you can remove the 6 | // normal matrix multiplication for optimal performance. 7 | 8 | in highp vec4 position; 9 | in mediump vec2 texcoord0; 10 | in highp vec3 normal; 11 | in mediump vec4 bone_weights; 12 | in mediump vec4 bone_indices; 13 | 14 | // When 'mtx_world' and 'mtx_normal' is specified as attributes, 15 | // instanced rendering is automatically triggered. 16 | // To read more about instancing in Defold, navigate to 17 | // https://defold.com/manuals/material/#instancing 18 | in mediump mat4 mtx_world; 19 | in mediump mat4 mtx_normal; 20 | in mediump vec4 animation_data; 21 | 22 | uniform vs_uniforms 23 | { 24 | highp mat4 mtx_view; 25 | highp mat4 mtx_proj; 26 | highp mat4 mtx_light; 27 | }; 28 | 29 | out highp vec4 var_view_position; 30 | out highp vec4 var_position; 31 | out highp vec3 var_normal; 32 | out mediump vec2 var_texcoord0; 33 | out highp vec4 var_texcoord0_shadow; 34 | 35 | #include "/builtins/materials/skinning.glsl" 36 | 37 | void main() 38 | { 39 | vec4 skinned_position = get_skinned_position(position); 40 | vec4 pw = mtx_world * vec4(skinned_position.xyz, 1.0); 41 | vec4 p = mtx_view * pw; 42 | var_view_position = p; 43 | var_position = pw; 44 | var_texcoord0 = texcoord0; 45 | var_texcoord0_shadow = mtx_light * pw; 46 | var_normal = normalize((mtx_world * vec4(normal, 0.0)).xyz); 47 | gl_Position = mtx_proj * p; 48 | 49 | } 50 | 51 | -------------------------------------------------------------------------------- /light_and_shadows/materials/sprite/light_sprite.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | tags: "shadow" 4 | vertex_program: "/light_and_shadows/materials/sprite/sprite.vp" 5 | fragment_program: "/light_and_shadows/materials/sprite/sprite.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "mtx_view" 12 | type: CONSTANT_TYPE_VIEW 13 | } 14 | vertex_constants { 15 | name: "normal" 16 | type: CONSTANT_TYPE_USER 17 | value { 18 | y: 0.25 19 | z: 1.0 20 | } 21 | } 22 | fragment_constants { 23 | name: "tint" 24 | type: CONSTANT_TYPE_USER 25 | value { 26 | x: 1.0 27 | y: 1.0 28 | z: 1.0 29 | w: 1.0 30 | } 31 | } 32 | fragment_constants { 33 | name: "ambient" 34 | type: CONSTANT_TYPE_USER 35 | value { 36 | x: 0.8 37 | y: 0.8 38 | z: 0.8 39 | w: 1.0 40 | } 41 | } 42 | fragment_constants { 43 | name: "fog_color" 44 | type: CONSTANT_TYPE_USER 45 | value { 46 | x: 0.5 47 | y: 0.5 48 | z: 0.5 49 | w: 1.0 50 | } 51 | } 52 | fragment_constants { 53 | name: "fog" 54 | type: CONSTANT_TYPE_USER 55 | value { 56 | x: 1000.0 57 | y: 10000.0 58 | } 59 | } 60 | samplers { 61 | name: "tex0" 62 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 63 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 64 | filter_min: FILTER_MODE_MIN_DEFAULT 65 | filter_mag: FILTER_MODE_MAG_DEFAULT 66 | max_anisotropy: 0.0 67 | } 68 | samplers { 69 | name: "tex1" 70 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 71 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 72 | filter_min: FILTER_MODE_MIN_NEAREST 73 | filter_mag: FILTER_MODE_MAG_NEAREST 74 | max_anisotropy: 0.0 75 | } 76 | -------------------------------------------------------------------------------- /examples/tinyworld/materials/model_instanced_nearest.material: -------------------------------------------------------------------------------- 1 | name: "model_instanced" 2 | tags: "model" 3 | tags: "shadow_instanced_textured" 4 | vertex_program: "/examples/tinyworld/materials/model_instanced.vp" 5 | fragment_program: "/examples/tinyworld/materials/model_emissive.fp" 6 | vertex_space: VERTEX_SPACE_LOCAL 7 | vertex_constants { 8 | name: "mtx_view" 9 | type: CONSTANT_TYPE_VIEW 10 | } 11 | vertex_constants { 12 | name: "mtx_proj" 13 | type: CONSTANT_TYPE_PROJECTION 14 | } 15 | vertex_constants { 16 | name: "mtx_world" 17 | type: CONSTANT_TYPE_WORLD 18 | } 19 | fragment_constants { 20 | name: "tint" 21 | type: CONSTANT_TYPE_USER 22 | value { 23 | x: 1.0 24 | y: 1.0 25 | z: 1.0 26 | w: 1.0 27 | } 28 | } 29 | fragment_constants { 30 | name: "ambient" 31 | type: CONSTANT_TYPE_USER 32 | value { 33 | x: 0.8 34 | y: 0.8 35 | z: 0.8 36 | w: 1.0 37 | } 38 | } 39 | fragment_constants { 40 | name: "fog_color" 41 | type: CONSTANT_TYPE_USER 42 | value { 43 | x: 0.5 44 | y: 0.5 45 | z: 0.5 46 | w: 1.0 47 | } 48 | } 49 | fragment_constants { 50 | name: "fog" 51 | type: CONSTANT_TYPE_USER 52 | value { 53 | x: 1000.0 54 | y: 10000.0 55 | } 56 | } 57 | samplers { 58 | name: "tex0" 59 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 60 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 61 | filter_min: FILTER_MODE_MIN_NEAREST 62 | filter_mag: FILTER_MODE_MAG_NEAREST 63 | max_anisotropy: 0.0 64 | } 65 | samplers { 66 | name: "tex1" 67 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 68 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 69 | filter_min: FILTER_MODE_MIN_NEAREST 70 | filter_mag: FILTER_MODE_MAG_NEAREST 71 | max_anisotropy: 0.0 72 | } 73 | -------------------------------------------------------------------------------- /examples/tinyworld/models/decor1.gltf: -------------------------------------------------------------------------------- 1 | {"asset":{"version":"2.0","generator":"Blockbench 4.7.2 glTF exporter"},"scenes":[{"nodes":[1],"name":"blockbench_export"}],"scene":0,"nodes":[{"rotation":[0.7071067811865475,0,0,0.7071067811865476],"name":"plane","mesh":0},{"children":[0]}],"bufferViews":[{"buffer":0,"byteOffset":0,"byteLength":48,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":48,"byteLength":48,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":96,"byteLength":32,"target":34962,"byteStride":8},{"buffer":0,"byteOffset":128,"byteLength":12,"target":34963}],"buffers":[{"byteLength":140,"uri":"data:application/octet-stream;base64,AACgPgAAAAAAAAAAAACgPgAAAAAAAIC+AACgvgAAAAAAAIC+AACgvgAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAACYPgAAED4AAJg+AAAAPgAAhD4AAAA+AACEPgAAED4AAAEAAgAAAAIAAwA="}],"accessors":[{"bufferView":0,"componentType":5126,"count":4,"max":[0.3125,0,0],"min":[-0.3125,0,-0.25],"type":"VEC3"},{"bufferView":1,"componentType":5126,"count":4,"max":[0,1,0],"min":[0,1,0],"type":"VEC3"},{"bufferView":2,"componentType":5126,"count":4,"max":[0.296875,0.140625],"min":[0.2578125,0.125],"type":"VEC2"},{"bufferView":3,"componentType":5123,"count":6,"max":[3],"min":[0],"type":"SCALAR"}],"materials":[{"pbrMetallicRoughness":{"metallicFactor":0,"roughnessFactor":1,"baseColorTexture":{"index":0}},"alphaMode":"MASK","alphaCutoff":0.05,"doubleSided":true}],"textures":[{"sampler":0,"source":0,"name":"texture.png"}],"samplers":[{"magFilter":9728,"minFilter":9728,"wrapS":33071,"wrapT":33071}],"images":[{"mimeType":"image/png","uri":"file:///C:/_dev/_/tw/assets/tinyworld/texture.png?10"}],"meshes":[{"primitives":[{"mode":4,"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]}]} -------------------------------------------------------------------------------- /light_and_shadows/render/default.render: -------------------------------------------------------------------------------- 1 | script: "/light_and_shadows/render/default.render_script" 2 | render_resources { 3 | name: "shadow" 4 | path: "/light_and_shadows/materials/shadow/shadow.material" 5 | } 6 | render_resources { 7 | name: "shadowmap" 8 | path: "/light_and_shadows/render/shadowmap.render_target" 9 | } 10 | render_resources { 11 | name: "shadow_local" 12 | path: "/light_and_shadows/materials/shadow/shadow_local.material" 13 | } 14 | render_resources { 15 | name: "shadow_instanced" 16 | path: "/light_and_shadows/materials/shadow/shadow_instanced.material" 17 | } 18 | render_resources { 19 | name: "shadow_skinned_instanced" 20 | path: "/light_and_shadows/materials/shadow/skinned/shadow_skinned_instanced.material" 21 | } 22 | render_resources { 23 | name: "shadow_skinned" 24 | path: "/light_and_shadows/materials/shadow/skinned/shadow_skinned.material" 25 | } 26 | render_resources { 27 | name: "blur_horizontal" 28 | path: "/light_and_shadows/materials/post/blur_horizontal/blur_horizontal.material" 29 | } 30 | render_resources { 31 | name: "blur_vertical" 32 | path: "/light_and_shadows/materials/post/blur_horizontal/blur_vertical.material" 33 | } 34 | render_resources { 35 | name: "copy" 36 | path: "/light_and_shadows/materials/copy/copy.material" 37 | } 38 | render_resources { 39 | name: "shadow_instanced_billboard" 40 | path: "/light_and_shadows/materials/shadow/shadow_instanced_billboard.material" 41 | } 42 | render_resources { 43 | name: "shadow_instanced_textured" 44 | path: "/light_and_shadows/materials/shadow/shadow_instanced_textured.material" 45 | } 46 | render_resources { 47 | name: "mix" 48 | path: "/light_and_shadows/materials/post/mix/mix.material" 49 | } 50 | -------------------------------------------------------------------------------- /examples/example4/model_alpha_blend.material: -------------------------------------------------------------------------------- 1 | name: "model_alpha_blend" 2 | tags: "model_alpha_blend" 3 | vertex_program: "/light_and_shadows/materials/model/model_local.vp" 4 | fragment_program: "/light_and_shadows/materials/model/model.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_view" 8 | type: CONSTANT_TYPE_VIEW 9 | } 10 | vertex_constants { 11 | name: "mtx_proj" 12 | type: CONSTANT_TYPE_PROJECTION 13 | } 14 | vertex_constants { 15 | name: "mtx_normal" 16 | type: CONSTANT_TYPE_NORMAL 17 | } 18 | vertex_constants { 19 | name: "mtx_world" 20 | type: CONSTANT_TYPE_WORLD 21 | } 22 | fragment_constants { 23 | name: "tint" 24 | type: CONSTANT_TYPE_USER 25 | value { 26 | x: 1.0 27 | y: 1.0 28 | z: 1.0 29 | w: 0.75 30 | } 31 | } 32 | fragment_constants { 33 | name: "ambient" 34 | type: CONSTANT_TYPE_USER 35 | value { 36 | x: 0.8 37 | y: 0.8 38 | z: 0.8 39 | w: 1.0 40 | } 41 | } 42 | fragment_constants { 43 | name: "fog_color" 44 | type: CONSTANT_TYPE_USER 45 | value { 46 | x: 0.5 47 | y: 0.5 48 | z: 0.5 49 | w: 1.0 50 | } 51 | } 52 | fragment_constants { 53 | name: "fog" 54 | type: CONSTANT_TYPE_USER 55 | value { 56 | x: 1000.0 57 | y: 10000.0 58 | } 59 | } 60 | samplers { 61 | name: "tex0" 62 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 63 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 64 | filter_min: FILTER_MODE_MIN_LINEAR 65 | filter_mag: FILTER_MODE_MAG_LINEAR 66 | max_anisotropy: 0.0 67 | } 68 | samplers { 69 | name: "tex1" 70 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 71 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 72 | filter_min: FILTER_MODE_MIN_NEAREST 73 | filter_mag: FILTER_MODE_MAG_NEAREST 74 | max_anisotropy: 0.0 75 | } 76 | -------------------------------------------------------------------------------- /light_and_shadows/materials/model/model.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in highp vec4 var_position; 4 | in highp vec3 var_normal; 5 | in highp vec4 var_view_position; 6 | in mediump vec2 var_texcoord0; 7 | in highp vec4 var_texcoord0_shadow; 8 | 9 | out vec4 out_fragColor; 10 | 11 | uniform mediump sampler2D tex0; 12 | uniform mediump sampler2D tex1; 13 | 14 | #include "/light_and_shadows/materials/fun.glsl" 15 | #include "/light_and_shadows/materials/fog_fun.glsl" 16 | 17 | void main() 18 | { 19 | // Pre-multiply alpha since all runtime textures already are 20 | vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 21 | vec4 color = texture(tex0, var_texcoord0.xy) * tint_pm; 22 | if(color.a < 0.2) discard; 23 | 24 | // Editor does not support Lights and Shadows previews yet, so ignore it. 25 | #ifdef EDITOR 26 | out_fragColor = color; 27 | #else 28 | // Diffuse light calculations 29 | vec3 diff_light = diffuse_light(ambient.xyz); 30 | 31 | // Shadow map 32 | vec3 minus_color = vec3(0.); 33 | if(shadow_color.w > 0.) // on 34 | { 35 | vec4 depth_proj = var_texcoord0_shadow / var_texcoord0_shadow.w; 36 | float shadow = shadow_calculation(depth_proj.xyzw); 37 | minus_color = shadow_color.xyz * shadow; 38 | }; 39 | 40 | // Direct light minus shadow 41 | diff_light += direct_light(color0.xyz, light.xyz, var_position.xyz, var_normal, minus_color); 42 | diff_light = clamp(diff_light, 0.0, ambient.w); 43 | vec3 frag_color = color.rgb * diff_light ; 44 | 45 | // Add the fog 46 | frag_color = add_fog(frag_color, var_view_position.z, fog.x, fog.y, fog_color.rgb*color.a, fog_color.a); 47 | 48 | out_fragColor = vec4(frag_color, color.a); 49 | #endif 50 | } 51 | 52 | -------------------------------------------------------------------------------- /examples/example1/ui.gui: -------------------------------------------------------------------------------- 1 | script: "/examples/example1/ui.gui_script" 2 | fonts { 3 | name: "cardfont" 4 | font: "/assets/fnt/cardfont.font" 5 | } 6 | textures { 7 | name: "tiles" 8 | texture: "/assets/rgba/tiles.atlas" 9 | } 10 | nodes { 11 | position { 12 | x: -98.161 13 | y: 826.229 14 | } 15 | scale { 16 | x: 0.443 17 | y: 0.443 18 | z: 0.443 19 | } 20 | type: TYPE_BOX 21 | texture: "tiles/Icon-coin" 22 | id: "coin" 23 | xanchor: XANCHOR_LEFT 24 | yanchor: YANCHOR_TOP 25 | inherit_alpha: true 26 | size_mode: SIZE_MODE_AUTO 27 | visible: false 28 | } 29 | nodes { 30 | position { 31 | y: 846.0 32 | } 33 | type: TYPE_BOX 34 | id: "corner" 35 | xanchor: XANCHOR_LEFT 36 | yanchor: YANCHOR_TOP 37 | inherit_alpha: true 38 | size_mode: SIZE_MODE_AUTO 39 | visible: false 40 | } 41 | nodes { 42 | position { 43 | x: 77.0 44 | } 45 | scale { 46 | x: 0.443 47 | y: 0.443 48 | z: 0.443 49 | } 50 | type: TYPE_BOX 51 | texture: "tiles/Icon-coin" 52 | id: "box" 53 | xanchor: XANCHOR_LEFT 54 | yanchor: YANCHOR_TOP 55 | parent: "corner" 56 | inherit_alpha: true 57 | size_mode: SIZE_MODE_AUTO 58 | } 59 | nodes { 60 | position { 61 | x: 72.974 62 | } 63 | scale { 64 | x: 2.0 65 | y: 2.0 66 | } 67 | size { 68 | x: 200.0 69 | y: 100.0 70 | } 71 | type: TYPE_TEXT 72 | text: "0/0" 73 | font: "cardfont" 74 | id: "coins" 75 | pivot: PIVOT_W 76 | outline { 77 | x: 0.2 78 | z: 0.2 79 | } 80 | shadow { 81 | x: 1.0 82 | y: 1.0 83 | z: 1.0 84 | } 85 | parent: "box" 86 | inherit_alpha: true 87 | } 88 | material: "/builtins/materials/gui.material" 89 | adjust_reference: ADJUST_REFERENCE_PARENT 90 | -------------------------------------------------------------------------------- /light_and_shadows/materials/sprite/sprite.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in mediump vec2 var_texcoord0; 4 | in highp vec3 var_normal; 5 | in highp vec4 var_position; 6 | in highp vec4 var_view_position; 7 | in highp vec4 var_texcoord0_shadow; 8 | 9 | out vec4 out_fragColor; 10 | 11 | uniform mediump sampler2D tex0; 12 | uniform mediump sampler2D tex1; 13 | 14 | #include "/light_and_shadows/materials/fun.glsl" 15 | #include "/light_and_shadows/materials/fog_fun.glsl" 16 | 17 | void main() 18 | { 19 | // Pre-multiply alpha since all runtime textures already are 20 | mediump vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 21 | vec4 color = texture(tex0, var_texcoord0.xy)*tint_pm; 22 | // if(color.a < 0.1) discard; 23 | 24 | // Editor does not support Lights and Shadows previews yet, so ignore it. 25 | #ifdef EDITOR 26 | out_fragColor = color; 27 | #else 28 | // Diffuse light calculations 29 | vec3 diff_light = diffuse_light(ambient.xyz); 30 | 31 | // Shadow map 32 | vec3 minus_color = vec3(0.); 33 | if(shadow_color.w > 0.) // on 34 | { 35 | vec4 depth_proj = var_texcoord0_shadow / var_texcoord0_shadow.w; 36 | float shadow = shadow_calculation(depth_proj.xyzw); 37 | minus_color = shadow_color.xyz * shadow; 38 | }; 39 | 40 | // Direct light minus shadow 41 | diff_light += direct_light(color0.xyz, light.xyz, var_position.xyz, var_normal, minus_color); 42 | diff_light = clamp(diff_light, 0.0, ambient.w); 43 | vec3 frag_color = color.rgb * diff_light ; 44 | 45 | // Add the fog 46 | frag_color = add_fog(frag_color, var_view_position.z, fog.x, fog.y, fog_color.rgb*color.a, fog_color.a); 47 | 48 | out_fragColor = vec4(frag_color, color.a); 49 | #endif 50 | } 51 | -------------------------------------------------------------------------------- /light_and_shadows/materials/model/model_local.material: -------------------------------------------------------------------------------- 1 | name: "model_local" 2 | tags: "model" 3 | tags: "shadow_local" 4 | vertex_program: "/light_and_shadows/materials/model/model_local.vp" 5 | fragment_program: "/light_and_shadows/materials/model/model.fp" 6 | vertex_space: VERTEX_SPACE_LOCAL 7 | vertex_constants { 8 | name: "mtx_view" 9 | type: CONSTANT_TYPE_VIEW 10 | } 11 | vertex_constants { 12 | name: "mtx_proj" 13 | type: CONSTANT_TYPE_PROJECTION 14 | } 15 | vertex_constants { 16 | name: "mtx_normal" 17 | type: CONSTANT_TYPE_NORMAL 18 | } 19 | vertex_constants { 20 | name: "mtx_world" 21 | type: CONSTANT_TYPE_WORLD 22 | } 23 | fragment_constants { 24 | name: "tint" 25 | type: CONSTANT_TYPE_USER 26 | value { 27 | x: 1.0 28 | y: 1.0 29 | z: 1.0 30 | w: 1.0 31 | } 32 | } 33 | fragment_constants { 34 | name: "ambient" 35 | type: CONSTANT_TYPE_USER 36 | value { 37 | x: 0.8 38 | y: 0.8 39 | z: 0.8 40 | w: 1.0 41 | } 42 | } 43 | fragment_constants { 44 | name: "fog_color" 45 | type: CONSTANT_TYPE_USER 46 | value { 47 | x: 0.5 48 | y: 0.5 49 | z: 0.5 50 | w: 1.0 51 | } 52 | } 53 | fragment_constants { 54 | name: "fog" 55 | type: CONSTANT_TYPE_USER 56 | value { 57 | x: 1000.0 58 | y: 10000.0 59 | } 60 | } 61 | samplers { 62 | name: "tex0" 63 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 64 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 65 | filter_min: FILTER_MODE_MIN_DEFAULT 66 | filter_mag: FILTER_MODE_MAG_DEFAULT 67 | max_anisotropy: 0.0 68 | } 69 | samplers { 70 | name: "tex1" 71 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 72 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 73 | filter_min: FILTER_MODE_MIN_NEAREST 74 | filter_mag: FILTER_MODE_MAG_NEAREST 75 | max_anisotropy: 0.0 76 | } 77 | -------------------------------------------------------------------------------- /light_and_shadows/materials/fog_sprite/billboard/billboard_fog_sprite_linear.material: -------------------------------------------------------------------------------- 1 | name: "billboard_sprite" 2 | tags: "tile" 3 | vertex_program: "/light_and_shadows/materials/fog_sprite/billboard/billboard_sprite.vp" 4 | fragment_program: "/light_and_shadows/materials/fog_sprite/billboard/sprite.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "mtx_view" 11 | type: CONSTANT_TYPE_VIEW 12 | } 13 | vertex_constants { 14 | name: "proj" 15 | type: CONSTANT_TYPE_PROJECTION 16 | } 17 | fragment_constants { 18 | name: "tint" 19 | type: CONSTANT_TYPE_USER 20 | value { 21 | x: 1.0 22 | y: 1.0 23 | z: 1.0 24 | w: 1.0 25 | } 26 | } 27 | fragment_constants { 28 | name: "fog_color" 29 | type: CONSTANT_TYPE_USER 30 | value { 31 | x: 0.5 32 | y: 0.5 33 | z: 0.5 34 | w: 1.0 35 | } 36 | } 37 | fragment_constants { 38 | name: "fog" 39 | type: CONSTANT_TYPE_USER 40 | value { 41 | x: 1000.0 42 | y: 10000.0 43 | } 44 | } 45 | samplers { 46 | name: "texture_sampler" 47 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 48 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 49 | filter_min: FILTER_MODE_MIN_LINEAR 50 | filter_mag: FILTER_MODE_MAG_LINEAR 51 | max_anisotropy: 0.0 52 | } 53 | attributes { 54 | name: "local_position" 55 | semantic_type: SEMANTIC_TYPE_POSITION 56 | vector_type: VECTOR_TYPE_VEC3 57 | } 58 | attributes { 59 | name: "sprite_scale" 60 | double_values { 61 | v: 1.0 62 | v: 1.0 63 | v: 1.0 64 | } 65 | vector_type: VECTOR_TYPE_VEC3 66 | } 67 | attributes { 68 | name: "color" 69 | semantic_type: SEMANTIC_TYPE_COLOR 70 | double_values { 71 | v: 1.0 72 | v: 1.0 73 | v: 1.0 74 | v: 1.0 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /light_and_shadows/materials/fog_sprite/billboard/billboard_fog_sprite_nearest.material: -------------------------------------------------------------------------------- 1 | name: "billboard_sprite" 2 | tags: "tile" 3 | vertex_program: "/light_and_shadows/materials/fog_sprite/billboard/billboard_sprite.vp" 4 | fragment_program: "/light_and_shadows/materials/fog_sprite/billboard/sprite.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "mtx_view" 11 | type: CONSTANT_TYPE_VIEW 12 | } 13 | vertex_constants { 14 | name: "proj" 15 | type: CONSTANT_TYPE_PROJECTION 16 | } 17 | fragment_constants { 18 | name: "tint" 19 | type: CONSTANT_TYPE_USER 20 | value { 21 | x: 1.0 22 | y: 1.0 23 | z: 1.0 24 | w: 1.0 25 | } 26 | } 27 | fragment_constants { 28 | name: "fog_color" 29 | type: CONSTANT_TYPE_USER 30 | value { 31 | x: 0.5 32 | y: 0.5 33 | z: 0.5 34 | w: 1.0 35 | } 36 | } 37 | fragment_constants { 38 | name: "fog" 39 | type: CONSTANT_TYPE_USER 40 | value { 41 | x: 1000.0 42 | y: 10000.0 43 | } 44 | } 45 | samplers { 46 | name: "texture_sampler" 47 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 48 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 49 | filter_min: FILTER_MODE_MIN_NEAREST 50 | filter_mag: FILTER_MODE_MAG_NEAREST 51 | max_anisotropy: 0.0 52 | } 53 | attributes { 54 | name: "local_position" 55 | semantic_type: SEMANTIC_TYPE_POSITION 56 | vector_type: VECTOR_TYPE_VEC3 57 | } 58 | attributes { 59 | name: "sprite_scale" 60 | double_values { 61 | v: 1.0 62 | v: 1.0 63 | v: 1.0 64 | } 65 | vector_type: VECTOR_TYPE_VEC3 66 | } 67 | attributes { 68 | name: "color" 69 | semantic_type: SEMANTIC_TYPE_COLOR 70 | double_values { 71 | v: 1.0 72 | v: 1.0 73 | v: 1.0 74 | v: 1.0 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /light_and_shadows/materials/mesh/mesh.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in mediump vec4 var_color0; 4 | in highp vec4 var_position; 5 | in highp vec3 var_normal; 6 | in highp vec4 var_view_position; 7 | in mediump vec2 var_texcoord0; 8 | in highp vec4 var_texcoord0_shadow; 9 | 10 | out vec4 out_fragColor; 11 | 12 | uniform mediump sampler2D tex0; 13 | uniform mediump sampler2D tex1; 14 | 15 | #include "/light_and_shadows/materials/fun.glsl" 16 | #include "/light_and_shadows/materials/fog_fun.glsl" 17 | 18 | void main() 19 | { 20 | // Pre-multiply alpha since all runtime textures already are 21 | vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 22 | vec4 color = texture(tex0, var_texcoord0.xy) * tint_pm; 23 | if(color.a < 0.2) discard; 24 | 25 | // Editor does not support Lights and Shadows previews yet, so ignore it. 26 | #ifdef EDITOR 27 | out_fragColor = color; 28 | #else 29 | // Diffuse light calculations 30 | vec3 diff_light = diffuse_light(ambient.xyz); 31 | 32 | // Shadow map 33 | vec3 minus_color = vec3(0.); 34 | if(shadow_color.w > 0.) // on 35 | { 36 | vec4 depth_proj = var_texcoord0_shadow / var_texcoord0_shadow.w; 37 | float shadow = shadow_calculation(depth_proj.xyzw); 38 | minus_color = shadow_color.xyz * shadow; 39 | }; 40 | 41 | // Direct light minus shadow 42 | diff_light += direct_light(color0.xyz, light.xyz, var_position.xyz, var_normal, minus_color); 43 | diff_light = clamp(diff_light, 0.0, ambient.w); 44 | vec3 frag_color = var_color0.rgb * color.rgb * diff_light; 45 | 46 | // Add the fog 47 | frag_color = add_fog(frag_color, var_view_position.z, fog.x, fog.y, fog_color.rgb*color.a, fog_color.a); 48 | 49 | out_fragColor = vec4(frag_color, color.a); 50 | #endif 51 | } 52 | 53 | 54 | -------------------------------------------------------------------------------- /examples/example1/manager.script: -------------------------------------------------------------------------------- 1 | local common = require 'helper.common' 2 | local broadcast = require 'helper.broadcast' 3 | 4 | local coins = {} 5 | 6 | local function click(message, sender) 7 | 8 | local from, to = common.screen_to_world_ray(message.x, message.y, "camera#camera") 9 | local result = physics.raycast(from, to, {hash("coin")}, {all = false}) 10 | if result ~= nil then 11 | local r = result[1] 12 | print("click:", r.id ) 13 | 14 | -- found a coin 15 | if r and coins[r.id] then 16 | common.play_sound("button", common.pan(r.position)) 17 | go.animate(r.id, "scale", go.PLAYBACK_ONCE_PINGPONG, go.get_scale(r.id)*1.1, go.EASING_INBOUNCE, .2, 0, 18 | function() 19 | go.delete(r.id) 20 | broadcast.send("coin_found", message) 21 | end) 22 | coins[r.id] = nil 23 | end 24 | 25 | 26 | else 27 | -- if you want to know the world position where was click: 28 | -- local p = rendercam.screen_to_world_plane(message.x, message.y, vmath.vector3(0, 1, 0), go.get_position("root")) 29 | end 30 | 31 | end 32 | 33 | function init(self) 34 | broadcast.register("click", click) 35 | broadcast.register("coin_register", function(message, sender) 36 | if message.id then coins[message.id] = message.id end 37 | end) 38 | end 39 | 40 | function final(self) 41 | broadcast.unregister("coin_register") 42 | broadcast.unregister("click") 43 | end 44 | 45 | function update(self, dt) 46 | end 47 | 48 | function on_message(self, message_id, message, sender) 49 | if broadcast.on_message(message_id, message, sender) then 50 | -- message was handled 51 | return 52 | end 53 | end 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /light_and_shadows/materials/model/billboard/billboard_model_instanced.vp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | // Positions can be world or local space, since world and normal 4 | // matrices are identity for world vertex space materials. 5 | // If world vertex space is selected, you can remove the 6 | // normal matrix multiplication for optimal performance. 7 | 8 | in highp vec4 position; 9 | in mediump vec2 texcoord0; 10 | in highp vec3 normal; 11 | 12 | // When 'mtx_world' and 'mtx_normal' is specified as attributes, 13 | // instanced rendering is automatically triggered. 14 | // #ifndef EDITOR 15 | in highp mat4 mtx_world; 16 | in highp mat4 mtx_normal; 17 | // #endif 18 | 19 | uniform vs_uniforms 20 | { 21 | // #ifdef EDITOR 22 | // highp mat4 mtx_world; 23 | // #endif 24 | highp mat4 mtx_view; 25 | highp mat4 mtx_proj; 26 | highp mat4 mtx_light; 27 | }; 28 | 29 | out highp vec4 var_view_position; 30 | out highp vec4 var_position; 31 | out highp vec3 var_normal; 32 | out mediump vec2 var_texcoord0; 33 | out highp vec4 var_texcoord0_shadow; 34 | 35 | void main() 36 | { 37 | vec4 pw = mtx_world * vec4(position.xyz, 1.0); 38 | vec4 p = mtx_view * pw; 39 | var_view_position = p; 40 | var_position = pw; 41 | var_texcoord0 = texcoord0; 42 | var_texcoord0_shadow = mtx_light * pw; 43 | var_normal = normalize((mtx_world * vec4(normal, 0.0)).xyz); 44 | // gl_Position = mtx_proj * p; 45 | 46 | vec3 axis_factor = vec3(1.0, 1.0, 1.0); // which axis should use to toward the camera 47 | float scaling_factor = mtx_world[0].x; // ger model scale 48 | vec3 model_scale = axis_factor * scaling_factor; 49 | gl_Position = (mtx_proj * mtx_view * vec4(pw.xyz - position.xyz * model_scale, 1.0)) + (mtx_proj * vec4(position.xy * model_scale.xy, 0.0, 0.0)); 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /examples/example4/model_skinned_instanced_no_shadow.material: -------------------------------------------------------------------------------- 1 | name: "model_skinned_instanced" 2 | tags: "model" 3 | vertex_program: "/light_and_shadows/materials/model/skinned/model_skinned_instanced.vp" 4 | fragment_program: "/light_and_shadows/materials/model/model.fp" 5 | vertex_space: VERTEX_SPACE_LOCAL 6 | vertex_constants { 7 | name: "mtx_view" 8 | type: CONSTANT_TYPE_VIEW 9 | } 10 | vertex_constants { 11 | name: "mtx_proj" 12 | type: CONSTANT_TYPE_PROJECTION 13 | } 14 | fragment_constants { 15 | name: "tint" 16 | type: CONSTANT_TYPE_USER 17 | value { 18 | x: 1.0 19 | y: 1.0 20 | z: 1.0 21 | w: 1.0 22 | } 23 | } 24 | fragment_constants { 25 | name: "ambient" 26 | type: CONSTANT_TYPE_USER 27 | value { 28 | x: 0.8 29 | y: 0.8 30 | z: 0.8 31 | w: 1.0 32 | } 33 | } 34 | fragment_constants { 35 | name: "fog_color" 36 | type: CONSTANT_TYPE_USER 37 | value { 38 | x: 0.5 39 | y: 0.5 40 | z: 0.5 41 | w: 1.0 42 | } 43 | } 44 | fragment_constants { 45 | name: "fog" 46 | type: CONSTANT_TYPE_USER 47 | value { 48 | x: 1000.0 49 | y: 10000.0 50 | } 51 | } 52 | samplers { 53 | name: "tex0" 54 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 55 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 56 | filter_min: FILTER_MODE_MIN_LINEAR 57 | filter_mag: FILTER_MODE_MAG_LINEAR 58 | max_anisotropy: 0.0 59 | } 60 | samplers { 61 | name: "pose_matrix_cache" 62 | wrap_u: WRAP_MODE_REPEAT 63 | wrap_v: WRAP_MODE_REPEAT 64 | filter_min: FILTER_MODE_MIN_NEAREST 65 | filter_mag: FILTER_MODE_MAG_NEAREST 66 | max_anisotropy: 0.0 67 | } 68 | samplers { 69 | name: "tex1" 70 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 71 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 72 | filter_min: FILTER_MODE_MIN_NEAREST 73 | filter_mag: FILTER_MODE_MAG_NEAREST 74 | max_anisotropy: 0.0 75 | } 76 | -------------------------------------------------------------------------------- /light_and_shadows/materials/fog_label/font.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in mediump vec2 var_texcoord0; 4 | in mediump vec4 var_face_color; 5 | in mediump vec4 var_outline_color; 6 | in mediump vec4 var_shadow_color; 7 | in mediump vec4 var_layer_mask; 8 | 9 | out vec4 out_fragColor; 10 | 11 | uniform mediump sampler2D texture_sampler; 12 | 13 | uniform fs_uniforms 14 | { 15 | mediump vec4 fog_color; 16 | mediump vec4 fog; 17 | }; 18 | 19 | in highp vec4 var_view_position; 20 | #include "/light_and_shadows/materials/fog_fun.glsl" 21 | 22 | void main() 23 | { 24 | mediump float is_single_layer = var_layer_mask.a; 25 | mediump vec3 t = texture(texture_sampler, var_texcoord0.xy).xyz; 26 | float face_alpha = var_face_color.w * t.x; 27 | 28 | float raw_outline_alpha = var_outline_color.w * t.y; 29 | float max_outline_alpha = (1.0 - face_alpha * is_single_layer); 30 | float outline_alpha = min(raw_outline_alpha, max_outline_alpha); 31 | 32 | float raw_shadow_alpha = var_shadow_color.w * t.z; 33 | float max_shadow_alpha = (1.0 - (face_alpha + outline_alpha) * is_single_layer); 34 | float shadow_alpha = min(raw_shadow_alpha, max_shadow_alpha); 35 | 36 | mediump vec4 face_color = var_layer_mask.x * vec4(var_face_color.xyz, 1.0) * face_alpha; 37 | mediump vec4 outline_color = var_layer_mask.y * vec4(var_outline_color.xyz, 1.0) * outline_alpha; 38 | mediump vec4 shadow_color = var_layer_mask.z * vec4(var_shadow_color.xyz, 1.0) * shadow_alpha; 39 | 40 | vec4 frag_color = face_color + outline_color + shadow_color; 41 | 42 | // Add the fog 43 | frag_color.rgb = add_fog(frag_color.rgb, var_view_position.z, fog.x, fog.y, fog_color.rgb*frag_color.a, fog_color.a); 44 | 45 | out_fragColor = frag_color; 46 | } 47 | -------------------------------------------------------------------------------- /examples/example4/model_skinned_instanced_nearest.material: -------------------------------------------------------------------------------- 1 | name: "model_skinned_instanced" 2 | tags: "model" 3 | tags: "shadow_skinned_instanced" 4 | vertex_program: "/light_and_shadows/materials/model/skinned/model_skinned_instanced.vp" 5 | fragment_program: "/light_and_shadows/materials/model/model.fp" 6 | vertex_space: VERTEX_SPACE_LOCAL 7 | vertex_constants { 8 | name: "mtx_view" 9 | type: CONSTANT_TYPE_VIEW 10 | } 11 | vertex_constants { 12 | name: "mtx_proj" 13 | type: CONSTANT_TYPE_PROJECTION 14 | } 15 | fragment_constants { 16 | name: "tint" 17 | type: CONSTANT_TYPE_USER 18 | value { 19 | x: 1.0 20 | y: 1.0 21 | z: 1.0 22 | w: 1.0 23 | } 24 | } 25 | fragment_constants { 26 | name: "ambient" 27 | type: CONSTANT_TYPE_USER 28 | value { 29 | x: 0.8 30 | y: 0.8 31 | z: 0.8 32 | w: 1.0 33 | } 34 | } 35 | fragment_constants { 36 | name: "fog_color" 37 | type: CONSTANT_TYPE_USER 38 | value { 39 | x: 0.5 40 | y: 0.5 41 | z: 0.5 42 | w: 1.0 43 | } 44 | } 45 | fragment_constants { 46 | name: "fog" 47 | type: CONSTANT_TYPE_USER 48 | value { 49 | x: 1000.0 50 | y: 10000.0 51 | } 52 | } 53 | samplers { 54 | name: "tex0" 55 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 56 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 57 | filter_min: FILTER_MODE_MIN_NEAREST 58 | filter_mag: FILTER_MODE_MAG_NEAREST 59 | max_anisotropy: 0.0 60 | } 61 | samplers { 62 | name: "pose_matrix_cache" 63 | wrap_u: WRAP_MODE_REPEAT 64 | wrap_v: WRAP_MODE_REPEAT 65 | filter_min: FILTER_MODE_MIN_NEAREST 66 | filter_mag: FILTER_MODE_MAG_NEAREST 67 | max_anisotropy: 0.0 68 | } 69 | samplers { 70 | name: "tex1" 71 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 72 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 73 | filter_min: FILTER_MODE_MIN_NEAREST 74 | filter_mag: FILTER_MODE_MAG_NEAREST 75 | max_anisotropy: 0.0 76 | } 77 | -------------------------------------------------------------------------------- /light_and_shadows/materials/model/skinned/model_skinned_instanced.material: -------------------------------------------------------------------------------- 1 | name: "model_skinned_instanced" 2 | tags: "model" 3 | tags: "shadow_skinned_instanced" 4 | vertex_program: "/light_and_shadows/materials/model/skinned/model_skinned_instanced.vp" 5 | fragment_program: "/light_and_shadows/materials/model/model.fp" 6 | vertex_space: VERTEX_SPACE_LOCAL 7 | vertex_constants { 8 | name: "mtx_view" 9 | type: CONSTANT_TYPE_VIEW 10 | } 11 | vertex_constants { 12 | name: "mtx_proj" 13 | type: CONSTANT_TYPE_PROJECTION 14 | } 15 | fragment_constants { 16 | name: "tint" 17 | type: CONSTANT_TYPE_USER 18 | value { 19 | x: 1.0 20 | y: 1.0 21 | z: 1.0 22 | w: 1.0 23 | } 24 | } 25 | fragment_constants { 26 | name: "ambient" 27 | type: CONSTANT_TYPE_USER 28 | value { 29 | x: 0.8 30 | y: 0.8 31 | z: 0.8 32 | w: 1.0 33 | } 34 | } 35 | fragment_constants { 36 | name: "fog_color" 37 | type: CONSTANT_TYPE_USER 38 | value { 39 | x: 0.5 40 | y: 0.5 41 | z: 0.5 42 | w: 1.0 43 | } 44 | } 45 | fragment_constants { 46 | name: "fog" 47 | type: CONSTANT_TYPE_USER 48 | value { 49 | x: 1000.0 50 | y: 10000.0 51 | } 52 | } 53 | samplers { 54 | name: "tex0" 55 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 56 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 57 | filter_min: FILTER_MODE_MIN_LINEAR 58 | filter_mag: FILTER_MODE_MAG_LINEAR 59 | max_anisotropy: 0.0 60 | } 61 | samplers { 62 | name: "pose_matrix_cache" 63 | wrap_u: WRAP_MODE_REPEAT 64 | wrap_v: WRAP_MODE_REPEAT 65 | filter_min: FILTER_MODE_MIN_NEAREST 66 | filter_mag: FILTER_MODE_MAG_NEAREST 67 | max_anisotropy: 0.0 68 | } 69 | samplers { 70 | name: "tex1" 71 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 72 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 73 | filter_min: FILTER_MODE_MIN_NEAREST 74 | filter_mag: FILTER_MODE_MAG_NEAREST 75 | max_anisotropy: 0.0 76 | } 77 | -------------------------------------------------------------------------------- /light_and_shadows/sun.script: -------------------------------------------------------------------------------- 1 | local constants = require "light_and_shadows.constants" 2 | local ls = require "light_and_shadows.light_and_shadows" 3 | 4 | go.property("color", vmath.vector4(0.75, 0.75, 0.5, 0)) 5 | go.property("shadow", vmath.vector4(0.25, 0.25, 0.2, 0)) 6 | 7 | go.property("near", -500) 8 | go.property("far", 500) 9 | go.property("PROJECTION_RESOLUTION", 400) 10 | go.property("perspective", false) 11 | go.property("fov", 2) 12 | go.property("static", true) 13 | go.property("depth_bias", 0.0004) 14 | go.property("max_lights", 8) 15 | 16 | local dir = vmath.vector3(0.1, -10, 0.1) 17 | 18 | local function set_color(self) 19 | constants.sun_color.x = self.color.x 20 | constants.sun_color.y = self.color.y 21 | constants.sun_color.z = self.color.z 22 | constants.shadow_color.x = self.shadow.x 23 | constants.shadow_color.y = self.shadow.y 24 | constants.shadow_color.z = self.shadow.z 25 | end 26 | 27 | local function set_position(self) 28 | local pos = go.get_world_position() 29 | constants.sun_position.x = pos.x 30 | constants.sun_position.y = pos.y 31 | constants.sun_position.z = pos.z 32 | 33 | constants.sun_dir = vmath.rotate(go.get_world_rotation(), dir) 34 | end 35 | 36 | function init(self) 37 | set_color(self) 38 | set_position(self) 39 | if self.perspective then 40 | ls.set_perspective_projection(self.fov, 1.0, self.near, self.far) 41 | else 42 | ls.set_orthographic_projection(self.PROJECTION_RESOLUTION, self.PROJECTION_RESOLUTION, self.near, self.far) 43 | end 44 | ls.depth_bias = self.depth_bias 45 | ls.max_lights = self.max_lights 46 | end 47 | 48 | -- Remove 'update' if the sun is static object 49 | function update(self, dt) 50 | if not self.static then 51 | set_position(self) 52 | end 53 | end 54 | 55 | function final(self) 56 | 57 | end 58 | -------------------------------------------------------------------------------- /light_and_shadows/light_setting.script: -------------------------------------------------------------------------------- 1 | local light = require 'light_and_shadows.light' 2 | 3 | go.property("clear_color", vmath.vector4(0.1, 0.2, 0.15, 0)) 4 | go.property("fog_color", vmath.vector4(0.1, 0.2, 0.15, 0)) 5 | go.property("fog_density", 0.7) 6 | go.property("fog_min_max", vmath.vector4(10, 200, 1, 1)) 7 | go.property("ambient", vmath.vector4(0.4, 0.4, 0.3, 0)) 8 | go.property("color_max", 1.3) 9 | go.property("on", true) 10 | 11 | -- Special script and module with functions to setup initial light shaders constants and 12 | -- manage the list of light sources during runtime in update function. 13 | -- This script sets constants into constants.lua module. You may do it in your own way. 14 | 15 | -- Only you need to do this is setup four vector4 in constants array. 16 | -- 1. Clear color or background color. 17 | -- 2. Fog color. Usually the same as the clear color. 4th component (.w) is the fog density (0 - 1.0). Where 0 is a very high density. 18 | -- 3. Fog minimum and maximum. Z-coord in camera view space where the fog is started. 19 | -- 4. Ambient color. 4th component (ambient.w) used as the maximum value of final color component at each pixels. 20 | -- If the color_max value > 1.0, the places where light sources overlap each other may have an excessive value. 21 | -- In shader it looks like 22 | -- diffuse_light = clamp(diffuse_light, 0.0, ambient.w); 23 | -- final_pixel_color = texture_color * diffuse_light; 24 | 25 | 26 | function init(self) 27 | -- light.reset(self) 28 | self.fog_color.w = self.fog_density 29 | self.ambient.w = self.color_max 30 | if self.on then 31 | light.set_color(self.fog_color, self.fog_min_max, self.ambient, self.clear_color) 32 | end 33 | end 34 | 35 | function update(self, dt) 36 | if self.on then 37 | light.update(self, dt) 38 | end 39 | end 40 | 41 | function final(self) 42 | light.reset(self) 43 | end 44 | -------------------------------------------------------------------------------- /examples/tinyworld/materials/billboard_light_sprite_nearest.material: -------------------------------------------------------------------------------- 1 | name: "billboard_sprite" 2 | tags: "tile" 3 | tags: "shadow" 4 | vertex_program: "/light_and_shadows/materials/sprite/billboard/billboard_sprite.vp" 5 | fragment_program: "/light_and_shadows/materials/sprite/sprite.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "mtx_view" 12 | type: CONSTANT_TYPE_VIEW 13 | } 14 | vertex_constants { 15 | name: "proj" 16 | type: CONSTANT_TYPE_PROJECTION 17 | } 18 | fragment_constants { 19 | name: "tint" 20 | type: CONSTANT_TYPE_USER 21 | value { 22 | x: 1.0 23 | y: 1.0 24 | z: 1.0 25 | w: 1.0 26 | } 27 | } 28 | fragment_constants { 29 | name: "ambient" 30 | type: CONSTANT_TYPE_USER 31 | value { 32 | x: 0.8 33 | y: 0.8 34 | z: 0.8 35 | w: 1.0 36 | } 37 | } 38 | fragment_constants { 39 | name: "fog_color" 40 | type: CONSTANT_TYPE_USER 41 | value { 42 | x: 0.5 43 | y: 0.5 44 | z: 0.5 45 | w: 1.0 46 | } 47 | } 48 | fragment_constants { 49 | name: "fog" 50 | type: CONSTANT_TYPE_USER 51 | value { 52 | x: 1000.0 53 | y: 10000.0 54 | } 55 | } 56 | samplers { 57 | name: "tex0" 58 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 59 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 60 | filter_min: FILTER_MODE_MIN_NEAREST 61 | filter_mag: FILTER_MODE_MAG_NEAREST 62 | max_anisotropy: 0.0 63 | } 64 | samplers { 65 | name: "tex1" 66 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 67 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 68 | filter_min: FILTER_MODE_MIN_NEAREST 69 | filter_mag: FILTER_MODE_MAG_NEAREST 70 | max_anisotropy: 0.0 71 | } 72 | attributes { 73 | name: "local_position" 74 | semantic_type: SEMANTIC_TYPE_POSITION 75 | vector_type: VECTOR_TYPE_VEC3 76 | } 77 | attributes { 78 | name: "sprite_scale" 79 | double_values { 80 | v: 1.0 81 | v: 0.75 82 | v: 1.0 83 | } 84 | vector_type: VECTOR_TYPE_VEC3 85 | } 86 | -------------------------------------------------------------------------------- /light_and_shadows/materials/sprite/billboard/billboard_light_sprite.material: -------------------------------------------------------------------------------- 1 | name: "billboard_sprite" 2 | tags: "tile" 3 | tags: "shadow" 4 | vertex_program: "/light_and_shadows/materials/sprite/billboard/billboard_sprite.vp" 5 | fragment_program: "/light_and_shadows/materials/sprite/sprite.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "mtx_view" 12 | type: CONSTANT_TYPE_VIEW 13 | } 14 | vertex_constants { 15 | name: "proj" 16 | type: CONSTANT_TYPE_PROJECTION 17 | } 18 | fragment_constants { 19 | name: "tint" 20 | type: CONSTANT_TYPE_USER 21 | value { 22 | x: 1.0 23 | y: 1.0 24 | z: 1.0 25 | w: 1.0 26 | } 27 | } 28 | fragment_constants { 29 | name: "ambient" 30 | type: CONSTANT_TYPE_USER 31 | value { 32 | x: 0.8 33 | y: 0.8 34 | z: 0.8 35 | w: 1.0 36 | } 37 | } 38 | fragment_constants { 39 | name: "fog_color" 40 | type: CONSTANT_TYPE_USER 41 | value { 42 | x: 0.5 43 | y: 0.5 44 | z: 0.5 45 | w: 1.0 46 | } 47 | } 48 | fragment_constants { 49 | name: "fog" 50 | type: CONSTANT_TYPE_USER 51 | value { 52 | x: 1000.0 53 | y: 10000.0 54 | } 55 | } 56 | samplers { 57 | name: "tex0" 58 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 59 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 60 | filter_min: FILTER_MODE_MIN_DEFAULT 61 | filter_mag: FILTER_MODE_MAG_DEFAULT 62 | max_anisotropy: 0.0 63 | } 64 | samplers { 65 | name: "tex1" 66 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 67 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 68 | filter_min: FILTER_MODE_MIN_NEAREST 69 | filter_mag: FILTER_MODE_MAG_NEAREST 70 | max_anisotropy: 0.0 71 | } 72 | attributes { 73 | name: "local_position" 74 | semantic_type: SEMANTIC_TYPE_POSITION 75 | vector_type: VECTOR_TYPE_VEC3 76 | } 77 | attributes { 78 | name: "sprite_scale" 79 | double_values { 80 | v: 1.0 81 | v: 1.0 82 | v: 1.0 83 | } 84 | vector_type: VECTOR_TYPE_VEC3 85 | } 86 | -------------------------------------------------------------------------------- /light_and_shadows/materials/model/skinned/model_skinned.material: -------------------------------------------------------------------------------- 1 | name: "model_skinned" 2 | tags: "model" 3 | tags: "shadow_skinned" 4 | vertex_program: "/light_and_shadows/materials/model/skinned/model_skinned.vp" 5 | fragment_program: "/light_and_shadows/materials/model/model.fp" 6 | vertex_space: VERTEX_SPACE_LOCAL 7 | vertex_constants { 8 | name: "mtx_view" 9 | type: CONSTANT_TYPE_VIEW 10 | } 11 | vertex_constants { 12 | name: "mtx_proj" 13 | type: CONSTANT_TYPE_PROJECTION 14 | } 15 | vertex_constants { 16 | name: "mtx_normal" 17 | type: CONSTANT_TYPE_NORMAL 18 | } 19 | vertex_constants { 20 | name: "mtx_world" 21 | type: CONSTANT_TYPE_WORLD 22 | } 23 | fragment_constants { 24 | name: "tint" 25 | type: CONSTANT_TYPE_USER 26 | value { 27 | x: 1.0 28 | y: 1.0 29 | z: 1.0 30 | w: 1.0 31 | } 32 | } 33 | fragment_constants { 34 | name: "ambient" 35 | type: CONSTANT_TYPE_USER 36 | value { 37 | x: 0.8 38 | y: 0.8 39 | z: 0.8 40 | w: 1.0 41 | } 42 | } 43 | fragment_constants { 44 | name: "fog_color" 45 | type: CONSTANT_TYPE_USER 46 | value { 47 | x: 0.5 48 | y: 0.5 49 | z: 0.5 50 | w: 1.0 51 | } 52 | } 53 | fragment_constants { 54 | name: "fog" 55 | type: CONSTANT_TYPE_USER 56 | value { 57 | x: 1000.0 58 | y: 10000.0 59 | } 60 | } 61 | samplers { 62 | name: "tex0" 63 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 64 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 65 | filter_min: FILTER_MODE_MIN_LINEAR 66 | filter_mag: FILTER_MODE_MAG_LINEAR 67 | max_anisotropy: 0.0 68 | } 69 | samplers { 70 | name: "pose_matrix_cache" 71 | wrap_u: WRAP_MODE_REPEAT 72 | wrap_v: WRAP_MODE_REPEAT 73 | filter_min: FILTER_MODE_MIN_NEAREST 74 | filter_mag: FILTER_MODE_MAG_NEAREST 75 | max_anisotropy: 0.0 76 | } 77 | samplers { 78 | name: "tex1" 79 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 80 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 81 | filter_min: FILTER_MODE_MIN_NEAREST 82 | filter_mag: FILTER_MODE_MAG_NEAREST 83 | max_anisotropy: 0.0 84 | } 85 | -------------------------------------------------------------------------------- /examples/tinyworld/materials/model_emissive.fp: -------------------------------------------------------------------------------- 1 | #version 140 2 | 3 | in highp vec4 var_position; 4 | in highp vec3 var_normal; 5 | in highp vec4 var_view_position; 6 | in mediump vec2 var_texcoord0; 7 | in highp vec4 var_texcoord0_shadow; 8 | 9 | out vec4 out_fragColor; 10 | 11 | uniform mediump sampler2D tex0; 12 | uniform mediump sampler2D tex1; 13 | 14 | #include "/light_and_shadows/materials/fun.glsl" 15 | #include "/light_and_shadows/materials/fog_fun.glsl" 16 | // #include "/examples/tinyworld/materials/rgss.glsl" 17 | 18 | void main() 19 | { 20 | // Pre-multiply alpha since all runtime textures already are 21 | vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 22 | vec4 color = texture(tex0, var_texcoord0.xy) * tint_pm; 23 | // vec4 color = rgss_tex2D(tex0, var_texcoord0.xy, -1.0) * tint_pm; 24 | if(color.a < 0.2) discard; 25 | 26 | // Editor does not support Lights and Shadows previews yet, so ignore it. 27 | #ifdef EDITOR 28 | out_fragColor = color; 29 | #else 30 | // Diffuse light calculations 31 | vec3 diff_light = diffuse_light(ambient.xyz); 32 | 33 | // Shadow map 34 | vec3 minus_color = vec3(0.); 35 | if(shadow_color.w > 0.) // on 36 | { 37 | vec4 depth_proj = var_texcoord0_shadow / var_texcoord0_shadow.w; 38 | float shadow = shadow_calculation(depth_proj.xyzw); 39 | minus_color = shadow_color.xyz * shadow; 40 | }; 41 | 42 | // Direct light minus shadow 43 | diff_light += direct_light(color0.xyz, light.xyz, var_position.xyz, var_normal, minus_color); 44 | diff_light = clamp(diff_light, 0.0, ambient.w); 45 | 46 | if(color.a < 1.0) 47 | { 48 | // SELF EMISSIVE if alfa < 1.0 49 | diff_light = vec3(1.0); 50 | }; 51 | vec3 frag_color = color.rgb * diff_light; 52 | 53 | // Add the fog 54 | frag_color = add_fog(frag_color, var_view_position.z, fog.x, fog.y, fog_color.rgb*color.a, fog_color.a); 55 | 56 | out_fragColor = vec4(frag_color, color.a); 57 | #endif 58 | } 59 | 60 | -------------------------------------------------------------------------------- /light_and_shadows/materials/sprite/repeat/repeat_sprite_nocast.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "bgtile" 3 | vertex_program: "/light_and_shadows/materials/sprite/repeat/repeat_sprite.vp" 4 | fragment_program: "/light_and_shadows/materials/sprite/repeat/repeat_sprite_nocast.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "uv_coord" 11 | type: CONSTANT_TYPE_USER 12 | value { 13 | } 14 | } 15 | vertex_constants { 16 | name: "uv_repeat" 17 | type: CONSTANT_TYPE_USER 18 | value { 19 | } 20 | } 21 | vertex_constants { 22 | name: "mtx_view" 23 | type: CONSTANT_TYPE_VIEW 24 | } 25 | vertex_constants { 26 | name: "normal" 27 | type: CONSTANT_TYPE_USER 28 | value { 29 | y: 1.0 30 | } 31 | } 32 | fragment_constants { 33 | name: "tint" 34 | type: CONSTANT_TYPE_USER 35 | value { 36 | x: 1.0 37 | y: 1.0 38 | z: 1.0 39 | w: 1.0 40 | } 41 | } 42 | fragment_constants { 43 | name: "ambient" 44 | type: CONSTANT_TYPE_USER 45 | value { 46 | x: 0.8 47 | y: 0.8 48 | z: 0.8 49 | w: 1.0 50 | } 51 | } 52 | fragment_constants { 53 | name: "fog_color" 54 | type: CONSTANT_TYPE_USER 55 | value { 56 | x: 0.5 57 | y: 0.5 58 | z: 0.5 59 | w: 0.1 60 | } 61 | } 62 | fragment_constants { 63 | name: "fog" 64 | type: CONSTANT_TYPE_USER 65 | value { 66 | x: 1000.0 67 | y: 10000.0 68 | } 69 | } 70 | samplers { 71 | name: "tex0" 72 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 73 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 74 | filter_min: FILTER_MODE_MIN_DEFAULT 75 | filter_mag: FILTER_MODE_MAG_DEFAULT 76 | max_anisotropy: 0.0 77 | } 78 | samplers { 79 | name: "tex1" 80 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 81 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 82 | filter_min: FILTER_MODE_MIN_NEAREST 83 | filter_mag: FILTER_MODE_MAG_NEAREST 84 | max_anisotropy: 0.0 85 | } 86 | attributes { 87 | name: "lp" 88 | semantic_type: SEMANTIC_TYPE_POSITION 89 | vector_type: VECTOR_TYPE_VEC3 90 | } 91 | --------------------------------------------------------------------------------