Home › Forums › v002 › v002 QC Plugins Support › rutt etra….
- This topic has 6 replies, 3 voices, and was last updated 10 years, 6 months ago by franz.
-
AuthorPosts
-
September 10, 2010 at 12:54 pm #4171franzParticipant
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
September 10, 2010 at 1:51 pm #4172bangnoiseKeymasterHey thanks for the heads-up. I’ll mail you the files now and we’ll update the download asap.
September 10, 2010 at 2:05 pm #4173franzParticipantthank you soooo much
September 10, 2010 at 4:34 pm #4174vadeKeymasterId 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?
September 10, 2010 at 4:49 pm #4175franzParticipantCurrently 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 ?
September 10, 2010 at 8:45 pm #4176vadeKeymasterThe 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;
September 11, 2010 at 9:09 am #4177franzParticipantthanks master vade.
(still banging my head tho’)
-
AuthorPosts
- You must be logged in to reply to this topic.