Geometry Shaders for Irrlicht(development closed till later)

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

possible only due to geometry shaders in opengl... we have this

Parallax Occlusion Mapping with fin extrusion... GPU gems 3 chap 4

Image
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

Nice work, can You release binary for it? I'm interesting of performance of this example. How is performance of this app on Your gfx card? Can You compare performance with GS OFF and ON?
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

all will be in the demo which will fry your gfx card.. i jsut need to fix my palm tree???

anyone know why im still getting culling on my leaves??? even though i put EMF_BACK_FACE_CULLING to false??? the trunk is not culled...

and also my gl_NormalMatrix appears to gently caress up
roelor
Posts: 240
Joined: Wed Aug 13, 2008 8:06 am

Post by roelor »

I'm going to cry.. Opengl is dead on my side.
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

Code: Select all

Index: /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLSLMaterialRenderer.cpp
===================================================================
--- /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLSLMaterialRenderer.cpp	(revision 2916)
+++ /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLSLMaterialRenderer.cpp	(working copy)
@@ -37,7 +37,10 @@
 		E_PIXEL_SHADER_TYPE psCompileTarget,

 		IShaderConstantSetCallBack* callback,

 		video::IMaterialRenderer* baseMaterial,

-		s32 userData)

+		s32 userData,

+		const c8* geometryShaderProgram,

+		const c8* geometryShaderEntryPointName,

+		E_GEOMETRY_SHADER_TYPE gsCompileTarget)

 	: Driver(driver), CallBack(callback), BaseMaterial(baseMaterial),

 		Program(0), UserData(userData)

 {

@@ -58,7 +61,16 @@
 	if (!Driver->queryFeature(EVDF_ARB_GLSL))

 		return;

 

-	init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram);

+	if (geometryShaderProgram)

+	{

+		if (!Driver->queryFeature(EVDF_GEOMETRY_SHADER))

+			init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram);

+		initGS(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram, geometryShaderProgram);

+	}

+	else

+	{

+		init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram);

+	}

 }

 

 

@@ -123,7 +135,40 @@
 	outMaterialTypeNr = Driver->addMaterialRenderer(this);

 }

 

+void COpenGLSLMaterialRenderer::initGS(s32& outMaterialTypeNr,

+	const c8* vertexShaderProgram,

+	const c8* pixelShaderProgram,

+	const c8* geometryShaderProgram)

+{

+	outMaterialTypeNr = -1;

 

+	if (!createProgram())

+		return;

+

+#if defined(GL_ARB_vertex_shader) && defined (GL_ARB_fragment_shader)

+	if (vertexShaderProgram)

+		if (!createShader(GL_VERTEX_SHADER_ARB, vertexShaderProgram))

+			return;

+

+

+	if (pixelShaderProgram)

+		if (!createShader(GL_FRAGMENT_SHADER_ARB, pixelShaderProgram))

+			return;

+#endif

+#if defined(_IRR_OPENGL_USE_EXTPOINTER_)

+	if (geometryShaderProgram)

+	{

+		if (!createShader(GL_GEOMETRY_SHADER_EXT, geometryShaderProgram))

+			return;

+	}

+#endif

+	if (!linkProgram())

+		return;

+

+	// register myself as new material

+	outMaterialTypeNr = Driver->addMaterialRenderer(this);

+}

+

 bool COpenGLSLMaterialRenderer::OnRender(IMaterialRendererServices* service,

 					E_VERTEX_TYPE vtxtype)

 {

@@ -212,6 +257,11 @@
 

 	Driver->extGlAttachObject(Program, shaderHandle);

 

+	if (shaderType==GL_GEOMETRY_SHADER_EXT)

+	{

+		Driver->extGlProgramParameteriEXT(Program);

+	}

+

 	return true;

 }

 

Index: /home/kielanmatt/geom/trunk/source/Irrlicht/CNullDriver.h
===================================================================
--- /home/kielanmatt/geom/trunk/source/Irrlicht/CNullDriver.h	(revision 2916)
+++ /home/kielanmatt/geom/trunk/source/Irrlicht/CNullDriver.h	(working copy)
@@ -508,6 +508,47 @@
 			E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,

 			s32 userData=0);

 

