Skip to content

Commit

Permalink
Tutorials update for HARFANG v3.1.0:
Browse files Browse the repository at this point in the history
 - Updated the code according to the v3.1.0 of the HARFANG API.
 - Fixed an upscale shader bug in the AAA rendering pipeline.
 - File cleanup.
  • Loading branch information
astrofra committed Dec 15, 2021
1 parent 7e4f289 commit 446d854
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 36 deletions.
50 changes: 25 additions & 25 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"cwd": "${workspaceFolder}/",
"console": "integratedTerminal"
},
{
"name": "Lua: Current File",
"type": "lua",
"request": "launch",
"stopOnEntry": false,
"program": "${file}",
"cwd": "${workspaceFolder}/",
"luaexe": "${workspaceFolder}/_bin/lua.exe",
}
]
}
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"cwd": "${workspaceFolder}/",
"console": "integratedTerminal"
},
{
"name": "Lua: Current File",
"type": "lua",
"request": "launch",
"stopOnEntry": false,
"program": "${file}",
"cwd": "${workspaceFolder}/",
"luaexe": "${workspaceFolder}/_bin/lua.exe",
}
]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# HARFANG® 3.0 Tutorials
# HARFANG® 3.1.0 Tutorials

These **tutorials** demonstrate the usage of the HARFANG 3.0 API in **Python** and **Lua**.
These **tutorials** demonstrate the usage of the HARFANG 3.1.0 API in **Python** and **Lua**.

To run the tutorials:

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion filesystem_recursive_directory_listing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end

entries = hg.ListDirRecursive('resources', hg.DE_All)

for i=0, entries:size() do
for i=0, entries:size()-1 do
entry = entries:at(i)
print(string.format('- %s is a %s', entry.name, entry_type_to_string(entry.type)))
end
2 changes: 1 addition & 1 deletion game_mouse_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def draw_circle(view_id, center, radius, color):
scene = hg.Scene()
hg.LoadSceneFromAssets('playground/playground.scn', scene, res, hg.GetForwardPipelineInfo())

plane_node = hg.CreateInstanceFromAssets(scene, hg.TranslationMat4(hg.Vec3(0, 4, 0)), 'paper_plane/paper_plane.scn', res, hg.GetForwardPipelineInfo())
plane_node, _ = hg.CreateInstanceFromAssets(scene, hg.TranslationMat4(hg.Vec3(0, 4, 0)), 'paper_plane/paper_plane.scn', res, hg.GetForwardPipelineInfo())
camera_node = hg.CreateCamera(scene, hg.TranslationMat4(hg.Vec3(0, 4, -5)), 0.01, 1000)

scene.SetCurrentCamera(camera_node)
Expand Down
2 changes: 1 addition & 1 deletion resources/core/shader/aaa_upsample_fs.sc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ float gaussian(float v, float sigma) {
}

void main() {
vec2 ratio = floor(textureSize(u_attr_hi, 0).xy / textureSize(u_attr_lo, 0).xy);
vec2 ratio = round(textureSize(u_attr_hi, 0).xy / textureSize(u_attr_lo, 0).xy);
vec2 pixel = gl_FragCoord.xy / ratio;
vec2 tmp = floor(pixel-vec2_splat(0.5)) + vec2_splat(0.5);
ivec2 coord = ivec2(tmp);
Expand Down
5 changes: 3 additions & 2 deletions scene_draw_to_texture.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ scene = hg.Scene()
hg.LoadSceneFromAssets("materials/materials.scn", scene, res, hg.GetForwardPipelineInfo())

-- create a 512x512 frame buffer to draw the scene to
frame_buffer = hg.CreateFrameBuffer(512, 512, hg.TF_RGBA32F, hg.TF_D24, 8, res, 'framebuffer') -- 8x MSAA
frame_buffer = hg.CreateFrameBuffer(512, 512, hg.TF_RGBA32F, hg.TF_D24, 8, 'framebuffer') -- 8x MSAA
color = hg.GetColorTexture(frame_buffer)

-- create the cube model
vtx_layout = hg.VertexLayoutPosFloatNormUInt8TexCoord0UInt8()
Expand Down Expand Up @@ -49,7 +50,7 @@ while not hg.ReadKeyboard():Key(hg.K_Escape) do
hg.SetViewPerspective(view_id, 0, 0, res_x, res_y, hg.TranslationMat4(hg.Vec3(0, 0, -1.8)))

val_uniforms = {hg.MakeUniformSetValue('color', hg.Vec4(1, 1, 1, 1))} -- note: these could be moved out of the main loop but are kept here for readability
tex_uniforms = {hg.MakeUniformSetTexture('s_tex', res:GetTexture(frame_buffer.color), 0)}
tex_uniforms = {hg.MakeUniformSetTexture('s_tex', color, 0)}

hg.DrawModel(view_id, cube_mdl, cube_prg, val_uniforms, tex_uniforms, hg.TransformationMat4(hg.Vec3(0, 0, 0), hg.Vec3(angle * 0.1, angle * 0.05, angle * 0.2)))

Expand Down
5 changes: 3 additions & 2 deletions scene_draw_to_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
hg.LoadSceneFromAssets("materials/materials.scn", scene, res, hg.GetForwardPipelineInfo())

# create a 512x512 frame buffer to draw the scene to
frame_buffer = hg.CreateFrameBuffer(512, 512, hg.TF_RGBA32F, hg.TF_D24, 8, res, 'framebuffer') # 8x MSAA
frame_buffer = hg.CreateFrameBuffer(512, 512, hg.TF_RGBA32F, hg.TF_D24, 8, 'framebuffer') # 8x MSAA
color = hg.GetColorTexture(frame_buffer)

# create the cube model
vtx_layout = hg.VertexLayoutPosFloatNormUInt8TexCoord0UInt8()
Expand Down Expand Up @@ -50,7 +51,7 @@
hg.SetViewPerspective(view_id, 0, 0, res_x, res_y, hg.TranslationMat4(hg.Vec3(0, 0, -1.8)))

val_uniforms = [hg.MakeUniformSetValue('color', hg.Vec4(1, 1, 1, 1))] # note: these could be moved out of the main loop but are kept here for readability
tex_uniforms = [hg.MakeUniformSetTexture('s_tex', res.GetTexture(frame_buffer.color), 0)]
tex_uniforms = [hg.MakeUniformSetTexture('s_tex', color, 0)]

hg.DrawModel(view_id, cube_mdl, cube_prg, val_uniforms, tex_uniforms, hg.TransformationMat4(hg.Vec3(0, 0, 0), hg.Vec3(angle * 0.1, angle * 0.05, angle * 0.2)))

Expand Down
1 change: 0 additions & 1 deletion scene_instances.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ while not keyboard:Pressed(hg.K_Escape) do
dt = hg.TickClock()

for i, actor in ipairs(actors) do
print(actor)
actor:update(dt)
end

Expand Down
2 changes: 1 addition & 1 deletion scene_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# declare the biped actor class
class BipedActor:
def __init__(self, pos):
self.__node = hg.CreateInstanceFromAssets(scene, hg.Mat4.Identity, "biped/biped.scn", res, hg.GetForwardPipelineInfo())
self.__node, _ = hg.CreateInstanceFromAssets(scene, hg.Mat4.Identity, "biped/biped.scn", res, hg.GetForwardPipelineInfo())
self.__node.GetTransform().SetPosRot(pos, hg.Deg3(0, hg.FRand(360), 0))

self.__delay = 0
Expand Down

0 comments on commit 446d854

Please sign in to comment.