├── deffx ├── render │ ├── 3d │ │ ├── main.render │ │ └── main.render_script │ ├── 3d_camera │ │ ├── main.render │ │ └── main.render_script │ ├── sprite_debug │ │ ├── default.render │ │ ├── default.display_profiles │ │ └── default.render_script │ ├── 3d_camera_rendertarget │ │ └── main.render │ └── rendertarget │ │ ├── render_target.render │ │ └── default.display_profiles ├── materials │ ├── _tools │ │ ├── _tools.zip │ │ ├── normal.fp │ │ ├── normal.vp │ │ ├── normal.material │ │ └── normal_packing.txt │ ├── render_material │ │ ├── overdraw.fp │ │ ├── overdraw.material │ │ └── overdraw.vp │ ├── model │ │ ├── normals.fp │ │ ├── wireframe.fp │ │ ├── 3d.vp │ │ ├── textured.fp │ │ ├── textured.vp │ │ ├── 3d.fp │ │ ├── facing_ratio.fp │ │ ├── checker.fp │ │ ├── checker.vp │ │ ├── lambert.vp │ │ ├── phong.vp │ │ ├── depth.fp │ │ ├── perturb_normals.vp │ │ ├── facing_ratio.vp │ │ ├── depth.vp │ │ ├── wireframe.vp │ │ ├── normals.vp │ │ ├── 3d.material │ │ ├── checker.material │ │ ├── textured.material │ │ ├── toon.vp │ │ ├── depth.material │ │ ├── phong.material │ │ ├── lambert.material │ │ ├── normals.material │ │ ├── lambert.fp │ │ ├── toon.fp │ │ ├── phong.fp │ │ ├── perturb_normals.material │ │ ├── wireframe.material │ │ ├── facing_ratio.material │ │ ├── _perterb-normals.fp │ │ ├── toon.material │ │ └── perturb_normals.fp │ ├── sprite │ │ ├── pixelart.vp │ │ ├── pixelart.fp │ │ ├── hsb.material │ │ ├── greyscale.material │ │ ├── dropshadow.material │ │ ├── greyscale.fp │ │ ├── lighten.fp │ │ ├── scrolling.fp │ │ ├── trim.vp │ │ ├── trim.fp │ │ ├── trim.material │ │ ├── lighten.material │ │ ├── pixelate.material │ │ ├── outerglow.material │ │ ├── pixelart.material │ │ ├── pixelate.fp │ │ ├── outerglow.fp │ │ ├── scrolling.material │ │ ├── simple_gradient.material │ │ ├── simple_gradient.fp │ │ ├── outerglow_copy.fp │ │ ├── hsb.fp │ │ ├── dropshadow.fp │ │ ├── linear_gradient.fp │ │ └── linear_gradient.material │ ├── rendertarget │ │ ├── pass.vp │ │ ├── noise.material │ │ ├── pixelate.fp │ │ ├── fxaa.material │ │ ├── blur_direction.fp │ │ ├── blur_direction.material │ │ ├── scanlines.material │ │ ├── chromatic_aberration_screen_edge.material │ │ ├── pixelate.material │ │ ├── blur_simple.material │ │ ├── noise.fp │ │ ├── blur_simple.fp │ │ ├── chromatic_aberration_screen_edge.fp │ │ ├── scanlines.fp │ │ └── fxaa.fp │ ├── blend │ │ ├── todo.txt │ │ ├── cross_fade.fp │ │ ├── cross_fade.material │ │ ├── vivid_light.fp │ │ └── vivid_light.material │ └── tilemap │ │ ├── animated_tilemap.fp │ │ ├── animated_tilemap.vp │ │ ├── pixel_sprite_normal_hstrip.vp │ │ ├── animate_tilemap.script │ │ ├── animated_tilemap.material │ │ ├── pixel_sprite_normal_hstrip.fp │ │ └── pixel_sprite_normal_hstrip.material ├── utils │ ├── screen_window_helper.lua │ ├── camera_helper.lua │ ├── render_helper.lua │ └── light_helper.lua ├── quad │ ├── quad.fp │ ├── unitquad.go │ ├── quad.vp │ ├── quad.material │ └── quad.dae ├── lights │ ├── point.script │ └── directional.script └── cameras │ └── look_at.script ├── docs └── images │ ├── 3d_phong.png │ ├── 3d_checkers.png │ ├── 3d_normals.png │ ├── 3d_textured.png │ ├── sprite_hsb.png │ ├── sprite_greyscale.png │ ├── sprite_lighten.png │ ├── blending_vivid_light.png │ ├── sprite_scrolling_texture.png │ └── postprocessing_scanlines_chromatic_distortion_vignette.png ├── _assets ├── models │ ├── defold.png │ └── cube.dae ├── textures │ ├── scrolling │ │ ├── 1.png │ │ └── scrolling.atlas │ ├── AnisoDirection1.jpg │ ├── outerglow │ │ ├── sample.png │ │ └── outerglow.atlas │ ├── defold │ │ ├── defold-icon.png │ │ ├── defold-large.png │ │ └── defold.atlas │ ├── public-domain │ │ ├── cal.png │ │ ├── arizona.jpg │ │ ├── hokusai.jpg │ │ ├── wild-turkey.png │ │ ├── japan-nach-reisen-und-studien.png │ │ └── public-domain.atlas │ ├── bars │ │ ├── decorated_health.png │ │ ├── decorated_mana.png │ │ ├── bar_mana.atlas │ │ └── bar_health.atlas │ ├── normal-maps │ │ └── brick-wall.jpg │ ├── uv-checkers │ │ ├── uv-checker-1.png │ │ └── uv-checker-2.png │ └── sprite_normals │ │ ├── dood_tilemap.png │ │ └── dood.tilesource └── gui │ └── blank.gui ├── examples_blending ├── blending_checker.psd ├── cross_fade │ ├── cross_fade.script │ └── cross_fade.collection └── vivid_light │ ├── vivid_light.script │ └── vivid_light.collection ├── .gitignore ├── examples_sprites ├── outerglow │ └── outerglow.script ├── scrolling_texture │ └── scrolling_texture.script ├── lighten │ └── lighten.script ├── normal_sprite_illumination │ ├── sprite_lit.script │ ├── light_manager.script │ ├── sprite_rotate.script │ ├── 2d_light.script │ └── normal_sprite_illumination.script ├── linear_gradient │ └── linear_gradient.script ├── simple_gradient │ └── simple_gradient.script ├── hsb │ └── hsb.script ├── greyscale │ └── greyscale.script ├── trim │ └── trim.script ├── outline │ └── outline.script └── dropshadow │ └── dropshadow.script ├── examples_render_materials └── overdraw │ ├── main.render │ ├── overdraw_toggle.script │ └── main.render_script ├── input └── game.input_binding ├── examples_postprocessing ├── scanlines │ └── scanlines.script ├── chromatic_aberration_screen_edge │ └── chromatic_aberration_screen_edge.script ├── noise │ └── noise.script ├── blur_simple │ └── blur_simple.script ├── blur_direction │ └── blur_direction.script └── pixelate │ └── pixelate.script ├── examples_3d ├── normals │ ├── hop.script │ └── normals.script ├── lambert │ ├── lambert.script │ └── lambert.collection ├── textured │ ├── textured.script │ └── textured.collection ├── _misc │ └── misc.script ├── skybox │ ├── checker.script │ └── checker.collection ├── checker │ ├── checker.script │ └── checker.collection ├── phong_rendertarget │ └── phong.script ├── perturb-normals │ └── perturb-normals.script └── phong │ └── phong.script ├── game.project ├── _main └── main.collection └── README.md /deffx/render/3d/main.render: -------------------------------------------------------------------------------- 1 | script: "/deffx/render/3d/main.render_script" 2 | -------------------------------------------------------------------------------- /deffx/render/3d_camera/main.render: -------------------------------------------------------------------------------- 1 | script: "/deffx/render/3d_camera/main.render_script" 2 | -------------------------------------------------------------------------------- /docs/images/3d_phong.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/docs/images/3d_phong.png -------------------------------------------------------------------------------- /_assets/models/defold.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/models/defold.png -------------------------------------------------------------------------------- /deffx/render/sprite_debug/default.render: -------------------------------------------------------------------------------- 1 | script: "/deffx/render/sprite_debug/default.render_script" 2 | -------------------------------------------------------------------------------- /docs/images/3d_checkers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/docs/images/3d_checkers.png -------------------------------------------------------------------------------- /docs/images/3d_normals.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/docs/images/3d_normals.png -------------------------------------------------------------------------------- /docs/images/3d_textured.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/docs/images/3d_textured.png -------------------------------------------------------------------------------- /docs/images/sprite_hsb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/docs/images/sprite_hsb.png -------------------------------------------------------------------------------- /_assets/textures/scrolling/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/scrolling/1.png -------------------------------------------------------------------------------- /docs/images/sprite_greyscale.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/docs/images/sprite_greyscale.png -------------------------------------------------------------------------------- /docs/images/sprite_lighten.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/docs/images/sprite_lighten.png -------------------------------------------------------------------------------- /deffx/materials/_tools/_tools.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/deffx/materials/_tools/_tools.zip -------------------------------------------------------------------------------- /deffx/render/3d_camera_rendertarget/main.render: -------------------------------------------------------------------------------- 1 | script: "/deffx/render/3d_camera_rendertarget/main.render_script" 2 | -------------------------------------------------------------------------------- /_assets/textures/AnisoDirection1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/AnisoDirection1.jpg -------------------------------------------------------------------------------- /_assets/textures/outerglow/sample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/outerglow/sample.png -------------------------------------------------------------------------------- /docs/images/blending_vivid_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/docs/images/blending_vivid_light.png -------------------------------------------------------------------------------- /_assets/textures/defold/defold-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/defold/defold-icon.png -------------------------------------------------------------------------------- /_assets/textures/public-domain/cal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/public-domain/cal.png -------------------------------------------------------------------------------- /examples_blending/blending_checker.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/examples_blending/blending_checker.psd -------------------------------------------------------------------------------- /_assets/textures/bars/decorated_health.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/bars/decorated_health.png -------------------------------------------------------------------------------- /_assets/textures/bars/decorated_mana.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/bars/decorated_mana.png -------------------------------------------------------------------------------- /_assets/textures/defold/defold-large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/defold/defold-large.png -------------------------------------------------------------------------------- /_assets/textures/public-domain/arizona.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/public-domain/arizona.jpg -------------------------------------------------------------------------------- /_assets/textures/public-domain/hokusai.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/public-domain/hokusai.jpg -------------------------------------------------------------------------------- /docs/images/sprite_scrolling_texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/docs/images/sprite_scrolling_texture.png -------------------------------------------------------------------------------- /_assets/textures/normal-maps/brick-wall.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/normal-maps/brick-wall.jpg -------------------------------------------------------------------------------- /_assets/textures/public-domain/wild-turkey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/public-domain/wild-turkey.png -------------------------------------------------------------------------------- /_assets/textures/uv-checkers/uv-checker-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/uv-checkers/uv-checker-1.png -------------------------------------------------------------------------------- /_assets/textures/uv-checkers/uv-checker-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/uv-checkers/uv-checker-2.png -------------------------------------------------------------------------------- /_assets/textures/sprite_normals/dood_tilemap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/sprite_normals/dood_tilemap.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .externalToolBuilders 2 | .DS_Store 3 | .lock-wscript 4 | build 5 | *.pyc 6 | .project 7 | .cproject 8 | builtins 9 | .internal 10 | -------------------------------------------------------------------------------- /deffx/utils/screen_window_helper.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | M.window_width = M.window_width or 0 4 | M.window_height = M.window_height or 0 5 | 6 | return M -------------------------------------------------------------------------------- /deffx/utils/camera_helper.lua: -------------------------------------------------------------------------------- 1 | -- central place to get / set information about the camera 2 | 3 | local M = {} 4 | 5 | M.enabled = false 6 | 7 | 8 | return M -------------------------------------------------------------------------------- /_assets/textures/scrolling/scrolling.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/_assets/textures/scrolling/1.png" 3 | } 4 | margin: 0 5 | extrude_borders: 0 6 | inner_padding: 0 7 | -------------------------------------------------------------------------------- /_assets/textures/bars/bar_mana.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/_assets/textures/bars/decorated_mana.png" 3 | } 4 | margin: 4 5 | extrude_borders: 0 6 | inner_padding: 0 7 | -------------------------------------------------------------------------------- /_assets/textures/bars/bar_health.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/_assets/textures/bars/decorated_health.png" 3 | } 4 | margin: 4 5 | extrude_borders: 0 6 | inner_padding: 0 7 | -------------------------------------------------------------------------------- /_assets/textures/outerglow/outerglow.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/_assets/textures/outerglow/sample.png" 3 | } 4 | margin: 0 5 | extrude_borders: 0 6 | inner_padding: 32 7 | -------------------------------------------------------------------------------- /_assets/textures/public-domain/japan-nach-reisen-und-studien.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/_assets/textures/public-domain/japan-nach-reisen-und-studien.png -------------------------------------------------------------------------------- /docs/images/postprocessing_scanlines_chromatic_distortion_vignette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subsoap/deffx/HEAD/docs/images/postprocessing_scanlines_chromatic_distortion_vignette.png -------------------------------------------------------------------------------- /deffx/materials/render_material/overdraw.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec4 position; 2 | varying mediump vec4 var_color; 3 | 4 | void main() 5 | { 6 | gl_FragColor = vec4(0.12, 0.0, 0.0, 0.0); 7 | } 8 | -------------------------------------------------------------------------------- /examples_sprites/outerglow/outerglow.script: -------------------------------------------------------------------------------- 1 | 2 | function init(self) 3 | self.timer = 0 4 | end 5 | 6 | 7 | function update(self, dt) 8 | self.timer = self.timer + dt 9 | 10 | end 11 | 12 | -------------------------------------------------------------------------------- /deffx/render/rendertarget/render_target.render: -------------------------------------------------------------------------------- 1 | script: "/deffx/render/rendertarget/render_target.render_script" 2 | materials { 3 | name: "post_pixelate" 4 | material: "/deffx/materials/sprite/pixelate.material" 5 | } 6 | -------------------------------------------------------------------------------- /examples_render_materials/overdraw/main.render: -------------------------------------------------------------------------------- 1 | script: "/examples_render_materials/overdraw/main.render_script" 2 | materials { 3 | name: "overdraw" 4 | material: "/deffx/materials/render_material/overdraw.material" 5 | } 6 | -------------------------------------------------------------------------------- /_assets/gui/blank.gui: -------------------------------------------------------------------------------- 1 | script: "" 2 | background_color { 3 | x: 0.0 4 | y: 0.0 5 | z: 0.0 6 | w: 0.0 7 | } 8 | material: "/builtins/materials/gui.material" 9 | adjust_reference: ADJUST_REFERENCE_LEGACY 10 | max_nodes: 512 11 | -------------------------------------------------------------------------------- /_assets/textures/defold/defold.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/_assets/textures/defold/defold-icon.png" 3 | } 4 | images { 5 | image: "/_assets/textures/defold/defold-large.png" 6 | } 7 | margin: 20 8 | extrude_borders: 0 9 | inner_padding: 20 10 | -------------------------------------------------------------------------------- /deffx/utils/render_helper.lua: -------------------------------------------------------------------------------- 1 | local M = {} 2 | 3 | function M.action_to_position(action) 4 | return vmath.vector3((M.xoffset or 0) + action.screen_x / (M.zoom_factor or 1), (M.yoffset or 0) + action.screen_y / (M.zoom_factor or 1), 0) 5 | end 6 | 7 | return M -------------------------------------------------------------------------------- /deffx/render/rendertarget/default.display_profiles: -------------------------------------------------------------------------------- 1 | profiles { 2 | name: "Landscape" 3 | qualifiers { 4 | width: 1280 5 | height: 720 6 | } 7 | } 8 | profiles { 9 | name: "Portrait" 10 | qualifiers { 11 | width: 720 12 | height: 1280 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /deffx/render/sprite_debug/default.display_profiles: -------------------------------------------------------------------------------- 1 | profiles { 2 | name: "Landscape" 3 | qualifiers { 4 | width: 1280 5 | height: 720 6 | } 7 | } 8 | profiles { 9 | name: "Portrait" 10 | qualifiers { 11 | width: 720 12 | height: 1280 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /deffx/utils/light_helper.lua: -------------------------------------------------------------------------------- 1 | -- get and set light information, can have multiple lights and add / remove them 2 | -- your light objects would then pull data from this module to send to their material shader programs 3 | 4 | local M = {} 5 | 6 | M.enabled = false 7 | 8 | 9 | return M -------------------------------------------------------------------------------- /input/game.input_binding: -------------------------------------------------------------------------------- 1 | key_trigger { 2 | input: KEY_LALT 3 | action: "alt" 4 | } 5 | key_trigger { 6 | input: KEY_RALT 7 | action: "alt" 8 | } 9 | key_trigger { 10 | input: KEY_F4 11 | action: "f4" 12 | } 13 | mouse_trigger { 14 | input: MOUSE_BUTTON_1 15 | action: "touch" 16 | } 17 | -------------------------------------------------------------------------------- /examples_render_materials/overdraw/overdraw_toggle.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | msg.post(".", "acquire_input_focus") 3 | end 4 | 5 | 6 | function on_input(self, action_id, action) 7 | if action_id == hash("touch") and action.released then 8 | msg.post("@render:", "toggle_overdraw") 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /deffx/materials/model/normals.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying mediump vec3 var_position; 3 | varying mediump vec3 var_normal; 4 | varying mediump vec3 var_tangent; 5 | varying mediump vec3 var_bitangent; 6 | 7 | void main() { 8 | 9 | gl_FragColor = vec4(normalize(var_normal) * 0.5 + 0.5, 1.0); 10 | } -------------------------------------------------------------------------------- /deffx/materials/model/wireframe.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying mediump vec3 var_position; 3 | varying mediump vec3 var_normal; 4 | 5 | // TODO - I think it would require extra information about the polygons being sent to the vp as a constant... 6 | 7 | void main() { 8 | gl_FragColor = vec4(0.4,0.4,0.4,0.9); 9 | } -------------------------------------------------------------------------------- /deffx/materials/model/3d.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | 4 | attribute mediump vec3 position; 5 | attribute mediump vec2 texcoord0; 6 | 7 | varying mediump vec2 var_texcoord0; 8 | 9 | void main(){ 10 | gl_Position = view_proj * world * vec4(position.xyz, 1.0); 11 | var_texcoord0 = texcoord0; 12 | } -------------------------------------------------------------------------------- /deffx/materials/_tools/normal.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying mediump vec3 var_position; 3 | varying mediump vec3 var_normal; 4 | 5 | 6 | uniform lowp sampler2D DIFFUSE_TEXTURE; 7 | 8 | 9 | void main() { 10 | 11 | gl_FragColor = vec4(normalize(var_normal) * 0.5 + 0.5, 1.); 12 | //gl_FragColor = vec4(var_normal, 1.0); 13 | } -------------------------------------------------------------------------------- /deffx/materials/model/textured.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform sampler2D diffuse_texture; 4 | uniform lowp vec4 tint; 5 | uniform lowp vec4 timer; 6 | 7 | void main() 8 | { 9 | lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w * timer.x); 10 | gl_FragColor = texture2D(diffuse_texture, var_texcoord0) * tint_pm; 11 | } -------------------------------------------------------------------------------- /examples_blending/cross_fade/cross_fade.script: -------------------------------------------------------------------------------- 1 | 2 | function init(self) 3 | self.timer = 0 4 | 5 | end 6 | 7 | 8 | 9 | function update(self, dt) 10 | self.timer = self.timer + dt 11 | self.offset = (math.sin(self.timer)) 12 | go.set("/unitquad#unitquad", "progress.x", self.offset) 13 | go.set("/unitquad1#unitquad", "progress.x", 1) 14 | end 15 | -------------------------------------------------------------------------------- /deffx/materials/sprite/pixelart.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | 3 | // positions are in world space 4 | attribute mediump vec4 position; 5 | attribute mediump vec2 texcoord0; 6 | 7 | varying mediump vec2 var_texcoord0; 8 | 9 | void main() 10 | { 11 | gl_Position = view_proj * vec4(position.xyz, 1.0); 12 | var_texcoord0 = texcoord0; 13 | } 14 | -------------------------------------------------------------------------------- /deffx/materials/model/textured.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | 4 | attribute mediump vec4 position; 5 | attribute mediump vec2 texcoord0; 6 | varying mediump vec2 var_texcoord0; 7 | 8 | void main() 9 | { 10 | mediump mat4 mvp = view_proj * world; 11 | gl_Position = mvp * vec4(position.xyz, 1.0); 12 | var_texcoord0 = texcoord0; 13 | } -------------------------------------------------------------------------------- /deffx/quad/quad.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D QUAD_TEXTURE; 4 | uniform lowp vec4 tint; 5 | 6 | void main() 7 | { 8 | // Pre-multiply alpha since all runtime textures already are 9 | //lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 10 | gl_FragColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy); // * tint_pm; 11 | } 12 | -------------------------------------------------------------------------------- /deffx/materials/model/3d.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying mediump vec3 var_position; 3 | 4 | uniform lowp sampler2D LEFT; 5 | uniform lowp sampler2D RIGHT; 6 | 7 | void main() { 8 | vec4 rc = texture2D(RIGHT, var_texcoord0.xy); 9 | rc.x = 0.0; 10 | vec4 lc = texture2D(LEFT, var_texcoord0.xy); 11 | lc.y = 0.0; 12 | lc.z = 0.0; 13 | gl_FragColor = lc + rc; 14 | } -------------------------------------------------------------------------------- /deffx/materials/sprite/pixelart.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp vec4 tint; 5 | 6 | void main() 7 | { 8 | // Pre-multiply alpha since all runtime textures already are 9 | lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 10 | gl_FragColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy) * tint_pm; 11 | } 12 | -------------------------------------------------------------------------------- /deffx/materials/model/facing_ratio.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying mediump vec3 var_position; 3 | varying mediump vec3 var_normal; 4 | 5 | uniform lowp vec4 color_inner; 6 | uniform lowp vec4 color_outer; 7 | 8 | 9 | void main() { 10 | 11 | float ratio = -1 * dot(normalize(var_position),normalize(var_normal)); 12 | clamp(ratio,0.0,1.0); 13 | gl_FragColor = mix(color_outer,color_inner,ratio); 14 | } -------------------------------------------------------------------------------- /deffx/materials/rendertarget/pass.vp: -------------------------------------------------------------------------------- 1 | // via britzl 2 | // this will make your post processing collection's bg show the processing 3 | // it's interesting but you probably want to use quad.vp instead so your editor is cleaner 4 | attribute mediump vec4 position; 5 | attribute mediump vec2 texcoord0; 6 | 7 | varying mediump vec2 var_texcoord0; 8 | 9 | void main(){ 10 | gl_Position = position; 11 | var_texcoord0 = texcoord0; 12 | } -------------------------------------------------------------------------------- /deffx/materials/sprite/hsb.material: -------------------------------------------------------------------------------- 1 | name: "hsb" 2 | tags: "tile" 3 | vertex_program: "/builtins/materials/sprite.vp" 4 | fragment_program: "/deffx/materials/sprite/hsb.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | fragment_constants { 10 | name: "hsb" 11 | type: CONSTANT_TYPE_USER 12 | value { 13 | x: 0.0 14 | y: 1.0 15 | z: 1.0 16 | w: 0.0 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /deffx/materials/blend/todo.txt: -------------------------------------------------------------------------------- 1 | disolve 2 | 3 | darken 4 | multiply 5 | color burn 6 | linear burn 7 | darker color 8 | 9 | lighten 10 | screen 11 | color dodge 12 | linear dodge (add) 13 | lighter color 14 | 15 | overlay 16 | soft light 17 | hard light 18 | vivid light 19 | linear light 20 | pin light 21 | hard mix 22 | 23 | difference 24 | exclusion 25 | subtract 26 | divide 27 | 28 | hue 29 | saturation 30 | color 31 | luminosity -------------------------------------------------------------------------------- /deffx/materials/tilemap/animated_tilemap.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec4 position; 2 | varying mediump vec2 var_texcoord0; 3 | 4 | uniform mediump sampler2D DIFFUSE_TEXTURE; 5 | uniform lowp vec4 tint; 6 | 7 | void main() 8 | { 9 | // Pre-multiply alpha since all runtime textures already are 10 | lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 11 | gl_FragColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy) * tint_pm; 12 | } 13 | -------------------------------------------------------------------------------- /_assets/textures/public-domain/public-domain.atlas: -------------------------------------------------------------------------------- 1 | images { 2 | image: "/_assets/textures/public-domain/japan-nach-reisen-und-studien.png" 3 | } 4 | images { 5 | image: "/_assets/textures/public-domain/wild-turkey.png" 6 | } 7 | images { 8 | image: "/_assets/textures/public-domain/arizona.jpg" 9 | } 10 | images { 11 | image: "/_assets/textures/public-domain/cal.png" 12 | } 13 | margin: 4 14 | extrude_borders: 0 15 | inner_padding: 4 16 | -------------------------------------------------------------------------------- /deffx/materials/blend/cross_fade.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp sampler2D BLEND; 5 | uniform lowp vec4 progress; 6 | 7 | 8 | void main() 9 | { 10 | vec4 base = texture2D(DIFFUSE_TEXTURE, var_texcoord0); 11 | vec4 blend = texture2D(BLEND, var_texcoord0); 12 | //gl_FragColor = base * (1.0 - progress) + blend * progress; 13 | gl_FragColor = mix(base, blend, progress); 14 | } -------------------------------------------------------------------------------- /deffx/materials/sprite/greyscale.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | vertex_program: "/builtins/materials/sprite.vp" 4 | fragment_program: "/deffx/materials/sprite/greyscale.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 | -------------------------------------------------------------------------------- /deffx/materials/sprite/dropshadow.material: -------------------------------------------------------------------------------- 1 | name: "hsb" 2 | tags: "tile" 3 | vertex_program: "/builtins/materials/sprite.vp" 4 | fragment_program: "/deffx/materials/sprite/dropshadow.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | fragment_constants { 10 | name: "dropshadow" 11 | type: CONSTANT_TYPE_USER 12 | value { 13 | x: 0.0 14 | y: 5.0 15 | z: 5.0 16 | w: 0.0 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /deffx/materials/tilemap/animated_tilemap.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | uniform lowp vec4 offset; 4 | 5 | attribute mediump vec4 position; 6 | attribute mediump vec2 texcoord0; 7 | 8 | varying mediump vec2 var_texcoord0; 9 | 10 | void main() 11 | { 12 | mediump mat4 mvp = view_proj * world; 13 | gl_Position = mvp * vec4(position.xyz, 1.0); 14 | var_texcoord0 = texcoord0+vec2(offset.xy); 15 | } 16 | -------------------------------------------------------------------------------- /_assets/textures/sprite_normals/dood.tilesource: -------------------------------------------------------------------------------- 1 | image: "/_assets/textures/sprite_normals/dood_tilemap.png" 2 | tile_width: 16 3 | tile_height: 16 4 | tile_margin: 0 5 | tile_spacing: 0 6 | collision: "" 7 | material_tag: "tile" 8 | animations { 9 | id: "stand" 10 | start_tile: 1 11 | end_tile: 2 12 | playback: PLAYBACK_LOOP_PINGPONG 13 | fps: 4 14 | flip_horizontal: 0 15 | flip_vertical: 0 16 | } 17 | extrude_borders: 0 18 | inner_padding: 0 19 | -------------------------------------------------------------------------------- /deffx/materials/sprite/greyscale.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp vec4 tint; 5 | 6 | void main() 7 | { 8 | 9 | vec4 color = texture2D(DIFFUSE_TEXTURE, var_texcoord0); 10 | float luminance = 0.2126*color.r + color.g*0.7152 + color.b*0.0722; 11 | lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 12 | gl_FragColor = vec4(luminance,luminance,luminance, color.a) * tint_pm; 13 | } -------------------------------------------------------------------------------- /deffx/quad/unitquad.go: -------------------------------------------------------------------------------- 1 | embedded_components { 2 | id: "unitquad" 3 | type: "model" 4 | data: "mesh: \"/deffx/quad/quad.dae\"\n" 5 | "material: \"/deffx/quad/quad.material\"\n" 6 | "skeleton: \"\"\n" 7 | "animations: \"\"\n" 8 | "default_animation: \"\"\n" 9 | "name: \"\"\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 | -------------------------------------------------------------------------------- /examples_postprocessing/scanlines/scanlines.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.timer = 0 3 | 4 | end 5 | 6 | 7 | 8 | function update(self, dt) 9 | self.timer = self.timer + dt --* 0.05 10 | go.set("/unitquad#unitquad", "time.x", self.timer) 11 | --local amount = math.floor(math.abs(math.sin(self.timer)) * self.pixelamount) 12 | --local amount = (math.abs(math.sin(self.timer)) * self.pixelamount) 13 | --go.set("/unitquad#unitquad", "options.x", amount) 14 | 15 | 16 | end 17 | -------------------------------------------------------------------------------- /deffx/quad/quad.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | 4 | attribute mediump vec4 position; 5 | attribute mediump vec2 texcoord0; 6 | 7 | varying mediump vec2 var_texcoord0; 8 | 9 | void main() 10 | { 11 | // NOTE: world isn't used here. Sprite positions are already transformed 12 | // prior to rendering but the world-transform is set for sorting. 13 | gl_Position = view_proj * vec4(position.xyz, 1.0); 14 | var_texcoord0 = texcoord0; 15 | } 16 | -------------------------------------------------------------------------------- /deffx/materials/sprite/lighten.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp vec4 tint; 5 | uniform lowp vec4 options; // options.x = lighten multiplier amount 6 | 7 | void main() 8 | { 9 | vec4 color = texture2D(DIFFUSE_TEXTURE, var_texcoord0); 10 | lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 11 | gl_FragColor = vec4(pow(color.r, options.x), pow(color.g, options.x), pow(color.b, options.x), color.a) * tint_pm; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /examples_postprocessing/chromatic_aberration_screen_edge/chromatic_aberration_screen_edge.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.timer = 0 3 | 4 | end 5 | 6 | 7 | 8 | function update(self, dt) 9 | self.timer = self.timer + dt --* 0.05 10 | go.set("/unitquad#unitquad", "time.x", self.timer) 11 | --local amount = math.floor(math.abs(math.sin(self.timer)) * self.pixelamount) 12 | --local amount = (math.abs(math.sin(self.timer)) * self.pixelamount) 13 | --go.set("/unitquad#unitquad", "options.x", amount) 14 | 15 | 16 | end 17 | -------------------------------------------------------------------------------- /deffx/materials/sprite/scrolling.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp vec4 tint; 5 | uniform lowp vec4 offset; 6 | uniform lowp vec4 timer; 7 | 8 | 9 | void main() 10 | { 11 | vec2 q = var_texcoord0.xy * 5; // should account for w/h scale 12 | vec2 uv = 0.5 + (q-0.5)*(0.9 + 0.1*sin(2.5*timer.x)); 13 | 14 | lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 15 | gl_FragColor = texture2D(DIFFUSE_TEXTURE, vec2(uv.x,-uv.y) + offset.xy) * tint_pm; 16 | } 17 | -------------------------------------------------------------------------------- /deffx/materials/sprite/trim.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | 4 | attribute mediump vec4 position; 5 | attribute mediump vec2 texcoord0; 6 | 7 | varying mediump vec2 var_texcoord0; 8 | varying mediump vec3 var_view_proj0; 9 | 10 | void main() 11 | { 12 | gl_Position = view_proj * vec4(position.xyz, 1.0); 13 | var_texcoord0 = texcoord0; 14 | vec3 direction = vec3(0.0); 15 | vec3 transformed_direction = vec3(view_proj * vec4(direction, 0.0)); 16 | var_view_proj0 = transformed_direction; 17 | } -------------------------------------------------------------------------------- /deffx/materials/sprite/trim.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec4 position; 2 | varying mediump vec2 var_texcoord0; 3 | varying mediump vec3 var_view_proj0; 4 | 5 | uniform lowp sampler2D DIFFUSE_TEXTURE; 6 | uniform lowp vec4 trim; 7 | uniform lowp vec4 ratio; 8 | 9 | void main() 10 | { 11 | lowp vec4 trim_by = vec4(1.0,1.0,1.0,1.0); 12 | 13 | if (var_texcoord0.x < trim.x * ratio.x || var_texcoord0.x > trim.y * ratio.x ) { 14 | trim_by = vec4(0.0,0.0,0.0,0.0); 15 | } 16 | 17 | gl_FragColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy) * trim_by; 18 | } 19 | -------------------------------------------------------------------------------- /deffx/materials/tilemap/pixel_sprite_normal_hstrip.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 mtx_normal; 3 | 4 | // positions are in world space 5 | attribute mediump vec4 position; 6 | attribute mediump vec2 texcoord0; 7 | attribute mediump vec3 normal; 8 | 9 | varying mediump vec2 var_texcoord0; 10 | varying mediump vec3 var_normal; 11 | 12 | void main() 13 | { 14 | gl_Position = view_proj * vec4(position.xyz, 1.0); 15 | var_texcoord0 = texcoord0; 16 | var_normal = normalize((mtx_normal * vec4(normal, 0.0)).xyz); 17 | } 18 | -------------------------------------------------------------------------------- /examples_3d/normals/hop.script: -------------------------------------------------------------------------------- 1 | -- bun bun bun 2 | -- lil bun look at your tiny spoon-shaped ears 3 | -- aww bun brave little lawnmower bun 4 | 5 | function init(self) 6 | self.go_position = go.get_position(".") 7 | self.initial_y = 0.0 8 | self.up = 0.1 9 | self.g = 0.01 10 | self.y = 0.0 11 | end 12 | 13 | 14 | function update(self, dt) 15 | self.y = self.y - self.up * dt * 10 16 | self.up = self.up - self.g * dt * 10 17 | 18 | if (self.y > self.initial_y) then self.up = 0.1 end 19 | 20 | self.go_position.y = math.abs(self.y) 21 | go.set_position(self.go_position) 22 | end 23 | -------------------------------------------------------------------------------- /deffx/materials/sprite/trim.material: -------------------------------------------------------------------------------- 1 | name: "trim" 2 | tags: "tile" 3 | vertex_program: "/deffx/materials/sprite/trim.vp" 4 | fragment_program: "/deffx/materials/sprite/trim.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | fragment_constants { 10 | name: "trim" 11 | type: CONSTANT_TYPE_USER 12 | value { 13 | x: 0.0 14 | y: 1.0 15 | z: 0.0 16 | w: 1.0 17 | } 18 | } 19 | fragment_constants { 20 | name: "ratio" 21 | type: CONSTANT_TYPE_USER 22 | value { 23 | x: 1.0 24 | y: 1.0 25 | z: 0.0 26 | w: 0.0 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /deffx/materials/sprite/lighten.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | vertex_program: "/builtins/materials/sprite.vp" 4 | fragment_program: "/deffx/materials/sprite/lighten.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: "options" 21 | type: CONSTANT_TYPE_USER 22 | value { 23 | x: 1.0 24 | y: 0.0 25 | z: 0.0 26 | w: 0.0 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /deffx/materials/sprite/pixelate.material: -------------------------------------------------------------------------------- 1 | name: "hsb" 2 | tags: "tile" 3 | vertex_program: "/builtins/materials/sprite.vp" 4 | fragment_program: "/deffx/materials/sprite/pixelate.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | fragment_constants { 10 | name: "options" 11 | type: CONSTANT_TYPE_USER 12 | value { 13 | x: 32.0 14 | y: 0.0 15 | z: 0.0 16 | w: 0.0 17 | } 18 | } 19 | fragment_constants { 20 | name: "resolution" 21 | type: CONSTANT_TYPE_USER 22 | value { 23 | x: 800.0 24 | y: 600.0 25 | z: 0.0 26 | w: 0.0 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /deffx/materials/sprite/outerglow.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | vertex_program: "/builtins/materials/sprite.vp" 4 | fragment_program: "/deffx/materials/sprite/outerglow.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | fragment_constants { 10 | name: "rgba" 11 | type: CONSTANT_TYPE_USER 12 | value { 13 | x: 156.0 14 | y: 255.0 15 | z: 255.0 16 | w: 1.0 17 | } 18 | } 19 | fragment_constants { 20 | name: "options" 21 | type: CONSTANT_TYPE_USER 22 | value { 23 | x: 25.0 24 | y: 25.0 25 | z: 0.0 26 | w: 4.0 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /deffx/materials/tilemap/animate_tilemap.script: -------------------------------------------------------------------------------- 1 | go.property("frames", 8) 2 | go.property("delay", 4) 3 | go.property("tilemap", msg.url()) 4 | 5 | function init(self) 6 | self.current_delay=0 7 | self.frame=0 8 | self.tile_width=1/((self.frames-1)*2) 9 | end 10 | 11 | function update(self, dt) 12 | self.current_delay=self.current_delay+1 13 | if self.current_delay>self.delay then 14 | self.frame=self.frame+1 15 | if self.frame>self.frames-1 then 16 | self.frame=0 17 | end 18 | tilemap.set_constant(self.tilemap, "offset", vmath.vector4(self.frame*self.tile_width,0,0,0)) 19 | self.current_delay=0 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /deffx/materials/sprite/pixelart.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | vertex_program: "/deffx/materials/sprite/pixelart.vp" 4 | fragment_program: "/deffx/materials/sprite/pixelart.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 | samplers { 20 | name: "DIFFUSE_TEXTURE" 21 | wrap_u: WRAP_MODE_REPEAT 22 | wrap_v: WRAP_MODE_REPEAT 23 | filter_min: FILTER_MODE_MIN_NEAREST 24 | filter_mag: FILTER_MODE_MAG_NEAREST 25 | } 26 | -------------------------------------------------------------------------------- /deffx/materials/model/checker.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying mediump vec3 var_position; 3 | varying mediump vec3 var_normal; 4 | 5 | uniform lowp vec4 options; // options.x = repeat distance 6 | 7 | uniform lowp sampler2D DIFFUSE_TEXTURE; 8 | 9 | 10 | void main() { 11 | float s = mod(floor(var_texcoord0.s * options.x), 2.0); 12 | float t = mod(floor(var_texcoord0.t * options.x), 2.0); 13 | 14 | if (s + t == 1.0) 15 | { 16 | gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); 17 | //gl_FragColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0); 18 | } else { 19 | gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0); 20 | } 21 | } 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /deffx/materials/tilemap/animated_tilemap.material: -------------------------------------------------------------------------------- 1 | name: "tile_map" 2 | tags: "tile" 3 | tags: "sprite" 4 | vertex_program: "/deffx/materials/tilemap/animated_tilemap.vp" 5 | fragment_program: "/deffx/materials/tilemap/animated_tilemap.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "world" 12 | type: CONSTANT_TYPE_WORLD 13 | } 14 | vertex_constants { 15 | name: "offset" 16 | type: CONSTANT_TYPE_USER 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 | -------------------------------------------------------------------------------- /examples_postprocessing/noise/noise.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.timer = 0 3 | go.set("/unitquad#unitquad", "options.y", 0.09) -- adjust opactity of noise layer added 4 | end 5 | 6 | 7 | 8 | function update(self, dt) 9 | self.timer = math.fmod(self.timer + dt, 1)+0.01 -- repeat noise pattern 10 | go.set("/unitquad#unitquad", "options.x", self.timer) 11 | 12 | --go.set("/unitquad#unitquad", "time.x", self.timer) 13 | 14 | --local amount = math.floor(math.abs(math.sin(self.timer)) * self.pixelamount) 15 | --local amount = (math.abs(math.sin(self.timer)) * self.pixelamount) 16 | --go.set("/unitquad#unitquad", "options.x", amount) 17 | 18 | 19 | end 20 | -------------------------------------------------------------------------------- /deffx/materials/_tools/normal.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | uniform mediump mat4 modelview; 4 | uniform mediump mat4 normalMat; 5 | 6 | attribute mediump vec3 position; 7 | attribute mediump vec3 normal; 8 | attribute mediump vec2 texcoord0; 9 | 10 | varying mediump vec2 var_texcoord0; 11 | varying mediump vec3 var_position; 12 | varying mediump vec3 var_normal; 13 | 14 | void main(){ 15 | gl_Position = view_proj * world * vec4(position.xyz, 1.0); 16 | 17 | vec4 vertPos4 = modelview * vec4(position, 1.0); 18 | var_position = vec3(vertPos4) / vertPos4.w; 19 | var_normal = vec3(normalMat * vec4(normal, 0.0)); 20 | var_texcoord0 = texcoord0; 21 | } -------------------------------------------------------------------------------- /deffx/materials/model/checker.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | uniform mediump mat4 modelview; 4 | uniform mediump mat4 normalMat; 5 | 6 | attribute mediump vec3 position; 7 | attribute mediump vec3 normal; 8 | attribute mediump vec2 texcoord0; 9 | 10 | varying mediump vec2 var_texcoord0; 11 | varying mediump vec3 var_position; 12 | varying mediump vec3 var_normal; 13 | 14 | void main(){ 15 | gl_Position = view_proj * world * vec4(position.xyz, 1.0); 16 | 17 | vec4 vertPos4 = modelview * vec4(position, 1.0); 18 | var_position = vec3(vertPos4) / vertPos4.w; 19 | var_normal = vec3(normalMat * vec4(normal, 0.0)); 20 | var_texcoord0 = texcoord0; 21 | } -------------------------------------------------------------------------------- /deffx/materials/model/lambert.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | uniform mediump mat4 modelview; 4 | uniform mediump mat4 normalMat; 5 | 6 | attribute mediump vec3 position; 7 | attribute mediump vec3 normal; 8 | attribute mediump vec2 texcoord0; 9 | 10 | varying mediump vec2 var_texcoord0; 11 | varying mediump vec3 var_position; 12 | varying mediump vec3 var_normal; 13 | 14 | void main(){ 15 | gl_Position = view_proj * world * vec4(position.xyz, 1.0); 16 | 17 | vec4 vertPos4 = modelview * vec4(position, 1.0); 18 | var_position = vec3(vertPos4) / vertPos4.w; 19 | var_normal = vec3(normalMat * vec4(normal, 0.0)); 20 | var_texcoord0 = texcoord0; 21 | } -------------------------------------------------------------------------------- /deffx/materials/model/phong.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | uniform mediump mat4 modelview; 4 | uniform mediump mat4 normalMat; 5 | 6 | attribute mediump vec3 position; 7 | attribute mediump vec3 normal; 8 | attribute mediump vec2 texcoord0; 9 | 10 | varying mediump vec2 var_texcoord0; 11 | varying mediump vec3 var_position; 12 | varying mediump vec3 var_normal; 13 | 14 | void main(){ 15 | gl_Position = view_proj * world * vec4(position.xyz, 1.0); 16 | 17 | vec4 vertPos4 = modelview * vec4(position, 1.0); 18 | var_position = vec3(vertPos4) / vertPos4.w; 19 | var_normal = vec3(normalMat * vec4(normal, 0.0)); 20 | var_texcoord0 = texcoord0; 21 | } -------------------------------------------------------------------------------- /deffx/quad/quad.material: -------------------------------------------------------------------------------- 1 | name: "unitquad" 2 | tags: "unitquad" 3 | vertex_program: "/deffx/quad/quad.vp" 4 | fragment_program: "/deffx/quad/quad.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "world" 11 | type: CONSTANT_TYPE_WORLD 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 | samplers { 24 | name: "QUAD_TEXTURE" 25 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 26 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 27 | filter_min: FILTER_MODE_MIN_LINEAR 28 | filter_mag: FILTER_MODE_MAG_LINEAR 29 | } 30 | -------------------------------------------------------------------------------- /game.project: -------------------------------------------------------------------------------- 1 | [project] 2 | title = DefFX 3 | version = 1.0 4 | dependencies = 5 | 6 | [input] 7 | game_binding = /input/game.input_bindingc 8 | 9 | [bootstrap] 10 | main_collection = /examples_sprites/normal_sprite_illumination/normal_sprite_illumination.collectionc 11 | render = /deffx/render/sprite_debug/default.renderc 12 | 13 | [display] 14 | width = 1600 15 | height = 800 16 | samples = 0 17 | 18 | [physics] 19 | scale = 0.02 20 | 21 | [script] 22 | shared_state = 1 23 | 24 | [library] 25 | include_dirs = deffx 26 | 27 | [android] 28 | package = com.subsoap.deffx 29 | 30 | [ios] 31 | bundle_identifier = com.subsoap.deffx 32 | 33 | [osx] 34 | bundle_identifier = com.subsoap.deffx 35 | 36 | -------------------------------------------------------------------------------- /deffx/materials/model/depth.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying mediump vec3 var_position; 3 | varying mediump vec3 var_normal; 4 | 5 | uniform lowp vec4 eye; 6 | uniform lowp vec4 lightPos4; 7 | uniform lowp sampler2D DIFFUSE_TEXTURE; 8 | 9 | // todo: update near far values from render script camera 10 | float near = 0.1; 11 | float far = 100.0; 12 | 13 | float linearize_depth(float depth) 14 | { 15 | float z = depth * 2.0 - 1.0; // Back to NDC 16 | return (2.0 * near * far) / (far + near - z * (far - near)); 17 | } 18 | 19 | 20 | void main( void ) 21 | { 22 | float depth = linearize_depth(gl_FragCoord.z) / far; 23 | 24 | gl_FragColor = vec4(vec3(depth), 1.0f); 25 | } -------------------------------------------------------------------------------- /deffx/materials/model/perturb_normals.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | uniform mediump mat4 modelview; 4 | uniform mediump mat4 normalMat; 5 | 6 | attribute mediump vec3 position; 7 | attribute mediump vec3 normal; 8 | attribute mediump vec2 texcoord0; 9 | 10 | varying mediump vec2 var_texcoord0; 11 | varying mediump vec3 var_position; 12 | varying mediump vec3 var_normal; 13 | 14 | void main(){ 15 | gl_Position = view_proj * world * vec4(position.xyz, 1.0); 16 | 17 | vec4 vertPos4 = modelview * vec4(position, 1.0); 18 | var_position = vec3(vertPos4) / vertPos4.w; 19 | var_normal = vec3(normalMat * vec4(normal, 0.0)); 20 | var_texcoord0 = texcoord0; 21 | } -------------------------------------------------------------------------------- /deffx/materials/model/facing_ratio.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | uniform mediump mat4 modelview; 4 | uniform mediump mat4 normalMat; 5 | 6 | attribute mediump vec3 position; 7 | attribute mediump vec3 normal; 8 | attribute mediump vec2 texcoord0; 9 | 10 | varying mediump vec2 var_texcoord0; 11 | varying mediump vec3 var_position; 12 | varying mediump vec3 var_normal; 13 | 14 | void main(){ 15 | 16 | 17 | gl_Position = view_proj * world * vec4(position.xyz, 1.0); 18 | 19 | vec4 vertPos4 = modelview * vec4(position, 1.0); 20 | var_position = vec3(vertPos4) / vertPos4.w; 21 | var_normal = vec3(normalMat * vec4(normal, 0.0)); 22 | var_texcoord0 = texcoord0; 23 | } -------------------------------------------------------------------------------- /deffx/materials/sprite/pixelate.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp vec4 options; 5 | uniform lowp vec4 resolution; 6 | 7 | void main() 8 | { 9 | // Pre-multiply alpha since all runtime textures already are 10 | //lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 11 | //gl_FragColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy) * tint_pm; 12 | 13 | float d = 1.0 / options.x; 14 | float ar = resolution.x / resolution.y; 15 | float u = floor( var_texcoord0.x / d ) * d; 16 | d = ar / options.x; 17 | float v = floor( var_texcoord0.y / d ) * d; 18 | gl_FragColor = texture2D( DIFFUSE_TEXTURE, vec2( u, v ) ); 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /deffx/materials/model/depth.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | uniform mediump mat4 modelview; 4 | uniform mediump mat4 normalMat; 5 | 6 | attribute mediump vec3 position; 7 | attribute mediump vec3 normal; 8 | attribute mediump vec2 texcoord0; 9 | 10 | varying mediump vec2 var_texcoord0; 11 | varying mediump vec3 var_position; 12 | varying mediump vec3 var_normal; 13 | 14 | 15 | 16 | void main(){ 17 | gl_Position = view_proj * world * vec4(position.xyz, 1.0); 18 | 19 | vec4 vertPos4 = modelview * vec4(position, 1.0); 20 | var_position = vec3(vertPos4) / vertPos4.w; 21 | var_normal = vec3(normalMat * vec4(normal, 0.0)); 22 | var_texcoord0 = texcoord0; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /deffx/materials/model/wireframe.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | uniform mediump mat4 modelview; 4 | uniform mediump mat4 normalMat; 5 | 6 | attribute mediump vec3 position; 7 | attribute mediump vec3 normal; 8 | attribute mediump vec2 texcoord0; 9 | 10 | varying mediump vec2 var_texcoord0; 11 | varying mediump vec3 var_position; 12 | varying mediump vec3 var_normal; 13 | 14 | 15 | 16 | void main(){ 17 | gl_Position = view_proj * world * vec4(position.xyz, 1.0); 18 | 19 | vec4 vertPos4 = modelview * vec4(position, 1.0); 20 | var_position = vec3(vertPos4) / vertPos4.w; 21 | var_normal = vec3(normalMat * vec4(normal, 0.0)); 22 | var_texcoord0 = texcoord0; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /deffx/materials/rendertarget/noise.material: -------------------------------------------------------------------------------- 1 | name: "unitquad" 2 | tags: "unitquad" 3 | vertex_program: "/deffx/quad/quad.vp" 4 | fragment_program: "/deffx/materials/rendertarget/noise.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "world" 11 | type: CONSTANT_TYPE_WORLD 12 | } 13 | fragment_constants { 14 | name: "options" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 128.0 18 | y: 0.25 19 | z: 0.0 20 | w: 0.0 21 | } 22 | } 23 | samplers { 24 | name: "" 25 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 26 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 27 | filter_min: FILTER_MODE_MIN_LINEAR 28 | filter_mag: FILTER_MODE_MAG_LINEAR 29 | } 30 | -------------------------------------------------------------------------------- /deffx/materials/render_material/overdraw.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | vertex_program: "/deffx/materials/render_material/overdraw.vp" 4 | fragment_program: "/deffx/materials/render_material/overdraw.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "world" 11 | type: CONSTANT_TYPE_WORLD 12 | } 13 | vertex_constants { 14 | name: "used_by_other_shader" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 1.0 18 | y: 0.0 19 | z: 0.0 20 | w: 1.0 21 | } 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 | -------------------------------------------------------------------------------- /examples_blending/vivid_light/vivid_light.script: -------------------------------------------------------------------------------- 1 | -- texture must be a power of 2 and the only image in its atlas 2 | 3 | function init(self) 4 | self.timer = 0 5 | 6 | end 7 | 8 | 9 | 10 | function update(self, dt) 11 | self.timer = self.timer + dt 12 | self.offset = (math.sin(self.timer)) 13 | go.set("/unitquad#unitquad", "tint.w", math.abs(self.offset)) 14 | --go.set("/go#sprite", "offset.y", self.offset + math.cos(self.timer * 0.4)) 15 | --go.set("/go#sprite", "timer.x", self.timer) 16 | 17 | --local amount = math.floor(math.abs(math.sin(self.timer)) * self.pixelamount) 18 | --local amount = (math.abs(math.sin(self.timer)) * self.pixelamount) 19 | --go.set("/unitquad#unitquad", "options.x", amount) 20 | 21 | 22 | end 23 | -------------------------------------------------------------------------------- /examples_postprocessing/blur_simple/blur_simple.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.timer = 0 3 | self.delta = 0 4 | --go.set("/unitquad#unitquad", "options.y", 0.09) -- adjust opactity of noise layer added 5 | end 6 | 7 | 8 | 9 | function update(self, dt) 10 | --self.timer = math.fmod(self.timer + dt *10, 10) 11 | self.timer = self.timer + dt 12 | self.delta = math.abs(math.sin(self.timer)) * 4 13 | go.set("/unitquad#unitquad", "delta.x", self.delta) 14 | --go.set("/unitquad#unitquad", "time.x", self.timer) 15 | 16 | --local amount = math.floor(math.abs(math.sin(self.timer)) * self.pixelamount) 17 | --local amount = (math.abs(math.sin(self.timer)) * self.pixelamount) 18 | --go.set("/unitquad#unitquad", "options.x", amount) 19 | 20 | 21 | end 22 | -------------------------------------------------------------------------------- /examples_sprites/scrolling_texture/scrolling_texture.script: -------------------------------------------------------------------------------- 1 | -- texture must be a power of 2 and the only image in its atlas 2 | 3 | function init(self) 4 | self.timer = 0 5 | 6 | end 7 | 8 | 9 | 10 | function update(self, dt) 11 | self.timer = self.timer + dt 12 | self.offset = (math.sin(self.timer)) 13 | --go.set("/go#sprite", "offset.x", self.offset + math.cos(self.timer * 1.2)) 14 | --go.set("/go#sprite", "offset.y", self.offset + math.cos(self.timer * 0.4)) 15 | --go.set("/go#sprite", "timer.x", self.timer) 16 | 17 | --local amount = math.floor(math.abs(math.sin(self.timer)) * self.pixelamount) 18 | --local amount = (math.abs(math.sin(self.timer)) * self.pixelamount) 19 | --go.set("/unitquad#unitquad", "options.x", amount) 20 | 21 | 22 | end 23 | -------------------------------------------------------------------------------- /examples_postprocessing/blur_direction/blur_direction.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.timer = 0 3 | self.delta = 0 4 | --go.set("/unitquad#unitquad", "options.y", 0.09) -- adjust opactity of noise layer added 5 | end 6 | 7 | 8 | 9 | function update(self, dt) 10 | --self.timer = math.fmod(self.timer + dt *10, 10) 11 | self.timer = self.timer + dt 12 | self.delta = math.abs(math.sin(self.timer)) --* 0.4 13 | go.set("/unitquad#unitquad", "delta.x", self.delta) 14 | --go.set("/unitquad#unitquad", "time.x", self.timer) 15 | 16 | --local amount = math.floor(math.abs(math.sin(self.timer)) * self.pixelamount) 17 | --local amount = (math.abs(math.sin(self.timer)) * self.pixelamount) 18 | --go.set("/unitquad#unitquad", "options.x", amount) 19 | 20 | 21 | end 22 | -------------------------------------------------------------------------------- /deffx/lights/point.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | -- Add initialization code here 3 | -- Remove this function if not needed 4 | end 5 | 6 | function final(self) 7 | -- Add finalization code here 8 | -- Remove this function if not needed 9 | end 10 | 11 | function update(self, dt) 12 | -- Add update code here 13 | -- Remove this function if not needed 14 | end 15 | 16 | function on_message(self, message_id, message, sender) 17 | -- Add message-handling code here 18 | -- Remove this function if not needed 19 | end 20 | 21 | function on_input(self, action_id, action) 22 | -- Add input-handling code here 23 | -- Remove this function if not needed 24 | end 25 | 26 | function on_reload(self) 27 | -- Add reload-handling code here 28 | -- Remove this function if not needed 29 | end 30 | -------------------------------------------------------------------------------- /deffx/lights/directional.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | -- Add initialization code here 3 | -- Remove this function if not needed 4 | end 5 | 6 | function final(self) 7 | -- Add finalization code here 8 | -- Remove this function if not needed 9 | end 10 | 11 | function update(self, dt) 12 | -- Add update code here 13 | -- Remove this function if not needed 14 | end 15 | 16 | function on_message(self, message_id, message, sender) 17 | -- Add message-handling code here 18 | -- Remove this function if not needed 19 | end 20 | 21 | function on_input(self, action_id, action) 22 | -- Add input-handling code here 23 | -- Remove this function if not needed 24 | end 25 | 26 | function on_reload(self) 27 | -- Add reload-handling code here 28 | -- Remove this function if not needed 29 | end 30 | -------------------------------------------------------------------------------- /examples_sprites/lighten/lighten.script: -------------------------------------------------------------------------------- 1 | -- Can be used to make objects flash when they take damage for example 2 | -- You can also apply a tint after making an object brighter to colorize its flash 3 | 4 | function init(self) 5 | self.timer = 0 6 | -- Add initialization code here 7 | -- Remove this function if not needed 8 | 9 | end 10 | 11 | function update(self, dt) 12 | self.timer = self.timer + dt * 0.5 13 | local offset = math.fmod(self.timer, 4) 14 | 15 | go.set("/public#turkey", "options.x", math.max(math.sin(self.timer * 1), 0.1) + math.max(math.sin(self.timer * 10), 0.1)) 16 | go.set("/public#japan", "options.x", offset) 17 | go.set("/defold#large", "options.x", offset) 18 | go.set("/defold#small", "options.x", 0.1) 19 | 20 | -- Add update code here 21 | -- Remove this function if not needed 22 | end 23 | -------------------------------------------------------------------------------- /examples_sprites/normal_sprite_illumination/sprite_lit.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | -- Add initialization code here 3 | -- Remove this function if not needed 4 | end 5 | 6 | function final(self) 7 | -- Add finalization code here 8 | -- Remove this function if not needed 9 | end 10 | 11 | function update(self, dt) 12 | -- Add update code here 13 | -- Remove this function if not needed 14 | end 15 | 16 | function on_message(self, message_id, message, sender) 17 | -- Add message-handling code here 18 | -- Remove this function if not needed 19 | end 20 | 21 | function on_input(self, action_id, action) 22 | -- Add input-handling code here 23 | -- Remove this function if not needed 24 | end 25 | 26 | function on_reload(self) 27 | -- Add reload-handling code here 28 | -- Remove this function if not needed 29 | end 30 | -------------------------------------------------------------------------------- /deffx/materials/blend/cross_fade.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | vertex_program: "/builtins/materials/sprite.vp" 4 | fragment_program: "/deffx/materials/blend/cross_fade.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | fragment_constants { 10 | name: "progress" 11 | type: CONSTANT_TYPE_USER 12 | value { 13 | x: 0.0 14 | y: 0.0 15 | z: 0.0 16 | w: 0.0 17 | } 18 | } 19 | samplers { 20 | name: "DIFFUSE_TEXTURE" 21 | wrap_u: WRAP_MODE_REPEAT 22 | wrap_v: WRAP_MODE_REPEAT 23 | filter_min: FILTER_MODE_MIN_LINEAR 24 | filter_mag: FILTER_MODE_MAG_LINEAR 25 | } 26 | samplers { 27 | name: "BLEND" 28 | wrap_u: WRAP_MODE_REPEAT 29 | wrap_v: WRAP_MODE_REPEAT 30 | filter_min: FILTER_MODE_MIN_LINEAR 31 | filter_mag: FILTER_MODE_MAG_LINEAR 32 | } 33 | -------------------------------------------------------------------------------- /_main/main.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "collection_loader" 5 | data: "embedded_components {\n" 6 | " id: \"collectionproxy\"\n" 7 | " type: \"collectionproxy\"\n" 8 | " data: \"collection: \\\"/examples_sprites/_blank/blank.collection\\\"\\n" 9 | "exclude: false\\n" 10 | "\"\n" 11 | " position {\n" 12 | " x: 0.0\n" 13 | " y: 0.0\n" 14 | " z: 0.0\n" 15 | " }\n" 16 | " rotation {\n" 17 | " x: 0.0\n" 18 | " y: 0.0\n" 19 | " z: 0.0\n" 20 | " w: 1.0\n" 21 | " }\n" 22 | "}\n" 23 | "" 24 | position { 25 | x: 0.0 26 | y: 0.0 27 | z: 0.0 28 | } 29 | rotation { 30 | x: 0.0 31 | y: 0.0 32 | z: 0.0 33 | w: 1.0 34 | } 35 | scale3 { 36 | x: 1.0 37 | y: 1.0 38 | z: 1.0 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples_sprites/linear_gradient/linear_gradient.script: -------------------------------------------------------------------------------- 1 | -- texture must be a power of 2 and the only image in its atlas 2 | 3 | function init(self) 4 | self.timer = 0 5 | 6 | end 7 | 8 | 9 | 10 | function update(self, dt) 11 | self.timer = self.timer + dt 12 | self.offset = (math.sin(self.timer)) 13 | go.set("/go#sprite", "gradient_start.x", math.sin(self.timer * 1.2)) 14 | go.set("/go#sprite", "gradient_start.y", math.cos(self.timer * 0.4)) 15 | go.set("/go#sprite", "gradient_stop.x", math.cos(self.timer * 1.2)) 16 | go.set("/go#sprite", "gradient_stop.y", math.sin(self.timer * 0.4)) 17 | 18 | --local amount = math.floor(math.abs(math.sin(self.timer)) * self.pixelamount) 19 | --local amount = (math.abs(math.sin(self.timer)) * self.pixelamount) 20 | --go.set("/unitquad#unitquad", "options.x", amount) 21 | 22 | 23 | end 24 | -------------------------------------------------------------------------------- /deffx/materials/sprite/outerglow.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | uniform lowp sampler2D DIFFUSE_TEXTURE; 3 | uniform lowp vec4 color; 4 | 5 | void main() 6 | { 7 | vec4 sum = vec4(0); 8 | vec2 texcoord = var_texcoord0; 9 | if (texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy).a <= 0.8 ) { 10 | 11 | for(int xx = -1; xx <= 0; xx++) { 12 | for(int yy = 3; yy <= 4; yy++) { 13 | float dist = sqrt(float(xx*xx) + float(yy*yy)); 14 | float factor = 0.0; 15 | if (dist == 0.0) { 16 | factor = 2.0; 17 | } else { 18 | factor = 2.0/abs(float(dist)); 19 | } 20 | sum += texture2D(DIFFUSE_TEXTURE, texcoord + vec2(xx, yy) * 0.0005) * factor; 21 | sum.r = 255.0 * sum.a; 22 | sum.g = 255.0 * sum.a; 23 | sum.b = 255.0 * sum.a; 24 | } 25 | } 26 | 27 | } 28 | 29 | gl_FragColor = sum * 0.025 + texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy); 30 | } 31 | -------------------------------------------------------------------------------- /deffx/materials/rendertarget/pixelate.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp sampler2D DEPTH_BUFFER; 5 | uniform lowp vec4 options; 6 | uniform lowp vec4 resolution; 7 | 8 | void main() 9 | { 10 | // Pre-multiply alpha since all runtime textures already are 11 | //lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 12 | //gl_FragColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy) * tint_pm; 13 | 14 | float d = 1.0 / options.x; 15 | float ar = resolution.x / resolution.y; 16 | float u = floor( var_texcoord0.x / d ) * d; 17 | d = ar / options.x; 18 | float v = floor( var_texcoord0.y / d ) * d; 19 | gl_FragColor = texture2D(DEPTH_BUFFER, vec2( u, v )); 20 | gl_FragColor.a = texture2D( DIFFUSE_TEXTURE, vec2( u, v ) ).a; 21 | //gl_FragColor = texture2D(DEPTH_BUFFER, var_texcoord0); 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /examples_sprites/simple_gradient/simple_gradient.script: -------------------------------------------------------------------------------- 1 | -- texture must be a power of 2 and the only image in its atlas 2 | 3 | function init(self) 4 | self.timer = 0 5 | 6 | end 7 | 8 | 9 | 10 | function update(self, dt) 11 | self.timer = self.timer + dt 12 | self.offset = (math.sin(self.timer)) 13 | go.set("/go#sprite", "gradient_start.x", math.sin(self.timer * 1.2)) 14 | go.set("/go#sprite", "gradient_start.y", math.cos(self.timer * 0.4)) 15 | go.set("/go#sprite", "gradient_stop.x", math.cos(self.timer * 1.2)) 16 | go.set("/go#sprite", "gradient_stop.y", math.sin(self.timer * 0.4)) 17 | --go.set("/go#sprite", "timer.x", self.timer) 18 | 19 | --local amount = math.floor(math.abs(math.sin(self.timer)) * self.pixelamount) 20 | --local amount = (math.abs(math.sin(self.timer)) * self.pixelamount) 21 | --go.set("/unitquad#unitquad", "options.x", amount) 22 | 23 | 24 | end 25 | -------------------------------------------------------------------------------- /deffx/materials/model/normals.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | uniform mediump mat4 modelview; 4 | uniform mediump mat4 normalMat; 5 | 6 | attribute mediump vec3 position; 7 | attribute mediump vec3 normal; 8 | attribute mediump vec3 tangent; 9 | attribute mediump vec2 texcoord0; 10 | 11 | varying mediump vec2 var_texcoord0; 12 | varying mediump vec3 var_position; 13 | varying mediump vec3 var_normal; 14 | varying mediump vec3 var_bitangent; 15 | varying mediump vec3 var_tangent; 16 | 17 | void main(){ 18 | gl_Position = view_proj * world * vec4(position.xyz, 1.0); 19 | 20 | vec4 vertPos4 = modelview * vec4(position, 1.0); 21 | var_position = vec3(vertPos4) / vertPos4.w; 22 | var_normal = vec3(normalMat * vec4(normal, 0.0)); 23 | var_texcoord0 = texcoord0; 24 | var_tangent = tangent; 25 | var_bitangent = cross(normal, tangent); 26 | 27 | 28 | 29 | } -------------------------------------------------------------------------------- /examples_sprites/normal_sprite_illumination/light_manager.script: -------------------------------------------------------------------------------- 1 | go.property("ambient_color", vmath.vector4(1.0, 1.0, 1.0, 0.0)) 2 | 3 | function init(self) 4 | -- Add initialization code here 5 | -- Remove this function if not needed 6 | end 7 | 8 | function final(self) 9 | -- Add finalization code here 10 | -- Remove this function if not needed 11 | end 12 | 13 | function update(self, dt) 14 | -- Add update code here 15 | -- Remove this function if not needed 16 | end 17 | 18 | function on_message(self, message_id, message, sender) 19 | -- Add message-handling code here 20 | -- Remove this function if not needed 21 | end 22 | 23 | function on_input(self, action_id, action) 24 | -- Add input-handling code here 25 | -- Remove this function if not needed 26 | end 27 | 28 | function on_reload(self) 29 | -- Add reload-handling code here 30 | -- Remove this function if not needed 31 | end 32 | -------------------------------------------------------------------------------- /deffx/materials/model/3d.material: -------------------------------------------------------------------------------- 1 | name: "3d" 2 | tags: "3d" 3 | vertex_program: "/deffx/materials/model/3d.vp" 4 | fragment_program: "/deffx/materials/model/3d.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "world" 11 | type: CONSTANT_TYPE_WORLD 12 | } 13 | fragment_constants { 14 | name: "color" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 0.0 18 | y: 0.0 19 | z: 0.0 20 | w: 0.0 21 | } 22 | } 23 | samplers { 24 | name: "LEFT" 25 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 26 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 27 | filter_min: FILTER_MODE_MIN_LINEAR 28 | filter_mag: FILTER_MODE_MAG_LINEAR 29 | } 30 | samplers { 31 | name: "RIGHT" 32 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 33 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 34 | filter_min: FILTER_MODE_MIN_LINEAR 35 | filter_mag: FILTER_MODE_MAG_LINEAR 36 | } 37 | -------------------------------------------------------------------------------- /deffx/materials/rendertarget/fxaa.material: -------------------------------------------------------------------------------- 1 | name: "fxaa" 2 | tags: "unitquad" 3 | vertex_program: "/deffx/quad/quad.vp" 4 | fragment_program: "/deffx/materials/rendertarget/fxaa.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "world" 11 | type: CONSTANT_TYPE_WORLD 12 | } 13 | fragment_constants { 14 | name: "options" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 1.0 18 | y: 0.0 19 | z: 0.0 20 | w: 0.0 21 | } 22 | } 23 | fragment_constants { 24 | name: "resolution" 25 | type: CONSTANT_TYPE_USER 26 | value { 27 | x: 1600.0 28 | y: 800.0 29 | z: 0.0 30 | w: 0.0 31 | } 32 | } 33 | samplers { 34 | name: "POST_TEXTURE" 35 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 36 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 37 | filter_min: FILTER_MODE_MIN_LINEAR 38 | filter_mag: FILTER_MODE_MAG_LINEAR 39 | } 40 | -------------------------------------------------------------------------------- /deffx/materials/model/checker.material: -------------------------------------------------------------------------------- 1 | name: "checker" 2 | tags: "model" 3 | tags: "3d" 4 | vertex_program: "/deffx/materials/model/checker.vp" 5 | fragment_program: "/deffx/materials/model/checker.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "world" 12 | type: CONSTANT_TYPE_WORLD 13 | } 14 | vertex_constants { 15 | name: "modelview" 16 | type: CONSTANT_TYPE_WORLDVIEW 17 | } 18 | vertex_constants { 19 | name: "normalMat" 20 | type: CONSTANT_TYPE_NORMAL 21 | } 22 | fragment_constants { 23 | name: "options" 24 | type: CONSTANT_TYPE_USER 25 | value { 26 | x: 15.0 27 | y: 0.0 28 | z: 0.0 29 | w: 0.0 30 | } 31 | } 32 | samplers { 33 | name: "DIFFUSE_TEXTURE" 34 | wrap_u: WRAP_MODE_REPEAT 35 | wrap_v: WRAP_MODE_REPEAT 36 | filter_min: FILTER_MODE_MIN_LINEAR 37 | filter_mag: FILTER_MODE_MAG_LINEAR 38 | } 39 | -------------------------------------------------------------------------------- /deffx/materials/model/textured.material: -------------------------------------------------------------------------------- 1 | name: "textured" 2 | tags: "model" 3 | tags: "3d" 4 | vertex_program: "/deffx/materials/model/textured.vp" 5 | fragment_program: "/deffx/materials/model/textured.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "world" 12 | type: CONSTANT_TYPE_WORLD 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: "timer" 26 | type: CONSTANT_TYPE_USER 27 | value { 28 | x: 1.0 29 | y: 0.0 30 | z: 0.0 31 | w: 0.0 32 | } 33 | } 34 | samplers { 35 | name: "DIFFUSE_TEXTURE" 36 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 37 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 38 | filter_min: FILTER_MODE_MIN_LINEAR 39 | filter_mag: FILTER_MODE_MAG_LINEAR 40 | } 41 | -------------------------------------------------------------------------------- /deffx/materials/rendertarget/blur_direction.fp: -------------------------------------------------------------------------------- 1 | //https://github.com/spite/Wagner/blob/master/fragment-shaders/box-blur-fs.glsl 2 | 3 | // weird halo on edge of pure black pixels? 4 | 5 | varying mediump vec2 var_texcoord0; 6 | uniform lowp sampler2D DIFFUSE_TEXTURE; 7 | uniform lowp vec4 options; 8 | uniform lowp vec4 delta; 9 | 10 | 11 | 12 | float random(vec3 scale,float seed){return fract(sin(dot(gl_FragCoord.xyz+seed,scale))*43758.5453+seed);} 13 | 14 | 15 | void main() 16 | { 17 | vec4 color=vec4(0.0); 18 | float total=0.0; 19 | float offset=random(vec3(12.9898,78.233,151.7182),0.0); 20 | for(float t=-30.0;t<=30.0;t++){ 21 | float percent=(t+offset-0.5)/30.0; 22 | float weight=1.0-abs(percent); 23 | vec4 sample=texture2D(DIFFUSE_TEXTURE,var_texcoord0+delta.x*percent); 24 | sample.rgb*=sample.a; 25 | color+=sample*weight; 26 | total+=weight; 27 | } 28 | 29 | gl_FragColor=color/total; 30 | gl_FragColor.rgb/=gl_FragColor.a+0.00001; 31 | } -------------------------------------------------------------------------------- /deffx/materials/model/toon.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | uniform mediump mat4 modelview; 4 | uniform mediump mat4 normalMat; 5 | 6 | attribute mediump vec3 position; 7 | attribute mediump vec3 normal; 8 | attribute mediump vec2 texcoord0; 9 | 10 | varying mediump vec2 var_texcoord0; 11 | varying mediump vec3 var_position; 12 | varying mediump vec3 var_normal; 13 | 14 | uniform mediump vec4 light_position; 15 | varying mediump vec3 light_position_transformed; 16 | 17 | void main(){ 18 | 19 | vec3 light_position_F = vec3(light_position.x, light_position.y, light_position.z); 20 | 21 | gl_Position = view_proj * world * vec4(position.xyz, 1.0); 22 | 23 | vec4 vertPos4 = modelview * vec4(position, 1.0); 24 | var_position = vec3(vertPos4) / vertPos4.w; 25 | var_normal = vec3(normalMat * vec4(normal, 0.0)); 26 | light_position_transformed = vec3(vertPos4) / vertPos4.w * light_position_F; 27 | var_texcoord0 = texcoord0; 28 | } -------------------------------------------------------------------------------- /deffx/materials/render_material/overdraw.vp: -------------------------------------------------------------------------------- 1 | uniform mediump mat4 view_proj; 2 | uniform mediump mat4 world; 3 | 4 | // You need to add all constants that your other shaders are uing here and retrive values for 5 | // uniform lowp vec4 used_by_other_shader; 6 | 7 | attribute mediump vec4 position; 8 | attribute mediump vec2 texcoord0; 9 | 10 | varying lowp vec4 var_color; 11 | 12 | 13 | void main() 14 | { 15 | // NOTE: world isn't used here. Sprite positions are already transformed 16 | // prior to rendering but the world-transform is set for sorting. 17 | gl_Position = view_proj * vec4(position.xyz, 1.0); 18 | 19 | // You need to add all constants that your other shaders are uing here and retrive values for 20 | // it will crash if they are not pressent. We also need to 'use' it so the compiler doesn't remove it. 21 | 22 | // used_by_other_shader; 23 | 24 | 25 | var_color = vec4(1.0, 1.0, 1.0, 1.0); 26 | } 27 | -------------------------------------------------------------------------------- /deffx/materials/sprite/scrolling.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | vertex_program: "/builtins/materials/sprite.vp" 4 | fragment_program: "/deffx/materials/sprite/scrolling.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: "offset" 21 | type: CONSTANT_TYPE_USER 22 | value { 23 | x: 0.0 24 | y: 0.0 25 | z: 0.0 26 | w: 0.0 27 | } 28 | } 29 | fragment_constants { 30 | name: "timer" 31 | type: CONSTANT_TYPE_USER 32 | value { 33 | x: 0.0 34 | y: 0.0 35 | z: 0.0 36 | w: 0.0 37 | } 38 | } 39 | samplers { 40 | name: "DIFFUSE_TEXTURE" 41 | wrap_u: WRAP_MODE_REPEAT 42 | wrap_v: WRAP_MODE_REPEAT 43 | filter_min: FILTER_MODE_MIN_LINEAR 44 | filter_mag: FILTER_MODE_MAG_LINEAR 45 | } 46 | -------------------------------------------------------------------------------- /examples_sprites/normal_sprite_illumination/sprite_rotate.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | go.animate(go.get_id(), "euler.z", go.PLAYBACK_LOOP_FORWARD, 360, go.EASING_LINEAR, 3) 3 | go.animate(go.get_id(), "euler.x", go.PLAYBACK_LOOP_FORWARD, 360, go.EASING_LINEAR, 4) 4 | go.animate(go.get_id(), "euler.y", go.PLAYBACK_LOOP_FORWARD, 360, go.EASING_LINEAR, 5) 5 | msg.post(".", "acquire_input_focus") 6 | self.alt_held_down = false 7 | end 8 | 9 | function on_input(self, action_id, action) 10 | -- check which input we received 11 | if action_id == hash("alt") then 12 | self.alt_held_down = true 13 | print("alt held down") 14 | end 15 | if action_id == hash("alt") and action.released then 16 | self.alt_held_down = false 17 | print("releaseing alt") 18 | end 19 | if action_id == hash("f4") and self.alt_held_down then 20 | print("show confirm dialog to close game") 21 | end 22 | if action_id == hash("f4") and action.pressed then 23 | print("f4") 24 | end 25 | end -------------------------------------------------------------------------------- /deffx/materials/model/depth.material: -------------------------------------------------------------------------------- 1 | name: "depth" 2 | tags: "model" 3 | tags: "3d" 4 | vertex_program: "/deffx/materials/model/depth.vp" 5 | fragment_program: "/deffx/materials/model/depth.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "world" 12 | type: CONSTANT_TYPE_WORLD 13 | } 14 | vertex_constants { 15 | name: "modelview" 16 | type: CONSTANT_TYPE_WORLDVIEW 17 | } 18 | vertex_constants { 19 | name: "normalMat" 20 | type: CONSTANT_TYPE_NORMAL 21 | } 22 | fragment_constants { 23 | name: "lightPos4" 24 | type: CONSTANT_TYPE_USER 25 | value { 26 | x: 0.0 27 | y: 0.0 28 | z: 0.0 29 | w: 0.0 30 | } 31 | } 32 | fragment_constants { 33 | name: "" 34 | type: CONSTANT_TYPE_USER 35 | value { 36 | x: 0.0 37 | y: 0.0 38 | z: 0.0 39 | w: 0.0 40 | } 41 | } 42 | samplers { 43 | name: "DIFFUSE_TEXTURE" 44 | wrap_u: WRAP_MODE_REPEAT 45 | wrap_v: WRAP_MODE_REPEAT 46 | filter_min: FILTER_MODE_MIN_LINEAR 47 | filter_mag: FILTER_MODE_MAG_LINEAR 48 | } 49 | -------------------------------------------------------------------------------- /deffx/materials/model/phong.material: -------------------------------------------------------------------------------- 1 | name: "phong" 2 | tags: "model" 3 | tags: "3d" 4 | vertex_program: "/deffx/materials/model/phong.vp" 5 | fragment_program: "/deffx/materials/model/phong.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "world" 12 | type: CONSTANT_TYPE_WORLD 13 | } 14 | vertex_constants { 15 | name: "modelview" 16 | type: CONSTANT_TYPE_WORLDVIEW 17 | } 18 | vertex_constants { 19 | name: "normalMat" 20 | type: CONSTANT_TYPE_NORMAL 21 | } 22 | fragment_constants { 23 | name: "lightPos4" 24 | type: CONSTANT_TYPE_USER 25 | value { 26 | x: 0.0 27 | y: 0.0 28 | z: 0.0 29 | w: 0.0 30 | } 31 | } 32 | fragment_constants { 33 | name: "" 34 | type: CONSTANT_TYPE_USER 35 | value { 36 | x: 0.0 37 | y: 0.0 38 | z: 0.0 39 | w: 0.0 40 | } 41 | } 42 | samplers { 43 | name: "DIFFUSE_TEXTURE" 44 | wrap_u: WRAP_MODE_REPEAT 45 | wrap_v: WRAP_MODE_REPEAT 46 | filter_min: FILTER_MODE_MIN_LINEAR 47 | filter_mag: FILTER_MODE_MAG_LINEAR 48 | } 49 | -------------------------------------------------------------------------------- /deffx/materials/model/lambert.material: -------------------------------------------------------------------------------- 1 | name: "phong" 2 | tags: "model" 3 | tags: "3d" 4 | vertex_program: "/deffx/materials/model/lambert.vp" 5 | fragment_program: "/deffx/materials/model/lambert.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "world" 12 | type: CONSTANT_TYPE_WORLD 13 | } 14 | vertex_constants { 15 | name: "modelview" 16 | type: CONSTANT_TYPE_WORLDVIEW 17 | } 18 | vertex_constants { 19 | name: "normalMat" 20 | type: CONSTANT_TYPE_NORMAL 21 | } 22 | fragment_constants { 23 | name: "lightPos4" 24 | type: CONSTANT_TYPE_USER 25 | value { 26 | x: 0.0 27 | y: 0.0 28 | z: 0.0 29 | w: 0.0 30 | } 31 | } 32 | fragment_constants { 33 | name: "" 34 | type: CONSTANT_TYPE_USER 35 | value { 36 | x: 0.0 37 | y: 0.0 38 | z: 0.0 39 | w: 0.0 40 | } 41 | } 42 | samplers { 43 | name: "DIFFUSE_TEXTURE" 44 | wrap_u: WRAP_MODE_REPEAT 45 | wrap_v: WRAP_MODE_REPEAT 46 | filter_min: FILTER_MODE_MIN_LINEAR 47 | filter_mag: FILTER_MODE_MAG_LINEAR 48 | } 49 | -------------------------------------------------------------------------------- /deffx/materials/model/normals.material: -------------------------------------------------------------------------------- 1 | name: "phong" 2 | tags: "model" 3 | tags: "3d" 4 | vertex_program: "/deffx/materials/model/normals.vp" 5 | fragment_program: "/deffx/materials/model/normals.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "world" 12 | type: CONSTANT_TYPE_WORLD 13 | } 14 | vertex_constants { 15 | name: "modelview" 16 | type: CONSTANT_TYPE_WORLDVIEW 17 | } 18 | vertex_constants { 19 | name: "normalMat" 20 | type: CONSTANT_TYPE_NORMAL 21 | } 22 | fragment_constants { 23 | name: "lightPos4" 24 | type: CONSTANT_TYPE_USER 25 | value { 26 | x: 0.0 27 | y: 0.0 28 | z: 0.0 29 | w: 0.0 30 | } 31 | } 32 | fragment_constants { 33 | name: "" 34 | type: CONSTANT_TYPE_USER 35 | value { 36 | x: 0.0 37 | y: 0.0 38 | z: 0.0 39 | w: 0.0 40 | } 41 | } 42 | samplers { 43 | name: "DIFFUSE_TEXTURE" 44 | wrap_u: WRAP_MODE_REPEAT 45 | wrap_v: WRAP_MODE_REPEAT 46 | filter_min: FILTER_MODE_MIN_LINEAR 47 | filter_mag: FILTER_MODE_MAG_LINEAR 48 | } 49 | -------------------------------------------------------------------------------- /deffx/materials/rendertarget/blur_direction.material: -------------------------------------------------------------------------------- 1 | name: "unitquad" 2 | tags: "unitquad" 3 | vertex_program: "/builtins/materials/sprite.vp" 4 | fragment_program: "/deffx/materials/rendertarget/blur_direction.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "world" 11 | type: CONSTANT_TYPE_WORLD 12 | } 13 | vertex_constants { 14 | name: "" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 0.0 18 | y: 0.0 19 | z: 0.0 20 | w: 0.0 21 | } 22 | } 23 | fragment_constants { 24 | name: "options" 25 | type: CONSTANT_TYPE_USER 26 | value { 27 | x: 1.0 28 | y: 1.0 29 | z: 1.0 30 | w: 0.0 31 | } 32 | } 33 | fragment_constants { 34 | name: "delta" 35 | type: CONSTANT_TYPE_USER 36 | value { 37 | x: 0.0 38 | y: 0.0 39 | z: 0.0 40 | w: 0.0 41 | } 42 | } 43 | samplers { 44 | name: "" 45 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 46 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 47 | filter_min: FILTER_MODE_MIN_LINEAR 48 | filter_mag: FILTER_MODE_MAG_LINEAR 49 | } 50 | -------------------------------------------------------------------------------- /deffx/materials/rendertarget/scanlines.material: -------------------------------------------------------------------------------- 1 | name: "unitquad" 2 | tags: "unitquad" 3 | vertex_program: "/deffx/quad/quad.vp" 4 | fragment_program: "/deffx/materials/rendertarget/scanlines.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "world" 11 | type: CONSTANT_TYPE_WORLD 12 | } 13 | fragment_constants { 14 | name: "options" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 2.0 18 | y: 4.0 19 | z: 1.0 20 | w: 4.0 21 | } 22 | } 23 | fragment_constants { 24 | name: "resolution" 25 | type: CONSTANT_TYPE_USER 26 | value { 27 | x: 1600.0 28 | y: 800.0 29 | z: 0.0 30 | w: 0.0 31 | } 32 | } 33 | fragment_constants { 34 | name: "time" 35 | type: CONSTANT_TYPE_USER 36 | value { 37 | x: 0.0 38 | y: 0.0 39 | z: 0.0 40 | w: 0.0 41 | } 42 | } 43 | samplers { 44 | name: "" 45 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 46 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 47 | filter_min: FILTER_MODE_MIN_LINEAR 48 | filter_mag: FILTER_MODE_MAG_LINEAR 49 | } 50 | -------------------------------------------------------------------------------- /deffx/materials/_tools/normal.material: -------------------------------------------------------------------------------- 1 | name: "normal" 2 | tags: "model" 3 | tags: "3d" 4 | vertex_program: "/deffx/materials/_tools/normal.vp" 5 | fragment_program: "/deffx/materials/_tools/normal.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "world" 12 | type: CONSTANT_TYPE_WORLD 13 | } 14 | vertex_constants { 15 | name: "modelview" 16 | type: CONSTANT_TYPE_WORLDVIEW 17 | } 18 | vertex_constants { 19 | name: "normalMat" 20 | type: CONSTANT_TYPE_NORMAL 21 | } 22 | fragment_constants { 23 | name: "lightPos4" 24 | type: CONSTANT_TYPE_USER 25 | value { 26 | x: 0.0 27 | y: 0.0 28 | z: 0.0 29 | w: 0.0 30 | } 31 | } 32 | fragment_constants { 33 | name: "" 34 | type: CONSTANT_TYPE_USER 35 | value { 36 | x: 0.0 37 | y: 0.0 38 | z: 0.0 39 | w: 0.0 40 | } 41 | } 42 | samplers { 43 | name: "DIFFUSE_TEXTURE" 44 | wrap_u: WRAP_MODE_REPEAT 45 | wrap_v: WRAP_MODE_REPEAT 46 | filter_min: FILTER_MODE_MIN_NEAREST 47 | filter_mag: FILTER_MODE_MAG_NEAREST 48 | } 49 | -------------------------------------------------------------------------------- /deffx/materials/model/lambert.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying mediump vec3 var_position; 3 | varying mediump vec3 var_normal; 4 | 5 | uniform lowp vec4 eye; 6 | uniform lowp vec4 lightPos4; 7 | uniform lowp sampler2D DIFFUSE_TEXTURE; 8 | //uniform lowp sampler2D PASS_TEXTURE; 9 | 10 | //const vec3 lightPos = vec3(1.0,1.0,1.0); 11 | const vec3 diffuseColor = vec3(0.5, 0.5, 0.5); 12 | const vec3 specColor = vec3(0.7, 0.7, 0.7); 13 | 14 | void main() { 15 | vec3 lightPos = vec3(lightPos4.x, lightPos4.y, lightPos4.z); 16 | vec3 lightDir = normalize(lightPos - var_position); 17 | vec3 normal = normalize(var_normal); 18 | 19 | float lambertian = max(dot(lightDir, normal), 0.0); 20 | float specular = 0.0; 21 | 22 | if(lambertian > 0.0) { 23 | vec3 viewDir = normalize(-var_position); 24 | vec3 halfDir = normalize(lightDir + viewDir); 25 | float specAngle = max(dot(halfDir, normal), 0.0); 26 | specular = 0.0; //pow(specAngle, 32.0); 27 | } 28 | 29 | gl_FragColor = vec4(lambertian * texture2D(DIFFUSE_TEXTURE, var_texcoord0) + specular * specColor, 1.0); 30 | } -------------------------------------------------------------------------------- /deffx/materials/model/toon.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying mediump vec3 var_position; 3 | varying mediump vec3 var_normal; 4 | 5 | uniform lowp vec4 color_highlight; 6 | uniform lowp vec4 color_mid; 7 | uniform lowp vec4 color_shadow; 8 | uniform lowp vec4 highlight_size; 9 | uniform lowp vec4 shadow_size; 10 | uniform lowp vec4 outline_width; 11 | 12 | varying mediump vec3 light_position_transformed; 13 | 14 | void main() { 15 | 16 | //float ratio = -1 * dot(normalize(var_position),normalize(var_normal)); 17 | //clamp(ratio,0.0,1.0); 18 | //gl_FragColor = mix(color_outer,color_inner,ratio); 19 | 20 | vec3 light_position_normalized = normalize(light_position_transformed); 21 | 22 | float lambert = dot(light_position_normalized,var_normal); 23 | vec4 color = color_mid; 24 | if (lambert > highlight_size.x) color = color_highlight; 25 | if (lambert < shadow_size.x) color = color_shadow; 26 | if (dot(var_normal,var_position + 3.8) < outline_width.x) color = color_mid; //vec4(0.0,0.0,0.0,1.0); 27 | 28 | gl_FragColor = color; 29 | 30 | 31 | } -------------------------------------------------------------------------------- /deffx/materials/blend/vivid_light.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp sampler2D BLEND; 5 | uniform lowp vec4 tint; 6 | 7 | 8 | vec4 VividLight( vec4 blend, vec4 base, float fill ) 9 | { 10 | vec4 canvas; 11 | 12 | blend.rgb = (mix( vec3(.5,.5,.5), blend.rgb, fill ) - 0.5) * 2.0; 13 | canvas.rgb = base.rgb + min(blend.rgb, 0.0); 14 | canvas.rgb /= max(1.0-abs(blend.rgb), 0.000001) * base.a; 15 | canvas = clamp( canvas, 0.0, 1.0 ); 16 | canvas.rgb *= blend.a; 17 | canvas.a = blend.a * base.a; 18 | return canvas; 19 | } 20 | 21 | void main() 22 | { 23 | vec4 base = texture2D( DIFFUSE_TEXTURE, var_texcoord0 ); 24 | vec4 blend = texture2D( BLEND, var_texcoord0 ) * tint; 25 | vec4 canvas = VividLight( blend, base, gl_Color.a ); 26 | 27 | canvas.rgb += (1.0 - blend.a) * base.rgb * base.a; 28 | canvas.a += (1.0 - blend.a) * base.a; 29 | blend.a *= gl_Color.a; 30 | canvas.rgb += (1.0 - base.a) * blend.rgb * blend.a; 31 | canvas.a += (1.0 - base.a) * blend.a; 32 | canvas.rgb /= canvas.a; 33 | 34 | gl_FragColor = canvas; 35 | } -------------------------------------------------------------------------------- /deffx/materials/model/phong.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying mediump vec3 var_position; 3 | varying mediump vec3 var_normal; 4 | 5 | uniform lowp vec4 eye; 6 | uniform lowp vec4 lightPos4; 7 | uniform lowp sampler2D DIFFUSE_TEXTURE; 8 | //uniform lowp sampler2D PASS_TEXTURE; 9 | 10 | //const vec3 lightPos = vec3(1.0,1.0,1.0); 11 | const vec3 diffuseColor = vec3(0.5, 0.5, 0.5); 12 | const vec3 specColor = vec3(0.7, 0.7, 0.7); 13 | 14 | void main() { 15 | vec3 lightPos = vec3(lightPos4.x, lightPos4.y, lightPos4.z); 16 | vec3 lightDir = normalize(lightPos - var_position); 17 | vec3 normal = normalize(var_normal); 18 | 19 | float lambertian = max(dot(lightDir, normal), 0.0); 20 | float specular = 0.0; 21 | 22 | if(lambertian > 0.0) { 23 | vec3 viewDir = normalize(-var_position); 24 | vec3 halfDir = normalize(lightDir + viewDir); 25 | float specAngle = max(dot(halfDir, normal), 0.0); 26 | specular = pow(specAngle, 32.0); 27 | } 28 | 29 | gl_FragColor = vec4(lambertian * texture2D(DIFFUSE_TEXTURE, var_texcoord0) + specular * specColor, 1.0); 30 | 31 | 32 | 33 | } -------------------------------------------------------------------------------- /examples_postprocessing/pixelate/pixelate.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.timer = 0 3 | self.pixelamount = 128 4 | -- Add initialization code here 5 | -- Remove this function if not needed 6 | end 7 | 8 | function final(self) 9 | -- Add finalization code here 10 | -- Remove this function if not needed 11 | end 12 | 13 | function update(self, dt) 14 | self.timer = self.timer + dt * 0.05 15 | --local amount = math.floor(math.abs(math.sin(self.timer)) * self.pixelamount) 16 | local amount = (math.abs(math.sin(self.timer)) * self.pixelamount) 17 | go.set("/unitquad#unitquad", "options.x", amount) 18 | 19 | -- Add update code here 20 | -- Remove this function if not needed 21 | end 22 | 23 | function on_message(self, message_id, message, sender) 24 | -- Add message-handling code here 25 | -- Remove this function if not needed 26 | end 27 | 28 | function on_input(self, action_id, action) 29 | -- Add input-handling code here 30 | -- Remove this function if not needed 31 | end 32 | 33 | function on_reload(self) 34 | -- Add reload-handling code here 35 | -- Remove this function if not needed 36 | end 37 | -------------------------------------------------------------------------------- /deffx/materials/rendertarget/chromatic_aberration_screen_edge.material: -------------------------------------------------------------------------------- 1 | name: "unitquad" 2 | tags: "unitquad" 3 | vertex_program: "/deffx/quad/quad.vp" 4 | fragment_program: "/deffx/materials/rendertarget/chromatic_aberration_screen_edge.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "world" 11 | type: CONSTANT_TYPE_WORLD 12 | } 13 | fragment_constants { 14 | name: "options" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 2.0 18 | y: 4.0 19 | z: 1.0 20 | w: 4.0 21 | } 22 | } 23 | fragment_constants { 24 | name: "resolution" 25 | type: CONSTANT_TYPE_USER 26 | value { 27 | x: 1600.0 28 | y: 800.0 29 | z: 0.0 30 | w: 0.0 31 | } 32 | } 33 | fragment_constants { 34 | name: "time" 35 | type: CONSTANT_TYPE_USER 36 | value { 37 | x: 0.0 38 | y: 0.0 39 | z: 0.0 40 | w: 0.0 41 | } 42 | } 43 | samplers { 44 | name: "" 45 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 46 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 47 | filter_min: FILTER_MODE_MIN_LINEAR 48 | filter_mag: FILTER_MODE_MAG_LINEAR 49 | } 50 | -------------------------------------------------------------------------------- /deffx/materials/model/perturb_normals.material: -------------------------------------------------------------------------------- 1 | name: "phong" 2 | tags: "model" 3 | tags: "3d" 4 | vertex_program: "/deffx/materials/model/perturb_normals.vp" 5 | fragment_program: "/deffx/materials/model/perturb_normals.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "world" 12 | type: CONSTANT_TYPE_WORLD 13 | } 14 | vertex_constants { 15 | name: "modelview" 16 | type: CONSTANT_TYPE_WORLDVIEW 17 | } 18 | vertex_constants { 19 | name: "normalMat" 20 | type: CONSTANT_TYPE_NORMAL 21 | } 22 | fragment_constants { 23 | name: "lightPos4" 24 | type: CONSTANT_TYPE_USER 25 | value { 26 | x: 0.0 27 | y: 0.0 28 | z: 0.0 29 | w: 0.0 30 | } 31 | } 32 | samplers { 33 | name: "DIFFUSE_TEXTURE" 34 | wrap_u: WRAP_MODE_REPEAT 35 | wrap_v: WRAP_MODE_REPEAT 36 | filter_min: FILTER_MODE_MIN_LINEAR 37 | filter_mag: FILTER_MODE_MAG_LINEAR 38 | } 39 | samplers { 40 | name: "NORMAL_MAP" 41 | wrap_u: WRAP_MODE_REPEAT 42 | wrap_v: WRAP_MODE_REPEAT 43 | filter_min: FILTER_MODE_MIN_LINEAR 44 | filter_mag: FILTER_MODE_MAG_LINEAR 45 | } 46 | -------------------------------------------------------------------------------- /deffx/materials/rendertarget/pixelate.material: -------------------------------------------------------------------------------- 1 | name: "unitquad" 2 | tags: "unitquad" 3 | vertex_program: "/deffx/quad/quad.vp" 4 | fragment_program: "/deffx/materials/rendertarget/pixelate.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "world" 11 | type: CONSTANT_TYPE_WORLD 12 | } 13 | fragment_constants { 14 | name: "options" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 256.0 18 | y: 0.0 19 | z: 0.0 20 | w: 0.0 21 | } 22 | } 23 | fragment_constants { 24 | name: "resolution" 25 | type: CONSTANT_TYPE_USER 26 | value { 27 | x: 1600.0 28 | y: 800.0 29 | z: 0.0 30 | w: 0.0 31 | } 32 | } 33 | samplers { 34 | name: "DIFFUSE_TEXTURE" 35 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 36 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 37 | filter_min: FILTER_MODE_MIN_LINEAR 38 | filter_mag: FILTER_MODE_MAG_LINEAR 39 | } 40 | samplers { 41 | name: "DEPTH_BUFFER" 42 | wrap_u: WRAP_MODE_CLAMP_TO_EDGE 43 | wrap_v: WRAP_MODE_CLAMP_TO_EDGE 44 | filter_min: FILTER_MODE_MIN_NEAREST 45 | filter_mag: FILTER_MODE_MAG_NEAREST 46 | } 47 | -------------------------------------------------------------------------------- /examples_sprites/hsb/hsb.script: -------------------------------------------------------------------------------- 1 | -- Hue goes between 0 to 1 with 0 and 1 wrapping around, hue shift range 2 | -- If saturation is 0 then it's unsaturated, 1 is normal satuation, 1+ more saturated 3 | -- If brightness is 0 then it's full black, 1 is normal, 1+ extra bright 4 | -- default values are hue 0, saturation 1, brightness 1 5 | -- hsb.x = hue, hsb.y = saturation, hsb.z = brightness 6 | -- http://geraldbakker.nl/psnumbers/hsb-explained.html 7 | 8 | function init(self) 9 | self.timer = 0 10 | -- Add initialization code here 11 | -- Remove this function if not needed 12 | 13 | end 14 | 15 | function update(self, dt) 16 | self.timer = self.timer + dt * 0.1 17 | local offset = math.fmod(self.timer, 1) 18 | go.set("/public#turkey", "hsb.x", offset) 19 | go.set("/public#turkey", "hsb.y", math.sin(self.timer * 20)) 20 | go.set("/public#turkey", "hsb.z", math.max(math.sin(self.timer * 1), 0.1) + math.max(math.sin(self.timer * 10), 0.1)) 21 | go.set("/public#japan", "hsb.x", offset) 22 | go.set("/defold#large", "hsb.x", offset) 23 | go.set("/defold#small", "hsb.x", offset) 24 | -- Add update code here 25 | -- Remove this function if not needed 26 | end 27 | -------------------------------------------------------------------------------- /deffx/materials/sprite/simple_gradient.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | vertex_program: "/builtins/materials/sprite.vp" 4 | fragment_program: "/deffx/materials/sprite/simple_gradient.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | fragment_constants { 10 | name: "gradient_start" 11 | type: CONSTANT_TYPE_USER 12 | value { 13 | x: 0.0 14 | y: 0.0 15 | z: 0.0 16 | w: 0.0 17 | } 18 | } 19 | fragment_constants { 20 | name: "gradient_stop" 21 | type: CONSTANT_TYPE_USER 22 | value { 23 | x: 0.5 24 | y: 0.5 25 | z: 0.0 26 | w: 0.0 27 | } 28 | } 29 | fragment_constants { 30 | name: "color_1" 31 | type: CONSTANT_TYPE_USER 32 | value { 33 | x: 1.0 34 | y: 1.0 35 | z: 1.0 36 | w: 1.0 37 | } 38 | } 39 | fragment_constants { 40 | name: "color_2" 41 | type: CONSTANT_TYPE_USER 42 | value { 43 | x: 0.2 44 | y: 0.7 45 | z: 0.6 46 | w: 1.0 47 | } 48 | } 49 | samplers { 50 | name: "DIFFUSE_TEXTURE" 51 | wrap_u: WRAP_MODE_REPEAT 52 | wrap_v: WRAP_MODE_REPEAT 53 | filter_min: FILTER_MODE_MIN_LINEAR 54 | filter_mag: FILTER_MODE_MAG_LINEAR 55 | } 56 | -------------------------------------------------------------------------------- /examples_sprites/greyscale/greyscale.script: -------------------------------------------------------------------------------- 1 | -- Hue goes between 0 to 1 with 0 and 1 wrapping around, hue shift range 2 | -- If saturation is 0 then it's unsaturated, 1 is normal satuation, 1+ more saturated 3 | -- If brightness is 0 then it's full black, 1 is normal, 1+ extra bright 4 | -- default values are hue 0, saturation 1, brightness 1 5 | -- hsb.x = hue, hsb.y = saturation, hsb.z = brightness 6 | -- http://geraldbakker.nl/psnumbers/hsb-explained.html 7 | 8 | function init(self) 9 | self.timer = 0 10 | -- Add initialization code here 11 | -- Remove this function if not needed 12 | 13 | end 14 | 15 | function update(self, dt) 16 | self.timer = self.timer + dt * 0.1 17 | local offset = math.fmod(self.timer, 1) 18 | --go.set("/public#turkey", "hsb.x", offset) 19 | --go.set("/public#turkey", "hsb.y", math.sin(self.timer * 20)) 20 | go.set("/public#turkey", "tint.x", math.max(math.sin(self.timer * 1), 0.1) + math.max(math.sin(self.timer * 10), 0.1)) 21 | --go.set("/public#japan", "hsb.x", offset) 22 | --go.set("/defold#large", "hsb.x", offset) 23 | --go.set("/defold#small", "hsb.x", offset) 24 | -- Add update code here 25 | -- Remove this function if not needed 26 | end 27 | -------------------------------------------------------------------------------- /deffx/materials/tilemap/pixel_sprite_normal_hstrip.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying mediump vec3 var_normal; 3 | 4 | uniform lowp sampler2D DIFFUSE_TEXTURE; 5 | uniform lowp vec4 tint; 6 | uniform lowp vec4 light_color_1; 7 | uniform lowp vec4 light_direction_1; 8 | 9 | void main() 10 | { 11 | // Pre-multiply alpha since all runtime textures already are 12 | lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 13 | lowp vec2 normal_offset = vec2(0.0, 0.5); 14 | 15 | vec4 diffuse = texture2D(DIFFUSE_TEXTURE, var_texcoord0) * tint_pm; 16 | 17 | vec3 normal; 18 | normal.xy = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy + normal_offset).rg * 2.0 - 1.0; 19 | normal.z = sqrt(1.0 - dot(normal.xy, normal.xy)); 20 | 21 | 22 | vec3 ambient = vec3(0.3); 23 | vec4 light_color_2 = vec4(0.7,0.7,0.8, 2.0); 24 | vec4 light_direction_2 = vec4(-1.0, 0.0, 0.0, 0.0); 25 | vec3 light = ambient.rgb + light_color_2.rgb * max(-dot(var_normal, light_direction_2.xyz), 0.0) * light_color_2.a + light_color_1.rgb * max(-dot(var_normal, light_direction_1.xyz), 0.0); 26 | light = clamp(light, 0.0, 1.0); 27 | 28 | 29 | 30 | gl_FragColor = vec4(diffuse.rgb * light.rgb, diffuse.a); 31 | } 32 | -------------------------------------------------------------------------------- /deffx/materials/rendertarget/blur_simple.material: -------------------------------------------------------------------------------- 1 | name: "unitquad" 2 | tags: "unitquad" 3 | vertex_program: "/builtins/materials/sprite.vp" 4 | fragment_program: "/deffx/materials/rendertarget/blur_simple.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "world" 11 | type: CONSTANT_TYPE_WORLD 12 | } 13 | vertex_constants { 14 | name: "" 15 | type: CONSTANT_TYPE_USER 16 | value { 17 | x: 0.0 18 | y: 0.0 19 | z: 0.0 20 | w: 0.0 21 | } 22 | } 23 | fragment_constants { 24 | name: "options" 25 | type: CONSTANT_TYPE_USER 26 | value { 27 | x: 1.0 28 | y: 1.0 29 | z: 1.0 30 | w: 0.0 31 | } 32 | } 33 | fragment_constants { 34 | name: "delta" 35 | type: CONSTANT_TYPE_USER 36 | value { 37 | x: 25.0 38 | y: 0.0 39 | z: 0.0 40 | w: 0.0 41 | } 42 | } 43 | fragment_constants { 44 | name: "resolution" 45 | type: CONSTANT_TYPE_USER 46 | value { 47 | x: 1600.0 48 | y: 800.0 49 | z: 0.0 50 | w: 0.0 51 | } 52 | } 53 | samplers { 54 | name: "" 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 | } 60 | -------------------------------------------------------------------------------- /deffx/materials/model/wireframe.material: -------------------------------------------------------------------------------- 1 | name: "wireframe" 2 | tags: "model" 3 | tags: "3d" 4 | vertex_program: "/deffx/materials/model/wireframe.vp" 5 | fragment_program: "/deffx/materials/model/wireframe.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "world" 12 | type: CONSTANT_TYPE_WORLD 13 | } 14 | vertex_constants { 15 | name: "modelview" 16 | type: CONSTANT_TYPE_WORLDVIEW 17 | } 18 | vertex_constants { 19 | name: "normalMat" 20 | type: CONSTANT_TYPE_NORMAL 21 | } 22 | fragment_constants { 23 | name: "lightPos4" 24 | type: CONSTANT_TYPE_USER 25 | value { 26 | x: 0.0 27 | y: 0.0 28 | z: 0.0 29 | w: 0.0 30 | } 31 | } 32 | fragment_constants { 33 | name: "color" 34 | type: CONSTANT_TYPE_USER 35 | value { 36 | x: 1.0 37 | y: 1.0 38 | z: 1.0 39 | w: 0.5 40 | } 41 | } 42 | fragment_constants { 43 | name: "color_factor" 44 | type: CONSTANT_TYPE_USER 45 | value { 46 | x: 0.1 47 | y: 0.0 48 | z: 0.0 49 | w: 0.0 50 | } 51 | } 52 | samplers { 53 | name: "DIFFUSE_TEXTURE" 54 | wrap_u: WRAP_MODE_REPEAT 55 | wrap_v: WRAP_MODE_REPEAT 56 | filter_min: FILTER_MODE_MIN_LINEAR 57 | filter_mag: FILTER_MODE_MAG_LINEAR 58 | } 59 | -------------------------------------------------------------------------------- /deffx/materials/model/facing_ratio.material: -------------------------------------------------------------------------------- 1 | name: "facing_ratio" 2 | tags: "model" 3 | tags: "3d" 4 | vertex_program: "/deffx/materials/model/facing_ratio.vp" 5 | fragment_program: "/deffx/materials/model/facing_ratio.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "world" 12 | type: CONSTANT_TYPE_WORLD 13 | } 14 | vertex_constants { 15 | name: "modelview" 16 | type: CONSTANT_TYPE_WORLDVIEW 17 | } 18 | vertex_constants { 19 | name: "normalMat" 20 | type: CONSTANT_TYPE_NORMAL 21 | } 22 | fragment_constants { 23 | name: "lightPos4" 24 | type: CONSTANT_TYPE_USER 25 | value { 26 | x: 0.0 27 | y: 0.0 28 | z: 0.0 29 | w: 0.0 30 | } 31 | } 32 | fragment_constants { 33 | name: "color_inner" 34 | type: CONSTANT_TYPE_USER 35 | value { 36 | x: 0.0 37 | y: 0.0 38 | z: 0.0 39 | w: 1.0 40 | } 41 | } 42 | fragment_constants { 43 | name: "color_outer" 44 | type: CONSTANT_TYPE_USER 45 | value { 46 | x: 1.0 47 | y: 1.0 48 | z: 1.0 49 | w: 1.0 50 | } 51 | } 52 | samplers { 53 | name: "DIFFUSE_TEXTURE" 54 | wrap_u: WRAP_MODE_REPEAT 55 | wrap_v: WRAP_MODE_REPEAT 56 | filter_min: FILTER_MODE_MIN_LINEAR 57 | filter_mag: FILTER_MODE_MAG_LINEAR 58 | } 59 | -------------------------------------------------------------------------------- /deffx/materials/model/_perterb-normals.fp: -------------------------------------------------------------------------------- 1 | // todo 2 | // needs nofrmal texture 3 | // ref phong probably 4 | 5 | 6 | 7 | varying mediump vec4 position; 8 | varying mediump vec2 var_texcoord0; 9 | 10 | uniform lowp sampler2D DIFFUSE_TEXTURE; 11 | uniform lowp vec4 tint; 12 | 13 | 14 | vec3 perturb(vec3 map, vec3 N, vec3 V, vec2 texcoord) { 15 | mat3 TBN = cotangent(N, -V, texcoord); 16 | return normalize(TBN * map); 17 | } 18 | 19 | 20 | void main() 21 | { 22 | // Pre-multiply alpha since all runtime textures already are 23 | lowp vec4 tint_pm = vec4(tint.xyz * tint.w, tint.w); 24 | gl_FragColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy) * tint_pm; 25 | } 26 | 27 | 28 | varying vec3 vNormal; 29 | varying vec2 vUv; 30 | varying vec3 vViewPosition; 31 | 32 | uniform sampler2D normalMap; 33 | uniform vec2 uvRepeat; 34 | const float normalScale = 0.85; 35 | 36 | void main() { 37 | //extract normal map from your texture 38 | vec3 normalRGB = texture2D(normalMap, vUv * uvRepeat).rgb; 39 | vec3 normalMap = normalRGB * 2.0 - 1.0; 40 | //you can adjust its strength like so... 41 | normalMap.xy *= normalScale; 42 | 43 | vec3 N = normalize(vNormal); 44 | vec3 V = normalize(vViewPosition); 45 | vec3 normal = perturb(normalMap, N, V, vUv); 46 | 47 | gl_FragColor.rgb = normal; 48 | gl_FragColor.a = 1.0; 49 | } -------------------------------------------------------------------------------- /deffx/materials/blend/vivid_light.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | vertex_program: "/builtins/materials/sprite.vp" 4 | fragment_program: "/deffx/materials/blend/vivid_light.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: "offset" 21 | type: CONSTANT_TYPE_USER 22 | value { 23 | x: 0.0 24 | y: 0.0 25 | z: 0.0 26 | w: 0.0 27 | } 28 | } 29 | fragment_constants { 30 | name: "timer" 31 | type: CONSTANT_TYPE_USER 32 | value { 33 | x: 0.0 34 | y: 0.0 35 | z: 0.0 36 | w: 0.0 37 | } 38 | } 39 | fragment_constants { 40 | name: "options" 41 | type: CONSTANT_TYPE_USER 42 | value { 43 | x: 0.0 44 | y: 0.0 45 | z: 0.0 46 | w: 0.0 47 | } 48 | } 49 | samplers { 50 | name: "DIFFUSE_TEXTURE" 51 | wrap_u: WRAP_MODE_REPEAT 52 | wrap_v: WRAP_MODE_REPEAT 53 | filter_min: FILTER_MODE_MIN_LINEAR 54 | filter_mag: FILTER_MODE_MAG_LINEAR 55 | } 56 | samplers { 57 | name: "BLEND" 58 | wrap_u: WRAP_MODE_REPEAT 59 | wrap_v: WRAP_MODE_REPEAT 60 | filter_min: FILTER_MODE_MIN_LINEAR 61 | filter_mag: FILTER_MODE_MAG_LINEAR 62 | } 63 | -------------------------------------------------------------------------------- /deffx/materials/tilemap/pixel_sprite_normal_hstrip.material: -------------------------------------------------------------------------------- 1 | name: "pixel_sprite_normal_hstrip" 2 | tags: "tile" 3 | vertex_program: "/deffx/materials/tilemap/pixel_sprite_normal_hstrip.vp" 4 | fragment_program: "/deffx/materials/tilemap/pixel_sprite_normal_hstrip.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | vertex_constants { 10 | name: "world" 11 | type: CONSTANT_TYPE_WORLD 12 | } 13 | vertex_constants { 14 | name: "mtx_normal" 15 | type: CONSTANT_TYPE_NORMAL 16 | value { 17 | x: 0.0 18 | y: 0.0 19 | z: 0.0 20 | w: 0.0 21 | } 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: "light_color_1" 35 | type: CONSTANT_TYPE_USER 36 | value { 37 | x: 0.95 38 | y: 0.51 39 | z: 0.18 40 | w: 0.0 41 | } 42 | } 43 | fragment_constants { 44 | name: "light_direction_1" 45 | type: CONSTANT_TYPE_USER 46 | value { 47 | x: 1.0 48 | y: 0.0 49 | z: 0.0 50 | w: 0.0 51 | } 52 | } 53 | samplers { 54 | name: "DIFFUSE_TEXTURE" 55 | wrap_u: WRAP_MODE_REPEAT 56 | wrap_v: WRAP_MODE_REPEAT 57 | filter_min: FILTER_MODE_MIN_NEAREST 58 | filter_mag: FILTER_MODE_MAG_NEAREST 59 | } 60 | -------------------------------------------------------------------------------- /examples_sprites/normal_sprite_illumination/2d_light.script: -------------------------------------------------------------------------------- 1 | 2 | go.property("color", vmath.vector4(1.0,1.0,1.0,1.0)) 3 | go.property("size", 1.0) 4 | 5 | 6 | function init(self) 7 | self.position = go.get_position() 8 | self.color = go.get("#script", "color") 9 | self.size = go.get("#script", "size") 10 | go.set_scale(self.size) 11 | end 12 | 13 | function final(self) 14 | -- Add finalization code here 15 | -- Remove this function if not needed 16 | end 17 | 18 | function update(self, dt) 19 | -- Add update code here 20 | -- Remove this function if not needed 21 | end 22 | 23 | function on_message(self, message_id, message, sender) 24 | if message_id == hash("set_position") then 25 | self.position = message.position 26 | end 27 | if message_id == hash("set_color") then 28 | self.color = message.color 29 | end 30 | if message_id == hash("set_color") then 31 | self.size = message.size 32 | end 33 | if message_id == hash("update") then 34 | self.position = message.position 35 | self.color = message.color 36 | self.size = size 37 | end 38 | end 39 | 40 | function on_input(self, action_id, action) 41 | -- Add input-handling code here 42 | -- Remove this function if not needed 43 | end 44 | 45 | function on_reload(self) 46 | -- Add reload-handling code here 47 | -- Remove this function if not needed 48 | end 49 | -------------------------------------------------------------------------------- /examples_3d/lambert/lambert.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | -- Register this game object on the input stack so we get user input 3 | msg.post(".", "acquire_input_focus") 4 | self.timer = 0 5 | end 6 | 7 | function update(self,dt) 8 | self.timer = self.timer + dt 9 | --go.set("/go#model", "tint", vmath.vector4(math.sin(self.timer) + 1, math.cos(self.timer) + 1, math.sin(math.cos(self.timer)) + 1, 1)) 10 | --go.set("/go#model", "timer.x", self.timer) 11 | go.set_position(vmath.vector3(0,0,math.abs(math.sin(self.timer * 0.01)) * -1)) 12 | end 13 | 14 | function on_input(self, action_id, action) 15 | -- React to touch and mouse presses 16 | if action_id == hash("touch") then 17 | -- Where did the user press/touch and how large is the screen? 18 | local x = action.x 19 | local y = action.y 20 | local dx = action.dx 21 | local dy = action.dy 22 | local width = sys.get_config("display.width") 23 | local height = sys.get_config("display.height") 24 | 25 | local rot = go.get_rotation() 26 | 27 | -- Translate the interaction position to rotations 28 | -- on X and Y axis. 29 | local xrot = vmath.quat_rotation_x(math.pi * 2 / height * dx) 30 | local yrot = vmath.quat_rotation_y(math.pi * 2 / width * dy) 31 | go.set_rotation(rot * xrot * yrot) 32 | 33 | -- Set the tint shader constant according to the 34 | -- interaction position. 35 | 36 | end 37 | end -------------------------------------------------------------------------------- /examples_3d/textured/textured.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | -- Register this game object on the input stack so we get user input 3 | msg.post(".", "acquire_input_focus") 4 | self.timer = 0 5 | end 6 | 7 | function update(self,dt) 8 | self.timer = self.timer + dt 9 | go.set("/go#model", "tint", vmath.vector4(math.sin(self.timer) + 1, math.cos(self.timer) + 1, math.sin(math.cos(self.timer)) + 1, 1)) 10 | --go.set("/go#model", "timer.x", self.timer) 11 | go.set_position(vmath.vector3(0,0,math.abs(math.sin(self.timer * 0.01)) * -1)) 12 | end 13 | 14 | function on_input(self, action_id, action) 15 | -- React to touch and mouse presses 16 | if action_id == hash("touch") then 17 | -- Where did the user press/touch and how large is the screen? 18 | local x = action.x 19 | local y = action.y 20 | local dx = action.dx 21 | local dy = action.dy 22 | local width = sys.get_config("display.width") 23 | local height = sys.get_config("display.height") 24 | 25 | local rot = go.get_rotation() 26 | 27 | -- Translate the interaction position to rotations 28 | -- on X and Y axis. 29 | local xrot = vmath.quat_rotation_x(math.pi * 2 / height * dx) 30 | local yrot = vmath.quat_rotation_y(math.pi * 2 / width * dy) 31 | go.set_rotation(rot * xrot * yrot) 32 | 33 | -- Set the tint shader constant according to the 34 | -- interaction position. 35 | 36 | end 37 | end -------------------------------------------------------------------------------- /examples_3d/_misc/misc.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | -- Register this game object on the input stack so we get user input 3 | msg.post(".", "acquire_input_focus") 4 | self.timer = 0 5 | end 6 | 7 | function update(self, dt) 8 | 9 | self.timer = self.timer + dt 10 | self.delta = math.cos(self.timer) 11 | --go.set("/go#model", "lightPos4.x", self.delta) 12 | --go.set("/go#model", "lightPos4.y", self.delta) 13 | --go.set("/go#model", "lightPos4.z", self.delta) 14 | end 15 | 16 | function on_input(self, action_id, action) 17 | -- React to touch and mouse presses 18 | if action_id == hash("touch") then 19 | -- Where did the user press/touch and how large is the screen? 20 | local x = action.x 21 | local y = action.y 22 | local dx = action.dx 23 | local dy = action.dy 24 | local width = sys.get_config("display.width") 25 | local height = sys.get_config("display.height") 26 | 27 | local rot = go.get_rotation() 28 | 29 | -- Translate the interaction position to rotations 30 | -- on X and Y axis. 31 | local xrot = vmath.quat_rotation_x(math.pi * 2 / height * dx) 32 | local yrot = vmath.quat_rotation_y(math.pi * 2 / width * dy) 33 | go.set_rotation(rot * xrot * yrot) 34 | 35 | -- Set the tint shader constant according to the 36 | -- interaction position. 37 | --go.set("/go#model", "tint", vmath.vector4(1 / width * (width - x), 1 / height * y, 1, 1)) 38 | end 39 | end -------------------------------------------------------------------------------- /examples_3d/skybox/checker.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | -- Register this game object on the input stack so we get user input 3 | msg.post(".", "acquire_input_focus") 4 | self.timer = 0 5 | end 6 | 7 | function update(self, dt) 8 | 9 | self.timer = self.timer + dt 10 | self.delta = math.cos(self.timer) 11 | --go.set("/go#model", "lightPos4.x", self.delta) 12 | --go.set("/go#model", "lightPos4.y", self.delta) 13 | --go.set("/go#model", "lightPos4.z", self.delta) 14 | end 15 | 16 | function on_input(self, action_id, action) 17 | -- React to touch and mouse presses 18 | if action_id == hash("touch") then 19 | -- Where did the user press/touch and how large is the screen? 20 | local x = action.x 21 | local y = action.y 22 | local dx = action.dx 23 | local dy = action.dy 24 | local width = sys.get_config("display.width") 25 | local height = sys.get_config("display.height") 26 | 27 | local rot = go.get_rotation() 28 | 29 | -- Translate the interaction position to rotations 30 | -- on X and Y axis. 31 | local xrot = vmath.quat_rotation_x(math.pi * 2 / height * dx) 32 | local yrot = vmath.quat_rotation_y(math.pi * 2 / width * dy) 33 | go.set_rotation(rot * xrot * yrot) 34 | 35 | -- Set the tint shader constant according to the 36 | -- interaction position. 37 | --go.set("/go#model", "tint", vmath.vector4(1 / width * (width - x), 1 / height * y, 1, 1)) 38 | end 39 | end -------------------------------------------------------------------------------- /examples_3d/checker/checker.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | -- Register this game object on the input stack so we get user input 3 | msg.post(".", "acquire_input_focus") 4 | self.timer = 0 5 | end 6 | 7 | function update(self, dt) 8 | 9 | self.timer = self.timer + dt 10 | self.delta = math.cos(self.timer) 11 | --go.set("/go#model", "lightPos4.x", self.delta) 12 | --go.set("/go#model", "lightPos4.y", self.delta) 13 | --go.set("/go#model", "lightPos4.z", self.delta) 14 | end 15 | 16 | function on_input(self, action_id, action) 17 | -- React to touch and mouse presses 18 | if action_id == hash("touch") then 19 | -- Where did the user press/touch and how large is the screen? 20 | local x = action.x 21 | local y = action.y 22 | local dx = action.dx 23 | local dy = action.dy 24 | local width = sys.get_config("display.width") 25 | local height = sys.get_config("display.height") 26 | 27 | local rot = go.get_rotation() 28 | 29 | -- Translate the interaction position to rotations 30 | -- on X and Y axis. 31 | local xrot = vmath.quat_rotation_x(math.pi * 2 / height * dx) 32 | local yrot = vmath.quat_rotation_y(math.pi * 2 / width * dy) 33 | go.set_rotation(rot * xrot * yrot) 34 | 35 | -- Set the tint shader constant according to the 36 | -- interaction position. 37 | --go.set("/go#model", "tint", vmath.vector4(1 / width * (width - x), 1 / height * y, 1, 1)) 38 | end 39 | end -------------------------------------------------------------------------------- /examples_3d/normals/normals.script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | -- Register this game object on the input stack so we get user input 3 | msg.post(".", "acquire_input_focus") 4 | self.timer = 0 5 | end 6 | 7 | function update(self, dt) 8 | 9 | self.timer = self.timer + dt 10 | self.delta = math.cos(self.timer) 11 | --go.set("/go#model", "lightPos4.x", self.delta) 12 | --go.set("/go#model", "lightPos4.y", self.delta) 13 | --go.set("/go#model", "lightPos4.z", self.delta) 14 | end 15 | 16 | function on_input(self, action_id, action) 17 | -- React to touch and mouse presses 18 | if action_id == hash("touch") then 19 | -- Where did the user press/touch and how large is the screen? 20 | local x = action.x 21 | local y = action.y 22 | local dx = action.dx 23 | local dy = action.dy 24 | local width = sys.get_config("display.width") 25 | local height = sys.get_config("display.height") 26 | 27 | local rot = go.get_rotation() 28 | 29 | -- Translate the interaction position to rotations 30 | -- on X and Y axis. 31 | local xrot = vmath.quat_rotation_x(math.pi * 2 / height * dx) 32 | local yrot = vmath.quat_rotation_y(math.pi * 2 / width * dy) 33 | go.set_rotation(rot * xrot * yrot) 34 | 35 | -- Set the tint shader constant according to the 36 | -- interaction position. 37 | --go.set("/go#model", "tint", vmath.vector4(1 / width * (width - x), 1 / height * y, 1, 1)) 38 | end 39 | end -------------------------------------------------------------------------------- /examples_sprites/normal_sprite_illumination/normal_sprite_illumination.script: -------------------------------------------------------------------------------- 1 | -- Hue goes between 0 to 1 with 0 and 1 wrapping around, hue shift range 2 | -- If saturation is 0 then it's unsaturated, 1 is normal satuation, 1+ more saturated 3 | -- If brightness is 0 then it's full black, 1 is normal, 1+ extra bright 4 | -- default values are hue 0, saturation 1, brightness 1 5 | -- hsb.x = hue, hsb.y = saturation, hsb.z = brightness 6 | -- http://geraldbakker.nl/psnumbers/hsb-explained.html 7 | 8 | function init(self) 9 | self.timer = 0 10 | -- Add initialization code here 11 | -- Remove this function if not needed 12 | 13 | end 14 | 15 | function update(self, dt) 16 | self.timer = self.timer + dt 17 | local offset = math.fmod(self.timer, 1) 18 | --go.set("/public#turkey", "hsb.x", offset) 19 | --go.set("/public#turkey", "hsb.y", math.sin(self.timer * 20)) 20 | go.set("/pixel_sprite_normal_hstrip#pixel_sprite_normal_hstrip", "light_direction_1.x",math.sin(self.timer)) 21 | go.set("/pixel_sprite_normal_hstrip#pixel_sprite_normal_hstrip", "light_direction_1.y",math.cos(self.timer )) 22 | go.set("/pixel_sprite_normal_hstrip#pixel_sprite_normal_hstrip", "light_color_1.x", math.sin(self.timer)) 23 | --go.set("/public#japan", "hsb.x", offset) 24 | --go.set("/defold#large", "hsb.x", offset) 25 | --go.set("/defold#small", "hsb.x", offset) 26 | -- Add update code here 27 | -- Remove this function if not needed 28 | end 29 | -------------------------------------------------------------------------------- /examples_3d/phong_rendertarget/phong.script: -------------------------------------------------------------------------------- 1 | -- Phong light shading combines ambient, diffuse, and specular 2 | 3 | 4 | 5 | function init(self) 6 | -- Register this game object on the input stack so we get user input 7 | msg.post(".", "acquire_input_focus") 8 | self.timer = 0 9 | end 10 | 11 | function update(self, dt) 12 | 13 | self.timer = self.timer + dt 14 | self.delta = math.cos(self.timer) 15 | go.set("/go#model", "lightPos4.x", self.delta) 16 | go.set("/go#model", "lightPos4.y", self.delta) 17 | go.set("/go#model", "lightPos4.z", self.delta) 18 | end 19 | 20 | function on_input(self, action_id, action) 21 | -- React to touch and mouse presses 22 | if action_id == hash("touch") then 23 | -- Where did the user press/touch and how large is the screen? 24 | local x = action.x 25 | local y = action.y 26 | local dx = action.dx 27 | local dy = action.dy 28 | local width = sys.get_config("display.width") 29 | local height = sys.get_config("display.height") 30 | 31 | local rot = go.get_rotation() 32 | 33 | -- Translate the interaction position to rotations 34 | -- on X and Y axis. 35 | local xrot = vmath.quat_rotation_x(math.pi * 2 / height * dx) 36 | local yrot = vmath.quat_rotation_y(math.pi * 2 / width * dy) 37 | go.set_rotation(rot * xrot * yrot) 38 | 39 | -- Set the tint shader constant according to the 40 | -- interaction position. 41 | --go.set("/go#model", "tint", vmath.vector4(1 / width * (width - x), 1 / height * y, 1, 1)) 42 | end 43 | end -------------------------------------------------------------------------------- /deffx/materials/sprite/simple_gradient.fp: -------------------------------------------------------------------------------- 1 | varying highp vec2 var_texcoord0; 2 | 3 | uniform highp sampler2D DIFFUSE_TEXTURE; 4 | uniform highp vec4 resolution; 5 | 6 | 7 | // if you need more colors in your gradients it's easy to add them 8 | // when arrays are added to use then hopefully this will be able to be cleaner 9 | uniform highp vec4 gradient_start; 10 | uniform highp vec4 gradient_stop; 11 | 12 | uniform highp vec4 color_1; 13 | uniform highp vec4 color_2; 14 | 15 | 16 | void main() { 17 | 18 | 19 | highp float alpha = atan( -gradient_stop.y + gradient_start.y, gradient_stop.x - gradient_start.x ); 20 | highp float gradient_start_rotated_x = gradient_start.x*cos(alpha) - gradient_start.y*sin(alpha); 21 | highp float gradient_stop_rotated_x = gradient_stop.x*cos(alpha) - gradient_stop.y*sin(alpha); 22 | highp float d = gradient_stop_rotated_x - gradient_start_rotated_x; 23 | 24 | 25 | //float y = resolution.y - gl_FragCoord.y; 26 | 27 | highp float x = var_texcoord0.x; 28 | highp float y = var_texcoord0.y; 29 | highp float x_location_rotated = x*cos( alpha ) - y*sin( alpha ); 30 | 31 | gl_FragColor = mix(color_1, color_2, smoothstep( gradient_start_rotated_x + d, gradient_start_rotated_x + d, x_location_rotated ) ); 32 | 33 | //gl_FragColor = vec4(gradient_start_rotated_x,gradient_start_rotated_x,gradient_start_rotated_x, 1.0 ); 34 | //gl_FragColor = vec4(x_location_rotated,x_location_rotated,x_location_rotated, 1.0 ); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /deffx/materials/rendertarget/noise.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp vec4 options; 5 | // options.x = seed, options.y = noise strength 6 | 7 | // https://gist.github.com/patriciogonzalezvivo/670c22f3966e662d2f83 8 | 9 | float random(vec2 co) 10 | { 11 | return fract(sin(dot(co.xy, vec2(12.9898, 78.2333))) * 43758.54532); 12 | 13 | 14 | } 15 | 16 | // 2D Noise based on Morgan McGuire @morgan3d 17 | // https://www.shadertoy.com/view/4dS3Wd 18 | float noise(vec2 st) { 19 | vec2 i = floor(st); 20 | vec2 f = fract(st); 21 | 22 | // Four corners in 2D of a tile 23 | float a = random(i); 24 | float b = random(i + vec2(1.0, 0.0)); 25 | float c = random(i + vec2(0.0, 1.0)); 26 | float d = random(i + vec2(1.0, 1.0)); 27 | 28 | // Smooth Interpolation 29 | 30 | // Cubic Hermine Curve. Same as SmoothStep() 31 | vec2 u = f*f*(3.0-2.0*f); 32 | // u = smoothstep(0.,1.,f); 33 | 34 | // Mix 4 coorners porcentages 35 | return mix(a, b, u.x) + 36 | (c - a)* u.y * (1.0 - u.x) + 37 | (d - b) * u.x * u.y; 38 | } 39 | 40 | void main() 41 | { 42 | vec4 color = texture2D(DIFFUSE_TEXTURE, var_texcoord0); 43 | float randomValue = noise(random(gl_FragCoord.xy * options.x)); 44 | float diff = (randomValue - 0.5) * options.y; 45 | 46 | 47 | color.r += diff; 48 | color.g += diff; 49 | color.b += diff; 50 | 51 | 52 | gl_FragColor = color; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /examples_3d/perturb-normals/perturb-normals.script: -------------------------------------------------------------------------------- 1 | -- Phong light shading combines ambient, diffuse, and specular 2 | 3 | 4 | 5 | function init(self) 6 | -- Register this game object on the input stack so we get user input 7 | msg.post(".", "acquire_input_focus") 8 | self.timer = 0 9 | end 10 | 11 | function update(self, dt) 12 | 13 | self.timer = self.timer + dt 14 | self.delta = math.cos(self.timer) 15 | go.set("/go#model", "lightPos4.x", self.delta) 16 | go.set("/go#model", "lightPos4.y", self.delta) 17 | go.set("/go#model", "lightPos4.z", self.delta) 18 | go.set("/go1#model", "lightPos4.x", self.delta) 19 | 20 | end 21 | 22 | function on_input(self, action_id, action) 23 | -- React to touch and mouse presses 24 | if action_id == hash("touch") then 25 | -- Where did the user press/touch and how large is the screen? 26 | local x = action.x 27 | local y = action.y 28 | local dx = action.dx 29 | local dy = action.dy 30 | local width = sys.get_config("display.width") 31 | local height = sys.get_config("display.height") 32 | 33 | local rot = go.get_rotation() 34 | 35 | -- Translate the interaction position to rotations 36 | -- on X and Y axis. 37 | local xrot = vmath.quat_rotation_x(math.pi * 2 / height * dx) 38 | local yrot = vmath.quat_rotation_y(math.pi * 2 / width * dy) 39 | go.set_rotation(rot * xrot * yrot) 40 | 41 | -- Set the tint shader constant according to the 42 | -- interaction position. 43 | --go.set("/go#model", "tint", vmath.vector4(1 / width * (width - x), 1 / height * y, 1, 1)) 44 | end 45 | end -------------------------------------------------------------------------------- /deffx/materials/rendertarget/blur_simple.fp: -------------------------------------------------------------------------------- 1 | 2 | varying mediump vec2 var_texcoord0; 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp vec4 options; 5 | // options.x = samplesx, options.y = samplesy - both must be odd 6 | // options.z = 7 | uniform lowp vec4 delta; 8 | uniform lowp vec4 resolution; 9 | 10 | 11 | void main() 12 | { 13 | vec3 irgb = texture2D(DIFFUSE_TEXTURE, var_texcoord0).rgb; 14 | float ResS = resolution.x; 15 | float ResT = resolution.y; 16 | 17 | vec2 stp0 = vec2(1./ResS, 0.); 18 | vec2 st0p = vec2(0., 1./ResT); 19 | vec2 stpp = vec2(1./ResS, 1./ResT); 20 | vec2 stpm = vec2(1./ResS, -1./ResT); 21 | 22 | vec3 i00 = texture2D(DIFFUSE_TEXTURE, var_texcoord0).rgb; 23 | vec3 im1m1 = texture2D(DIFFUSE_TEXTURE, var_texcoord0-stpp*delta.x).rgb; 24 | vec3 ip1p1 = texture2D(DIFFUSE_TEXTURE, var_texcoord0+stpp*delta.x).rgb; 25 | vec3 im1p1 = texture2D(DIFFUSE_TEXTURE, var_texcoord0-stpm*delta.x).rgb; 26 | vec3 ip1m1 = texture2D(DIFFUSE_TEXTURE, var_texcoord0+stpm*delta.x).rgb; 27 | vec3 im10 = texture2D(DIFFUSE_TEXTURE, var_texcoord0-stp0*delta.x).rgb; 28 | vec3 ip10 = texture2D(DIFFUSE_TEXTURE, var_texcoord0+stp0*delta.x).rgb; 29 | vec3 i0m1 = texture2D(DIFFUSE_TEXTURE, var_texcoord0-st0p*delta.x).rgb; 30 | vec3 i0p1 = texture2D(DIFFUSE_TEXTURE, var_texcoord0+st0p*delta.x).rgb; 31 | 32 | vec3 target = vec3(0., 0., 0.); 33 | target += 1.*(im1m1+ip1m1+ip1p1+im1p1); 34 | target += 2.*(im10+ip10+i0p1); 35 | target += 4.*(i00); 36 | target /= 16.; 37 | gl_FragColor = vec4(target, 1.); 38 | } -------------------------------------------------------------------------------- /deffx/materials/sprite/outerglow_copy.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp vec4 tint; 5 | 6 | uniform lowp vec4 rgba; 7 | uniform lowp vec4 options; 8 | // options : x pixel width, y pixel height, z outline only, w width 9 | 10 | void main() 11 | { 12 | 13 | vec4 colorTexture = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy); 14 | 15 | float dx = options.x*options.w; 16 | float dy = options.y*options.w; 17 | float diag = 0.7071; 18 | 19 | float a0 = texture2D(DIFFUSE_TEXTURE, var_texcoord0 + vec2(-dx*diag, dy*diag)).a; 20 | float a1 = texture2D(DIFFUSE_TEXTURE, var_texcoord0 + vec2(dx*diag, -dy*diag)).a; 21 | float a2 = texture2D(DIFFUSE_TEXTURE, var_texcoord0 + vec2(-dx*diag, -dy*diag)).a; 22 | float a3 = texture2D(DIFFUSE_TEXTURE, var_texcoord0 + vec2(dx*diag, dy*diag)).a; 23 | float a4 = texture2D(DIFFUSE_TEXTURE, var_texcoord0 + vec2(-dx, 0.0)).a; 24 | float a5 = texture2D(DIFFUSE_TEXTURE, var_texcoord0 + vec2(dx, 0.0)).a; 25 | float a6 = texture2D(DIFFUSE_TEXTURE, var_texcoord0 + vec2(0.0, dy)).a; 26 | float a7 = texture2D(DIFFUSE_TEXTURE, var_texcoord0 + vec2(0.0, -dy)).a; 27 | 28 | float ina=max(max(max(max(max(max(max(a0,a1),a2),a3),a4),a5),a6),a7)-colorTexture.a; 29 | if(options.z==0) 30 | { 31 | float outa = ina + colorTexture.a*(1.0-ina); 32 | vec3 outrgb = (vec3(rgba.x/255.0, rgba.y/255.0, rgba.z/255.0)*ina + colorTexture.rgb*colorTexture.a*(1.0-ina)); 33 | gl_FragColor = vec4(outrgb, outa); 34 | } 35 | else 36 | { 37 | gl_FragColor = vec4(vec3(rgba.x/255.0, rgba.y/255.0, rgba.z/255.0)*ina, ina); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples_3d/phong/phong.script: -------------------------------------------------------------------------------- 1 | -- Phong light shading combines ambient, diffuse, and specular 2 | 3 | 4 | 5 | function init(self) 6 | -- Register this game object on the input stack so we get user input 7 | msg.post(".", "acquire_input_focus") 8 | self.timer = 0 9 | end 10 | 11 | function update(self, dt) 12 | 13 | self.timer = self.timer + dt 14 | self.delta = math.cos(self.timer) 15 | go.set("/go#model", "lightPos4.x", self.delta) 16 | go.set("/go#model", "lightPos4.y", self.delta) 17 | go.set("/go#model", "lightPos4.z", self.delta) 18 | 19 | if (math.sin(self.timer)) > 0 then 20 | go.set("/unitquad#unitquad", "options.x", 1.0) 21 | print("FXAA On") 22 | else 23 | go.set("/unitquad#unitquad", "options.x", 0.0) 24 | print("FXAA Off") 25 | end 26 | end 27 | 28 | function on_input(self, action_id, action) 29 | -- React to touch and mouse presses 30 | if action_id == hash("touch") then 31 | -- Where did the user press/touch and how large is the screen? 32 | local x = action.x 33 | local y = action.y 34 | local dx = action.dx 35 | local dy = action.dy 36 | local width = sys.get_config("display.width") 37 | local height = sys.get_config("display.height") 38 | 39 | local rot = go.get_rotation() 40 | 41 | -- Translate the interaction position to rotations 42 | -- on X and Y axis. 43 | local xrot = vmath.quat_rotation_x(math.pi * 2 / height * dx) 44 | local yrot = vmath.quat_rotation_y(math.pi * 2 / width * dy) 45 | go.set_rotation(rot * xrot * yrot) 46 | 47 | -- Set the tint shader constant according to the 48 | -- interaction position. 49 | --go.set("/go#model", "tint", vmath.vector4(1 / width * (width - x), 1 / height * y, 1, 1)) 50 | end 51 | end -------------------------------------------------------------------------------- /deffx/materials/rendertarget/chromatic_aberration_screen_edge.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | uniform lowp sampler2D DIFFUSE_TEXTURE; 3 | uniform lowp vec4 options; 4 | // options.x = strength, options.y = magnitude, options.z = brightness, options.w = size 5 | uniform lowp vec4 resolution; 6 | uniform lowp vec4 time; 7 | 8 | 9 | void main() 10 | 11 | { 12 | 13 | vec2 pSize = (options.w * sin(var_texcoord0.y * options.y + time.x * options.x)) / vec2(resolution.x, resolution.y); 14 | float offsetX = sin(var_texcoord0.y * options.y + time.x * options.x) * pSize.x + cos(var_texcoord0.y * options.y + time.x * options.x * 1.3) * pSize.x; 15 | float corner = 10.0; 16 | 17 | 18 | if(var_texcoord0.x < 0.5) { 19 | if(var_texcoord0.y < 0.5) { 20 | options.z = min(var_texcoord0.x * var_texcoord0.y * corner, 1.0); 21 | } else { 22 | options.z = min(var_texcoord0.x * (1.0 - var_texcoord0.y) * corner, 1.0); 23 | } 24 | } else { 25 | if(var_texcoord0.y < 0.5) { 26 | options.z = min((1.0 - var_texcoord0.x) * var_texcoord0.y * corner, 1.0); 27 | } else { 28 | options.z = min((1.0 - var_texcoord0.x) * (1.0 - var_texcoord0.y) * corner, 1.0); 29 | } 30 | } 31 | 32 | float red = texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x + offsetX, var_texcoord0.y + pSize.y * 0.5)).r; 33 | float green = texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x + offsetX, var_texcoord0.y - pSize.y * 0.5)).g; 34 | float blue = texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x + offsetX, var_texcoord0.y)).b; 35 | 36 | if(mod(var_texcoord0.y * resolution.y, 2.0) > 0.5) { 37 | gl_FragColor = vec4(vec3(red, green, blue) * options.z, 1.0); 38 | } else { 39 | gl_FragColor = vec4(vec3(red * 0.75, green * 0.75, blue * 0.75) * options.z, 1.0); 40 | } 41 | } 42 | 43 | -------------------------------------------------------------------------------- /deffx/materials/rendertarget/scanlines.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | uniform lowp sampler2D DIFFUSE_TEXTURE; 3 | uniform lowp vec4 options; 4 | // options.x = strength, options.y = magnitude, options.z = brightness, options.w = size 5 | uniform lowp vec4 resolution; 6 | uniform lowp vec4 time; 7 | 8 | 9 | void main() 10 | 11 | { 12 | 13 | vec2 pSize = (options.w * sin(var_texcoord0.y * options.y + time.x * options.x)) / vec2(resolution.x, resolution.y); 14 | float offsetX = sin(var_texcoord0.y * options.y + time.x * options.x) * pSize.x + cos(var_texcoord0.y * options.y + time.x * options.x * 1.3) * pSize.x; 15 | float corner = 500.0; 16 | float brightness = options.z; 17 | 18 | 19 | if(var_texcoord0.x < 0.5) { 20 | if(var_texcoord0.y < 0.5) { 21 | brightness = min(var_texcoord0.x * var_texcoord0.y * corner, 1.0); 22 | } else { 23 | brightness = min(var_texcoord0.x * (1.0 - var_texcoord0.y) * corner, 1.0); 24 | } 25 | } else { 26 | if(var_texcoord0.y < 0.5) { 27 | brightness = min((1.0 - var_texcoord0.x) * var_texcoord0.y * corner, 1.0); 28 | } else { 29 | brightness = min((1.0 - var_texcoord0.x) * (1.0 - var_texcoord0.y) * corner, 1.0); 30 | } 31 | } 32 | 33 | float red = texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x + offsetX, var_texcoord0.y + pSize.y * 0.5)).r; 34 | float green = texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x + offsetX, var_texcoord0.y - pSize.y * 0.5)).g; 35 | float blue = texture2D(DIFFUSE_TEXTURE, vec2(var_texcoord0.x + offsetX, var_texcoord0.y)).b; 36 | 37 | if(mod(var_texcoord0.y * resolution.y, 2.0) > 0.5) { 38 | gl_FragColor = vec4(vec3(red, green, blue) * brightness, 1.0); 39 | } else { 40 | gl_FragColor = vec4(vec3(red * 0.75, green * 0.75, blue * 0.75) * brightness, 1.0); 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /examples_sprites/trim/trim.script: -------------------------------------------------------------------------------- 1 | -- Trim / clip off areas of your sprites based on horizontal and vertical start/stop percentages 2 | -- useful for example with decorated health 3 | -- really hacky right now because I don't know how to get relative texcoord0 of a texture in an atlas 4 | -- you must have only one texture in an atlas, and you must check to see the size of the atlas 5 | -- todo add vertical clip too 6 | 7 | local atlas_width = 512 8 | local atlas_height = 64 9 | local texture_width = 299 10 | local texture_height = 55 11 | local ratio_width = texture_width / atlas_width 12 | --ratio_width = 1 -- uncomment these to see what happens without the ratio correction 13 | 14 | function init(self) 15 | go.set("/bars#bar_health", "ratio", vmath.vector4(ratio_width, 0, 0, 0)) 16 | go.set("/bars#bar_mana", "ratio", vmath.vector4(ratio_width, 0, 0, 0)) 17 | go.set("/bars#bar_health", "trim", vmath.vector4(0, 0.50, 0, 1)) -- should be cut at 50% with ratio correction 18 | self.timer = 0 19 | end 20 | 21 | function final(self) 22 | -- Add finalization code here 23 | -- Remove this function if not needed 24 | end 25 | 26 | function update(self, dt) 27 | self.timer = self.timer + dt 28 | go.set("/bars#bar_health", "trim", vmath.vector4(math.abs(math.sin(self.timer * 0.32)), math.abs(math.sin(self.timer)), 0, 0)) 29 | go.set("/bars#bar_mana", "trim", vmath.vector4(0, (math.abs(math.sin(self.timer * 0.32))), 0, 0)) 30 | -- Add update code here 31 | -- Remove this function if not needed 32 | end 33 | 34 | function on_message(self, message_id, message, sender) 35 | -- Add message-handling code here 36 | -- Remove this function if not needed 37 | end 38 | 39 | function on_input(self, action_id, action) 40 | -- Add input-handling code here 41 | -- Remove this function if not needed 42 | end 43 | 44 | function on_reload(self) 45 | -- Add reload-handling code here 46 | -- Remove this function if not needed 47 | end 48 | -------------------------------------------------------------------------------- /examples_sprites/outline/outline.script: -------------------------------------------------------------------------------- 1 | -- Trim / clip off areas of your sprites based on horizontal and vertical start/stop percentages 2 | -- useful for example with decorated health 3 | -- really hacky right now because I don't know how to get relative texcoord0 of a texture in an atlas 4 | -- you must have only one texture in an atlas, and you must check to see the size of the atlas 5 | -- todo add vertical clip too 6 | 7 | local atlas_width = 512 8 | local atlas_height = 64 9 | local texture_width = 299 10 | local texture_height = 55 11 | local ratio_width = texture_width / atlas_width 12 | --ratio_width = 1 -- uncomment these to see what happens without the ratio correction 13 | 14 | function init(self) 15 | go.set("/bars#bar_health", "ratio", vmath.vector4(ratio_width, 0, 0, 0)) 16 | go.set("/bars#bar_mana", "ratio", vmath.vector4(ratio_width, 0, 0, 0)) 17 | go.set("/bars#bar_health", "trim", vmath.vector4(0, 0.50, 0, 1)) -- should be cut at 50% with ratio correction 18 | self.timer = 0 19 | end 20 | 21 | function final(self) 22 | -- Add finalization code here 23 | -- Remove this function if not needed 24 | end 25 | 26 | function update(self, dt) 27 | self.timer = self.timer + dt 28 | go.set("/bars#bar_health", "trim", vmath.vector4(math.abs(math.sin(self.timer * 0.32)), math.abs(math.sin(self.timer)), 0, 0)) 29 | go.set("/bars#bar_mana", "trim", vmath.vector4(0, (math.abs(math.sin(self.timer * 0.32))), 0, 0)) 30 | -- Add update code here 31 | -- Remove this function if not needed 32 | end 33 | 34 | function on_message(self, message_id, message, sender) 35 | -- Add message-handling code here 36 | -- Remove this function if not needed 37 | end 38 | 39 | function on_input(self, action_id, action) 40 | -- Add input-handling code here 41 | -- Remove this function if not needed 42 | end 43 | 44 | function on_reload(self) 45 | -- Add reload-handling code here 46 | -- Remove this function if not needed 47 | end 48 | -------------------------------------------------------------------------------- /examples_sprites/dropshadow/dropshadow.script: -------------------------------------------------------------------------------- 1 | -- Trim / clip off areas of your sprites based on horizontal and vertical start/stop percentages 2 | -- useful for example with decorated health 3 | -- really hacky right now because I don't know how to get relative texcoord0 of a texture in an atlas 4 | -- you must have only one texture in an atlas, and you must check to see the size of the atlas 5 | -- todo add vertical clip too 6 | 7 | local atlas_width = 512 8 | local atlas_height = 64 9 | local texture_width = 299 10 | local texture_height = 55 11 | local ratio_width = texture_width / atlas_width 12 | --ratio_width = 1 -- uncomment these to see what happens without the ratio correction 13 | 14 | function init(self) 15 | go.set("/bars#bar_health", "ratio", vmath.vector4(ratio_width, 0, 0, 0)) 16 | go.set("/bars#bar_mana", "ratio", vmath.vector4(ratio_width, 0, 0, 0)) 17 | go.set("/bars#bar_health", "trim", vmath.vector4(0, 0.50, 0, 1)) -- should be cut at 50% with ratio correction 18 | self.timer = 0 19 | end 20 | 21 | function final(self) 22 | -- Add finalization code here 23 | -- Remove this function if not needed 24 | end 25 | 26 | function update(self, dt) 27 | self.timer = self.timer + dt 28 | go.set("/bars#bar_health", "trim", vmath.vector4(math.abs(math.sin(self.timer * 0.32)), math.abs(math.sin(self.timer)), 0, 0)) 29 | go.set("/bars#bar_mana", "trim", vmath.vector4(0, (math.abs(math.sin(self.timer * 0.32))), 0, 0)) 30 | -- Add update code here 31 | -- Remove this function if not needed 32 | end 33 | 34 | function on_message(self, message_id, message, sender) 35 | -- Add message-handling code here 36 | -- Remove this function if not needed 37 | end 38 | 39 | function on_input(self, action_id, action) 40 | -- Add input-handling code here 41 | -- Remove this function if not needed 42 | end 43 | 44 | function on_reload(self) 45 | -- Add reload-handling code here 46 | -- Remove this function if not needed 47 | end 48 | -------------------------------------------------------------------------------- /deffx/materials/model/toon.material: -------------------------------------------------------------------------------- 1 | name: "toon" 2 | tags: "model" 3 | tags: "3d" 4 | vertex_program: "/deffx/materials/model/toon.vp" 5 | fragment_program: "/deffx/materials/model/toon.fp" 6 | vertex_constants { 7 | name: "view_proj" 8 | type: CONSTANT_TYPE_VIEWPROJ 9 | } 10 | vertex_constants { 11 | name: "world" 12 | type: CONSTANT_TYPE_WORLD 13 | } 14 | vertex_constants { 15 | name: "modelview" 16 | type: CONSTANT_TYPE_WORLDVIEW 17 | } 18 | vertex_constants { 19 | name: "normalMat" 20 | type: CONSTANT_TYPE_NORMAL 21 | } 22 | vertex_constants { 23 | name: "light_position" 24 | type: CONSTANT_TYPE_USER 25 | value { 26 | x: 1.0 27 | y: 1.0 28 | z: 0.0 29 | w: 0.0 30 | } 31 | } 32 | fragment_constants { 33 | name: "color_highlight" 34 | type: CONSTANT_TYPE_USER 35 | value { 36 | x: 0.9 37 | y: 0.6 38 | z: 1.0 39 | w: 1.0 40 | } 41 | } 42 | fragment_constants { 43 | name: "color_mid" 44 | type: CONSTANT_TYPE_USER 45 | value { 46 | x: 0.2 47 | y: 0.5 48 | z: 0.5 49 | w: 1.0 50 | } 51 | } 52 | fragment_constants { 53 | name: "color_shadow" 54 | type: CONSTANT_TYPE_USER 55 | value { 56 | x: 1.0 57 | y: 1.0 58 | z: 1.0 59 | w: 1.0 60 | } 61 | } 62 | fragment_constants { 63 | name: "highlight_size" 64 | type: CONSTANT_TYPE_USER 65 | value { 66 | x: 10.0 67 | y: 0.0 68 | z: 0.0 69 | w: 0.0 70 | } 71 | } 72 | fragment_constants { 73 | name: "shadow_size" 74 | type: CONSTANT_TYPE_USER 75 | value { 76 | x: 1.0 77 | y: 0.0 78 | z: 0.0 79 | w: 0.0 80 | } 81 | } 82 | fragment_constants { 83 | name: "outline_width" 84 | type: CONSTANT_TYPE_USER 85 | value { 86 | x: 1.0 87 | y: 0.0 88 | z: 0.0 89 | w: 0.0 90 | } 91 | } 92 | samplers { 93 | name: "DIFFUSE_TEXTURE" 94 | wrap_u: WRAP_MODE_REPEAT 95 | wrap_v: WRAP_MODE_REPEAT 96 | filter_min: FILTER_MODE_MIN_LINEAR 97 | filter_mag: FILTER_MODE_MAG_LINEAR 98 | } 99 | -------------------------------------------------------------------------------- /deffx/materials/sprite/hsb.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec4 position; 2 | varying mediump vec2 var_texcoord0; 3 | 4 | uniform lowp sampler2D DIFFUSE_TEXTURE; 5 | uniform lowp vec4 hsb; 6 | // hsb.x = hue 7 | // hsb.y = saturation 8 | // hsb.z = brightness 9 | // hsb.w = unused 10 | 11 | // https://gamedev.stackexchange.com/questions/59797/glsl-shader-change-hue-saturation-brightness 12 | // https://www.shadertoy.com/view/ltBSWd 13 | // https://www.shadertoy.com/view/ldyXWz 14 | 15 | vec3 RGBtoHSB(vec3 rgb) 16 | { 17 | // Hue: red = 0/6, yellow = 1/6, green = 2/6, 18 | // cyan = 3/6, blue = 4/6, magenta = 5/6 19 | vec3 hsb; 20 | float cmax = max(rgb.r, max(rgb.g, rgb.b)); 21 | float cmin = min(rgb.r, min(rgb.g, rgb.b)); 22 | 23 | hsb.z = cmax; // value 24 | 25 | float chroma = cmax - cmin; 26 | //if(chroma != 0.0) 27 | { 28 | hsb.y = chroma / cmax; // saturation 29 | 30 | //if(cmax == rgb.r) 31 | if(rgb.r > rgb.g && rgb.r > rgb.b) 32 | { 33 | hsb.x = (0.0 + (rgb.g - rgb.b) / chroma) / 6.0; // hue 34 | } 35 | //else if(cmax == rgb.m_Green) 36 | else if(rgb.g > rgb.b) 37 | { 38 | hsb.x = (2.0 + (rgb.b - rgb.r) / chroma) / 6.0; // hue 39 | } 40 | else 41 | { 42 | hsb.x = (4.0 + (rgb.r - rgb.g) / chroma) / 6.0; // hue 43 | } 44 | 45 | // Make sure hue is in range [0..1] 46 | hsb.x = fract(hsb.x); 47 | } 48 | return hsb; 49 | } 50 | 51 | vec3 HSBtoRGB(in vec3 c) // thanks to iq for this much more compact version! 52 | { 53 | vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0); 54 | return c.z * mix(vec3(1.0), rgb, c.y); 55 | } 56 | 57 | 58 | void main() 59 | { 60 | vec4 textureColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy); 61 | vec3 fragRGB = textureColor.rgb; 62 | vec3 fragHSB = RGBtoHSB(fragRGB).xyz; 63 | fragHSB.x += hsb.x; 64 | fragHSB.yz *= hsb.yz; 65 | // fragHSB.xyz = mod(fragHSB.xyz, 1.0); 66 | fragRGB = HSBtoRGB(fragHSB); 67 | gl_FragColor = vec4(fragRGB, textureColor.a); 68 | } -------------------------------------------------------------------------------- /deffx/materials/sprite/dropshadow.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec4 position; 2 | varying mediump vec2 var_texcoord0; 3 | 4 | uniform lowp sampler2D DIFFUSE_TEXTURE; 5 | uniform lowp vec4 hsb; 6 | // hsb.x = hue 7 | // hsb.y = saturation 8 | // hsb.z = brightness 9 | // hsb.w = unused 10 | 11 | // https://gamedev.stackexchange.com/questions/59797/glsl-shader-change-hue-saturation-brightness 12 | // https://www.shadertoy.com/view/ltBSWd 13 | // https://www.shadertoy.com/view/ldyXWz 14 | 15 | vec3 RGBtoHSB(vec3 rgb) 16 | { 17 | // Hue: red = 0/6, yellow = 1/6, green = 2/6, 18 | // cyan = 3/6, blue = 4/6, magenta = 5/6 19 | vec3 hsb; 20 | float cmax = max(rgb.r, max(rgb.g, rgb.b)); 21 | float cmin = min(rgb.r, min(rgb.g, rgb.b)); 22 | 23 | hsb.z = cmax; // value 24 | 25 | float chroma = cmax - cmin; 26 | //if(chroma != 0.0) 27 | { 28 | hsb.y = chroma / cmax; // saturation 29 | 30 | //if(cmax == rgb.r) 31 | if(rgb.r > rgb.g && rgb.r > rgb.b) 32 | { 33 | hsb.x = (0.0 + (rgb.g - rgb.b) / chroma) / 6.0; // hue 34 | } 35 | //else if(cmax == rgb.m_Green) 36 | else if(rgb.g > rgb.b) 37 | { 38 | hsb.x = (2.0 + (rgb.b - rgb.r) / chroma) / 6.0; // hue 39 | } 40 | else 41 | { 42 | hsb.x = (4.0 + (rgb.r - rgb.g) / chroma) / 6.0; // hue 43 | } 44 | 45 | // Make sure hue is in range [0..1] 46 | hsb.x = fract(hsb.x); 47 | } 48 | return hsb; 49 | } 50 | 51 | vec3 HSBtoRGB(in vec3 c) // thanks to iq for this much more compact version! 52 | { 53 | vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0); 54 | return c.z * mix(vec3(1.0), rgb, c.y); 55 | } 56 | 57 | 58 | void main() 59 | { 60 | vec4 textureColor = texture2D(DIFFUSE_TEXTURE, var_texcoord0.xy); 61 | vec3 fragRGB = textureColor.rgb; 62 | vec3 fragHSB = RGBtoHSB(fragRGB).xyz; 63 | fragHSB.x += hsb.x; 64 | fragHSB.yz *= hsb.yz; 65 | // fragHSB.xyz = mod(fragHSB.xyz, 1.0); 66 | fragRGB = HSBtoRGB(fragHSB); 67 | gl_FragColor = vec4(fragRGB, textureColor.a); 68 | } -------------------------------------------------------------------------------- /deffx/render/sprite_debug/default.render_script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.tile_pred = render.predicate({"tile"}) 3 | self.gui_pred = render.predicate({"gui"}) 4 | self.text_pred = render.predicate({"text"}) 5 | self.particle_pred = render.predicate({"particle"}) 6 | 7 | self.clear_color = vmath.vector4(0, 0, 0, 0) 8 | self.clear_color.x = sys.get_config("render.clear_color_red", 0) 9 | self.clear_color.y = sys.get_config("render.clear_color_green", 0) 10 | self.clear_color.z = sys.get_config("render.clear_color_blue", 0) 11 | self.clear_color.w = sys.get_config("render.clear_color_alpha", 0) 12 | 13 | self.view = vmath.matrix4() 14 | end 15 | 16 | function update(self) 17 | render.set_depth_mask(true) 18 | render.set_stencil_mask(0xff) 19 | render.clear({[render.BUFFER_COLOR_BIT] = self.clear_color, [render.BUFFER_DEPTH_BIT] = 1, [render.BUFFER_STENCIL_BIT] = 0}) 20 | 21 | render.set_viewport(0, 0, render.get_window_width(), render.get_window_height()) 22 | render.set_view(self.view) 23 | 24 | render.set_depth_mask(false) 25 | render.disable_state(render.STATE_DEPTH_TEST) 26 | render.disable_state(render.STATE_STENCIL_TEST) 27 | render.enable_state(render.STATE_BLEND) 28 | render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA) 29 | render.disable_state(render.STATE_CULL_FACE) 30 | 31 | render.set_projection(vmath.matrix4_orthographic(0, render.get_width(), 0, render.get_height(), -1000, 1000)) 32 | 33 | render.draw(self.tile_pred) 34 | render.draw(self.particle_pred) 35 | render.draw_debug3d() 36 | 37 | render.set_view(vmath.matrix4()) 38 | render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1)) 39 | 40 | render.enable_state(render.STATE_STENCIL_TEST) 41 | render.draw(self.gui_pred) 42 | render.draw(self.text_pred) 43 | render.disable_state(render.STATE_STENCIL_TEST) 44 | 45 | render.set_depth_mask(false) 46 | render.draw_debug2d() 47 | end 48 | 49 | function on_message(self, message_id, message) 50 | if message_id == hash("clear_color") then 51 | self.clear_color = message.color 52 | elseif message_id == hash("set_view_projection") then 53 | self.view = message.view 54 | end 55 | end 56 | -------------------------------------------------------------------------------- /deffx/materials/model/perturb_normals.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | varying mediump vec3 var_position; 3 | varying mediump vec3 var_normal; 4 | 5 | uniform lowp vec4 eye; 6 | uniform lowp vec4 lightPos4; 7 | uniform lowp sampler2D DIFFUSE_TEXTURE; 8 | uniform lowp sampler2D NORMAL_MAP; 9 | //uniform lowp sampler2D PASS_TEXTURE; 10 | 11 | //const vec3 lightPos = vec3(1.0,1.0,1.0); 12 | const vec3 diffuseColor = vec3(0.5, 0.5, 0.5); 13 | const vec3 specColor = vec3(0.7, 0.7, 0.7); 14 | 15 | mat3 cotangent(vec3 N, vec3 p, vec2 uv) { 16 | // get edge vectors of the pixel triangle 17 | vec3 dp1 = dFdx(p); 18 | vec3 dp2 = dFdy(p); 19 | vec2 duv1 = dFdx(uv); 20 | vec2 duv2 = dFdy(uv); 21 | 22 | // solve the linear system 23 | vec3 dp2perp = cross(dp2, N); 24 | vec3 dp1perp = cross(N, dp1); 25 | vec3 T = dp2perp * duv1.x + dp1perp * duv2.x; 26 | vec3 B = dp2perp * duv1.y + dp1perp * duv2.y; 27 | 28 | // construct a scale-invariant frame 29 | float invmax = 1.0 / sqrt(max(dot(T,T), dot(B,B))); 30 | return mat3(T * invmax, B * invmax, N); 31 | } 32 | 33 | vec3 perturb(vec3 map, vec3 N, vec3 V, vec2 texcoord) { 34 | mat3 TBN = cotangent(N, -V, texcoord); 35 | return normalize(TBN * map); 36 | } 37 | 38 | 39 | 40 | 41 | void main() { 42 | 43 | vec2 uv_repeat = vec2(5.0, 1.0); 44 | float normal_weight = 0.85; 45 | vec3 view_position = normalize(vec3(0.0, 0.0, 1.0)); 46 | 47 | vec3 normal_map_rgb = texture2D(NORMAL_MAP, var_texcoord0 * uv_repeat).rgb; 48 | vec3 normal_map = normal_map_rgb * 2.0 - 1.0; 49 | normal_map.xy = normal_map.xy * normal_weight; 50 | 51 | vec3 lightPos = vec3(lightPos4.x, lightPos4.y, lightPos4.z); 52 | vec3 lightDir = normalize(lightPos - var_position); 53 | vec3 perturb_normal = perturb(normal_map, normalize(var_normal), view_position, var_texcoord0); 54 | 55 | // this is not working yet 56 | 57 | vec3 normal = normalize(normal_map) * 0.25 + normalize(var_normal) * 0.75; 58 | 59 | 60 | float lambertian = max(dot(lightDir, normal), 0.0); 61 | float specular = 0.0; 62 | 63 | if(lambertian > 0.0) { 64 | vec3 viewDir = normalize(-var_position); 65 | vec3 halfDir = normalize(lightDir + viewDir); 66 | float specAngle = max(dot(halfDir, normal), 0.0); 67 | specular = pow(specAngle, 32.0); 68 | } 69 | 70 | gl_FragColor = vec4(lambertian * texture2D(DIFFUSE_TEXTURE, var_texcoord0) + specular * specColor, 1.0); 71 | 72 | } -------------------------------------------------------------------------------- /examples_render_materials/overdraw/main.render_script: -------------------------------------------------------------------------------- 1 | function init(self) 2 | self.tile_pred = render.predicate({"tile"}) 3 | self.gui_pred = render.predicate({"gui"}) 4 | self.text_pred = render.predicate({"text"}) 5 | self.particle_pred = render.predicate({"particle"}) 6 | 7 | self.clear_color = vmath.vector4(0, 0, 0, 0) 8 | self.clear_color.x = sys.get_config("render.clear_color_red", 0) 9 | self.clear_color.y = sys.get_config("render.clear_color_green", 0) 10 | self.clear_color.z = sys.get_config("render.clear_color_blue", 0) 11 | self.clear_color.w = sys.get_config("render.clear_color_alpha", 0) 12 | 13 | self.view = vmath.matrix4() 14 | self.toggle_overdraw = false 15 | end 16 | 17 | function update(self) 18 | render.set_depth_mask(true) 19 | render.set_stencil_mask(0xff) 20 | render.clear({[render.BUFFER_COLOR_BIT] = self.clear_color, [render.BUFFER_DEPTH_BIT] = 1, [render.BUFFER_STENCIL_BIT] = 0}) 21 | 22 | render.set_viewport(0, 0, render.get_window_width(), render.get_window_height()) 23 | render.set_view(self.view) 24 | 25 | render.set_depth_mask(false) 26 | render.disable_state(render.STATE_DEPTH_TEST) 27 | render.disable_state(render.STATE_STENCIL_TEST) 28 | render.enable_state(render.STATE_BLEND) 29 | render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA) 30 | render.disable_state(render.STATE_CULL_FACE) 31 | 32 | render.set_projection(vmath.matrix4_orthographic(0, render.get_width(), 0, render.get_height(), -1, 1)) 33 | 34 | render.draw(self.tile_pred) 35 | render.draw(self.particle_pred) 36 | render.draw_debug3d() 37 | 38 | render.set_view(vmath.matrix4()) 39 | render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1)) 40 | 41 | render.enable_state(render.STATE_STENCIL_TEST) 42 | render.draw(self.gui_pred) 43 | render.draw(self.text_pred) 44 | render.disable_state(render.STATE_STENCIL_TEST) 45 | 46 | render.set_depth_mask(false) 47 | render.draw_debug2d() 48 | 49 | if not self.toggle_overdraw then 50 | render.disable_material() 51 | else 52 | render.enable_material("overdraw") 53 | end 54 | end 55 | 56 | function on_message(self, message_id, message) 57 | if message_id == hash("clear_color") then 58 | self.clear_color = message.color 59 | elseif message_id == hash("set_view_projection") then 60 | self.view = message.view 61 | elseif message_id == hash("toggle_overdraw") then 62 | self.toggle_overdraw = not self.toggle_overdraw 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /deffx/materials/_tools/normal_packing.txt: -------------------------------------------------------------------------------- 1 | // Packing the normal to 2 components 2 | vec2 packed_normal = pack_normal_octahedron(my_normal); 3 | 4 | // Unpacking the formal from 3 components 5 | vec3 unpacked_normal = unpack_normal_octahedron(packed_normal); 6 | 7 | /* 8 | 9 | Normal packing as described in: 10 | A Survey of Efficient Representations for Independent Unit Vectors 11 | Source: http://jcgt.org/published/0003/02/01/paper.pdf 12 | 13 | */ 14 | 15 | // For each component of v, returns -1 if the component is < 0, else 1 16 | vec2 sign_not_zero(vec2 v) { 17 | #if 1 18 | // Branch-Less version 19 | return fma(step(vec2(0.0), v), vec2(2.0), vec2(-1.0)); 20 | #else 21 | // Version with branches (for GLSL < 4.00) 22 | return vec2( 23 | v.x >= 0 ? 1.0 : -1.0, 24 | v.y >= 0 ? 1.0 : -1.0 25 | ); 26 | #endif 27 | } 28 | 29 | // Packs a 3-component normal to 2 channels using octahedron normals 30 | vec2 pack_normal_octahedron(vec3 v) { 31 | #if 0 32 | // Version as proposed by the paper 33 | // Project the sphere onto the octahedron, and then onto the xy plane 34 | vec2 p = v.xy * (1.0 / (abs(v.x) + abs(v.y) + abs(v.z))); 35 | // Reflect the folds of the lower hemisphere over the diagonals 36 | return (v.z <= 0.0) ? ((1.0 - abs(p.yx)) * sign_not_zero(p)) : p; 37 | #else 38 | // Faster version using newer GLSL capatibilities 39 | v.xy /= dot(abs(v), vec3(1)); 40 | 41 | #if 0 42 | // Version with branches 43 | if (v.z <= 0) v.xy = (1.0 - abs(v.yx)) * sign_not_zero(v.xy); 44 | return v.xy; 45 | #else 46 | // Branch-Less version 47 | return mix(v.xy, (1.0 - abs(v.yx)) * sign_not_zero(v.xy), step(v.z, 0.0)); 48 | #endif 49 | #endif 50 | } 51 | 52 | 53 | // Unpacking from octahedron normals, input is the output from pack_normal_octahedron 54 | vec3 unpack_normal_octahedron(vec2 packed_nrm) { 55 | #if 1 56 | // Version using newer GLSL capatibilities 57 | vec3 v = vec3(packed_nrm.xy, 1.0 - abs(packed_nrm.x) - abs(packed_nrm.y)); 58 | #if 1 59 | // Version with branches, seems to take less cycles than the 60 | // branch-less version 61 | if (v.z < 0) v.xy = (1.0 - abs(v.yx)) * sign_not_zero(v.xy); 62 | #else 63 | // Branch-Less version 64 | v.xy = mix(v.xy, (1.0 - abs(v.yx)) * sign_not_zero(v.xy), step(v.z, 0)); 65 | #endif 66 | 67 | return normalize(v); 68 | #else 69 | // Version as proposed in the paper. 70 | vec3 v = vec3(packed_nrm, 1.0 - dot(vec2(1), abs(packed_nrm))); 71 | if (v.z < 0) 72 | v.xy = (vec2(1) - abs(v.yx)) * sign_not_zero(v.xy); 73 | return normalize(v); 74 | #endif 75 | } -------------------------------------------------------------------------------- /deffx/materials/rendertarget/fxaa.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | uniform lowp sampler2D POST_TEXTURE; 3 | 4 | uniform lowp vec4 options; 5 | 6 | vec4 apply_fxaa() { 7 | // The parameters are hardcoded for now, but could be 8 | // made into uniforms to control from the program. 9 | vec2 tex_offset = vec2(1.0, 1.0); 10 | float FXAA_SPAN_MAX = 8.0; 11 | float FXAA_REDUCE_MUL = 1.0/8.0; 12 | float FXAA_REDUCE_MIN = (1.0/128.0); 13 | 14 | vec3 rgbNW = texture2D(POST_TEXTURE, var_texcoord0.xy + (vec2(-1.0, -1.0) * tex_offset)).xyz; 15 | vec3 rgbNE = texture2D(POST_TEXTURE, var_texcoord0.xy + (vec2(+1.0, -1.0) * tex_offset)).xyz; 16 | vec3 rgbSW = texture2D(POST_TEXTURE, var_texcoord0.xy + (vec2(-1.0, +1.0) * tex_offset)).xyz; 17 | vec3 rgbSE = texture2D(POST_TEXTURE, var_texcoord0.xy + (vec2(+1.0, +1.0) * tex_offset)).xyz; 18 | vec3 rgbM = texture2D(POST_TEXTURE, var_texcoord0.xy).xyz; 19 | 20 | vec3 luma = vec3(0.299, 0.587, 0.114); 21 | float lumaNW = dot(rgbNW, luma); 22 | float lumaNE = dot(rgbNE, luma); 23 | float lumaSW = dot(rgbSW, luma); 24 | float lumaSE = dot(rgbSE, luma); 25 | float lumaM = dot(rgbM, luma); 26 | 27 | float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); 28 | float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); 29 | 30 | vec2 dir; 31 | dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE)); 32 | dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE)); 33 | 34 | float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); 35 | 36 | float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce); 37 | 38 | dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), 39 | max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * tex_offset; 40 | 41 | vec3 rgbA = (1.0/2.0) * ( 42 | texture2D(POST_TEXTURE, var_texcoord0.xy + dir * (1.0/3.0 - 0.5)).xyz + 43 | texture2D(POST_TEXTURE, var_texcoord0.xy + dir * (2.0/3.0 - 0.5)).xyz); 44 | vec3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * ( 45 | texture2D(POST_TEXTURE, var_texcoord0.xy + dir * (0.0/3.0 - 0.5)).xyz + 46 | texture2D(POST_TEXTURE, var_texcoord0.xy + dir * (3.0/3.0 - 0.5)).xyz); 47 | float lumaB = dot(rgbB, luma); 48 | 49 | vec4 color = vec4(1.0, 1.0, 1.0, 1.0); 50 | 51 | if((lumaB < lumaMin) || (lumaB > lumaMax)){ 52 | color.xyz = rgbA; 53 | } else { 54 | color.xyz = rgbB; 55 | } 56 | color.a = 1.0; 57 | return color; 58 | } 59 | 60 | void main () { 61 | if (options.x == 1.0) { 62 | gl_FragColor = apply_fxaa(); 63 | } else { 64 | gl_FragColor = texture2D(POST_TEXTURE, var_texcoord0); 65 | //gl_FragColor = vec4(0.4,0.4,0.4,1.0); 66 | } 67 | 68 | //gl_FragColor = texture2D(POST_TEXTURE, var_texcoord0); 69 | 70 | } -------------------------------------------------------------------------------- /deffx/materials/sprite/linear_gradient.fp: -------------------------------------------------------------------------------- 1 | varying mediump vec2 var_texcoord0; 2 | 3 | uniform lowp sampler2D DIFFUSE_TEXTURE; 4 | uniform lowp vec4 resolution; 5 | 6 | 7 | // if you need more colors in your gradients it's easy to add them 8 | // when arrays are added to use then hopefully this will be able to be cleaner 9 | uniform lowp vec4 gradient_start; 10 | uniform lowp vec4 gradient_stop; 11 | 12 | uniform lowp vec4 number_of_colors; 13 | uniform lowp vec4 color_1; 14 | uniform lowp vec4 color_2; 15 | uniform lowp vec4 color_3; 16 | uniform lowp vec4 color_4; 17 | uniform lowp vec4 color_5; 18 | uniform lowp vec4 color_6; 19 | uniform lowp vec4 color_7; 20 | uniform lowp vec4 color_8; 21 | 22 | uniform lowp vec4 number_of_stops; 23 | uniform lowp vec4 stop_1; 24 | uniform lowp vec4 stop_2; 25 | uniform lowp vec4 stop_3; 26 | uniform lowp vec4 stop_4; 27 | uniform lowp vec4 stop_5; 28 | uniform lowp vec4 stop_6; 29 | uniform lowp vec4 stop_7; 30 | uniform lowp vec4 stop_8; 31 | 32 | 33 | void main() { 34 | 35 | vec4 colors[]; 36 | float stops[]; 37 | 38 | // replace when can use arrays 39 | 40 | if (number_of_colors.x > 0.0) colors[1] = color_1; 41 | if (number_of_colors.x > 1.0) colors[2] = color_2; 42 | if (number_of_colors.x > 2.0) colors[3] = color_3; 43 | if (number_of_colors.x > 3.0) colors[4] = color_4; 44 | if (number_of_colors.x > 4.0) colors[5] = color_5; 45 | if (number_of_colors.x > 5.0) colors[6] = color_6; 46 | if (number_of_colors.x > 6.0) colors[7] = color_7; 47 | if (number_of_colors.x > 7.0) colors[8] = color_8; 48 | 49 | if (number_of_stops.x > 0.0) stops[1] = stop_1.x; 50 | if (number_of_stops.x > 1.0) stops[2] = stop_2.x; 51 | if (number_of_stops.x > 2.0) stops[3] = stop_3.x; 52 | if (number_of_stops.x > 3.0) stops[4] = stop_4.x; 53 | if (number_of_stops.x > 4.0) stops[5] = stop_5.x; 54 | if (number_of_stops.x > 5.0) stops[6] = stop_6.x; 55 | if (number_of_stops.x > 6.0) stops[7] = stop_7.x; 56 | if (number_of_stops.x > 7.0) stops[8] = stop_8.x; 57 | 58 | 59 | float alpha = atan( -gradient_stop.y + gradient_start.y, gradient_stop.x - gradient_start.x ); 60 | float gradient_start_rotated_x = gradient_start.x*cos(alpha) - gradient_start.y*sin(alpha); 61 | float gradient_stop_rotated_x = gradient_stop.x*cos(alpha) - gradient_stop.y*sin(alpha); 62 | float d = gradient_stop_rotated_x - gradient_start_rotated_x; 63 | 64 | 65 | //float y = resolution.y - gl_FragCoord.y; 66 | float y = var_texcoord0.y; 67 | float x = var_texcoord0.x; 68 | float x_location_rotated = x*cos( alpha ) - y*sin( alpha ); 69 | 70 | vec4 color; 71 | 72 | color = mix(colors[0], colors[1], smoothstep( gradient_start_rotated_x + stops[0]*d, gradient_start_rotated_x + stops[1]*d, x_location_rotated ) ); 73 | for ( int i=1; i 2 | 3 | 4 | 5 | Blender User 6 | Blender 2.77.0 commit date:2016-03-18, commit time:12:34, hash:22a2853 7 | 8 | 2016-05-07T10:39:48 9 | 2016-05-07T10:39:48 10 | 11 | Z_UP 12 | 13 | 14 | 15 | 16 | 17 | 18 | -1 -1 -1 -1 -1 1 -1 1 -1 -1 1 1 1 -1 -1 1 -1 1 1 1 -1 1 1 1 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -1 0 0 0 1 0 1 0 0 0 -1 0 0 0 -1 0 0 1 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 1 0 0 -1 0 0 1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 -1 0 0 0 1 1 0 0 0 0 1 -1 0 0 0 1 0 1 -1 0 -1 1 0 1 -1 0 -1 -1 0 -1 -1 0 -1 -1 0 -1 -1 0 -1 0 1 1 1 1 0 0 1 -1 1 -1 0 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 3 3 3 3 3 3 3 3 3 3 3 3 54 |