+// DEVSH MODS

+		virtual s32 addHighLevelShaderMaterialFromFiles(

+			io::IReadFile* vertexShaderProgram,

+			const c8* vertexShaderEntryPointName = "main",

+			E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,

+			io::IReadFile* pixelShaderProgram = 0,

+			const c8* pixelShaderEntryPointName = "main",

+			E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,

+			io::IReadFile* geometryShaderProgram= 0,

+			const c8* geometryShaderEntryPointName = "main",

+			E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,

+			IShaderConstantSetCallBack* callback = 0,

+			E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,

+			s32 userData = 0);

+		virtual s32 addHighLevelShaderMaterialFromFiles(

+			const core::string<c16>& vertexShaderProgramFileName,

+			const c8* vertexShaderEntryPointName = "main",

+			E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,

+			const core::string<c16>& pixelShaderProgramFileName = "",

+			const c8* pixelShaderEntryPointName = "main",

+			E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,

+			const core::string<c16>& geometryShaderProgramFileName="",

+			const c8* geometryShaderEntryPointName = "main",

+			E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,

+			IShaderConstantSetCallBack* callback = 0,

+			E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,

+			s32 userData = 0);

+		virtual s32 addHighLevelShaderMaterial(

+			const c8* vertexShaderProgram,

+			const c8* vertexShaderEntryPointName = "main",

+			E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,

+			const c8* pixelShaderProgram = 0,

+			const c8* pixelShaderEntryPointName = "main",

+			E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,

+			const c8* geometryShaderProgram = 0,

+			const c8* geometryShaderEntryPointName = "main",

+			E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,

+			IShaderConstantSetCallBack* callback = 0,

+			E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,

+			s32 userData = 0 );

+

 		//! Returns a pointer to the mesh manipulator.

 		virtual scene::IMeshManipulator* getMeshManipulator();

 

Index: /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLExtensionHandler.cpp
===================================================================
--- /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLExtensionHandler.cpp	(revision 2916)
+++ /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLExtensionHandler.cpp	(working copy)
@@ -48,7 +48,7 @@
 	pGlIsBufferARB(0), pGlGetBufferParameterivARB(0), pGlGetBufferPointervARB(0),

 	pGlProvokingVertexARB(0), pGlProvokingVertexEXT(0),

 	pGlColorMaskIndexedEXT(0), pGlEnableIndexedEXT(0), pGlDisableIndexedEXT(0),

-	pGlBlendFuncIndexedAMD(0), pGlBlendFunciARB(0)

