GithubHelp home page GithubHelp logo

harfang3d / harfang3d Goto Github PK

View Code? Open in Web Editor NEW
518.0 15.0 54.0 8.34 MB

HARFANG 3D source code public repository

Home Page: https://www.harfang3d.com

License: GNU Lesser General Public License v3.0

CMake 3.23% Python 8.75% C 5.74% Smarty 0.19% C++ 82.07% Lua 0.02%
3d realtime cpp vr pbr physics python lua opengl opengles directx bgfx vulkan game-engine industry-40

harfang3d's People

Contributors

astrofra avatar blockos avatar ejulien avatar eliemichel avatar harfang3dadmin avatar pmp-p avatar robewbank1 avatar tommo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

harfang3d's Issues

Object culling seems too aggressive

Object culling seems too aggressive. In some cases, the object disappears before it completely goes out of the camera field:

culling.mp4

It could be something that was introduced lately.

Bug between pitchs of Stereo / Spatialized sounds

Bug between pitchs of Stereo / Spatialized sounds
A cache bug need a fix in sound system.

how to reproduce the bug:

  1. Start a Stereo sound
  2. Stop the stereo source
  3. Start a spatilized sound
  4. Update the velocity of spatialized sound, to affect the pitch of the sound
  5. Stop Spatialized sound
  6. Restart Stereo sound : The pitch of Stereo sound is the same as last pitch updated for Spatialized sound.

If Stereo source is not stopped, playing in loop mode, its pitch is not affected by Spatialized sound velocity calculations.

Repro case:

import harfang as hg

hg.InputInit()
hg.WindowSystemInit()
hg.AudioInit()
hg.AddAssetsFolder("assets_compiled")

width, height = 1280, 720
window = hg.RenderInit('Harfang window', width, height, hg.RF_None)


stereo_sound_ref = hg.LoadWAVSoundAsset("main_left.wav")
stereo_state = hg.StereoSourceState()
stereo_state.volume = 1
stereo_state.repeat = hg.SR_Loop
stereo_state.panning = 0

spacialized_sound_ref = hg.LoadWAVSoundAsset("turbine.wav")
spacialized_state = hg.SpatializedSourceState(hg.TranslationMat4(hg.Vec3(0, 0, 10)))
spacialized_state.vel = hg.Vec3(0, 0, -50)
spacialized_state.volume = 1
spacialized_state.repeat = hg.SR_Loop

keyboard = hg.Keyboard()

while not keyboard.Pressed(hg.K_Escape):
   keyboard.Update()
   dt = hg.TickClock()
   dts = hg.time_to_sec_f(dt)

   view_id = 0
   hg.SetViewClear(view_id, hg.CF_Color | hg.CF_Depth, hg.Color.Green)
   hg.SetViewRect(view_id, 0, 0, width, height)

   hg.Touch(view_id)

   if keyboard.Pressed(hg.K_F1):
       hg.StopAllSources()
       stereo_source = hg.PlayStereo(stereo_sound_ref, stereo_state)
   elif keyboard.Pressed(hg.K_F2):
       hg.StopAllSources()
       spacialized_source = hg.PlaySpatialized(spacialized_sound_ref, spacialized_state)


   hg.Frame()
   hg.UpdateWindow(window)

hg.StopAllSources()
hg.RenderShutdown()

hg.DestroyWindow(window)
  • Press F1 first to start Stereo sound
  • Press F2 to start Spatialized sound
  • Re press F1, the pitch of Stereo sound is the same as Spatialized sound with velocity.

Need to fix CaptureTexture() for Python / Lua

Need to fix CaptureTexture() for Python / Lua. In Python and Lua, the CaptureTexture() function don't work.
In Python, afte CaptureTexture() call, next Frame() causes program exit silently:

# Draw scene to texture

import harfang as hg
import math

hg.InputInit()
hg.WindowSystemInit()

res_x, res_y = 1024, 1024
win = hg.RenderInit('Draw Scene to Texture', res_x, res_y, hg.RF_VSync | hg.RF_MSAA8X)

hg.AddAssetsFolder("resources_compiled")

# create pipeline
pipeline = hg.CreateForwardPipeline()
res = hg.PipelineResources()

# load the scene to draw to a texture
scene = hg.Scene()
hg.LoadSceneFromAssets("materials/materials.scn", scene, res, hg.GetForwardPipelineInfo())

# create a 512x512 frame buffer to draw the scene to
tex_size = 512

picture = hg.Picture(tex_size, tex_size, hg.PF_RGBA32)

tex_color = hg.CreateTexture(tex_size, tex_size, "color_texture",hg.TF_ReadBack | hg.TF_RenderTarget | hg.TF_SamplerMinAnisotropic, hg.TF_RGBA8)
tex_color_ref = res.AddTexture("tex_rb", tex_color)
tex_depth =  hg.CreateTexture(tex_size, tex_size, "depth_texture", hg.TF_RenderTarget, hg.TF_D24)
frame_buffer = hg.CreateFrameBuffer(tex_color, tex_depth, "framebuffer")

# create the cube model
vtx_layout = hg.VertexLayoutPosFloatNormUInt8TexCoord0UInt8()

cube_mdl = hg.CreateCubeModel(vtx_layout, 1, 1, 1)
cube_ref = res.AddModel('cube', cube_mdl)

# prepare the cube shader program
cube_prg = hg.LoadProgramFromAssets('shaders/texture')

# main loop
angle = 0
frame_count = 0
flag_capture_texture = False

while not hg.ReadKeyboard().Key(hg.K_Escape) and hg.IsWindowOpen(win):
	dt = hg.TickClock()
	angle = angle + hg.time_to_sec_f(dt)

	# update scene and render to the frame buffer
	scene.GetCurrentCamera().GetTransform().SetPos(hg.Vec3(0, 0, -(math.sin(angle) * 3 + 4)))  # animate the scene current camera on Z

	scene.Update(dt)

	view_id = 0
	view_id, pass_ids = hg.SubmitSceneToPipeline(view_id, scene, hg.IntRect(0, 0, 512, 512), True, pipeline, res, frame_buffer.handle)
	
	if not flag_capture_texture and hg.ReadKeyboard().Key(hg.K_Space):
		flag_capture_texture = True
		frame_count_capture = hg.CaptureTexture(res, tex_color_ref, picture)

	# draw a rotating cube in immediate mode using the texture the scene was rendered to
	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', 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)))

	#
	frame_count = hg.Frame()

	# Save captured picture:
	if flag_capture_texture and frame_count_capture <= frame_count:
		hg.SavePNG(picture, "captured_picture.png")
		flag_capture_texture = False

	hg.UpdateWindow(win)

hg.RenderShutdown()
hg.WindowSystemShutdown()

In Lua, CreateTexture() with TF_ReadBack | TF_RenderTarget causes program crash:

-- Draw scene to texture

hg = require("harfang")

hg.InputInit()
hg.WindowSystemInit()

res_x, res_y = 1024, 1024
win = hg.RenderInit('Draw Scene to Texture', res_x, res_y, hg.RF_VSync | hg.RF_MSAA8X)

hg.AddAssetsFolder("resources_compiled")

-- create pipeline
pipeline = hg.CreateForwardPipeline()
res = hg.PipelineResources()

-- load the scene to draw to a texture
scene = hg.Scene()
hg.LoadSceneFromAssets("materials/materials.scn", scene, res, hg.GetForwardPipelineInfo())

-- create a 512x512 frame buffer to draw the scene to
tex_size = 512

picture = hg.Picture(tex_size, tex_size, hg.PF_RGBA32)

tex_color = hg.CreateTexture(tex_size, tex_size, "color_texture",hg.TF_ReadBack | hg.TF_RenderTarget | hg.TF_SamplerMinAnisotropic, hg.TF_RGBA8)
tex_color_ref = res:AddTexture("tex_rb", tex_color)
tex_depth =  hg.CreateTexture(tex_size, tex_size, "depth_texture", hg.TF_RenderTarget, hg.TF_D24)
frame_buffer = hg.CreateFrameBuffer(tex_color, tex_depth, "framebuffer")

-- create the cube model
vtx_layout = hg.VertexLayoutPosFloatNormUInt8TexCoord0UInt8()

cube_mdl = hg.CreateCubeModel(vtx_layout, 1, 1, 1)
cube_ref = res:AddModel('cube', cube_mdl)

-- prepare the cube shader program
cube_prg = hg.LoadProgramFromAssets('shaders/texture')

-- main loop
angle = 0
frame_count = 0
flag_capture_texture = false

while not hg.ReadKeyboard():Key(hg.K_Escape) and hg.IsWindowOpen(win) do
	dt = hg.TickClock()
	angle = angle + hg.time_to_sec_f(dt)

	-- update scene and render to the frame buffer
	scene:GetCurrentCamera():GetTransform():SetPos(hg.Vec3(0, 0, -(math.sin(angle) * 3 + 4)))  -- animate the scene current camera on Z

	scene:Update(dt)

	view_id = 0
	view_id, pass_ids = hg.SubmitSceneToPipeline(view_id, scene, hg.IntRect(0, 0, 512, 512), true, pipeline, res, frame_buffer.handle)

    if not flag_capture_texture and hg.ReadKeyboard():Key(hg.K_Space) then
		flag_capture_texture = true
		frame_count_capture = hg.CaptureTexture(res, tex_color_ref, picture)
    end

	-- draw a rotating cube in immediate mode using the texture the scene was rendered to
	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', 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)))

	--
	frame_count = hg.Frame()

    -- Save captured picture:
    if flag_capture_texture and frame_count_capture <= frame_count then
	    hg.SavePNG(picture, "captured_picture.png")
		flag_capture_texture = false
    end

	hg.UpdateWindow(win)
