Some minor issues with current OpenB3D commit

Started by Krischan, June 25, 2020, 09:54:49

Previous topic - Next topic

Krischan

Hi there,

beside many other and perhaps more important problems the world currently faces in real life, I just want to mention that I'm still there and traditionally have some minor issues with the current version (June 23, 2020 commit), before that I've been working with the Dec 7, 2019 commit. Mark, perhaps you can investigate these issues when you find some time.

1) Shadows are not working in a MaxGUI window, using only the Graphics3D command they work (all commits)

2) running the following code only works in Debug mode only, in Release mode I only get a black screen (it works with the Dec 7 commit)

Code (Blitzmax) Select
SuperStrict

Framework Openb3dmax.B3dglgraphics
Import maxgui.Drivers

Local SCREEN_WIDTH:Int = 1920
Local SCREEN_HEIGHT:Int = 1080

' shadows not working / crash with shaders
Local MAXGUI_WINDOW:TGadget = CreateWindow("Test", ClientWidth(Desktop()) / 2 - ((SCREEN_WIDTH) / 2), ClientHeight(Desktop()) / 2 - ((SCREEN_HEIGHT) / 2), (SCREEN_WIDTH), SCREEN_HEIGHT, Null, WINDOW_TITLEBAR)
Local MAXGUI_CANVAS:TGadget = CreateCanvas(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, MAXGUI_WINDOW, 0)
SetGadgetLayout(MAXGUI_CANVAS, 1, 1, 1, 1)
ActivateGadget(MAXGUI_CANVAS)
SetGraphics CanvasGraphics(MAXGUI_CANVAS)
Graphics3D(SCREEN_WIDTH, SCREEN_HEIGHT, 0, 2, 60, -1, True)
EnablePolledInput()

' working
Graphics3D DesktopWidth(), DesktopHeight(), 0, 2

Local camera:TCamera=CreateCamera()
PositionEntity camera,0,0,-15

Local light_piv:TPivot=CreatePivot()
Local light:TLight=CreateLight(2,light_piv)
PositionEntity light,25,10,25

Local plane:TMesh=CreateCube()
ScaleEntity plane,25,0.1,25
MoveEntity plane, 0, -2, 0

Local cube:TMesh = CreateCube()
Local cube_shadow:TShadowObject=CreateShadow(cube)

Local alpha_piv:TPivot = CreatePivot()

Local cube2:TMesh = CreateCube(alpha_piv)
PositionEntity cube2, -5, -1, -5
Local cube_shadow2:TShadowObject = CreateShadow(cube2)

While Not KeyDown(KEY_ESCAPE)

' render
CameraClsMode camera, 1, 1
RenderWorld

' 2D output
BeginMax2D()

DrawText("Max2D Test", 0, 0)

EndMax2D()

TurnEntity cube, 0.1, 0.2, 0.3

Flip True

Wend

End


3) I'm not sure but I think I can only run GLSL 130 examples, what about "newer" Shaders like 330 or 450? is it possible or does this require a complete overhaul for the shader code? The problem is that I can't run many examples I've found in the internet and 130 is *very* outdated

4) I'd like to see how to implement shadows using a shader only, but I don't know how to do this with OpenB3D

5) a working example of Parallax Occlusion mapping in a shader with OpenB3D would be nice, too

I've added my current OpenB3D/Blitzmax PBR shader sandbox demo as an attachment - with the problems above mentioned but compiled with the Dec 7 commit to see it in action. In the "_PBR" texture, the Ambient Occlusion/Roughness/Metallic textures are compiled in the R/G/B channels.
Kind regards
Krischan

Windows 10 Pro | i7 9700K@ 3.6GHz | RTX 2080 8GB]
Metaverse | Blitzbasic Archive | My Github projects

Kippykip


markcwm

#2
1) is from a hack on Mar 26 Fix for cubemap black line where you have to change the graphics height in win32 by deducting the titlebar height to fix BackBufferToTex. It's a hack because it should be deducting the actual height of the titlebar instead of getting GraphicsHeight, and I didn't think of smaller windowed mode at the time.

2) still hunting the black screen but found if you add UpdateCanvas(can,cam) at the start of the loop it fixes it.

Krischan

Thanks for the response, so I should wait for the next commit?

I forgot to mention a more serious issue. In the PBR demo I'm unable to use the CreateShadow() function - the demo always runs in an exception then (and beside that, it doesn't work). I could connect the problem to the GL lights in the InitLights() function but I don't understand the problem. I just want that the GL lights create shadows on the level geometry while keeping the PBR shading.

I modified the demo code a little bit, see attachment. Just walk towards the skull for a crash or walk around to see strange shadow artefacts.
Kind regards
Krischan

Windows 10 Pro | i7 9700K@ 3.6GHz | RTX 2080 8GB]
Metaverse | Blitzbasic Archive | My Github projects

markcwm

Hi Krischan, I'm snowed under by real life concerns so I will be unable to help any more. Very sorry.

markcwm

#5
Well I found some time today, so here's an update July 4. Happy American independence day!

It's only a fix for 2) Maxgui has black screen in release mode.
Although I got a black screen in debug mode too (so maybe not the right fix, needs a test). It was when I made a fix for texture rendering in fullsize windowed mode where GlobalHeight was not what you expect, anyway in Maxgui GraphicsHeight returns zero and that caused the black screen.

It's also an update to Audio3d, to make it like Blitz3d syntax so now you don't have to import the audio modules and can use CreateListener (Init3DSound) and EmitSound (Start3DSound).

The reason 1) doesn't have shadows in Maxgui is because you have to init the buffers, so that's not a bug:
Local flags%=GRAPHICS_BACKBUFFER|GRAPHICS_ALPHABUFFER|GRAPHICS_DEPTHBUFFER|GRAPHICS_STENCILBUFFER|GRAPHICS_ACCUMBUFFER
SetGraphicsDriver GLMax2DDriver(),flags ' before SetGraphics

Krischan

It's a pity to hear that Real Life involves you as much as it does me - I'd like to code a lot more but somehow I have less and less time.

With your fix the shadows now work in MaxGUI but I still get fatal exceptions when I use a shader and move around, so I won't use shadows anymore as i don't know how to debug this. Instead I continued to work on my shader and for better visualization I've created a cave with really good textures and the PBR shader now looks very nice even without shadows.
Kind regards
Krischan

Windows 10 Pro | i7 9700K@ 3.6GHz | RTX 2080 8GB]
Metaverse | Blitzbasic Archive | My Github projects