+	pGlBlendFuncIndexedAMD(0), pGlBlendFunciARB(0), pGlProgramParameteriEXT(0)

 #endif // _IRR_OPENGL_USE_EXTPOINTER_

 {

 	for (u32 i=0; i<IRR_OpenGL_Feature_Count; ++i)

@@ -195,6 +195,7 @@
 	pGlDisableIndexedEXT= (PFNGLDISABLEINDEXEDEXTPROC) wglGetProcAddress("glDisableIndexedEXT");

 	pGlBlendFuncIndexedAMD= (PFNGLBLENDFUNCINDEXEDAMDPROC) wglGetProcAddress("glBlendFuncIndexedAMD");

 	pGlBlendFunciARB= (PFNGLBLENDFUNCIPROC) wglGetProcAddress("glBlendFunciARB");

+	pGlProgramParameteriEXT= (PFNGLPROGRAMPARAMETERIEXTPROC) wglGetProcAddress("glProgramParameteriEXT");

 

 

 #elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined (_IRR_COMPILE_WITH_SDL_DEVICE_)

@@ -421,6 +422,8 @@
 	IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glBlendFuncIndexedAMD"));

 	pGlBlendFunciARB= (PFNGLBLENDFUNCIPROC)

 	IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glBlendFunciARB"));

+	pGlProgramParameteriEXT = (PFNGLPROGRAMPARAMETERIEXTPROC)

+	IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glProgramParameteriEXT"));

 

 	#endif // _IRR_OPENGL_USE_EXTPOINTER_

 #endif // _IRR_WINDOWS_API_

@@ -535,6 +538,8 @@
 		return FeatureAvailable[IRR_ARB_vertex_program];

 	case EVDF_ARB_FRAGMENT_PROGRAM_1:

 		return FeatureAvailable[IRR_ARB_fragment_program];

+	case EVDF_GEOMETRY_SHADER:

+		return FeatureAvailable[IRR_EXT_geometry_program];

 	case EVDF_ARB_GLSL:

 		return (FeatureAvailable[IRR_ARB_shading_language_100]||Version>=200);

 	case EVDF_TEXTURE_NSQUARE:

Index: /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLExtensionHandler.h
===================================================================
--- /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLExtensionHandler.h	(revision 2916)
+++ /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLExtensionHandler.h	(working copy)
@@ -979,6 +979,7 @@
 		PFNGLDISABLEINDEXEDEXTPROC pGlDisableIndexedEXT;

 		PFNGLBLENDFUNCINDEXEDAMDPROC pGlBlendFuncIndexedAMD;

 		PFNGLBLENDFUNCIPROC pGlBlendFunciARB;

+		PFNGLPROGRAMPARAMETERIEXTPROC pGlProgramParameteriEXT;

 	#endif

 };

 

Index: /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLDriver.h
===================================================================
--- /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLDriver.h	(revision 2916)
+++ /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLDriver.h	(working copy)
@@ -266,6 +266,24 @@
 			E_PIXEL_SHADER_TYPE psCompileTarget, IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial,

 			s32 userData);

 

+		virtual void extGlProgramParameteriEXT(GLhandleARB program)

+		{

+#if defined(_IRR_OPENGL_USE_EXTPOINTER_)

+			pGlProgramParameteriEXT(program,GL_GEOMETRY_INPUT_TYPE_EXT,GL_TRIANGLES);

+			pGlProgramParameteriEXT(program,GL_GEOMETRY_OUTPUT_TYPE_EXT,GL_TRIANGLE_STRIP);

+			// query maximum

+			int n;

+			glGetIntegerv( GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT, &n );

+			// set maximum. may be inefficient, but of universal use.

+			pGlProgramParameteriEXT(program, GL_GEOMETRY_VERTICES_OUT_EXT, n );

+#endif

+		}

+		virtual s32 addHighLevelShaderMaterial(const c8* vertexShaderProgram,const c8* vertexShaderEntryPointName,

+			E_VERTEX_SHADER_TYPE vsCompileTarget,const c8* pixelShaderProgram,const c8* pixelShaderEntryPointName,

+			E_PIXEL_SHADER_TYPE psCompileTarget,const c8* geometryShaderProgram,const c8* geometryShaderEntryPointName,

+			E_GEOMETRY_SHADER_TYPE gsCompileTarget,IShaderConstantSetCallBack* callback,E_MATERIAL_TYPE baseMaterial,

+			s32 userData);

+

 		//! Returns pointer to the IGPUProgrammingServices interface.

 		virtual IGPUProgrammingServices* getGPUProgrammingServices();

 

Index: /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLDriver.cpp
===================================================================
--- /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLDriver.cpp	(revision 2916)
+++ /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLDriver.cpp	(working copy)
@@ -3250,6 +3250,33 @@
 	return nr;

 }

 

+// DEVSH MODS

+s32 COpenGLDriver::addHighLevelShaderMaterial(

+	const c8* vertexShaderProgram,const c8* vertexShaderEntryPointName,

+	E_VERTEX_SHADER_TYPE vsCompileTarget,const c8* pixelShaderProgram,const c8* pixelShaderEntryPointName,

+	E_PIXEL_SHADER_TYPE psCompileTarget,const c8* geometryShaderProgram,const c8* geometryShaderEntryPointName,

+	E_GEOMETRY_SHADER_TYPE gsCompileTarget,IShaderConstantSetCallBack* callback,E_MATERIAL_TYPE baseMaterial,

+	s32 userData)

+{

+	s32 nr = -1;

+	if (queryFeature(EVDF_GEOMETRY_SHADER))

+	{

+		COpenGLSLMaterialRenderer* r = new COpenGLSLMaterialRenderer(

+			this, nr, vertexShaderProgram, vertexShaderEntryPointName,

+			vsCompileTarget, pixelShaderProgram, pixelShaderEntryPointName, psCompileTarget,

+			callback,getMaterialRenderer(baseMaterial), userData, geometryShaderProgram, geometryShaderEntryPointName, gsCompileTarget);

+		r->drop();

+		return nr;

+	}

+	//If someone  chooses to make a geom shader but doesnt have geom shad capabilities... fall back on vertex+pixel only

+	COpenGLSLMaterialRenderer* r = new COpenGLSLMaterialRenderer(

+		this, nr, vertexShaderProgram, vertexShaderEntryPointName,

+		vsCompileTarget, pixelShaderProgram, pixelShaderEntryPointName, psCompileTarget,

+		callback,getMaterialRenderer(baseMaterial), userData);

+	r->drop();

+	return nr;

+}

+

 //! Returns a pointer to the IVideoDriver interface. (Implementation for

 //! IMaterialRendererServices)

 IVideoDriver* COpenGLDriver::getVideoDriver()

Index: /home/kielanmatt/geom/trunk/source/Irrlicht/CNullDriver.cpp
===================================================================
--- /home/kielanmatt/geom/trunk/source/Irrlicht/CNullDriver.cpp	(revision 2916)
+++ /home/kielanmatt/geom/trunk/source/Irrlicht/CNullDriver.cpp	(working copy)
@@ -1784,7 +1784,170 @@
 	return 0;

 }

 

+s32 CNullDriver::addHighLevelShaderMaterial(

+		const c8* vertexShaderProgram,

+		const c8* vertexShaderEntryPointName,

+		E_VERTEX_SHADER_TYPE vsCompileTarget,

+		const c8* pixelShaderProgram,

+		const c8* pixelShaderEntryPointName,

+		E_PIXEL_SHADER_TYPE psCompileTarget,

+		const c8* geometryShaderProgram,

+		const c8* geometryShaderEntryPointName,

+		E_GEOMETRY_SHADER_TYPE gsCompileTarget,

+		IShaderConstantSetCallBack* callback,

+		E_MATERIAL_TYPE baseMaterial,

+		s32 userData)

+{

+	os::Printer::log("Shader materials not implemented yet in this driver, sorry.");

+	return -1;

+}

 

+s32 CNullDriver::addHighLevelShaderMaterialFromFiles(

+		io::IReadFile* vertexShaderProgram,

+		const c8* vertexShaderEntryPointName,

+		E_VERTEX_SHADER_TYPE vsCompileTarget,

+		io::IReadFile* pixelShaderProgram,

+		const c8* pixelShaderEntryPointName,

+		E_PIXEL_SHADER_TYPE psCompileTarget,

+		io::IReadFile* geometryShaderProgram,

+		const c8* geometryShaderEntryPointName,

+		E_GEOMETRY_SHADER_TYPE gsCompileTarget,

+		IShaderConstantSetCallBack* callback,

+		E_MATERIAL_TYPE baseMaterial,

+		s32 userData)

