[Ok] Additive Shadows distorted with OpenGL

Everything related to 3D programming
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

[Ok] Additive Shadows distorted with OpenGL

Post 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.
Last edited by Olby on Sun May 05, 2013 12:50 pm, edited 1 time in total.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: Additive Shadows distorted with OpenGL

Post 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
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: Additive Shadows distorted with OpenGL

Post 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.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Fred
Administrator
Administrator
Posts: 18384
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [Ok] Additive Shadows distorted with OpenGL

Post by Fred »

The TextureAdditive issue is a bug which has been corrected for the next version.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: [Ok] Additive Shadows distorted with OpenGL

Post by Olby »

Thanks Fred, good to know.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
Post Reply