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 

EXTERNAL: Re: Writing texture coordinates on a mesh without going through traversal code?


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 11971

PostPosted: Sat Apr 14, 2018 5:48 pm    Post subject:
EXTERNAL: Re: Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

On 14 April 2018 at 17:27, Rowley, Marlin R < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:

Hi Robert!
 
After a lot of hours staying up last night, this morning I found the solution.  It was surprisingly easy.
 
When I get back to work on Monday I will post the code that hopefully will help other people in the future.  It didn’t have to be as complicated as we were going from before.  Especially not with VS/PS 3.0+.  Fixed-function pipeline is all but obsolete these days.



Fixed function is still widely used, some OSG users still just use 100% fixed function and get on fine, other mix both, others go 100% shaders.  I don't know your background, skills or the real requirements of your application so at this point it's inappropriate to make assumptions about your particular needs. 


For you it might be that a mix of fixed function and shaders will be the most productive approach, for instance you can mix fixed function with shaders via the built in uniforms that it provides.   So with my suggestion of looking at osg::ClipNode / osgclip example is starting place, to illustrate an example of positional state, osg::TexGenNode would be another.  Both of these are fixed function but also can be used directly in shaders when you use the compatible profile or GL2 builds.


As a general note, I'm here trying to help you.  I have almost 17 years of experience with helping new OSG users along the path of using the OSG effectively.  One the most common troubles that I see is in users getting a bit of ahead of themselves trying to solve the more complicated problems before understanding the basics of the OSG, this often leads to trying to force the OSG to work in a way that is far more complex than is actually required.  The best way to help is not to trying a resolve the complex route they have chosen for themselves but to get them to take a step back and explain the end goal that they are trying to achieve rather than solution that they have decided upon.  


Once you know where they are going you can start point them in a more productive route and then help them take baby steps along this path.  Once they get on the right path they get to know the OSG API better and also how to think about solutions to problems.


Robert.








 

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 9:48 pm    Post subject:
EXTERNAL: Re: Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hi Robert!

After a lot of hours staying up last night, this morning I found the solution. It was surprisingly easy.

When I get back to work on Monday I will post the code that hopefully will help other people in the future. It didn’t have to be as complicated as we were going from before. Especially not with VS/PS 3.0+. Fixed-function pipeline is all but obsolete these days.

-M

From: osg-users [mailto:] On Behalf Of Robert Osfield
Sent: Saturday, April 14, 2018 2:15 AM
To: OpenSceneGraph Users <>
Subject: EXTERNAL: Re: Writing texture coordinates on a mesh without going through traversal code?

HI Marlin,


I would hope that you can implement what you need without getting your hands dirty with internals of the OSG. It sound like you want something similar to osg::ClipPlaneNode. Have a look at osgclip to see how it works.



Robert.



On 13 April 2018 at 22:30, Rowley, Marlin R < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:
Quote:

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));
// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());
// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)




_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
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 EXTERNAL: Re: World space normal. Rowley, Marlin R General 1 Wed Jul 11, 2018 4:30 pm View latest post
No new posts osgOcean - Render to Texture Camera rob_ewbank osgOcean [osgOcean] 3 Wed Jul 04, 2018 11:27 am View latest post
No new posts LineSegmentIntersector doesn't give a... MaFa18 General 3 Thu Jun 21, 2018 10:12 am View latest post
No new posts Writing .osg files: how to set colors... eMiliano General 0 Tue Jun 19, 2018 2:02 pm View latest post
No new posts EXTERNAL: Announcement: VulkanSceneGr... Rowley, Marlin R General 0 Mon Jun 04, 2018 3:00 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