+{

+	c8* vs = 0;

+	c8* ps = 0;

+	c8* gs = 0;

+

+	if (vertexShaderProgram)

+	{

+		const long size = vertexShaderProgram->getSize();

+		if (size)

+		{

+			vs = new c8[size+1];

+			vertexShaderProgram->read(vs, size);

+			vs[size] = 0;

+		}

+	}

+

+	if (pixelShaderProgram)

+	{

+		const long size = pixelShaderProgram->getSize();

+		if (size)

+		{

+			// if both handles are the same we must reset the file

+			if (pixelShaderProgram==vertexShaderProgram)

+				pixelShaderProgram->seek(0);

+			ps = new c8[size+1];

+			pixelShaderProgram->read(ps, size);

+			ps[size] = 0;

+		}

+	}

+	if (geometryShaderProgram)

+	{

+		const long size = geometryShaderProgram->getSize();

+		if (size)

+		{

+			// if both handles are the same we must reset the file

+			if (geometryShaderProgram==vertexShaderProgram)

+				geometryShaderProgram->seek(0);

+			if (geometryShaderProgram==pixelShaderProgram)

+				geometryShaderProgram->seek(0);

+			gs = new c8[size+1];

+			geometryShaderProgram->read(gs, size);

+			gs[size] = 0;

+		}

+	}

+

+	s32 result = this->addHighLevelShaderMaterial(

+		vs, vertexShaderEntryPointName, vsCompileTarget,

+		ps, pixelShaderEntryPointName, psCompileTarget,

+		gs, geometryShaderEntryPointName, gsCompileTarget,

+		callback, baseMaterial, userData);

+

+	delete [] vs;

+	delete [] ps;

+	delete [] gs;

+

+	return result;

+}

+s32 CNullDriver::addHighLevelShaderMaterialFromFiles(

+		const core::string<c16>& vertexShaderProgramFileName,

+		const c8* vertexShaderEntryPointName,

+		E_VERTEX_SHADER_TYPE vsCompileTarget,

+		const core::string<c16>& pixelShaderProgramFileName,

+		const c8* pixelShaderEntryPointName,

+		E_PIXEL_SHADER_TYPE psCompileTarget,

+		const core::string<c16>& geometryShaderProgramFileName,

+		const c8* geometryShaderEntryPointName,

+		E_GEOMETRY_SHADER_TYPE gsCompileTarget,

+		IShaderConstantSetCallBack* callback,

+		E_MATERIAL_TYPE baseMaterial,

+		s32 userData)

+{

+	io::IReadFile* vsfile = 0;

+	io::IReadFile* psfile = 0;

+	io::IReadFile* gsfile = 0;

+

+	if (vertexShaderProgramFileName.size() )

+	{

+		vsfile = FileSystem->createAndOpenFile(vertexShaderProgramFileName);

+		if (!vsfile)

+		{

+			os::Printer::log("Could not open vertex shader program file",

+				vertexShaderProgramFileName, ELL_WARNING);

+			return -1;

+		}

+	}

+

+	if (pixelShaderProgramFileName.size() )

+	{

+		psfile = FileSystem->createAndOpenFile(pixelShaderProgramFileName);

+		if (!psfile)

+		{

+			os::Printer::log("Could not open pixel shader program file",

+				pixelShaderProgramFileName, ELL_WARNING);

+			if (vsfile)

+				vsfile->drop();

+			return -1;

+		}

+	}

+

+	if (geometryShaderProgramFileName.size() )

+	{

+		gsfile = FileSystem->createAndOpenFile(geometryShaderProgramFileName);

+		if (!gsfile)

+		{

+			os::Printer::log("Could not open geometry shader program file",

+				geometryShaderProgramFileName, ELL_WARNING);

+			if (vsfile)

+				vsfile->drop();

+			if (psfile)

+				psfile->drop();

+			return -1;

+		}

+	}

+

+	s32 result = addHighLevelShaderMaterialFromFiles(

+		vsfile, vertexShaderEntryPointName, vsCompileTarget,

+		psfile, pixelShaderEntryPointName, psCompileTarget,

+		gsfile, geometryShaderEntryPointName, gsCompileTarget,

+		callback, baseMaterial, userData);

+

+	if (psfile)

+		psfile->drop();

+

+	if (vsfile)

+		vsfile->drop();

+

+	if (gsfile)

+		gsfile->drop();

+

+	return result;

+}

+

