Re: [Opensg-users] tesselation shader

2016-11-02 Thread Carsten Neumann
Hello Victor,

On 2016-11-01 15:08, Victor Haefner wrote:
> I tried with
>
> char errbuf[4096];
> GLsizei len;
> GLint link_ok = GL_FALSE;
> VRWindowPtr window =
> VRSetup::getCurrent()->getWindows().begin()->second;
> if (!window) return;
> Window* pWin = window->getOSGWindow();
> GLuint uiProgram = GLuint(pWin->getGLObjectId(p->getGLId()));
> if (!uiProgram) return;
>
> glGetProgramInfoLog(uiProgram, sizeof(errbuf), &len, errbuf);
> glGetProgramiv(uiProgram, GL_LINK_STATUS, &link_ok);
> if (!link_ok)  {
> string e = "The shaders did not link correctly: ";
> e += string(errbuf);
> VRGuiManager::get()->printToConsole("Errors", e);
> }
>
> but I did not get anything usefull.

hmm, the only things that come to mind are:
- is the OpenGL context for that OSG::Window active at the point in time 
when you make those calls?
- has OpenSG had a chance to create, compile, and link the program? This 
would probably happen as part of the first render that uses the program.

> So I just compile the shader and get the logs
>
> GLuint shaderObject = glCreateShader(type);
> int N = shader.size();
> const char* str = shader.c_str();
> glShaderSourceARB(shaderObject, 1, &str, &N);
> glCompileShaderARB(shaderObject);
>
> GLint compiled;
> glGetObjectParameterivARB(shaderObject, GL_COMPILE_STATUS, &compiled);
> if (!compiled) gm->printToConsole("Errors", "Shader "+name+" of
> material "+getName()+" did not compiled!\n");
>
> GLint blen = 0;
> GLsizei slen = 0;
> glGetShaderiv(shaderObject, GL_INFO_LOG_LENGTH , &blen);
> if (blen > 1) {
> GLchar* compiler_log = (GLchar*)malloc(blen);
> glGetInfoLogARB(shaderObject, blen, &slen, compiler_log);
> VRGuiManager::get()->printToConsole("Errors", string(compiler_log));
> free(compiler_log);
> }
>
> Would there be a downside on that approach?
> At least it works with the osg attributes

Well, the shader gets compiled twice (once by OpenSG, once by you for 
error checking).

Cheers,
Carsten

--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
___
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users


Re: [Opensg-users] tesselation shader

2016-11-01 Thread Victor Haefner
Hello Carsten,

I tried with

char errbuf[4096];
GLsizei len;
GLint link_ok = GL_FALSE;
VRWindowPtr window = VRSetup::getCurrent()->
getWindows().begin()->second;
if (!window) return;
Window* pWin = window->getOSGWindow();
GLuint uiProgram = GLuint(pWin->getGLObjectId(p->getGLId()));
if (!uiProgram) return;

glGetProgramInfoLog(uiProgram, sizeof(errbuf), &len, errbuf);
glGetProgramiv(uiProgram, GL_LINK_STATUS, &link_ok);
if (!link_ok)  {
string e = "The shaders did not link correctly: ";
e += string(errbuf);
VRGuiManager::get()->printToConsole("Errors", e);
}

but I did not get anything usefull.

So I just compile the shader and get the logs

GLuint shaderObject = glCreateShader(type);
int N = shader.size();
const char* str = shader.c_str();
glShaderSourceARB(shaderObject, 1, &str, &N);
glCompileShaderARB(shaderObject);

GLint compiled;
glGetObjectParameterivARB(shaderObject, GL_COMPILE_STATUS, &compiled);
if (!compiled) gm->printToConsole("Errors", "Shader "+name+" of
material "+getName()+" did not compiled!\n");

GLint blen = 0;
GLsizei slen = 0;
glGetShaderiv(shaderObject, GL_INFO_LOG_LENGTH , &blen);
if (blen > 1) {
GLchar* compiler_log = (GLchar*)malloc(blen);
glGetInfoLogARB(shaderObject, blen, &slen, compiler_log);
VRGuiManager::get()->printToConsole("Errors", string(compiler_log));
free(compiler_log);
}

Would there be a downside on that approach?
At least it works with the osg attributes

Best Regards,
Victor




Mit freundlichen Grüßen,
Victor Häfner

On Wed, Oct 19, 2016 at 3:56 PM, Carsten Neumann <
carsten.p.neum...@gmail.com> wrote:

> Hello Victor,
>
> On 2016-10-19 02:41, Victor Haefner wrote:
> > I have a tool, an editor, where users can write GLSL shader,
> > but I am still missing warning and error output in the gui.
> >
> > How could I get the error logs of the shader compilation and linkage
> > from OpenSG?
>
> I don't think that is exposed at the moment. When a shader is compiled
> it is checked for success and any errors are logged (through the usual
> OpenSG log).
> IIRC there are ways to intercept the log streams - but you would likely
> get other messages as well, not just those from the shader compiles. I
> guess the other option could be to get the real GL id of the shader
> object (Window::getGLObjectId, I think) and make the necessary GL calls
> directly - ensuring that the correct GL context corresponding to the
> Window is active at the time.
>
> Cheers,
> Carsten
>
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> ___
> Opensg-users mailing list
> Opensg-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/opensg-users
>
--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi___
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users


Re: [Opensg-users] tesselation shader

2016-10-19 Thread Carsten Neumann
Hello Victor,

On 2016-10-19 02:41, Victor Haefner wrote:
> I have a tool, an editor, where users can write GLSL shader,
> but I am still missing warning and error output in the gui.
>
> How could I get the error logs of the shader compilation and linkage
> from OpenSG?

I don't think that is exposed at the moment. When a shader is compiled 
it is checked for success and any errors are logged (through the usual 
OpenSG log).
IIRC there are ways to intercept the log streams - but you would likely 
get other messages as well, not just those from the shader compiles. I 
guess the other option could be to get the real GL id of the shader 
object (Window::getGLObjectId, I think) and make the necessary GL calls 
directly - ensuring that the correct GL context corresponding to the 
Window is active at the time.

Cheers,
Carsten

--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users


Re: [Opensg-users] tesselation shader

2016-10-19 Thread Victor Haefner
hi all,


I have a tool, an editor, where users can write GLSL shader,
but I am still missing warning and error output in the gui.

How could I get the error logs of the shader compilation and linkage from
OpenSG?


Best Regards,
Victor Häfner
--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot___
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users


Re: [Opensg-users] tesselation shader

2016-10-18 Thread Victor Haefner
Hi all


..and now it works.. ( as usual, right after posting on the list :D )
I missed the part with patch vertices..
sorry for the false alarm :)

Best Regards,
Victor
--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot___
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users


[Opensg-users] tesselation shader

2016-10-18 Thread Victor Haefner
Hi all,

I am trying to get tesselation shader to work (OpenSG 2).
I got rid of all errors but still nothing to see..

I set them up like that:


vProgram = ShaderProgram::createVertexShader  ();
fProgram = ShaderProgram::createFragmentShader();
gProgram = ShaderProgram::createGeometryShader();
tcProgram = ShaderProgram::create();
tcProgram->setShaderType(GL_TESS_CONTROL_SHADER);
teProgram = ShaderProgram::create();
teProgram->setShaderType(GL_TESS_EVALUATION_SHADER);

shaderChunk->addShader(md->vProgram);
shaderChunk->addShader(md->fProgram);
shaderChunk->addShader(md->gProgram);
shaderChunk->addShader(md->tcProgram);
shaderChunk->addShader(md->teProgram);

vProgram->setProgram(vp.c_str());
fProgram->setProgram(fp.c_str());
pProgram->setProgram(gp.c_str());
tcProgram->setProgram(tcp.c_str());
teProgram->setProgram(tep.c_str());

vertex shader:
#version 120

attribute vec4 osg_Vertex;
attribute vec2 osg_MultiTexCoord0;

void main(void) {
gl_Position = osg_Vertex;
}


fragment shader:
#version 120

void main( void ) {
gl_FragColor = vec4(1.0);
}


geometry shader:
#version 400 compatibility

#extension GL_EXT_gpu_shader4: enable
#extension GL_EXT_geometry_shader4: enable

layout(triangles) in;
layout(triangle_strip, max_vertices = 200) out;

void main(void) {
  gl_Position = gl_ProjectionMatrix * vec4(gl_PositionIn[0].xyz, 1.);
EmitVertex();
  gl_Position = gl_ProjectionMatrix * vec4(gl_PositionIn[1].xyz, 1.);
EmitVertex();
  gl_Position = gl_ProjectionMatrix * vec4(gl_PositionIn[2].xyz, 1.);
EmitVertex();
EndPrimitive();
}


tess control shader:
#version 400
#extension GL_ARB_tessellation_shader : enable

layout(vertices = 16) out;
out vec3 tcPosition[];

void main() {
tcPosition[gl_InvocationID] = gl_in[gl_InvocationID].gl_Position.xyz;

if (gl_InvocationID == 0) {
gl_TessLevelInner[0] = 4;
gl_TessLevelInner[1] = 4;

gl_TessLevelOuter[0] = 4;
gl_TessLevelOuter[1] = 4;
gl_TessLevelOuter[2] = 4;
gl_TessLevelOuter[3] = 4;
}
}

tess eval shader:
#version 400
#extension GL_ARB_tessellation_shader : enable

layout( quads ) in;
in vec3 tcPosition[];

void main() {
float u = gl_TessCoord.x;
float v = gl_TessCoord.y;
vec3 a = mix(tcPosition[0], tcPosition[3], u);
vec3 b = mix(tcPosition[12], tcPosition[15], u);
vec3 tePosition = mix(a, b, v);
gl_Position = vec4(tePosition, 1);
}




I tried debugging with gDEBugger,
compiling the program gives the following warnings and errors:

-- Build Started: GL Context 1 --
Compiling...
Linking...
Program 1
 Tessellation control info
 -
 (0) : warning C6029: No output primitive type
 (0) : warning C7543: geometry shaders require #extension
GL_EXT_geometry_shader4
 Tessellation evaluation info
 
 (0) : warning C7543: geometry shaders require #extension
GL_EXT_geometry_shader4
 (0) : error C7005: no tessellation primitive mode specified
- Done -
   Compile: 3 Succeeded, 0 Failed
   Link: Failed
   Validate: Not Executed

Strange is that gDEBugger only sees the vertex fragment and geometry
shader, not the two tesselation shader..

any hints on what I am doing wrong?


Best regards,
Victor
--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot___
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users