end

hg.RenderShutdown()
hg.WindowSystemShutdown()

Cone & capsule models are not aligned to the collision shape

Describe the bug
It seems that both the cone and the capsule have their builtin models misaligned in regards to the collision shape.
Possibly this issue is related to the way Bullet physics defines the collision shape (height vs half-height, centered pivot...)

In HG3.2.3, it looks like this :

image

Expected behavior
Both cone & capsule should have the model aligned to the collision shape (and not the other way around!)

Bloom broken on Linux studio

Bloom seems to be broken on Linux studio.

Studio version 0.8.3 but latest studio versions crash on startup on Ubuntu 22.04.

To Reproduce

Open up any scene in studio, switch to forward AAA pipeline. Crank up bloom settings. Observe a vertical banding effect. Shown here on cornel-box/main_direct.scn from sample projects.

image

Expected behavior

Smooth bloom without vertical banding.

Desktop:

  • OS: Ubuntu 22.04. nvidia gpu (3080).

Linux studio build 0.8.4 crashes on startup

Linux studio build 0.8.4 crashes on startup.

(From here: https://github.com/harfang3d/harfang3d/releases/download/v3.2.6/studio-0.8.4-ubuntu64.zip).

Splash screen briefly displays then it disappears, no console output.

Previous version runs fine on this machine. Ubuntu 22.04. Replicate on another Ubuntu 22.04 machine. nvidia gpu.

I tried a little debugging in gdb:

gdb ./studio 
GNU gdb (Ubuntu 12.0.90-0ubuntu1) 12.0.90
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./studio...
(No debugging symbols found in ./studio)
(gdb) set follow-fork-mode child
(gdb) break exit
Breakpoint 1 at 0x5c4d0 (2 locations)
(gdb) break abort
Breakpoint 2 at 0x5c770
(gdb) break _exit
Breakpoint 3 at 0x5d320
(gdb) start
Temporary breakpoint 4 at 0xaea20
Starting program: /home/luke/harfang/studio/studio-0.8.4-ubuntu64/studio 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Temporary breakpoint 4, 0x0000555555602a20 in main ()
(gdb) continue
Continuing.
[Attaching after Thread 0x7ffff57fcac0 (LWP 332375) fork to child process 332381]
[New inferior 2 (process 332381)]
[Detaching after fork from parent process 332375]
[Inferior 1 (process 332375) detached]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
process 332381 is executing new program: /usr/bin/dash
Error in re-setting breakpoint 1: Function "exit" not defined.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Attaching after Thread 0x7ffff7d6b740 (LWP 332381) vfork to child process 332384]
[New inferior 3 (process 332384)]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Switching to Thread 0x7ffff7d6b740 (LWP 332384)]

Thread 3.1 "sh" hit Breakpoint 3, __GI__exit (status=126) at ../sysdeps/unix/sysv/linux/_exit.c:27
27      ../sysdeps/unix/sysv/linux/_exit.c: No such file or directory.
(gdb) bt
#0  __GI__exit (status=126) at ../sysdeps/unix/sysv/linux/_exit.c:27
#1  0x000055555555956f in ?? ()
#2  0x000055555556b740 in ?? ()
#3  0x000055555555cc25 in ?? ()
#4  0x000055555555d8de in ?? ()
#5  0x00005555555673ac in ?? ()
#6  0x0000555555560c00 in ?? ()
#7  0x0000555555560c00 in ?? ()
#8  0x00005555555646c2 in ?? ()
#9  0x0000555555558d36 in ?? ()
#10 0x00007ffff7d97d90 in __libc_start_call_main (main=main@entry=0x555555558ae0, argc=argc@entry=3, argv=argv@entry=0x7fffffffdcc8) at ../sysdeps/nptl/libc_start_call_main.h:58
#11 0x00007ffff7d97e40 in __libc_start_main_impl (main=0x555555558ae0, argc=3, argv=0x7fffffffdcc8, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fffffffdcb8) at ../csu/libc-start.c:392
#12 0x0000555555558f15 in ?? ()
(gdb) list
22      in ../sysdeps/unix/sysv/linux/_exit.c
(gdb) continue
Continuing.
[Detaching vfork parent process 332381 after child exit]
[Inferior 2 (process 332381) detached]
[Inferior 3 (process 332384) exited with code 0176]
(gdb) 
quit

Wrong height on cylinder collision shape

Wrong height on cylinder collision shape
It seems the height of a cylinder collision shape sent to Bullet is wrong, as shown when comparing the colshapes preview between Harfang Studio and the runtime :

image

Cannot handle cursor outside of the main client window

It is impossible to get the mouse cursor coordinates when it is outside of the main client window. This can be an issue when dealing with an application that would require the main display to occur in a VR headset while having the user working with the mouse.

Best solution would be to be able to disable the cursor when the harfang-based application is running.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.