Copyright (C) 2012, Tomas Davidovic
Light Transport Simulation with Vertex Connection and Merging.
download: libvcm.zip
Some FreeBASIC tests and C++ source code included.
Joshy
material: diffuse
material: glossy
material: mirror
material: glass
material: glass as water
different materials:
libVCM Windows/Linux 32/64-bit
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
libVCM Windows/Linux 32/64-bit
Last edited by D.J.Peters on Oct 12, 2022 18:45, edited 2 times in total.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: libVCM Windows/Linux 32/64-bit
I changed the pinhole camera C++ class.
In detail the projection matrix and added a missing ratio.
Before the projection plane behind the lens was a quad width=height it can be any ratio 16:9 4:3 ... now.
Libs for Windows Linux 32/64-bit and the source code are included.
Joshy
In detail the projection matrix and added a missing ratio.
Before the projection plane behind the lens was a quad width=height it can be any ratio 16:9 4:3 ... now.
Libs for Windows Linux 32/64-bit and the source code are included.
Joshy
Last edited by D.J.Peters on Oct 12, 2022 18:46, edited 2 times in total.
Re: libVCM Windows/Linux 32/64-bit
attempting stereo render. therefore, it is easy to have w < h
which produces incorrect ratio
which produces incorrect ratio
Code: Select all
#include once "vcm.bi"
type imagevars
as any ptr im, pixels
as integer w,h,bpp,bypp,pitch,numpages,flags,rate, is_screen, pitchBy, wm,hm
as single midx,midy, diagonal
as string driver_name
declare sub scr_inf
Declare Sub screen_init(wid As long, hgt As long, bpp as UInteger=32, numPages as integer=1, Flags as integer=0)
Declare Function create(wid As long = -1, hgt As long=0, color As Ulong=RGB(0,0,0)) As Any ptr
Declare Sub destroy
declare sub vars_common
Declare Destructor
end type
Destructor imagevars
Destroy
End Destructor
Sub imagevars.Destroy()
If im <> 0 Then ImageDestroy im: im = 0
End Sub
sub imagevars.vars_common
wm=w-1: hm=h-1: midx=wm/2: midy=hm/2: pitchBy=pitch\bypp
diagonal = sqr(w*w+h*h)
end sub
sub imagevars.scr_inf
ScreenInfo w,h, bpp, bypp, pitch, rate, driver_name: pixels = ScreenPtr
vars_common
end sub
Sub imagevars.screen_init(_w As long, _h As long, _bpp as UInteger, _numpages as integer, _flags as integer)
Destroy: ScreenRes _w,_h,_bpp,_numpages,_flags: scr_inf: is_screen = true
numpages = _numpages: flags=_flags: if numPages > 1 then screenset 0,1
End sub
Function imagevars.create(wid As long, hgt As long, col As ULong) As Any Ptr
if hgt=0 then scr_inf: wid=w: hgt=h
Destroy: im = ImageCreate( wid, hgt, col )
ImageInfo im, w, h, bypp, pitch, pixels: bpp = bypp * 8
vars_common: is_screen = 0: Return im
End Function
dim as imagevars buf, imgL,imgR
buf.screen_init 512,360
imgL.create buf.w\2,buf.h
imgR.create imgL.w,imgL.h
var scn = SceneNew(imgL.w,imgL.h)
SceneAddSphere scn,v3(-1,-.5,1),1,SceneAddGlossyMaterial(scn,v3(0,.6,0),v3(.8),10)
SceneAddSphere scn,v3( 0,-.5, 0),1,SceneAddGlossyMaterial(scn,v3(0,0,.8),v3(.8),20)
SceneAddSphere scn,v3( 1,-.5,1),1,SceneAddGlossyMaterial(scn,v3(.6,0,0),v3(.8),190)
' note: second material is optional (checker pattern)
SceneAddFloorGrid scn, _
5, _ ' size x,z
-2, _ ' y position
4, _ ' number of fields = value*value
0, _ ' y=yposition + rnd2()*random
SceneAddDiffuseMaterial(scn,v3(.1)), _ ' material 1
SceneAddDiffuseMaterial(scn,v3(.7)) ' material 2
SceneAddAreaCeilLight scn,4,.99,v3(1)*8
var renL = RendererNew(scn,300)
var renR = RendererNew(scn,300)
const as single GAMMA = 2 ' optional
dim as integer itera
while inkey()="" andalso itera<64
var eye_rot=0.03
var half_ipd = 0.2
'' cam position eye dir up fov
Scenelookat scn,v3(-half_ipd,0,6),v3(+eye_rot,0,-1),v3(0,1,0)
RendererIterate renL,itera
Scenelookat scn,v3(+half_ipd,0,6),v3(-eye_rot,0,-1),v3(0,1,0)
RendererIterate renR,itera
RendererGetRGBAPixels renL,imgL.pixels,,GAMMA
RendererGetRGBAPixels renR,imgR.pixels,,GAMMA
put (0,0),imgL.im,PSET
put (imgL.w,0),imgR.im,PSET
WindowTitle "it:" & itera
itera+=1
wend
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: libVCM Windows/Linux 32/64-bit
You are right :-(
this in camera.hxx
must bea temporary work around.
this in camera.hxx
Code: Select all
if (mResolution.y<mResolution.x)
mRatio = mResolution.y/mResolution.x;
else
mRatio = mResolution.x/mResolution.y;
Code: Select all
mRatio = mResolution.y/mResolution.x;
Code: Select all
#include once "vcm.bi"
dim as integer scr_h = 320
dim as integer scr_w = scr_h * 2
screenres scr_w,scr_h,32
var imgl = imagecreate(scr_h,scr_h)
var imgr = imagecreate(scr_h,scr_h)
var scn = SceneNew(scr_h,scr_h)
SceneAddSphere scn,v3(-1,-.5,1),1,SceneAddGlossyMaterial(scn,v3(0,.6,0),v3(.8),10)
SceneAddSphere scn,v3( 0,-.5, 0),1,SceneAddGlossyMaterial(scn,v3(0,0,.8),v3(.8),20)
SceneAddSphere scn,v3( 1,-.5,1),1,SceneAddGlossyMaterial(scn,v3(.6,0,0),v3(.8),190)
' note: second material is optional (checker pattern)
SceneAddFloorGrid scn, _
5, _ ' size x,z
-2, _ ' y position
4, _ ' number of fields = value*value
0, _ ' y=yposition + rnd2()*random
SceneAddDiffuseMaterial(scn,v3(.1)), _ ' material 1
SceneAddDiffuseMaterial(scn,v3(.7)) ' material 2
SceneAddAreaCeilLight scn,4,.99,v3(1)*8
var renL = RendererNew(scn)
var renR = RendererNew(scn)
const as single GAMMA = 2 ' optional
dim as integer itera
while inkey()="" andalso itera<64
var eye_rot=0.03
var half_ipd = 0.2
'' cam position eye dir up fov
Scenelookat scn,v3(-half_ipd,0,6),v3(+eye_rot,0,-1),v3(0,1,0)
RendererIterate renL,itera
Scenelookat scn,v3(+half_ipd,0,6),v3(-eye_rot,0,-1),v3(0,1,0)
RendererIterate renR,itera
RendererGetRGBAPixels renL,imgL+32
RendererGetRGBAPixels renR,imgR+32
put (0,0),imgL,PSET
put (scr_h,0),imgR,PSET
WindowTitle "it:" & itera
itera+=1
wend