OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

geometry shader with opengles


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
lyn
Newbie


Joined: 02 Apr 2018
Posts: 8

PostPosted: Mon Apr 02, 2018 1:41 am    Post subject:
geometry shader with opengles
Reply with quote

Hi,

I want to know if osg support geometry shader with opengles3.2?I have changed the profile to GLES3.I'm now testing on IOS.
I have info like this:
GEOMETRY glCompileShader "" FAILED
GEOMETRY Shader "" infolog:
ERROR: 0:15: 'layout' : syntax error: syntax error

and this is my code:

#version 300 es

precision highp float;
precision highp int;

uniform mat4 osg_ModelViewMatrix;
uniform mat4 osg_ViewMatrix;
uniform mat4 osg_ProjectionMatrix;
uniform mat4 osg_ViewMatrixInverse;
uniform float TubeRadius;
uniform int EdgeCount;
uniform vec3 DirLightDir_V3;


layout(points) in;

layout(triangle_strip, max_vertices = 4) out;

out vec2 gf_uv;

void main()
{
vec4 offset0 = vec4(0,0,0,0);
vec4 offset1 = vec4(1,0,0,0);
vec4 offset2 = vec4(1,1,0,0);
vec4 offset3 = vec4(0,1,0,0);
gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset0);
gf_uv = offset0.xy;
EmitVertex();

gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset1);
gf_uv = offset1.xy;

EmitVertex();

gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset3);
gf_uv = offset3.xy;

EmitVertex();

gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset2);
gf_uv = offset2.xy;

EmitVertex();
EndPrimitive();
}

Any help is welcome!

Thank you!

Cheers,
lin
Back to top
View user's profile Send private message
mp3butcher (Julien Valentin)
Appreciator


Joined: 17 Feb 2010
Posts: 471
Location: France

PostPosted: Tue Apr 03, 2018 2:09 am    Post subject:
Re: geometry shader with opengles
Reply with quote

Hi
osgtransformfeedback example is surely what you're searching for.
(you'll have to adapt for core es profile but the simpliest pattern is there)
And give us feedback, i haven't tested tfb on es plateform..

Cheers
lyn wrote:
Hi,

I want to know if osg support geometry shader with opengles3.2?I have changed the profile to GLES3.I'm now testing on IOS.
I have info like this:
GEOMETRY glCompileShader "" FAILED
GEOMETRY Shader "" infolog:
ERROR: 0:15: 'layout' : syntax error: syntax error

and this is my code:

#version 300 es

precision highp float;
precision highp int;

uniform mat4 osg_ModelViewMatrix;
uniform mat4 osg_ViewMatrix;
uniform mat4 osg_ProjectionMatrix;
uniform mat4 osg_ViewMatrixInverse;
uniform float TubeRadius;
uniform int EdgeCount;
uniform vec3 DirLightDir_V3;


layout(points) in;

layout(triangle_strip, max_vertices = 4) out;

out vec2 gf_uv;

void main()
{
vec4 offset0 = vec4(0,0,0,0);
vec4 offset1 = vec4(1,0,0,0);
vec4 offset2 = vec4(1,1,0,0);
vec4 offset3 = vec4(0,1,0,0);
gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset0);
gf_uv = offset0.xy;
EmitVertex();

gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset1);
gf_uv = offset1.xy;

EmitVertex();

gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset3);
gf_uv = offset3.xy;

EmitVertex();

gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset2);
gf_uv = offset2.xy;

EmitVertex();
EndPrimitive();
}

Any help is welcome!

Thank you!

Cheers,
lin
Back to top
View user's profile Send private message Visit poster's website
lyn
Newbie


Joined: 02 Apr 2018
Posts: 8

PostPosted: Tue Apr 03, 2018 12:23 pm    Post subject:
Reply with quote

Hi,

I have succeeded on Android ,But not well on IOS,whether it is iphone4 or 6p or 6sp...
they all show: version '310' is not supported
(geometry shader only works on es3.1 later)
But version 300 is OK(but couldn't use geometry shader),So is there somthing i missed?

code now like this:
#version 310 es
#extension GL_EXT_geometry_shader : enable

uniform mat4 osg_ModelViewMatrix;
uniform mat4 osg_ViewMatrix;
uniform mat4 osg_ProjectionMatrix;
uniform mat4 osg_ViewMatrixInverse;
uniform float TubeRadius;
uniform int EdgeCount;
uniform vec3 DirLightDir_V3;


layout(points) in;

layout(triangle_strip, max_vertices = 4) out;

out vec2 gf_uv;

void main()
{
vec4 offset0 = vec4(0,0,0,0);
vec4 offset1 = vec4(1,0,0,0);
vec4 offset2 = vec4(1,1,0,0);
vec4 offset3 = vec4(0,1,0,0);
gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset0);
gf_uv = offset0.xy;
EmitVertex();

gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset1);
gf_uv = offset1.xy;

EmitVertex();

gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset3);
gf_uv = offset3.xy;

EmitVertex();

gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset2);
gf_uv = offset2.xy;

EmitVertex();
EndPrimitive();
}

Thank you!

Cheers,
lin
Back to top
View user's profile Send private message
mp3butcher (Julien Valentin)
Appreciator


Joined: 17 Feb 2010
Posts: 471
Location: France

PostPosted: Tue Apr 03, 2018 12:48 pm    Post subject:
Reply with quote

On osx, opengl requires strict gl context, so you have to use core version your shader

lyn wrote:
Hi,

I have succeeded on Android ,But not well on IOS,whether it is iphone4 or 6p or 6sp...
they all show: version '310' is not supported
(geometry shader only works on es3.1 later)
But version 300 is OK(but couldn't use geometry shader),So is there somthing i missed?

code now like this:
#version 310 es
#extension GL_EXT_geometry_shader : enable

uniform mat4 osg_ModelViewMatrix;
uniform mat4 osg_ViewMatrix;
uniform mat4 osg_ProjectionMatrix;
uniform mat4 osg_ViewMatrixInverse;
uniform float TubeRadius;
uniform int EdgeCount;
uniform vec3 DirLightDir_V3;


layout(points) in;

layout(triangle_strip, max_vertices = 4) out;

out vec2 gf_uv;

void main()
{
vec4 offset0 = vec4(0,0,0,0);
vec4 offset1 = vec4(1,0,0,0);
vec4 offset2 = vec4(1,1,0,0);
vec4 offset3 = vec4(0,1,0,0);
gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset0);
gf_uv = offset0.xy;
EmitVertex();

gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset1);
gf_uv = offset1.xy;

EmitVertex();

gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset3);
gf_uv = offset3.xy;

EmitVertex();

gl_Position = osg_ProjectionMatrix * (gl_in[0].gl_Position + offset2);
gf_uv = offset2.xy;

EmitVertex();
EndPrimitive();
}

Thank you!

Cheers,
lin
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Problem with output - OSG/Shader romulogcerqueira General 3 Sat Aug 04, 2018 6:36 pm View latest post
No new posts [HELP] Properly using osg::VertexAttr... ppsychrite General 3 Wed Aug 01, 2018 12:17 pm View latest post
No new posts [Crash issue] How to add&remove d... pwang General 2 Thu Jul 26, 2018 10:10 am View latest post
No new posts Draw geometry on demand sergio2k18 General 5 Sun Jun 10, 2018 7:53 am View latest post
No new posts Shader Program stops working after Ch... ceranco General 0 Mon May 21, 2018 3:09 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP