Skip to content

Commit

Permalink
Site changes [skip-ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
defold-services committed Dec 9, 2024
1 parent 3ab1358 commit 4d625cd
Show file tree
Hide file tree
Showing 35 changed files with 79 additions and 1 deletion.
6 changes: 6 additions & 0 deletions _data/examplesindex.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,12 @@
"name": "Collisions",
"path": "tilemap/collisions"
},
{
"category": "MODEL",
"collection": "model/cubemap",
"name": "Cubemap",
"path": "model/cubemap"
},
{
"category": "DEBUG",
"collection": "debug/profile",
Expand Down
7 changes: 7 additions & 0 deletions _includes/examples/model/cubemap/cubemap_model_fp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
varying mediump vec3 vReflect;

uniform samplerCube envMap;

void main() {
gl_FragColor = textureCube(envMap, vReflect);
}
21 changes: 21 additions & 0 deletions _includes/examples/model/cubemap/cubemap_model_vp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
uniform mediump mat4 view_proj;
uniform mediump mat4 world;
uniform mediump mat4 normal_transform;
uniform mediump mat4 world_view;
uniform mediump vec4 cameraPosition;

attribute mediump vec3 position;
attribute mediump vec3 normal;
attribute mediump vec2 texcoord0;

varying mediump vec3 vReflect;

void main()
{
vec4 worldP = world * vec4(position, 1.0);
gl_Position = view_proj * worldP;

vec3 worldNormal = normalize(normal);
vec3 cameraToVertex = normalize( worldP.xyz - cameraPosition.xyz );
vReflect = reflect( cameraToVertex, worldNormal );
}
34 changes: 34 additions & 0 deletions _includes/examples/model/cubemap/cubemap_script.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
local ZOOM_SPEED = 0.1
local ROTATION_SPEED = 1

function init(self)
msg.post("@render:", "use_camera_projection")
msg.post(".", "acquire_input_focus")
self.yaw = 0 -- for camera rotation
self.pitch = 0 -- for camera rotation
self.zoom = 5 -- default zoom
self.zoom_offset = 0 -- modification from default zoom
end

function update(self, dt)
local camera_yaw = vmath.quat_rotation_y(math.rad(self.yaw))
local camera_pitch = vmath.quat_rotation_x(math.rad(self.pitch))
local camera_rot = camera_yaw * camera_pitch
local camera_position = vmath.rotate(camera_rot, vmath.vector3(0, 0, self.zoom + self.zoom_offset))
go.set_position(camera_position)
go.set_rotation(camera_rot)

local cameraposv4 = vmath.vector4(camera_position.x, camera_position.y, camera_position.z, 1)
go.set("logo#model", "cameraPosition", cameraposv4)
end

function on_input(self, action_id, action)
if action_id == hash("touch") then
self.yaw = self.yaw - action.dx * ROTATION_SPEED
self.pitch = self.pitch + action.dy * ROTATION_SPEED
elseif action_id == hash("wheel_up") then
self.zoom_offset = self.zoom_offset - ZOOM_SPEED
elseif action_id == hash("wheel_down") then
self.zoom_offset = self.zoom_offset + ZOOM_SPEED
end
end
2 changes: 1 addition & 1 deletion examples/archive/archive_files.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"content":[{"name":"game.projectc","size":4024,"pieces":[{"name":"game0.projectc","offset":0}]},{"name":"game.arci","size":52848,"pieces":[{"name":"game0.arci","offset":0}]},{"name":"game.arcd","size":4253084,"pieces":[{"name":"game0.arcd","offset":0},{"name":"game1.arcd","offset":2097152},{"name":"game2.arcd","offset":4194304}]},{"name":"game.dmanifest","size":57932,"pieces":[{"name":"game0.dmanifest","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game0.public.der","offset":0}]}],"total_size":4368050}
{"content":[{"name":"game.projectc","size":4024,"pieces":[{"name":"game0.projectc","offset":0}]},{"name":"game.arci","size":53888,"pieces":[{"name":"game0.arci","offset":0}]},{"name":"game.arcd","size":41311496,"pieces":[{"name":"game0.arcd","offset":0},{"name":"game1.arcd","offset":2097152},{"name":"game2.arcd","offset":4194304},{"name":"game3.arcd","offset":6291456},{"name":"game4.arcd","offset":8388608},{"name":"game5.arcd","offset":10485760},{"name":"game6.arcd","offset":12582912},{"name":"game7.arcd","offset":14680064},{"name":"game8.arcd","offset":16777216},{"name":"game9.arcd","offset":18874368},{"name":"game10.arcd","offset":20971520},{"name":"game11.arcd","offset":23068672},{"name":"game12.arcd","offset":25165824},{"name":"game13.arcd","offset":27262976},{"name":"game14.arcd","offset":29360128},{"name":"game15.arcd","offset":31457280},{"name":"game16.arcd","offset":33554432},{"name":"game17.arcd","offset":35651584},{"name":"game18.arcd","offset":37748736},{"name":"game19.arcd","offset":39845888}]},{"name":"game.dmanifest","size":59070,"pieces":[{"name":"game0.dmanifest","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game0.public.der","offset":0}]}],"total_size":41428640}
Binary file modified examples/archive/game0.arcd
Binary file not shown.
Binary file modified examples/archive/game0.arci
Binary file not shown.
Binary file modified examples/archive/game0.dmanifest
Binary file not shown.
Binary file modified examples/archive/game0.public.der
Binary file not shown.
Binary file modified examples/archive/game1.arcd
Binary file not shown.
Binary file added examples/archive/game10.arcd
Binary file not shown.
Binary file added examples/archive/game11.arcd
Binary file not shown.
Binary file added examples/archive/game12.arcd
Binary file not shown.
Binary file added examples/archive/game13.arcd
Binary file not shown.
Binary file added examples/archive/game14.arcd
Binary file not shown.
Binary file added examples/archive/game15.arcd
Binary file not shown.
Binary file added examples/archive/game16.arcd
Binary file not shown.
Binary file added examples/archive/game17.arcd
Binary file not shown.
Binary file added examples/archive/game18.arcd
Binary file not shown.
Binary file added examples/archive/game19.arcd
Binary file not shown.
Binary file modified examples/archive/game2.arcd
Binary file not shown.
Binary file added examples/archive/game3.arcd
Binary file not shown.
Binary file added examples/archive/game4.arcd
Binary file not shown.
Binary file added examples/archive/game5.arcd
Binary file not shown.
Binary file added examples/archive/game6.arcd
Binary file not shown.
Binary file added examples/archive/game7.arcd
Binary file not shown.
Binary file added examples/archive/game8.arcd
Binary file not shown.
Binary file added examples/archive/game9.arcd
Binary file not shown.
Binary file added examples/model/cubemap/assets/nx.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/model/cubemap/assets/ny.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/model/cubemap/assets/nz.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/model/cubemap/assets/px.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/model/cubemap/assets/py.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/model/cubemap/assets/pz.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions examples/model/cubemap/cubemap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
layout: example
permalink: examples/model/cubemap/
collection: model/cubemap
title: Cubemap Reflection
brief: This example shows how to use a cubemap to draw environment reflections on a model.
scripts: cubemap.script, cubemap_model.fp, cubemap_model.vp
---

This example contains a game object with a model component in the shape of the Defold logo. The model has a special `cubemap_model.material` which uses a cubemap sampler to calculate reflections on the model from the cubemap.

0 comments on commit 4d625cd

Please sign in to comment.