-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ab1358
commit 4d625cd
Showing
35 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |