Combining PBS materials with custom HLMS

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
User avatar
bishopnator
Gnome
Posts: 395
Joined: Thu Apr 26, 2007 11:43 am
Location: Slovakia / Switzerland
x 18

Combining PBS materials with custom HLMS

Post by bishopnator »

Hi, I have a custom HLMS implementation to render the 3D objects in wireframe and supporting different render settings of the same scene in multiple windows at the same time. As an example, here a screenshot of 2 windows - left is just a wireframe rendering, right is same scene rendered with detection of the hidden lines and applying custom style to them (color / line pattern).
Image

I would like in left window to combine wireframe with the rendered triangles using the PBS materials. I am aware that I can just create new item per object and assign PBS datablock to it and according to my rendersettings, handle the visibility of this item per window. My concern is about adding this new extra item per object. I already have up to 3 items for a single rendered object - faces (due to hidden lines detection), thin wireframe and thick wireframe. Supporting the PBS material would mean adding a 4th item.

The question is, is it possible and thinkable to integrate somehow the PBS materials into my HLMS so I can somehow redirect rendering of my Ogre::Item for faces to be rendered as PBS material so I don't have to add new extra Ogre::Item there? I have several concerns:

  • as the custom HLMS, I have custom datablocks - this need to "subclass" (as member?) the PBS datablocks
  • in the case of rendering an item with PBS datablock, I have to redirect all the virtual calls to PBS hlms (which will be them also as new member of my HLMS?)
  • some other details which I am not aware of right now? ...

Should I be concerned about number of the items in scene? In ogre-next, I found somewhere in the description, that it should handled 100K+ (?) .. but still I would rather ask about the opinion and possible directions here.

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5586
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1413
Contact:

Re: Combining PBS materials with custom HLMS

Post by dark_sylinc »

If I recall Tutorial_Hlms05_CustomizationPerObjData does that.

Also take notes that HlmsTerra derives from HlmsPbs to inherit many of its properties while still recreating the whole thing from scratch. Basically it uses HlmsPbs shader library code for lighting, and C++' code for setting up lighting related stuff (e.g. Forward+).

But ultimately the complexity of your customization is what determines whether the "wireframe shader" can easily be sticked on top of PBS and then combined or you get lots of roadblocks (the biggest roadblock is usually passing more per-material or per-object data than what the default implementations gives you space for).

In ogre-next, I found somewhere in the description, that it should handled 100K+

If the amount of Items to clone is less than 100, don't even think twice.
Unless the amount of "duplicated" vertices (it's not duplicated in VRAM, but it still consumes GPU vertex and pixel shader processing time) goes far beyond what a GPU can reasonably do.

Also watch out if draw order / alpha blending makes it a tough problem or not. Usually it's not a problem but it might if there are other alpha blended objects that want to ignore depth writes.

User avatar
bishopnator
Gnome
Posts: 395
Joined: Thu Apr 26, 2007 11:43 am
Location: Slovakia / Switzerland
x 18

Re: Combining PBS materials with custom HLMS

Post by bishopnator »

If the amount of Items to clone is less than 100, don't even think twice.
Unless the amount of "duplicated" vertices (it's not duplicated in VRAM, but it still consumes GPU vertex and pixel shader processing time) goes far beyond what a GPU can reasonably do.

This shouldn't be an issue, because regardless, how I integrate PBS, the triangles must be drawn. Within a same scene pass, there will be either my "triangles" item visible, or PBS item (or none of them). It is just that this extra item sits in the memory and I will need to handle its visibility (e.g. through the visibility mask of the scene pass). Definitely there will be tons of those extra items. I am writing a renderer for CAD-like applications and there could be a lot of 3D objects (and each will have then this extra item).

I will definitely check the suggested tutorial an HlmsTerra.

Post Reply