Page 1 of 1

[Ok] Additive Shadows distorted with OpenGL

Posted: Sun May 05, 2013 3:03 am
by Olby
Run the following code (you will need cube50.mesh file):

Code: Select all

CompilerIf Subsystem("OpenGL")
	Debug "Compiling with the OpenGL subsystem"
	
	If InitEngine3D(#PB_Engine3D_DebugOutput)
	
	  Add3DArchive(".\",#PB_3DArchive_FileSystem)
	
	  InitSprite()
	  InitKeyboard()
	  InitMouse()
	  AntialiasingMode(#PB_AntialiasingMode_x2)
	
	  If OpenWindow(0, 0, 0, 800, 600, "PureBasic (OpenGL vs DirectX)", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 0, 0, 0)
	
	  	AmbientColor(RGB(32, 32, 32))
	  	WorldShadows(#PB_Shadow_Additive,100,0,2048)
	  	
	    CreateCamera(0, 0, 0, 100, 100)
	    CreateCube(0,10)
	    CreateEntity(0,MeshID(0),0)
	    
	    CreateLight(1,RGB(255,0,0),0,0,0)
	    CreateSphere(1,5)
	    CreateEntity(1,MeshID(1),0,0,0,0)
	    AttachEntityObject(1,"",LightID(1))
	    EntityRenderMode(1,0)
	
	    LoadMesh(2,"cube50.mesh")
	    TransformMesh(2,0,0,0,1.0,1.0,1.0,0,0,0)
	    NormalizeMesh(2)
	    CreateEntity(2,MeshID(2),0,0,0,0)
	    EntityRenderMode(2,0)
	    
	    CreateLight(2,RGB(0,255,0),0,0,0)
	    CreateSphere(3,5)
	    CreateEntity(3,MeshID(3),0,0,0,0)
	    AttachEntityObject(3,"",LightID(2))
	    EntityRenderMode(3,0)
	    
	    MoveCamera(0,0,0,90)
	    
	    Repeat
	    	ExamineKeyboard()
	    	ExamineMouse()
	
	    	MoveEntity(1, (10.0 * Cos(ElapsedMilliseconds() / 300)),  15, (10.0 * Sin(ElapsedMilliseconds() / 300)), #PB_Absolute)
	    	MoveEntity(3, (10.0 * Cos(ElapsedMilliseconds() /1000)), -15, (10.0 * Sin(ElapsedMilliseconds() /1000)), #PB_Absolute)
	    	RotateEntity(0,1.0,0,1.0,#PB_Relative)
	    	;RotateEntity(2,1.0,0,1.0,#PB_Relative)
	
	      RenderWorld()
	      FlipBuffers()
	      
	    Until KeyboardPushed(#PB_Key_Escape) Or WindowEvent() = #PB_Event_CloseWindow
	  EndIf
	
	EndIf

CompilerElse
	CompilerError "Please compile with the OpenGL subsystem"	
CompilerEndIf

End
Using OpenGL subsystem additive shadows are distorted if compared to DirectX counterpart (see screen print).

Image

Please feel free to move this to bug forum once and if confirmed.

Running on the latest official nVidia drivers here.

Re: Additive Shadows distorted with OpenGL

Posted: Sun May 05, 2013 5:16 am
by applePi
Hi Olby
the shadow using opengl subsys seems good on my system look the picture
Image
the same as using dx.
my vga card is Geforce 210, and using the glview from http://www.realtech-vr.com/glview/ it gives the following info for my graphics system
Image

Re: Additive Shadows distorted with OpenGL

Posted: Sun May 05, 2013 12:49 pm
by Olby
Thanks Pi, after running GLView I noticed that my nVidia drivers were automatically switching to the built in video card, as soon as I forced it to always use the high-performance Geforce GT630 (it supports OpenGL up to v4.3) problems vanished. Good catch.

[Edit]

ApplePi, can you try the "textureadditive" variant for the shadows. They seem not to work properly if more than one light source is used.

Re: [Ok] Additive Shadows distorted with OpenGL

Posted: Sun May 05, 2013 1:34 pm
by Fred
The TextureAdditive issue is a bug which has been corrected for the next version.

Re: [Ok] Additive Shadows distorted with OpenGL

Posted: Sun May 05, 2013 3:07 pm
by Olby
Thanks Fred, good to know.