+

 //! Adds a new material renderer to the VideoDriver, based on a high level shading

 //! language. Currently only HLSL in D3D9 is supported.

 s32 CNullDriver::addHighLevelShaderMaterial(

Index: /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLSLMaterialRenderer.h
===================================================================
--- /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLSLMaterialRenderer.h	(revision 2916)
+++ /home/kielanmatt/geom/trunk/source/Irrlicht/COpenGLSLMaterialRenderer.h	(working copy)
@@ -62,7 +62,10 @@
 		E_PIXEL_SHADER_TYPE psCompileTarget,

 		IShaderConstantSetCallBack* callback,

 		IMaterialRenderer* baseMaterial,

-		s32 userData);

+		s32 userData,

+		const c8* geometryShaderProgram=0,

+		const c8* geometryShaderEntryPointName = "main",

+		E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0);

 

 	//! Destructor

 	virtual ~COpenGLSLMaterialRenderer();

@@ -97,6 +100,11 @@
 	void init(s32& outMaterialTypeNr, 

 		const c8* vertexShaderProgram, 

 		const c8* pixelShaderProgram);

+// DEVSH

+	void initGS(s32& outMaterialTypeNr, 

+		const c8* vertexShaderProgram, 

+		const c8* pixelShaderProgram,

+		const c8* geometryShaderProgram);

 

 	bool createProgram();

 	bool createShader(GLenum shaderType, const char* shader);

Index: /home/kielanmatt/geom/trunk/include/IGPUProgrammingServices.h
===================================================================
--- /home/kielanmatt/geom/trunk/include/IGPUProgrammingServices.h	(revision 2916)
+++ /home/kielanmatt/geom/trunk/include/IGPUProgrammingServices.h	(working copy)
@@ -71,6 +71,19 @@
 	"ps_3_0",

 	0 };

 

+//DEVSH

+enum E_GEOMETRY_SHADER_TYPE

+{

+	EGST_GS_4_0 = 0,

+

+	//! This is not a type, but a value indicating how much types there are.

+	EGST_COUNT

+};

+

+const c8* const GEOMETRY_SHADER_TYPE_NAMES[] = {

+	"gs_4_0",

+	0 };

+

 //! Interface making it possible to create and use programs running on the GPU.

 class IGPUProgrammingServices

 {

@@ -211,6 +224,47 @@
 		E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,

 		s32 userData = 0) = 0;

 

+	// DEVSH MODS - geom shaders

+	virtual s32 addHighLevelShaderMaterialFromFiles(

+		io::IReadFile* vertexShaderProgram,

+		const c8* vertexShaderEntryPointName = "main",

+		E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,

+		io::IReadFile* pixelShaderProgram = 0,

+		const c8* pixelShaderEntryPointName = "main",

+		E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,

+		io::IReadFile* geometryShaderProgram = 0,

+		const c8* geometryShaderEntryPointName = "main",

+		E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,

+		IShaderConstantSetCallBack* callback = 0,

+		E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,

+		s32 userData = 0) = 0;

+	virtual s32 addHighLevelShaderMaterialFromFiles(

+		const core::string<c16>& vertexShaderProgramFileName,

+		const c8* vertexShaderEntryPointName = "main",

+		E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,

+		const core::string<c16>& pixelShaderProgramFileName = "",

+		const c8* pixelShaderEntryPointName = "main",

+		E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,

+		const core::string<c16>& geometryShaderProgramFileName="",

+		const c8* geometryShaderEntryPointName = "main",

+		E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,

+		IShaderConstantSetCallBack* callback = 0,

+		E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,

+		s32 userData = 0) = 0;

+	virtual s32 addHighLevelShaderMaterial(

+		const c8* vertexShaderProgram,

+		const c8* vertexShaderEntryPointName = "main",

+		E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,

+		const c8* pixelShaderProgram = 0,

+		const c8* pixelShaderEntryPointName = "main",

+		E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,

+		const c8* geometryShaderProgram = 0,

+		const c8* geometryShaderEntryPointName = "main",

+		E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,

+		IShaderConstantSetCallBack* callback = 0,

+		E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,

+		s32 userData = 0 ) = 0;

