rutt etra….

Home Forums v002 v002 QC Plugins Support rutt etra….

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #4171
    franz
    Participant

    Hi v002 !
    So right now I’m into custom plugins using shaders.
    (trying to use geometry shaders ….)
    I’ve been reading at your RuttEtra source -thanks again for making it open- , and I noticed you where using shaders ! Hoora !
    However, all your shader stuff link to the v002shader class, which is, unfortunately, not present in the source package. I assume you forgot to include it … or was it intentional ?
    Would you consider sending me this file, as it would obviously help me understand what’s going on, and how to load shaders within a custom plugin.

    Any info or little push on that subject would make my day. No, my week actually …;)
    Since I’m currently trying to load and compile shaders at runtime, without success….

    As a sidenote, I’m using Polytrans at the moment to convert FBX or OBJ models directly into openGL commands…. This works greatly, dunno what framework you’re using to load models, but I would recommend having a look at it.

    Regards

    #4172
    bangnoise
    Keymaster

    Hey thanks for the heads-up. I’ll mail you the files now and we’ll update the download asap.

    #4173
    franz
    Participant

    thank you soooo much

    #4174
    vade
    Keymaster

    Id like to mention that the v002Shader included there *does not* work with Geometry shaders. you need to do some extra work and supply some additional compile time constants to mark you input geometry format, output geometry format and max number of vertices out.

    Do you release source with your plugins?

    #4175
    franz
    Participant

    Currently i don’t release any source with my plugins, provided they’re home made, public and free.
    I just don’t feel myself being at the level to do so.(==clean code, useful comments, like you guys do)

    I’m doing some researches with shaders, and if i use techniques developed by v002 (or just inspired by), i’ll release source as well, this is mandatory.
    Having said that, at the moment I don’t have any plugin using shaders, at all.
    Do you think i should publish some sources ? What plugin in particular ?
    (Honestly, when I’ve a look at your code, I feel myself as a crappy hobby-ist coder… )

    On the geometry shader side, can’t i just add a “getGeometryShaderSourceFromResource” method ?

    #4176
    vade
    Keymaster

    The v002 Shader code has some assumptions regarding having to have both a vertex and a fragment (you can have just one or the other). However for a geometry shader, you have to have a vertex program. The following is, I think, pretty tight. You will also have to clean up your 3 shaders after linking to a program.

    As for the source issue, I was just curious. Its more of a half regret sometimes releasing source, I get very little out of it, and others get quite a lot, so it feels a bit odd sometimes.

    Anyway, try this out.

    CGLContextObj cgl_ctx = context;
    
    		// create our shaders from the source
    		if(vertexShaderSource != NULL)
    		{
    			vertexProgram = glCreateShader(GL_VERTEX_SHADER);
    			glCheckForErrors;
    
    			glShaderSource(vertexProgram, 1, &vertexShaderSource, NULL);
    			glCheckForErrors;
    			glCompileShader(vertexProgram);
    			glCheckForErrors;
    		}
    
    		if(fragmentShaderSource != NULL)
    		{
    			fragmentProgram = glCreateShader(GL_FRAGMENT_SHADER);
    			glCheckForErrors;
    
    			glShaderSource(fragmentProgram, 1, &fragmentShaderSource, NULL);
    			glCheckForErrors;
    			glCompileShader(fragmentProgram);
    			glCheckForErrors;
    		}
    
    		if(geometryShaderSource != NULL)
    		{
    			geometryProgram = glCreateShader(GL_GEOMETRY_SHADER_EXT);
    			glCheckForErrors;
    
    			glShaderSource(geometryProgram, 1, &geometryShaderSource, NULL);
    			glCheckForErrors;
    			glCompileShader(geometryProgram);
    			glCheckForErrors;
    		}
    
    		// now that we have our shaders, we have to create a program and attach them all
    		programObject = glCreateProgram();
    		glCheckForErrors;
    
    		if(vertexProgram && programObject)
    		{
    			glAttachShader(programObject,vertexProgram);
    			glCheckForErrors;
    
    			// check log for errors, print if necessary
    			[self printShaderInfoLog:vertexProgram];
    		}
    
    		if(fragmentProgram && programObject)
    		{
    			glAttachShader(programObject,fragmentProgram);
    			glCheckForErrors;
    
    			// check log for errors, print if necessary
    			[self printShaderInfoLog:fragmentProgram];
    		}
    
    		if(geometryProgram && programObject)
    		{
    			glAttachShader(programObject,geometryProgram);
    			glCheckForErrors;
    
    			glProgramParameteriEXT(programObject,GL_GEOMETRY_INPUT_TYPE_EXT, [[attributes valueForKey:kNIGLSLShaderGeomInputPrimitive] unsignedIntValue]);
    			glCheckForErrors;
    			glProgramParameteriEXT(programObject,GL_GEOMETRY_OUTPUT_TYPE_EXT, [[attributes valueForKey:kNIGLSLShaderGeomOutputPrimitive] unsignedIntValue]);
    			glCheckForErrors;
    
    			// TODO: make this an input variable, as specifying max emitabble vertices is poor form and poor for performance
    
    			GLint temp;
    			if(![[attributes valueForKey:kNIGLSLShaderGeomMaxPoints] unsignedIntValue] || [[attributes valueForKey:kNIGLSLShaderGeomMaxPoints] unsignedIntegerValue] == 0)
    			{
    				glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT, &temp);
    				glCheckForErrors;
    			}
    			else
    				temp = [[attributes valueForKey:kNIGLSLShaderGeomMaxPoints] intValue];
    
    			glProgramParameteriEXT(programObject,GL_GEOMETRY_VERTICES_OUT_EXT,temp);
    			glCheckForErrors;
    
    			// check log for errors, print if necessary
    			[self printShaderInfoLog:geometryProgram];
    
    		}
    
    		glLinkProgram(programObject);
    		glCheckForErrors;
    #4177
    franz
    Participant

    thanks master vade.

    (still banging my head tho’)

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.