3 0 0 0 0 1 1 0 2 7 1 3 2 1 4 3 1 5 5 2 6 6 2 7 7 2 8 1 3 9 4 3 10 5 3 11 2 4 12 4 4 13 0 4 14 7 5 15 1 5 16 5 5 17 3 0 18 2 0 19 0 0 20 7 1 21 6 1 22 2 1 23 5 2 24 4 2 25 6 2 26 1 3 27 0 3 28 4 3 29 2 4 30 6 4 31 4 4 32 7 5 33 3 5 34 1 5 35

55 |
56 |
57 |
58 |
59 | 60 | 61 | 62 | 63 | 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 |
-------------------------------------------------------------------------------- /deffx/render/3d_camera/main.render_script: -------------------------------------------------------------------------------- 1 | screen_window_helper = require("deffx.utils.screen_window_helper") 2 | 3 | function init(self) 4 | 5 | self.gui_pred = render.predicate({"gui"}) 6 | self.text_pred = render.predicate({"text"}) 7 | 8 | 9 | self.threede_pred = render.predicate({"3d"}) 10 | 11 | self.clear_color = vmath.vector4(0, 0, 0, 0) 12 | self.clear_color.x = sys.get_config("render.clear_color_red", 0) 13 | self.clear_color.y = sys.get_config("render.clear_color_green", 0) 14 | self.clear_color.z = sys.get_config("render.clear_color_blue", 0) 15 | self.clear_color.w = sys.get_config("render.clear_color_alpha", 0) 16 | 17 | self.timer = 0 18 | 19 | 20 | 21 | end 22 | 23 | local screen_window_helper = require("deffx.utils.screen_window_helper") 24 | 25 | function update(self) 26 | 27 | self.timer = self.timer + 0.01 28 | 29 | screen_window_helper.window_width = render.get_window_width() 30 | screen_window_helper.window_height = render.get_window_height() 31 | 32 | ---------------------------------------------------------------------------------------- 33 | -- setup viewport and clear the screen 34 | render.set_viewport(0, 0, render.get_window_width(), render.get_window_height()) 35 | render.clear({[render.BUFFER_COLOR_BIT] = self.clear_color, [render.BUFFER_DEPTH_BIT] = 1, [render.BUFFER_STENCIL_BIT] = 0}) 36 | 37 | -- setup state (we need to enable depth testing for 3D stuff) 38 | render.enable_state(render.STATE_DEPTH_TEST) 39 | render.set_depth_mask(true) 40 | 41 | if (screen_window_helper.using_camera == true) then 42 | 43 | render.set_view(screen_window_helper.view_matrix) 44 | render.set_projection(screen_window_helper.projection_matrix) 45 | 46 | else 47 | 48 | -- create view and projection matrices 49 | local cam_lookat = vmath.vector3(0.0,0.0,0.0) 50 | local cam_pos = vmath.vector3(0.0,0.0,1.0 + math.abs(math.sin(self.timer))) 51 | --local cam_pos = vmath.vector3(0.0,0.0,20.0) -- this moves the camera further away 52 | local cam_up = vmath.vector3(0,1,0) 53 | local view_mtx = vmath.matrix4_look_at(cam_pos, cam_lookat, cam_up) 54 | local fov = (math.pi / 180.0) * 60.0 -- 60 degrees 55 | local proj_mtx = vmath.matrix4_perspective(fov, render.get_window_width() / render.get_window_height(), 0.1, 100.0) 56 | 57 | -- set matrices 58 | render.set_view(view_mtx) 59 | render.set_projection(proj_mtx) 60 | 61 | end 62 | 63 | 64 | 65 | -- draw cube predicate 66 | render.draw(self.threede_pred) 67 | 68 | -- 69 | 70 | render.disable_state(render.STATE_DEPTH_TEST) 71 | render.disable_state(render.STATE_STENCIL_TEST) 72 | render.enable_state(render.STATE_BLEND) 73 | render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA) 74 | render.disable_state(render.STATE_CULL_FACE) 75 | 76 | render.set_view(vmath.matrix4()) 77 | render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1)) 78 | 79 | render.enable_state(render.STATE_STENCIL_TEST) 80 | render.draw(self.gui_pred) 81 | render.draw(self.text_pred) 82 | render.disable_state(render.STATE_STENCIL_TEST) 83 | 84 | 85 | 86 | end 87 | 88 | 89 | function on_message(self, message_id, message) 90 | if message_id == hash("clear_color") then 91 | self.clear_color = message.color 92 | elseif message_id == hash("set_view_projection") then 93 | self.view = message.view 94 | end 95 | end 96 | 97 | -------------------------------------------------------------------------------- /deffx/cameras/look_at.script: -------------------------------------------------------------------------------- 1 | --[[ 2 | local eye = vmath.vector3(0, 0, 100) 3 | local look_at = vmath.vector3(0, 0, 0) 4 | local up = vmath.vector3(0, 1, 0) 5 | local view = vmath.matrix4_look_at(eye, look_at, up) 6 | render.set_view(view) 7 | local proj = vmath.matrix4_perspective(3.141592/2, 4/3, 1, 1000) 8 | --]] 9 | 10 | --[[ 11 | -- create view and projection matrices 12 | local cam_lookat = vmath.vector3(0.0,0.0,0.0) 13 | local cam_pos = vmath.vector3(0.0,0.0,1.0 + math.abs(math.sin(self.timer))) 14 | --local cam_pos = vmath.vector3(0.0,0.0,20.0) -- this moves the camera further away 15 | local cam_up = vmath.vector3(0,1,0) 16 | local view_mtx = vmath.matrix4_look_at(cam_pos, cam_lookat, cam_up) 17 | local fov = (math.pi / 180.0) * 60.0 -- 60 degrees 18 | local proj_mtx = vmath.matrix4_perspective(fov, render.get_window_width() / render.get_window_height(), 0.1, 100.0) 19 | 20 | -- set matrices 21 | render.set_view(view_mtx) 22 | render.set_projection(proj_mtx) 23 | 24 | --]] 25 | 26 | --[[ 27 | 28 | This is a simple look at camera. You can set its position and change what it is looking at via message passing. 29 | 30 | It updates view matrix and view projection information to the screen_window_helper module so that a render script can use the data directly. 31 | 32 | --]] 33 | 34 | 35 | local screen_window_helper = require("deffx.utils.screen_window_helper") 36 | 37 | local function look_at(self, target) 38 | screen_window_helper.view_matrix = vmath.matrix4_look_at(self.position,target,self.up) 39 | screen_window_helper.projection_matrix = vmath.matrix4_perspective(self.fov, screen_window_helper.window_width / screen_window_helper.window_height, 0.1, 100.0) 40 | end 41 | 42 | 43 | local function demo(self) 44 | 45 | end 46 | 47 | 48 | function init(self) 49 | 50 | self.timer = 0 51 | 52 | screen_window_helper.using_camera = true 53 | 54 | --[[ 55 | self.position = vmath.vector3(0,0,1) 56 | self.target = vmath.vector3(0,0,0) 57 | self.up = vmath.vector3(0,1,0) 58 | self.fov = (math.pi / 180.0) * 60.0 -- 60 degrees 59 | look_at(self,self.target) 60 | --]] 61 | -- create view and projection matrices 62 | 63 | --[[ Demo - add extra comment to start of line to enable 64 | self.timer = 0 65 | self.demo = true 66 | self.position.x = 1 * math.cos(self.timer) 67 | self.position.y = 2 * math.sin(self.timer) + 10 68 | --]] 69 | end 70 | 71 | function final(self) 72 | 73 | end 74 | 75 | function update(self, dt) 76 | self.timer = self.timer + dt 77 | demo(self) 78 | local cam_lookat = vmath.vector3(0.0,0.0,0.0) 79 | screen_window_helper.camera_lookat = cam_lookat 80 | local cam_pos = vmath.vector3(0.0,0.0,1.0 + math.abs(math.sin(self.timer))) 81 | screen_window_helper.camera_position = cam_pos 82 | cam_pos.x = 1 * math.cos(self.timer) 83 | cam_pos.y = 2 * math.sin(self.timer) 84 | --local cam_pos = vmath.vector3(0.0,0.0,20.0) -- this moves the camera further away 85 | local cam_up = vmath.vector3(0,1,0) 86 | screen_window_helper.view_matrix = vmath.matrix4_look_at(cam_pos, cam_lookat, cam_up) 87 | local fov = (math.pi / 180.0) * 60.0 -- 60 degrees 88 | screen_window_helper.projection_matrix = vmath.matrix4_perspective(fov, screen_window_helper.window_width / screen_window_helper.window_height, 0.1, 100.0) 89 | 90 | 91 | end 92 | 93 | function on_message(self, message_id, message, sender) 94 | -- update all camera information 95 | if message_id == hash("update_camera") then 96 | 97 | end 98 | 99 | if message_id == hash("set_position") then 100 | 101 | end 102 | if message_id == hash("look_at") then 103 | 104 | end 105 | end 106 | 107 | function on_input(self, action_id, action) 108 | -- Add input-handling code here 109 | -- Remove this function if not needed 110 | end 111 | 112 | function on_reload(self) 113 | 114 | end 115 | -------------------------------------------------------------------------------- /deffx/materials/sprite/linear_gradient.material: -------------------------------------------------------------------------------- 1 | name: "sprite" 2 | tags: "tile" 3 | vertex_program: "/builtins/materials/sprite.vp" 4 | fragment_program: "/deffx/materials/sprite/linear_gradient.fp" 5 | vertex_constants { 6 | name: "view_proj" 7 | type: CONSTANT_TYPE_VIEWPROJ 8 | } 9 | fragment_constants { 10 | name: "resolution" 11 | type: CONSTANT_TYPE_USER 12 | value { 13 | x: 1600.0 14 | y: 800.0 15 | z: 0.0 16 | w: 0.0 17 | } 18 | } 19 | fragment_constants { 20 | name: "gradient_start" 21 | type: CONSTANT_TYPE_USER 22 | value { 23 | x: 0.0 24 | y: 0.0 25 | z: 0.0 26 | w: 0.0 27 | } 28 | } 29 | fragment_constants { 30 | name: "gradient_stop" 31 | type: CONSTANT_TYPE_USER 32 | value { 33 | x: 0.5 34 | y: 0.5 35 | z: 0.0 36 | w: 0.0 37 | } 38 | } 39 | fragment_constants { 40 | name: "number_of_colors" 41 | type: CONSTANT_TYPE_USER 42 | value { 43 | x: 2.0 44 | y: 0.0 45 | z: 0.0 46 | w: 0.0 47 | } 48 | } 49 | fragment_constants { 50 | name: "color_1" 51 | type: CONSTANT_TYPE_USER 52 | value { 53 | x: 1.0 54 | y: 1.0 55 | z: 1.0 56 | w: 1.0 57 | } 58 | } 59 | fragment_constants { 60 | name: "color_2" 61 | type: CONSTANT_TYPE_USER 62 | value { 63 | x: 0.2 64 | y: 0.0 65 | z: 0.0 66 | w: 1.0 67 | } 68 | } 69 | fragment_constants { 70 | name: "color_3" 71 | type: CONSTANT_TYPE_USER 72 | value { 73 | x: 0.0 74 | y: 0.0 75 | z: 0.0 76 | w: 0.0 77 | } 78 | } 79 | fragment_constants { 80 | name: "color_4" 81 | type: CONSTANT_TYPE_USER 82 | value { 83 | x: 0.0 84 | y: 0.0 85 | z: 0.0 86 | w: 0.0 87 | } 88 | } 89 | fragment_constants { 90 | name: "color_5" 91 | type: CONSTANT_TYPE_USER 92 | value { 93 | x: 0.0 94 | y: 0.0 95 | z: 0.0 96 | w: 0.0 97 | } 98 | } 99 | fragment_constants { 100 | name: "color_6" 101 | type: CONSTANT_TYPE_USER 102 | value { 103 | x: 0.0 104 | y: 0.0 105 | z: 0.0 106 | w: 0.0 107 | } 108 | } 109 | fragment_constants { 110 | name: "color_7" 111 | type: CONSTANT_TYPE_USER 112 | value { 113 | x: 0.0 114 | y: 0.0 115 | z: 0.0 116 | w: 0.0 117 | } 118 | } 119 | fragment_constants { 120 | name: "color_8" 121 | type: CONSTANT_TYPE_USER 122 | value { 123 | x: 0.0 124 | y: 0.0 125 | z: 0.0 126 | w: 0.0 127 | } 128 | } 129 | fragment_constants { 130 | name: "number_of_stops" 131 | type: CONSTANT_TYPE_USER 132 | value { 133 | x: 3.0 134 | y: 0.0 135 | z: 0.0 136 | w: 0.0 137 | } 138 | } 139 | fragment_constants { 140 | name: "stop_1" 141 | type: CONSTANT_TYPE_USER 142 | value { 143 | x: 0.0 144 | y: 0.0 145 | z: 0.0 146 | w: 0.0 147 | } 148 | } 149 | fragment_constants { 150 | name: "stop_2" 151 | type: CONSTANT_TYPE_USER 152 | value { 153 | x: 1.0 154 | y: 1.0 155 | z: 0.0 156 | w: 0.0 157 | } 158 | } 159 | fragment_constants { 160 | name: "stop_3" 161 | type: CONSTANT_TYPE_USER 162 | value { 163 | x: 0.0 164 | y: 0.0 165 | z: 0.0 166 | w: 0.0 167 | } 168 | } 169 | fragment_constants { 170 | name: "stop_4" 171 | type: CONSTANT_TYPE_USER 172 | value { 173 | x: 0.0 174 | y: 0.0 175 | z: 0.0 176 | w: 0.0 177 | } 178 | } 179 | fragment_constants { 180 | name: "stop_5" 181 | type: CONSTANT_TYPE_USER 182 | value { 183 | x: 0.0 184 | y: 0.0 185 | z: 0.0 186 | w: 0.0 187 | } 188 | } 189 | fragment_constants { 190 | name: "stop_6" 191 | type: CONSTANT_TYPE_USER 192 | value { 193 | x: 0.0 194 | y: 0.0 195 | z: 0.0 196 | w: 0.0 197 | } 198 | } 199 | fragment_constants { 200 | name: "stop_7" 201 | type: CONSTANT_TYPE_USER 202 | value { 203 | x: 0.0 204 | y: 0.0 205 | z: 0.0 206 | w: 0.0 207 | } 208 | } 209 | fragment_constants { 210 | name: "stop_8" 211 | type: CONSTANT_TYPE_USER 212 | value { 213 | x: 0.0 214 | y: 0.0 215 | z: 0.0 216 | w: 0.0 217 | } 218 | } 219 | samplers { 220 | name: "DIFFUSE_TEXTURE" 221 | wrap_u: WRAP_MODE_REPEAT 222 | wrap_v: WRAP_MODE_REPEAT 223 | filter_min: FILTER_MODE_MIN_LINEAR 224 | filter_mag: FILTER_MODE_MAG_LINEAR 225 | } 226 | -------------------------------------------------------------------------------- /deffx/quad/quad.dae: -------------------------------------------------------------------------------- 1 | 2 | 3 | FBX COLLADA exporter2012-10-10T12:34:45Z2012-10-10T12:34:45ZY_UP 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 0.000000 0.000000 0.000000 1.000000 16 | 17 | 18 | 0.000000 0.000000 0.000000 1.000000 19 | 20 | 21 | 0.400000 0.400000 0.400000 1.000000 22 | 23 | 24 | 0.000000 0.000000 0.000000 1.000000 25 | 26 | 27 | 1.000000 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -1.000000 -1.000000 0.000000 40 | 1.000000 -1.000000 0.000000 41 | -1.000000 1.000000 0.000000 42 | 1.000000 1.000000 0.000000 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 0.000000 0.000000 1.000000 55 | 0.000000 0.000000 1.000000 56 | 0.000000 0.000000 1.000000 57 | 0.000000 0.000000 1.000000 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 0.000000 0.000000 70 | 1.000000 0.000000 71 | 0.000000 1.000000 72 | 1.000000 1.000000 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 |