+

 	//! Adds a new ASM shader material renderer to the VideoDriver

 	/** Note that it is a good idea to call IVideoDriver::queryFeature() in

 	advance to check if the IVideoDriver supports the vertex and/or pixel

Index: /home/kielanmatt/geom/trunk/include/EDriverFeatures.h
===================================================================
--- /home/kielanmatt/geom/trunk/include/EDriverFeatures.h	(revision 2916)
+++ /home/kielanmatt/geom/trunk/include/EDriverFeatures.h	(working copy)
@@ -67,6 +67,9 @@
 		//! Are ARB fragment programs v1.0 supported?

 		EVDF_ARB_FRAGMENT_PROGRAM_1,

 

+		//! Is GEOMETRY Shaders supported?

+		EVDF_GEOMETRY_SHADER,

+

 		//! Is GLSL supported?

 		EVDF_ARB_GLSL,

 
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, as you recognized yourself already, this patch was completely broken. Anyway, I've grep'ed out the most important stuff and build my own geometry shaders solution, which is not in SVN/trunk. Please try it out and tell me about problems or success. A geometry shader example would also help.
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

BTW, I think, that we should change:
EVDF_ARB_FRAGMENT_PROGRAM_1, EVDF_ARB_GLSL, EVDF_GEOMETRY_SHADER, EVDF_PIXEL_SHADER_2_0, EVDF_HLSL etc.
to similar to this:
EVDF_SHADER_MODEL_1_1, EVDF_SHADER_MODEL_1_3, EVDF_SHADER_MODEL_1_4, EVDF_SHADER_MODEL_2_0,
EVDF_SHADER_MODEL_2_0_A, EVDF_SHADER_MODEL_2_0_B, EVDF_SHADER_MODEL_3_0, EVDF_SHADER_MODEL_4_0, EVDF_SHADER_MODEL_4_1, EVDF_SHADER_MODEL_5_0

Maybe we can will also integrate with them NPOT texture feature etc.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, the shader models don't exactly match across the two APIs. But I see the problems with the current approach. What do you mean with NPOT feature?
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Post by Nadro »

hybrid wrote:Well, the shader models don't exactly match across the two APIs. But I see the problems with the current approach. What do you mean with NPOT feature?
I mean, NPOT = Shader Model 2.0+ etc, but I don't know how it looks on mobile devices. On desktop it should be enought with properly drivers eg. for Radeon 9550-9800.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

We already have the NPOT driver check, and for OpenGL it's not necessarily given that support for shader model 2 (which is largely equaivalent to GLSL 1.10) means NPOT support. With OpenGL 2.0 you have both, but that's not an equivalence. Moreover, it's also much simpler to have some additional feature checks, as many people might not know all relations between shader models and driver features.
However, we might reduce to (or add to the existing ones) some simpler flags which say "ASM shader", "High-level shader", "Shader Model X", and other stuff.
I went through the OpenGL stuff and found that the ARB ASM shaders seem to be shader model 1.1/1.2, which GLSL is starting somewhere around 2.0, and might go up to the other models as well. Moreover, some special proprietray extensions can also lift the ASM shader models. I guess it's best to add some query method to the ProgrammingServices to give the supported shader models. Any hints on a proper mapping are very welcome
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

ok boys and girls....

we have example 22.GeometryShadersGLSL

http://project-ninja-star.googlecode.co ... /trunk.zip

unfortunately no vcprojs and cbps, but a make and .dev

also some stuff to add to ./media

btw would it hurt if you acknowledged my involvement in geometry shaders&&example22??? (SVN)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, you were already mentioned on SVN, and you'll also be mentioned once this stuff is in changes.txt. I will even be so kind and not say how bad your original code was :wink:
However, the example looks like crap on my machine :(
devsh
Competition winner
Posts: 2057
Joined: Tue Dec 09, 2008 6:00 pm
Location: UK
Contact:

Post by devsh »

if the devs agree

this will be irrlicht example 24.GeomShaders

basically dx11 tesselation in openGL

Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Looks interesting. Always remember to provide nice code and full references about where you got the shaders from :wink:
Post Reply