3 3 2 2 0 0 3 3 0 0 1 1

86 |
87 |
88 |
89 | 90 | 91 | 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 1.0000001.000000 92 | 24.0000000.0416672.000000 93 | 94 | 95 | 96 | 97 | 98 |
-------------------------------------------------------------------------------- /examples_3d/lambert/lambert.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "components {\n" 6 | " id: \"script\"\n" 7 | " component: \"/examples_3d/lambert/lambert.script\"\n" 8 | " position {\n" 9 | " x: 0.0\n" 10 | " y: 0.0\n" 11 | " z: 0.0\n" 12 | " }\n" 13 | " rotation {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " w: 1.0\n" 18 | " }\n" 19 | "}\n" 20 | "embedded_components {\n" 21 | " id: \"model\"\n" 22 | " type: \"model\"\n" 23 | " data: \"mesh: \\\"/deffx/materials/_tools/stanford-bunny.dae\\\"\\n" 24 | "material: \\\"/deffx/materials/model/lambert.material\\\"\\n" 25 | "textures: \\\"/_assets/textures/public-domain/hokusai.jpg\\\"\\n" 26 | "skeleton: \\\"\\\"\\n" 27 | "animations: \\\"\\\"\\n" 28 | "default_animation: \\\"\\\"\\n" 29 | "name: \\\"unnamed\\\"\\n" 30 | "\"\n" 31 | " position {\n" 32 | " x: 0.0\n" 33 | " y: 0.0\n" 34 | " z: 0.0\n" 35 | " }\n" 36 | " rotation {\n" 37 | " x: 0.0\n" 38 | " y: 0.0\n" 39 | " z: 0.0\n" 40 | " w: 1.0\n" 41 | " }\n" 42 | "}\n" 43 | "" 44 | position { 45 | x: 0.0 46 | y: 0.0 47 | z: 0.0 48 | } 49 | rotation { 50 | x: 0.0 51 | y: 0.0 52 | z: 0.0 53 | w: 1.0 54 | } 55 | scale3 { 56 | x: 0.05 57 | y: 0.05 58 | z: 0.05 59 | } 60 | } 61 | embedded_instances { 62 | id: "_label" 63 | data: "embedded_components {\n" 64 | " id: \"label\"\n" 65 | " type: \"label\"\n" 66 | " data: \"size {\\n" 67 | " x: 128.0\\n" 68 | " y: 32.0\\n" 69 | " z: 0.0\\n" 70 | " w: 0.0\\n" 71 | "}\\n" 72 | "scale {\\n" 73 | " x: 1.0\\n" 74 | " y: 1.0\\n" 75 | " z: 1.0\\n" 76 | " w: 0.0\\n" 77 | "}\\n" 78 | "color {\\n" 79 | " x: 1.0\\n" 80 | " y: 1.0\\n" 81 | " z: 1.0\\n" 82 | " w: 1.0\\n" 83 | "}\\n" 84 | "outline {\\n" 85 | " x: 0.0\\n" 86 | " y: 0.0\\n" 87 | " z: 0.0\\n" 88 | " w: 1.0\\n" 89 | "}\\n" 90 | "shadow {\\n" 91 | " x: 0.0\\n" 92 | " y: 0.0\\n" 93 | " z: 0.0\\n" 94 | " w: 1.0\\n" 95 | "}\\n" 96 | "leading: 1.0\\n" 97 | "tracking: 0.0\\n" 98 | "pivot: PIVOT_NW\\n" 99 | "blend_mode: BLEND_MODE_ALPHA\\n" 100 | "line_break: false\\n" 101 | "text: \\\"3d: Lambert\\\"\\n" 102 | "font: \\\"/builtins/fonts/system_font.font\\\"\\n" 103 | "material: \\\"/builtins/fonts/label.material\\\"\\n" 104 | "\"\n" 105 | " position {\n" 106 | " x: 18.647\n" 107 | " y: 783.54\n" 108 | " z: 0.0\n" 109 | " }\n" 110 | " rotation {\n" 111 | " x: 0.0\n" 112 | " y: 0.0\n" 113 | " z: 0.0\n" 114 | " w: 1.0\n" 115 | " }\n" 116 | "}\n" 117 | "embedded_components {\n" 118 | " id: \"label1\"\n" 119 | " type: \"label\"\n" 120 | " data: \"size {\\n" 121 | " x: 128.0\\n" 122 | " y: 32.0\\n" 123 | " z: 0.0\\n" 124 | " w: 0.0\\n" 125 | "}\\n" 126 | "scale {\\n" 127 | " x: 1.0\\n" 128 | " y: 1.0\\n" 129 | " z: 1.0\\n" 130 | " w: 0.0\\n" 131 | "}\\n" 132 | "color {\\n" 133 | " x: 1.0\\n" 134 | " y: 1.0\\n" 135 | " z: 1.0\\n" 136 | " w: 1.0\\n" 137 | "}\\n" 138 | "outline {\\n" 139 | " x: 0.0\\n" 140 | " y: 0.0\\n" 141 | " z: 0.0\\n" 142 | " w: 1.0\\n" 143 | "}\\n" 144 | "shadow {\\n" 145 | " x: 0.0\\n" 146 | " y: 0.0\\n" 147 | " z: 0.0\\n" 148 | " w: 1.0\\n" 149 | "}\\n" 150 | "leading: 1.0\\n" 151 | "tracking: 0.0\\n" 152 | "pivot: PIVOT_NW\\n" 153 | "blend_mode: BLEND_MODE_ALPHA\\n" 154 | "line_break: false\\n" 155 | "text: \\\"3d: Lambert\\\"\\n" 156 | "font: \\\"/builtins/fonts/system_font.font\\\"\\n" 157 | "material: \\\"/builtins/fonts/font.material\\\"\\n" 158 | "\"\n" 159 | " position {\n" 160 | " x: 24.215\n" 161 | " y: 762.662\n" 162 | " z: 0.0\n" 163 | " }\n" 164 | " rotation {\n" 165 | " x: 0.0\n" 166 | " y: 0.0\n" 167 | " z: 0.0\n" 168 | " w: 1.0\n" 169 | " }\n" 170 | "}\n" 171 | "" 172 | position { 173 | x: 0.0 174 | y: 0.0 175 | z: 0.0 176 | } 177 | rotation { 178 | x: 0.0 179 | y: 0.0 180 | z: 0.0 181 | w: 1.0 182 | } 183 | scale3 { 184 | x: 1.0 185 | y: 1.0 186 | z: 1.0 187 | } 188 | } 189 | embedded_instances { 190 | id: "_screensize" 191 | data: "components {\n" 192 | " id: \"gui\"\n" 193 | " component: \"/_assets/gui/blank.gui\"\n" 194 | " position {\n" 195 | " x: 0.0\n" 196 | " y: 0.0\n" 197 | " z: 0.0\n" 198 | " }\n" 199 | " rotation {\n" 200 | " x: 0.0\n" 201 | " y: 0.0\n" 202 | " z: 0.0\n" 203 | " w: 1.0\n" 204 | " }\n" 205 | "}\n" 206 | "" 207 | position { 208 | x: 0.0 209 | y: 0.0 210 | z: 0.0 211 | } 212 | rotation { 213 | x: 0.0 214 | y: 0.0 215 | z: 0.0 216 | w: 1.0 217 | } 218 | scale3 { 219 | x: 1.0 220 | y: 1.0 221 | z: 1.0 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /examples_3d/textured/textured.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "components {\n" 6 | " id: \"script\"\n" 7 | " component: \"/examples_3d/textured/textured.script\"\n" 8 | " position {\n" 9 | " x: 0.0\n" 10 | " y: 0.0\n" 11 | " z: 0.0\n" 12 | " }\n" 13 | " rotation {\n" 14 | " x: 0.0\n" 15 | " y: 0.0\n" 16 | " z: 0.0\n" 17 | " w: 1.0\n" 18 | " }\n" 19 | "}\n" 20 | "embedded_components {\n" 21 | " id: \"model\"\n" 22 | " type: \"model\"\n" 23 | " data: \"mesh: \\\"/_assets/models/rock01.dae\\\"\\n" 24 | "material: \\\"/deffx/materials/model/textured.material\\\"\\n" 25 | "textures: \\\"/_assets/textures/public-domain/japan-nach-reisen-und-studien.png\\\"\\n" 26 | "skeleton: \\\"\\\"\\n" 27 | "animations: \\\"\\\"\\n" 28 | "default_animation: \\\"\\\"\\n" 29 | "name: \\\"unnamed\\\"\\n" 30 | "\"\n" 31 | " position {\n" 32 | " x: 0.0\n" 33 | " y: 0.0\n" 34 | " z: 0.0\n" 35 | " }\n" 36 | " rotation {\n" 37 | " x: 0.0\n" 38 | " y: 0.0\n" 39 | " z: 0.0\n" 40 | " w: 1.0\n" 41 | " }\n" 42 | "}\n" 43 | "" 44 | position { 45 | x: 0.0 46 | y: 0.0 47 | z: 0.0 48 | } 49 | rotation { 50 | x: 0.0 51 | y: 0.0 52 | z: 0.0 53 | w: 1.0 54 | } 55 | scale3 { 56 | x: 0.5449717 57 | y: 0.5449717 58 | z: 0.5449717 59 | } 60 | } 61 | embedded_instances { 62 | id: "_label" 63 | data: "embedded_components {\n" 64 | " id: \"label\"\n" 65 | " type: \"label\"\n" 66 | " data: \"size {\\n" 67 | " x: 128.0\\n" 68 | " y: 32.0\\n" 69 | " z: 0.0\\n" 70 | " w: 0.0\\n" 71 | "}\\n" 72 | "scale {\\n" 73 | " x: 1.0\\n" 74 | " y: 1.0\\n" 75 | " z: 1.0\\n" 76 | " w: 0.0\\n" 77 | "}\\n" 78 | "color {\\n" 79 | " x: 1.0\\n" 80 | " y: 1.0\\n" 81 | " z: 1.0\\n" 82 | " w: 1.0\\n" 83 | "}\\n" 84 | "outline {\\n" 85 | " x: 0.0\\n" 86 | " y: 0.0\\n" 87 | " z: 0.0\\n" 88 | " w: 1.0\\n" 89 | "}\\n" 90 | "shadow {\\n" 91 | " x: 0.0\\n" 92 | " y: 0.0\\n" 93 | " z: 0.0\\n" 94 | " w: 1.0\\n" 95 | "}\\n" 96 | "leading: 1.0\\n" 97 | "tracking: 0.0\\n" 98 | "pivot: PIVOT_NW\\n" 99 | "blend_mode: BLEND_MODE_ALPHA\\n" 100 | "line_break: false\\n" 101 | "text: \\\"3d: Textured\\\"\\n" 102 | "font: \\\"/builtins/fonts/system_font.font\\\"\\n" 103 | "material: \\\"/builtins/fonts/label.material\\\"\\n" 104 | "\"\n" 105 | " position {\n" 106 | " x: 18.647\n" 107 | " y: 783.54\n" 108 | " z: 0.0\n" 109 | " }\n" 110 | " rotation {\n" 111 | " x: 0.0\n" 112 | " y: 0.0\n" 113 | " z: 0.0\n" 114 | " w: 1.0\n" 115 | " }\n" 116 | "}\n" 117 | "embedded_components {\n" 118 | " id: \"label1\"\n" 119 | " type: \"label\"\n" 120 | " data: \"size {\\n" 121 | " x: 128.0\\n" 122 | " y: 32.0\\n" 123 | " z: 0.0\\n" 124 | " w: 0.0\\n" 125 | "}\\n" 126 | "scale {\\n" 127 | " x: 1.0\\n" 128 | " y: 1.0\\n" 129 | " z: 1.0\\n" 130 | " w: 0.0\\n" 131 | "}\\n" 132 | "color {\\n" 133 | " x: 1.0\\n" 134 | " y: 1.0\\n" 135 | " z: 1.0\\n" 136 | " w: 1.0\\n" 137 | "}\\n" 138 | "outline {\\n" 139 | " x: 0.0\\n" 140 | " y: 0.0\\n" 141 | " z: 0.0\\n" 142 | " w: 1.0\\n" 143 | "}\\n" 144 | "shadow {\\n" 145 | " x: 0.0\\n" 146 | " y: 0.0\\n" 147 | " z: 0.0\\n" 148 | " w: 1.0\\n" 149 | "}\\n" 150 | "leading: 1.0\\n" 151 | "tracking: 0.0\\n" 152 | "pivot: PIVOT_NW\\n" 153 | "blend_mode: BLEND_MODE_ALPHA\\n" 154 | "line_break: false\\n" 155 | "text: \\\"3d: Textured\\\"\\n" 156 | "font: \\\"/builtins/fonts/system_font.font\\\"\\n" 157 | "material: \\\"/builtins/fonts/font.material\\\"\\n" 158 | "\"\n" 159 | " position {\n" 160 | " x: 24.215\n" 161 | " y: 762.662\n" 162 | " z: 0.0\n" 163 | " }\n" 164 | " rotation {\n" 165 | " x: 0.0\n" 166 | " y: 0.0\n" 167 | " z: 0.0\n" 168 | " w: 1.0\n" 169 | " }\n" 170 | "}\n" 171 | "" 172 | position { 173 | x: 0.0 174 | y: 0.0 175 | z: 0.0 176 | } 177 | rotation { 178 | x: 0.0 179 | y: 0.0 180 | z: 0.0 181 | w: 1.0 182 | } 183 | scale3 { 184 | x: 1.0 185 | y: 1.0 186 | z: 1.0 187 | } 188 | } 189 | embedded_instances { 190 | id: "_screensize" 191 | data: "components {\n" 192 | " id: \"gui\"\n" 193 | " component: \"/_assets/gui/blank.gui\"\n" 194 | " position {\n" 195 | " x: 0.0\n" 196 | " y: 0.0\n" 197 | " z: 0.0\n" 198 | " }\n" 199 | " rotation {\n" 200 | " x: 0.0\n" 201 | " y: 0.0\n" 202 | " z: 0.0\n" 203 | " w: 1.0\n" 204 | " }\n" 205 | "}\n" 206 | "" 207 | position { 208 | x: 0.0 209 | y: 0.0 210 | z: 0.0 211 | } 212 | rotation { 213 | x: 0.0 214 | y: 0.0 215 | z: 0.0 216 | w: 1.0 217 | } 218 | scale3 { 219 | x: 1.0 220 | y: 1.0 221 | z: 1.0 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /examples_blending/cross_fade/cross_fade.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "_label" 5 | data: "embedded_components {\n" 6 | " id: \"label\"\n" 7 | " type: \"label\"\n" 8 | " data: \"size {\\n" 9 | " x: 128.0\\n" 10 | " y: 32.0\\n" 11 | " z: 0.0\\n" 12 | " w: 0.0\\n" 13 | "}\\n" 14 | "scale {\\n" 15 | " x: 1.0\\n" 16 | " y: 1.0\\n" 17 | " z: 1.0\\n" 18 | " w: 0.0\\n" 19 | "}\\n" 20 | "color {\\n" 21 | " x: 1.0\\n" 22 | " y: 1.0\\n" 23 | " z: 1.0\\n" 24 | " w: 1.0\\n" 25 | "}\\n" 26 | "outline {\\n" 27 | " x: 0.0\\n" 28 | " y: 0.0\\n" 29 | " z: 0.0\\n" 30 | " w: 1.0\\n" 31 | "}\\n" 32 | "shadow {\\n" 33 | " x: 0.0\\n" 34 | " y: 0.0\\n" 35 | " z: 0.0\\n" 36 | " w: 1.0\\n" 37 | "}\\n" 38 | "leading: 1.0\\n" 39 | "tracking: 0.0\\n" 40 | "pivot: PIVOT_NW\\n" 41 | "blend_mode: BLEND_MODE_ALPHA\\n" 42 | "line_break: false\\n" 43 | "text: \\\"Blending : Cross Fade\\\"\\n" 44 | "font: \\\"/builtins/fonts/system_font.font\\\"\\n" 45 | "material: \\\"/builtins/fonts/label.material\\\"\\n" 46 | "\"\n" 47 | " position {\n" 48 | " x: 18.647\n" 49 | " y: 783.54\n" 50 | " z: 0.0\n" 51 | " }\n" 52 | " rotation {\n" 53 | " x: 0.0\n" 54 | " y: 0.0\n" 55 | " z: 0.0\n" 56 | " w: 1.0\n" 57 | " }\n" 58 | "}\n" 59 | "" 60 | position { 61 | x: 0.0 62 | y: 0.0 63 | z: 0.0 64 | } 65 | rotation { 66 | x: 0.0 67 | y: 0.0 68 | z: 0.0 69 | w: 1.0 70 | } 71 | scale3 { 72 | x: 1.0 73 | y: 1.0 74 | z: 1.0 75 | } 76 | } 77 | embedded_instances { 78 | id: "_screensize" 79 | data: "components {\n" 80 | " id: \"gui\"\n" 81 | " component: \"/_assets/gui/blank.gui\"\n" 82 | " position {\n" 83 | " x: 0.0\n" 84 | " y: 0.0\n" 85 | " z: 0.0\n" 86 | " }\n" 87 | " rotation {\n" 88 | " x: 0.0\n" 89 | " y: 0.0\n" 90 | " z: 0.0\n" 91 | " w: 1.0\n" 92 | " }\n" 93 | "}\n" 94 | "" 95 | position { 96 | x: 0.0 97 | y: 0.0 98 | z: 0.0 99 | } 100 | rotation { 101 | x: 0.0 102 | y: 0.0 103 | z: 0.0 104 | w: 1.0 105 | } 106 | scale3 { 107 | x: 1.0 108 | y: 1.0 109 | z: 1.0 110 | } 111 | } 112 | embedded_instances { 113 | id: "script" 114 | data: "components {\n" 115 | " id: \"script\"\n" 116 | " component: \"/examples_blending/cross_fade/cross_fade.script\"\n" 117 | " position {\n" 118 | " x: 0.0\n" 119 | " y: 0.0\n" 120 | " z: 0.0\n" 121 | " }\n" 122 | " rotation {\n" 123 | " x: 0.0\n" 124 | " y: 0.0\n" 125 | " z: 0.0\n" 126 | " w: 1.0\n" 127 | " }\n" 128 | "}\n" 129 | "" 130 | position { 131 | x: 0.0 132 | y: 0.0 133 | z: 0.0 134 | } 135 | rotation { 136 | x: 0.0 137 | y: 0.0 138 | z: 0.0 139 | w: 1.0 140 | } 141 | scale3 { 142 | x: 1.0 143 | y: 1.0 144 | z: 1.0 145 | } 146 | } 147 | embedded_instances { 148 | id: "unitquad" 149 | data: "embedded_components {\n" 150 | " id: \"unitquad\"\n" 151 | " type: \"model\"\n" 152 | " data: \"mesh: \\\"/deffx/quad/quad.dae\\\"\\n" 153 | "material: \\\"/deffx/materials/blend/cross_fade.material\\\"\\n" 154 | "textures: \\\"/_assets/textures/public-domain/hokusai.jpg\\\"\\n" 155 | "textures: \\\"/_assets/textures/defold/defold-large.png\\\"\\n" 156 | "skeleton: \\\"\\\"\\n" 157 | "animations: \\\"\\\"\\n" 158 | "default_animation: \\\"\\\"\\n" 159 | "name: \\\"\\\"\\n" 160 | "\"\n" 161 | " position {\n" 162 | " x: 0.0\n" 163 | " y: 0.0\n" 164 | " z: 0.0\n" 165 | " }\n" 166 | " rotation {\n" 167 | " x: 0.0\n" 168 | " y: 0.0\n" 169 | " z: 0.0\n" 170 | " w: 1.0\n" 171 | " }\n" 172 | "}\n" 173 | "" 174 | position { 175 | x: 482.017 176 | y: 407.309 177 | z: 0.0 178 | } 179 | rotation { 180 | x: 0.0 181 | y: 0.0 182 | z: 0.0 183 | w: 1.0 184 | } 185 | scale3 { 186 | x: 256.0 187 | y: 256.0 188 | z: 1.0 189 | } 190 | } 191 | embedded_instances { 192 | id: "unitquad1" 193 | data: "embedded_components {\n" 194 | " id: \"unitquad\"\n" 195 | " type: \"model\"\n" 196 | " data: \"mesh: \\\"/deffx/quad/quad.dae\\\"\\n" 197 | "material: \\\"/deffx/materials/blend/cross_fade.material\\\"\\n" 198 | "textures: \\\"/_assets/textures/public-domain/hokusai.jpg\\\"\\n" 199 | "textures: \\\"/_assets/textures/defold/defold-large.png\\\"\\n" 200 | "skeleton: \\\"\\\"\\n" 201 | "animations: \\\"\\\"\\n" 202 | "default_animation: \\\"\\\"\\n" 203 | "name: \\\"\\\"\\n" 204 | "\"\n" 205 | " position {\n" 206 | " x: 0.0\n" 207 | " y: 0.0\n" 208 | " z: 0.0\n" 209 | " }\n" 210 | " rotation {\n" 211 | " x: 0.0\n" 212 | " y: 0.0\n" 213 | " z: 0.0\n" 214 | " w: 1.0\n" 215 | " }\n" 216 | "}\n" 217 | "" 218 | position { 219 | x: 1054.408 220 | y: 407.309 221 | z: 0.0 222 | } 223 | rotation { 224 | x: 0.0 225 | y: 0.0 226 | z: 0.0 227 | w: 1.0 228 | } 229 | scale3 { 230 | x: 256.0 231 | y: 256.0 232 | z: 1.0 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /examples_blending/vivid_light/vivid_light.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "_label" 5 | data: "embedded_components {\n" 6 | " id: \"label\"\n" 7 | " type: \"label\"\n" 8 | " data: \"size {\\n" 9 | " x: 128.0\\n" 10 | " y: 32.0\\n" 11 | " z: 0.0\\n" 12 | " w: 0.0\\n" 13 | "}\\n" 14 | "scale {\\n" 15 | " x: 1.0\\n" 16 | " y: 1.0\\n" 17 | " z: 1.0\\n" 18 | " w: 0.0\\n" 19 | "}\\n" 20 | "color {\\n" 21 | " x: 1.0\\n" 22 | " y: 1.0\\n" 23 | " z: 1.0\\n" 24 | " w: 1.0\\n" 25 | "}\\n" 26 | "outline {\\n" 27 | " x: 0.0\\n" 28 | " y: 0.0\\n" 29 | " z: 0.0\\n" 30 | " w: 1.0\\n" 31 | "}\\n" 32 | "shadow {\\n" 33 | " x: 0.0\\n" 34 | " y: 0.0\\n" 35 | " z: 0.0\\n" 36 | " w: 1.0\\n" 37 | "}\\n" 38 | "leading: 1.0\\n" 39 | "tracking: 0.0\\n" 40 | "pivot: PIVOT_NW\\n" 41 | "blend_mode: BLEND_MODE_ALPHA\\n" 42 | "line_break: false\\n" 43 | "text: \\\"Blending : Vivid Light\\\"\\n" 44 | "font: \\\"/builtins/fonts/system_font.font\\\"\\n" 45 | "material: \\\"/builtins/fonts/label.material\\\"\\n" 46 | "\"\n" 47 | " position {\n" 48 | " x: 18.647\n" 49 | " y: 783.54\n" 50 | " z: 0.0\n" 51 | " }\n" 52 | " rotation {\n" 53 | " x: 0.0\n" 54 | " y: 0.0\n" 55 | " z: 0.0\n" 56 | " w: 1.0\n" 57 | " }\n" 58 | "}\n" 59 | "" 60 | position { 61 | x: 0.0 62 | y: 0.0 63 | z: 0.0 64 | } 65 | rotation { 66 | x: 0.0 67 | y: 0.0 68 | z: 0.0 69 | w: 1.0 70 | } 71 | scale3 { 72 | x: 1.0 73 | y: 1.0 74 | z: 1.0 75 | } 76 | } 77 | embedded_instances { 78 | id: "_screensize" 79 | data: "components {\n" 80 | " id: \"gui\"\n" 81 | " component: \"/_assets/gui/blank.gui\"\n" 82 | " position {\n" 83 | " x: 0.0\n" 84 | " y: 0.0\n" 85 | " z: 0.0\n" 86 | " }\n" 87 | " rotation {\n" 88 | " x: 0.0\n" 89 | " y: 0.0\n" 90 | " z: 0.0\n" 91 | " w: 1.0\n" 92 | " }\n" 93 | "}\n" 94 | "" 95 | position { 96 | x: 0.0 97 | y: 0.0 98 | z: 0.0 99 | } 100 | rotation { 101 | x: 0.0 102 | y: 0.0 103 | z: 0.0 104 | w: 1.0 105 | } 106 | scale3 { 107 | x: 1.0 108 | y: 1.0 109 | z: 1.0 110 | } 111 | } 112 | embedded_instances { 113 | id: "script" 114 | data: "components {\n" 115 | " id: \"script\"\n" 116 | " component: \"/examples_blending/vivid_light/vivid_light.script\"\n" 117 | " position {\n" 118 | " x: 0.0\n" 119 | " y: 0.0\n" 120 | " z: 0.0\n" 121 | " }\n" 122 | " rotation {\n" 123 | " x: 0.0\n" 124 | " y: 0.0\n" 125 | " z: 0.0\n" 126 | " w: 1.0\n" 127 | " }\n" 128 | "}\n" 129 | "" 130 | position { 131 | x: 0.0 132 | y: 0.0 133 | z: 0.0 134 | } 135 | rotation { 136 | x: 0.0 137 | y: 0.0 138 | z: 0.0 139 | w: 1.0 140 | } 141 | scale3 { 142 | x: 1.0 143 | y: 1.0 144 | z: 1.0 145 | } 146 | } 147 | embedded_instances { 148 | id: "unitquad" 149 | data: "embedded_components {\n" 150 | " id: \"unitquad\"\n" 151 | " type: \"model\"\n" 152 | " data: \"mesh: \\\"/deffx/quad/quad.dae\\\"\\n" 153 | "material: \\\"/deffx/materials/blend/vivid_light.material\\\"\\n" 154 | "textures: \\\"/_assets/textures/public-domain/hokusai.jpg\\\"\\n" 155 | "textures: \\\"/_assets/textures/defold/defold-large.png\\\"\\n" 156 | "skeleton: \\\"\\\"\\n" 157 | "animations: \\\"\\\"\\n" 158 | "default_animation: \\\"\\\"\\n" 159 | "name: \\\"\\\"\\n" 160 | "\"\n" 161 | " position {\n" 162 | " x: 0.0\n" 163 | " y: 0.0\n" 164 | " z: 0.0\n" 165 | " }\n" 166 | " rotation {\n" 167 | " x: 0.0\n" 168 | " y: 0.0\n" 169 | " z: 0.0\n" 170 | " w: 1.0\n" 171 | " }\n" 172 | "}\n" 173 | "" 174 | position { 175 | x: 482.017 176 | y: 407.309 177 | z: 0.0 178 | } 179 | rotation { 180 | x: 0.0 181 | y: 0.0 182 | z: 0.0 183 | w: 1.0 184 | } 185 | scale3 { 186 | x: 256.0 187 | y: 256.0 188 | z: 1.0 189 | } 190 | } 191 | embedded_instances { 192 | id: "unitquad1" 193 | data: "embedded_components {\n" 194 | " id: \"unitquad\"\n" 195 | " type: \"model\"\n" 196 | " data: \"mesh: \\\"/deffx/quad/quad.dae\\\"\\n" 197 | "material: \\\"/deffx/materials/blend/vivid_light.material\\\"\\n" 198 | "textures: \\\"/_assets/textures/public-domain/hokusai.jpg\\\"\\n" 199 | "textures: \\\"/_assets/textures/defold/defold-large.png\\\"\\n" 200 | "skeleton: \\\"\\\"\\n" 201 | "animations: \\\"\\\"\\n" 202 | "default_animation: \\\"\\\"\\n" 203 | "name: \\\"\\\"\\n" 204 | "\"\n" 205 | " position {\n" 206 | " x: 0.0\n" 207 | " y: 0.0\n" 208 | " z: 0.0\n" 209 | " }\n" 210 | " rotation {\n" 211 | " x: 0.0\n" 212 | " y: 0.0\n" 213 | " z: 0.0\n" 214 | " w: 1.0\n" 215 | " }\n" 216 | "}\n" 217 | "" 218 | position { 219 | x: 1054.408 220 | y: 407.309 221 | z: 0.0 222 | } 223 | rotation { 224 | x: 0.0 225 | y: 0.0 226 | z: 0.0 227 | w: 1.0 228 | } 229 | scale3 { 230 | x: 256.0 231 | y: 256.0 232 | z: 1.0 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DefFX 2 | A collection of useful shader effects made ready to be used with the Defold game engine 3 | 4 | The purpose of this shader collection is for each to be generally useful, efficient, and to work on Open GL ES 2.0. If you've made a shader which you think would be useful to others please consider contributing it via a pull request. If you can improve an existing shader to add useful features or increase performance please submit your changes! 5 | 6 | ## Installation 7 | You can use DefFX in your own project by adding this project as a [Defold library dependency](http://www.defold.com/manuals/libraries/). Open your game.project file and in the dependencies field under project add: 8 | 9 | https://github.com/subsoap/deffx/archive/master.zip 10 | 11 | Once installed, you can select the materials you wish to use from their associated folders much like you would builtin materials. When you make builds Defold will only package the materials you actually use so do not worry about the extra files. Check your build folder to see for yourself. 12 | 13 | Check the source files and examples for full usage. 14 | 15 | This collection will likely change over time though we'll try to not break any existing shaders. You may wish to download a static version of these files for use in your project, or create a fork of this project to link to within Defold. At some point, this project will have versioned releases which will be guaranteed to not change and will be easily linked to. 16 | 17 | ## Expanded Usage 18 | Each shader has different potential usage. There are shaders which could be used for sprites, text, and as post processing effects but are not already setup for each. Making shader versions for features like spine animations is possible. If you would like to help versions specific for each situation please contribute them. 19 | 20 | ## Gotchas 21 | You may wish to adjust, or merge multiple shader files together for your projects to improve batching and lower draw calls and then make your single shader be able to do multiple effects or single effects at once based on variables sent to the shader programs. 22 | 23 | Be careful about breaking batching! If you have a ton of different sprites with various materials set to them at different z positions you may significantly lower your game's performance. This is why you should consider merging multiple shaders with the effects you want possible on your sprites into a single shader for your own use. The process of merging can be complex so ask on the Defold forum if you need assistance. 24 | 25 | Some of the examples may have extreme effects to illustrate the range of effects so if you are sensitive to light / have epilepsy be warned! 26 | 27 | Sometimes it is better to make pre-baked raster images with some extra polish effects rather than using complex shaders. Performance matters a great deal on mobile and it's easy to kill it with complex shaders. 28 | 29 | You may want to add kill switches for certain targets to completely bypass the normal shader code for complex shaders, especially with low FPS. Or to give users config options. 30 | 31 | For post processing effects, they can be very expensive for mobile, such as blurs. It would be a good idea to scale down the size of the rendered texture which is then blurred for example. You could example more expensive shaders on desktop targets while enabling less expensive versions for mobile. 32 | 33 | ## Sprite Ready Shaders 34 | These shaders can be added to sprites. You may need to send data to the shader program over time such as a timer value so check the associated demos for each. 35 | 36 | * HSB - Adjust the Hue, Saturation, and Brightness of sprites at runtime. 37 | 38 | ![](docs/images/sprite_hsb.png) 39 | 40 | * Scrolling Texture - Offset / pan / zoom seamless textures. 41 | 42 | ![](docs/images/sprite_scrolling_texture.png) 43 | 44 | * Greyscale 45 | 46 | ![](docs/images/sprite_greyscale.png) 47 | 48 | * Lighten - useful for making sprites flash when taking damage for example. 49 | 50 | ![](docs/images/sprite_lighten.png) 51 | 52 | * Noise 53 | * Simple Blur 54 | * Directional Blur 55 | * Pixelate 56 | 57 | 58 | ## Post Processing Effect Shaders 59 | These shaders are meant to be applied to render targets. Generally this means you draw your game layers to the render target, and then apply the post processing shader effect. Using these effects requires a custom render script. These shaders require a render script set which has a render target setup. 60 | 61 | * Scanlines + Chromatic Shift + Distortion + Vignetting 62 | 63 | ![](docs/images/postprocessing_scanlines_chromatic_distortion_vignette.png) 64 | 65 | ## 3D Model Shaders 66 | These shaders are meant for use in 3D models. They can be used as foundations for greater effects. These shaders require a render script which supports 3D models. 67 | 68 | * Phong 69 | 70 | ![](docs/images/3d_phong.png) 71 | 72 | * Textured (unlit / no shading) 73 | 74 | ![](docs/images/3d_textured.png) 75 | 76 | * Checkers 77 | 78 | ![](docs/images/3d_checkers.png) 79 | 80 | * Normals 81 | 82 | ![](docs/images/3d_normals.png) 83 | 84 | ## Blending Shaders 85 | Use image editing blending modes between two textures. Could be used for example as additional render target steps to apply textures to entire screen in some way. 86 | 87 | * Vivid Light 88 | 89 | ![](docs/images/blending_vivid_light.png) -------------------------------------------------------------------------------- /examples_3d/checker/checker.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "script" 5 | data: "" 6 | position { 7 | x: 0.0 8 | y: 0.0 9 | z: 0.0 10 | } 11 | rotation { 12 | x: 0.0 13 | y: 0.0 14 | z: 0.0 15 | w: 1.0 16 | } 17 | scale3 { 18 | x: 1.0 19 | y: 1.0 20 | z: 1.0 21 | } 22 | } 23 | embedded_instances { 24 | id: "_label" 25 | data: "embedded_components {\n" 26 | " id: \"label\"\n" 27 | " type: \"label\"\n" 28 | " data: \"size {\\n" 29 | " x: 128.0\\n" 30 | " y: 32.0\\n" 31 | " z: 0.0\\n" 32 | " w: 0.0\\n" 33 | "}\\n" 34 | "scale {\\n" 35 | " x: 1.0\\n" 36 | " y: 1.0\\n" 37 | " z: 1.0\\n" 38 | " w: 0.0\\n" 39 | "}\\n" 40 | "color {\\n" 41 | " x: 1.0\\n" 42 | " y: 1.0\\n" 43 | " z: 1.0\\n" 44 | " w: 1.0\\n" 45 | "}\\n" 46 | "outline {\\n" 47 | " x: 0.0\\n" 48 | " y: 0.0\\n" 49 | " z: 0.0\\n" 50 | " w: 1.0\\n" 51 | "}\\n" 52 | "shadow {\\n" 53 | " x: 0.0\\n" 54 | " y: 0.0\\n" 55 | " z: 0.0\\n" 56 | " w: 1.0\\n" 57 | "}\\n" 58 | "leading: 1.0\\n" 59 | "tracking: 0.0\\n" 60 | "pivot: PIVOT_NW\\n" 61 | "blend_mode: BLEND_MODE_ALPHA\\n" 62 | "line_break: false\\n" 63 | "text: \\\"3d: Checker\\\"\\n" 64 | "font: \\\"/builtins/fonts/system_font.font\\\"\\n" 65 | "material: \\\"/builtins/fonts/label.material\\\"\\n" 66 | "\"\n" 67 | " position {\n" 68 | " x: 18.647\n" 69 | " y: 783.54\n" 70 | " z: 0.0\n" 71 | " }\n" 72 | " rotation {\n" 73 | " x: 0.0\n" 74 | " y: 0.0\n" 75 | " z: 0.0\n" 76 | " w: 1.0\n" 77 | " }\n" 78 | "}\n" 79 | "embedded_components {\n" 80 | " id: \"label1\"\n" 81 | " type: \"label\"\n" 82 | " data: \"size {\\n" 83 | " x: 128.0\\n" 84 | " y: 32.0\\n" 85 | " z: 0.0\\n" 86 | " w: 0.0\\n" 87 | "}\\n" 88 | "scale {\\n" 89 | " x: 1.0\\n" 90 | " y: 1.0\\n" 91 | " z: 1.0\\n" 92 | " w: 0.0\\n" 93 | "}\\n" 94 | "color {\\n" 95 | " x: 1.0\\n" 96 | " y: 1.0\\n" 97 | " z: 1.0\\n" 98 | " w: 1.0\\n" 99 | "}\\n" 100 | "outline {\\n" 101 | " x: 0.0\\n" 102 | " y: 0.0\\n" 103 | " z: 0.0\\n" 104 | " w: 1.0\\n" 105 | "}\\n" 106 | "shadow {\\n" 107 | " x: 0.0\\n" 108 | " y: 0.0\\n" 109 | " z: 0.0\\n" 110 | " w: 1.0\\n" 111 | "}\\n" 112 | "leading: 1.0\\n" 113 | "tracking: 0.0\\n" 114 | "pivot: PIVOT_NW\\n" 115 | "blend_mode: BLEND_MODE_ALPHA\\n" 116 | "line_break: false\\n" 117 | "text: \\\"3d: Checker\\\"\\n" 118 | "font: \\\"/builtins/fonts/system_font.font\\\"\\n" 119 | "material: \\\"/builtins/fonts/font.material\\\"\\n" 120 | "\"\n" 121 | " position {\n" 122 | " x: 24.215\n" 123 | " y: 762.662\n" 124 | " z: 0.0\n" 125 | " }\n" 126 | " rotation {\n" 127 | " x: 0.0\n" 128 | " y: 0.0\n" 129 | " z: 0.0\n" 130 | " w: 1.0\n" 131 | " }\n" 132 | "}\n" 133 | "" 134 | position { 135 | x: 0.0 136 | y: 0.0 137 | z: 0.0 138 | } 139 | rotation { 140 | x: 0.0 141 | y: 0.0 142 | z: 0.0 143 | w: 1.0 144 | } 145 | scale3 { 146 | x: 1.0 147 | y: 1.0 148 | z: 1.0 149 | } 150 | } 151 | embedded_instances { 152 | id: "_screensize" 153 | data: "components {\n" 154 | " id: \"gui\"\n" 155 | " component: \"/_assets/gui/blank.gui\"\n" 156 | " position {\n" 157 | " x: 0.0\n" 158 | " y: 0.0\n" 159 | " z: 0.0\n" 160 | " }\n" 161 | " rotation {\n" 162 | " x: 0.0\n" 163 | " y: 0.0\n" 164 | " z: 0.0\n" 165 | " w: 1.0\n" 166 | " }\n" 167 | "}\n" 168 | "" 169 | position { 170 | x: 0.0 171 | y: 0.0 172 | z: 0.0 173 | } 174 | rotation { 175 | x: 0.0 176 | y: 0.0 177 | z: 0.0 178 | w: 1.0 179 | } 180 | scale3 { 181 | x: 1.0 182 | y: 1.0 183 | z: 1.0 184 | } 185 | } 186 | embedded_instances { 187 | id: "go1" 188 | data: "components {\n" 189 | " id: \"script\"\n" 190 | " component: \"/examples_3d/checker/checker.script\"\n" 191 | " position {\n" 192 | " x: 0.0\n" 193 | " y: 0.0\n" 194 | " z: 0.0\n" 195 | " }\n" 196 | " rotation {\n" 197 | " x: 0.0\n" 198 | " y: 0.0\n" 199 | " z: 0.0\n" 200 | " w: 1.0\n" 201 | " }\n" 202 | "}\n" 203 | "embedded_components {\n" 204 | " id: \"model\"\n" 205 | " type: \"model\"\n" 206 | " data: \"mesh: \\\"/_assets/models/openbox.dae\\\"\\n" 207 | "material: \\\"/deffx/materials/model/checker.material\\\"\\n" 208 | "textures: \\\"/_assets/textures/public-domain/hokusai.jpg\\\"\\n" 209 | "skeleton: \\\"\\\"\\n" 210 | "animations: \\\"\\\"\\n" 211 | "default_animation: \\\"\\\"\\n" 212 | "name: \\\"unnamed\\\"\\n" 213 | "\"\n" 214 | " position {\n" 215 | " x: 0.0\n" 216 | " y: 0.0\n" 217 | " z: 0.0\n" 218 | " }\n" 219 | " rotation {\n" 220 | " x: 0.0\n" 221 | " y: 0.0\n" 222 | " z: 0.0\n" 223 | " w: 1.0\n" 224 | " }\n" 225 | "}\n" 226 | "" 227 | position { 228 | x: 0.0 229 | y: 0.0 230 | z: 0.0 231 | } 232 | rotation { 233 | x: 0.0 234 | y: 0.0 235 | z: 0.0 236 | w: 1.0 237 | } 238 | scale3 { 239 | x: 0.5 240 | y: 0.5 241 | z: 0.5 242 | } 243 | } 244 | -------------------------------------------------------------------------------- /examples_3d/skybox/checker.collection: -------------------------------------------------------------------------------- 1 | name: "default" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "script" 5 | data: "" 6 | position { 7 | x: 0.0 8 | y: 0.0 9 | z: 0.0 10 | } 11 | rotation { 12 | x: 0.0 13 | y: 0.0 14 | z: 0.0 15 | w: 1.0 16 | } 17 | scale3 { 18 | x: 1.0 19 | y: 1.0 20 | z: 1.0 21 | } 22 | } 23 | embedded_instances { 24 | id: "_label" 25 | data: "embedded_components {\n" 26 | " id: \"label\"\n" 27 | " type: \"label\"\n" 28 | " data: \"size {\\n" 29 | " x: 128.0\\n" 30 | " y: 32.0\\n" 31 | " z: 0.0\\n" 32 | " w: 0.0\\n" 33 | "}\\n" 34 | "scale {\\n" 35 | " x: 1.0\\n" 36 | " y: 1.0\\n" 37 | " z: 1.0\\n" 38 | " w: 0.0\\n" 39 | "}\\n" 40 | "color {\\n" 41 | " x: 1.0\\n" 42 | " y: 1.0\\n" 43 | " z: 1.0\\n" 44 | " w: 1.0\\n" 45 | "}\\n" 46 | "outline {\\n" 47 | " x: 0.0\\n" 48 | " y: 0.0\\n" 49 | " z: 0.0\\n" 50 | " w: 1.0\\n" 51 | "}\\n" 52 | "shadow {\\n" 53 | " x: 0.0\\n" 54 | " y: 0.0\\n" 55 | " z: 0.0\\n" 56 | " w: 1.0\\n" 57 | "}\\n" 58 | "leading: 1.0\\n" 59 | "tracking: 0.0\\n" 60 | "pivot: PIVOT_NW\\n" 61 | "blend_mode: BLEND_MODE_ALPHA\\n" 62 | "line_break: false\\n" 63 | "text: \\\"3d: Checker\\\"\\n" 64 | "font: \\\"/builtins/fonts/system_font.font\\\"\\n" 65 | "material: \\\"/builtins/fonts/label.material\\\"\\n" 66 | "\"\n" 67 | " position {\n" 68 | " x: 18.647\n" 69 | " y: 783.54\n" 70 | " z: 0.0\n" 71 | " }\n" 72 | " rotation {\n" 73 | " x: 0.0\n" 74 | " y: 0.0\n" 75 | " z: 0.0\n" 76 | " w: 1.0\n" 77 | " }\n" 78 | "}\n" 79 | "embedded_components {\n" 80 | " id: \"label1\"\n" 81 | " type: \"label\"\n" 82 | " data: \"size {\\n" 83 | " x: 128.0\\n" 84 | " y: 32.0\\n" 85 | " z: 0.0\\n" 86 | " w: 0.0\\n" 87 | "}\\n" 88 | "scale {\\n" 89 | " x: 1.0\\n" 90 | " y: 1.0\\n" 91 | " z: 1.0\\n" 92 | " w: 0.0\\n" 93 | "}\\n" 94 | "color {\\n" 95 | " x: 1.0\\n" 96 | " y: 1.0\\n" 97 | " z: 1.0\\n" 98 | " w: 1.0\\n" 99 | "}\\n" 100 | "outline {\\n" 101 | " x: 0.0\\n" 102 | " y: 0.0\\n" 103 | " z: 0.0\\n" 104 | " w: 1.0\\n" 105 | "}\\n" 106 | "shadow {\\n" 107 | " x: 0.0\\n" 108 | " y: 0.0\\n" 109 | " z: 0.0\\n" 110 | " w: 1.0\\n" 111 | "}\\n" 112 | "leading: 1.0\\n" 113 | "tracking: 0.0\\n" 114 | "pivot: PIVOT_NW\\n" 115 | "blend_mode: BLEND_MODE_ALPHA\\n" 116 | "line_break: false\\n" 117 | "text: \\\"3d: Checker\\\"\\n" 118 | "font: \\\"/builtins/fonts/system_font.font\\\"\\n" 119 | "material: \\\"/builtins/fonts/font.material\\\"\\n" 120 | "\"\n" 121 | " position {\n" 122 | " x: 24.215\n" 123 | " y: 762.662\n" 124 | " z: 0.0\n" 125 | " }\n" 126 | " rotation {\n" 127 | " x: 0.0\n" 128 | " y: 0.0\n" 129 | " z: 0.0\n" 130 | " w: 1.0\n" 131 | " }\n" 132 | "}\n" 133 | "" 134 | position { 135 | x: 0.0 136 | y: 0.0 137 | z: 0.0 138 | } 139 | rotation { 140 | x: 0.0 141 | y: 0.0 142 | z: 0.0 143 | w: 1.0 144 | } 145 | scale3 { 146 | x: 1.0 147 | y: 1.0 148 | z: 1.0 149 | } 150 | } 151 | embedded_instances { 152 | id: "_screensize" 153 | data: "components {\n" 154 | " id: \"gui\"\n" 155 | " component: \"/_assets/gui/blank.gui\"\n" 156 | " position {\n" 157 | " x: 0.0\n" 158 | " y: 0.0\n" 159 | " z: 0.0\n" 160 | " }\n" 161 | " rotation {\n" 162 | " x: 0.0\n" 163 | " y: 0.0\n" 164 | " z: 0.0\n" 165 | " w: 1.0\n" 166 | " }\n" 167 | "}\n" 168 | "" 169 | position { 170 | x: 0.0 171 | y: 0.0 172 | z: 0.0 173 | } 174 | rotation { 175 | x: 0.0 176 | y: 0.0 177 | z: 0.0 178 | w: 1.0 179 | } 180 | scale3 { 181 | x: 1.0 182 | y: 1.0 183 | z: 1.0 184 | } 185 | } 186 | embedded_instances { 187 | id: "go1" 188 | data: "components {\n" 189 | " id: \"script\"\n" 190 | " component: \"/examples_3d/checker/checker.script\"\n" 191 | " position {\n" 192 | " x: 0.0\n" 193 | " y: 0.0\n" 194 | " z: 0.0\n" 195 | " }\n" 196 | " rotation {\n" 197 | " x: 0.0\n" 198 | " y: 0.0\n" 199 | " z: 0.0\n" 200 | " w: 1.0\n" 201 | " }\n" 202 | "}\n" 203 | "embedded_components {\n" 204 | " id: \"model\"\n" 205 | " type: \"model\"\n" 206 | " data: \"mesh: \\\"/_assets/models/kocmoc.dae\\\"\\n" 207 | "material: \\\"/deffx/materials/model/checker.material\\\"\\n" 208 | "textures: \\\"/_assets/textures/public-domain/hokusai.jpg\\\"\\n" 209 | "skeleton: \\\"\\\"\\n" 210 | "animations: \\\"\\\"\\n" 211 | "default_animation: \\\"\\\"\\n" 212 | "name: \\\"unnamed\\\"\\n" 213 | "\"\n" 214 | " position {\n" 215 | " x: 0.0\n" 216 | " y: 0.0\n" 217 | " z: 0.0\n" 218 | " }\n" 219 | " rotation {\n" 220 | " x: 0.0\n" 221 | " y: 0.0\n" 222 | " z: 0.0\n" 223 | " w: 1.0\n" 224 | " }\n" 225 | "}\n" 226 | "" 227 | position { 228 | x: 0.0 229 | y: 0.0 230 | z: 0.0 231 | } 232 | rotation { 233 | x: 0.0 234 | y: 0.0 235 | z: 0.0 236 | w: 1.0 237 | } 238 | scale3 { 239 | x: 0.25 240 | y: 0.25 241 | z: 0.25 242 | } 243 | } 244 | --------------------------------------------------------------------------------