Few serious questions for Ogre-Next, moving Stunt Rally

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


Post Reply
User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

Okay. I'll try that class someday, I guess it'll require more files to add. But sounds better than using ManualObject nowadays.
But I'm also thinking of having whole HUD done in shader (since a while) similar to that demo, it even has antialiased stuff. It would allow really cool effects, like any elements, not from texture, glow, whole screen flash, drops on screen etc. Only font would need more care I guess. I think this isn't too much to handle for GPUs these days.

Could you also answer my previous post questions? viewtopic.php?p=553815#p553815 also that soft particles part.
I'm starting to write shaders and it is a bit overwhelming at start. Especially seeing so much code already written and so many cases :o, respect.
Also a couple of new, related questions:

  • Can I write postprocess shaders in .any? Or are those v1 and must be have full code in .glsl and .hlsl etc?
  • What is the minimal set for a new shader? I'd like to use .any files, since they are translated. But then, any other stuff like structs with params and samplers etc, need to be separate in glsl and hlsl files, do I get this right?
  • What should I do if I want my own variant of Pbs shader for glass pipes? It has 2 passes: 1st with cull_hardware clockwise, and 2nd with cull_hardware anticlockwise. This way at least I got rid of those freaking slice ellipses issue. What could be the best / minimal approach to modify for this? I don't want to change too much, since Pbs already works for me.
  • I'm guessing for things like grass / trees wind I don't want to have own Hlms right? I can just add a parameter for Pbs and use it in grass trees materials and just skip in all others. Same with grass fading in distance.
  • Only big things like water would need own Hlms with big cpp code for it too, right? I'm trying to avoid this and use Pbs as much as possible.
  • Can I have an unlit variant but with some sort of basic diffuse light for particles, grass etc, done from Pbs? I really can't have unlit particles, they need to be darker in shadows and change colors from sun diffuse on other sceneries etc.
  • So if Pbs already has 4 detail maps, are those sampled if not present? Or just the ones specified are used and end in shader?

I got to keep watch on microcodeCodeCache.cache :) I once after a while saw it had 1GB and game was starting slow. Doesn't take much to reach over 100MB after some shader editing.

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

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by dark_sylinc »

Crystal Hammer wrote: Mon Dec 05, 2022 11:07 pm
  • Can I write postprocess shaders in .any? Or are those v1 and must be have full code in .glsl and .hlsl etc?

Yes, but you are giving us too much credit on .any. It's just a clever trick. We're not doing anything special in C++ side.

We are basically doing this:

Code: Select all

// Vulkan & GL3+ will change 'ogre_glsl_ver_330' for 330 in GL3+ and a hardcoded 450 in Vulkan
#version ogre_glsl_ver_330

// Abstract GLSL difference see CrossPlatformSettings_piece_all.glsl
#define float4 vec4
#define OGRE_Sample( tex, sampler, uv ) texture( tex, uv )

void main()
{
    #include "SharedCode.any"
}

And then do the same for HLSL & Metal.

In Hlms we will collect and parse *.any files before collecting and parsing *.glsl/hlsl/metal. While low level materials work like in Ogre 1.x.

The atmosphere shader that renders the sky shows this trick's simplicity:

The files CrossPlatformSettings_piece_all.glsl/CrossPlatformSettings_piece_all.hlsl/CrossPlatformSettings_piece_all.metal is much more complete when it comes to all the abstraction macros (usually overkill for postprocessing).

But it is written with Hlms syntax in it. However you can enable the Hlms parser for Low level materials:

Code: Select all

fragment_program Ogre/Copy/4xFP32_ps_VK glslvk
{
	source Copyback_4xFP32_ps.glsl
	use_hlms_parser true
}

And in the GLSL do:

Code: Select all

#include "CrossPlatformSettings_piece_all.glsl"
@insertpiece( SetCrossPlatformSettings )

- What is the minimal set for a new shader? I'd like to use .any files, since they are translated. But then, any other stuff like structs with params and samplers etc, need to be separate in glsl and hlsl files, do I get this right?

Indeed. You may notice I do:

Code: Select all

#define p_paramName paramName

Then use p_paramName. The reason for this is that Metal needs to hold (more than one) parameters in a struct, hence in Metal it is:

Code: Select all

#define p_paramName p.paramName

- What should I do if I want my own variant of Pbs shader for glass pipes? It has 2 passes: 1st with cull_hardware clockwise, and 2nd with cull_hardware anticlockwise. This way at least I got rid of those freaking slice ellipses issue. What could be the best / minimal approach to modify for this? I don't want to change too much, since Pbs already works for me.

See Dealing with multi pass rendering in ogre next.

- I'm guessing for things like grass / trees wind I don't want to have own Hlms right? I can just add a parameter for Pbs and use it in grass trees materials and just skip in all others. Same with grass fading in distance.

I suppose that's possible, yes. Hlms is customizable.

- Only big things like water would need own Hlms with big cpp code for it too, right? I'm trying to avoid this and use Pbs as much as possible.

That's up to you. I've personally used my own Hlms for much simpler stuff as well. The thing about Hlms is that it has a high up-front cost, but once you got it running it's extremely flexible to do whatever you want.

- Can I have an unlit variant but with some sort of basic diffuse light for particles, grass etc, done from Pbs? I really can't have unlit particles, they need to be darker in shadows and change colors from sun diffuse on other sceneries etc.

You can set diffuse to 0 and work with emissive instead.

And you can set the Hlms property custom_disable_directional_lights to 1 to disable lighting.

If the shader still contains stuff you don't want to use, you can also do in a customization:

Code: Select all

@undefpiece( forwardPlusDoCubemaps )

Just make sure your custom piece is parsed after the file that defines forwardPlusDoCubemaps. That's why files are numbered (e.g. 200.DetailMaps_piece_ps.any) Hlms files are parsed in alphabetical order, so the numbers help you sort out the correct order.

- So if Pbs already has 4 detail maps, are those sampled if not present? Or just the ones specified are used and end in shader?

Just the one you want to specify.

User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

Great, this explained a lot, thanks.

So are unlit materials for v1 meshes and pbs for v2 items?
I see unlit materials apply vertex colors by default, is this possible to do with Pbs shaders? I can't see an option, does this need to be added in shaders?
I made a v1::BillboardSet and with unlit it looks okay, but with pbs I just see completely white squares, no matter what I set in .material.
I think I have a similar issue with v1::RibbonTrail.

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

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by dark_sylinc »

Yes, you'll have to add a custom piece.

The reason for this is that vertex colours are often old school tricks/"hacks".

But in PBS there may be many (non-colour) uses to vertex colours, or even specific colour uses (that are more involved than just multyplying everything that by colour).

In Unlit it makes sense to provide this functionality out of the box, since it's what everyone would expects, but it's not so crystal clear for Pbs.

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

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by dark_sylinc »

Crystal Hammer wrote: Thu Dec 22, 2022 9:21 pm

So are unlit materials for v1 meshes and pbs for v2 items?

I forgot to answer this question: You can apply anything with anything. Unlit/Pbs goes with v1/v2.

The difference is that v2 is preferred as v1 may force us to do more stalls (extremely rare), reduce instancing capabilities (particularly our ability to batch different meshes together), or break up rendering passes which hurts performance.

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

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by dark_sylinc »

Btw for the v1 vs v2 thing, you may want to take a look at RenderQueue section in the manual.

I just updated this section so it may take a while to reflect the changes.

User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

Thanks.
Ok it's been a while. I've been busy with editor too. So I'm also writing an update on what's done.
For HUD I made a class based on Renderable (initially from MyCustomRenderable), my code here (GPLv3 like SR). Works also for 3D and I made even pacenotes (signs above terrain) with it, better than billboards, since now they're all are 1 batch. Has similar methods as ManualObject, but it's tricky since it needs the same vertex count in update, can't add more.

For glass pipes, it worked. (Having 2 items, 2nd has a cloned datablock with opposite cull).
But not exactly, I can see a new bug now. Not very noticeable for glass but it does have wrong light (order), these dark ellipses where pipe meshes connect. I think they aren't exactly rendered as before, so:
1st mesh: 1st pass then 2nd pass, 2nd mesh: 1st pass then 2nd pass,
but in other way:
(1st mesh, 2nd mesh, 1st mesh again, 2nd mesh or similar).
Best visible with broken materials/wrap on screen. But otherwise not very visible, surely not from inside.
And I'm glad they're sorted now, and don't blink furiously.

0312``.jpg
0312``.jpg (228.72 KiB) Viewed 43086 times

Editing road is really slow now. I remember in old SR editor I was editing 4 segments (destroying, and creating) each frame at 60 Fps no problem (38 Fps for pipes with bridges and columns too). Now recreating only 4 road meshes drops to 24 Fps and with bridges even to 16 Fps. Seems it's not only that v2 to v1, tangents and back to v2 that's causing it. I guess I'll leave it for now, added skip frames so it updates like 3 times per second.

Last edited by Crystal Hammer on Fri Jan 06, 2023 3:41 pm, edited 2 times in total.
User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

So I got new problems, more important.

Cube reflections.

  • [Fixed] I can't get them to look the same after first load. Every next track loaded has broken roughness, not the same look for same values, very rough.
    code here, close to tutorial.
    I kind of narrowed it down to mip maps, if I comment out both mCubeReflTex->setNumMipmaps,
    then yes, next load has same reflections, but obviously roughness doesn't work at all, i.e. I get flat mirrors.
    I tried many combinations of commenting out various parts of code, and added destroying first but still same issue.
    I simply want to call minimizeMemory() from Tutorial_MemoryGameState and then DynamicCubemapGameState::setupCompositor() and have the same reflections with roughness.
  • They are slow. Only okay with IblLow, it has cubemap size 256, looks bad close. Anything higher and it drops below 60 Fps and Fps isn't smooth anymore.
    In old SR I use 1024 size, and rendering 2 maps per frame (not all 6) and it is smooth.
    How do I now set frame skip and/or render less cubemap faces each frame?
  • How do I set reflection cube in .material? I have createOrRetrieveTexture called DynamicCubemap but:
    reflection_map DynamicCubemap
    in .material gives me this:
    OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource DynamicCubemap_rt. in resource group Autodetect or any other group. in ResourceGroupManager::_getArchiveToResource at ../../OgreMain/src/Ogre
    And using this name from .compositor: expose demo_dynamic_cubemap
    in .material, gives this, and 6 similar:
    OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource demo_dynamic_cubemap_lf.
    Surely I'm missing something.
    And doing it in code works:
    datablock->setTexture( PBSM_REFLECTION, mCubeReflTex );
  • How to add shadows in this cubemap with reflections? Can I use the same shadowmap as for rest?

Since I have now split screen, with views for 2 to 4 players, I see that terrain has LOD only in first view.
Thus getting huge terrain triangles in last 3rd view, while 1st view has good LOD only.

0186`s3.jpg
0186`s3.jpg (178.77 KiB) Viewed 43048 times

How do I set LOD camera and update view for each player? In old SR there was

Code: Select all

preViewportUpdate(const RenderTargetViewportEvent& evt)

where we were setting such things for each player's view.

Ok. Loading times are horribly long, compared to old SR. I'm not joking, in old SR I could load a test track in 1 sec, with a car, 100 trees and few objects. And it looks like GPU RAM use was also lower. I see below 200MB in old SR test tracks.
Now in new SR3 I need like 5 sec to load same track, and it ends with close to 500MB. And this is with commented out terrain shadowmap (it took 5 sec more). IDK exactly, it seems like everything is slower, createItem etc. It happens also with tracks having no road and no vegetation.

Last edited by Crystal Hammer on Tue Jan 17, 2023 8:28 pm, edited 7 times in total.
User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

Ok I think I finally got the 1st one

Crystal Hammer wrote: Fri Jan 06, 2023 2:16 pm

can't get them to look the same after first load.

I'm now calling:

Code: Select all

int mips = PixelFormatGpuUtils::getMaxMipmapCount( resolution );
hlmsPbs->resetIblSpecMipmap( mips - 4u );

not with 0u and now I get same reflections each load. Roughness at 0.5 is already very blurry but at least the same.

Just curious, I don't know the theory here, isn't it possible to have a very dark black material but with very visible reflections like glass has? If I set color to 0.05 to get it so dark black, then I don't see reflections. IDK, maybe those materials in old SR were not physically correct at all. Or would I need something else like clear-coat or something?

But, on to bigger question:

  • Could you add triplanar option to Terra shaders? I think it'd be way easier, I'm lost after trying. Or at least guide or direct me to lines in shader and what to add?
    We need to sample terrain normal map first to get normal and blend factors (for 3 planes) from it, IDK how to even get this, so early in shader. Then in all sampled textures (diffuse, normal, (roughness, metalness etc) for each detail map), (if layer has triplanar property) instead of sampling once, we need to sample 3 times and mix them with blend factors. As I tried I even found that (if I'm right IDK) Terra diffuse for detail maps shader was sampled by code from PBS shader. I can't even. New code is almost written in that post just missing the parts I'm also lost with.
User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

How do I get RenderingMetrics stats from all render passes (or just the one that does most)? Since I've split to have HUD in own pass (in compositor) I get only tiny values.

User avatar
TaaTT4
OGRE Contributor
OGRE Contributor
Posts: 267
Joined: Wed Apr 23, 2014 3:49 pm
Location: Bologna, Italy
x 75
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by TaaTT4 »

Crystal Hammer wrote: Fri Jan 06, 2023 3:19 pm

But, on to bigger question:

  • Could you add triplanar option to Terra shaders? I think it'd be way easier, I'm lost after trying. Or at least guide or direct me to lines in shader and what to add?

If you're not in a hurry, I could try to create a PR. In my engine I added triplanar mapping support (only for detail maps); it can be enabled by setting a property and works on diffuse, normal (that's the hardest part!), roughness and metalness. But you have to give me some time: I have to merge months of OGRE commits in my fork, (re)gather ideas, clean up and remove other custom code and, most importantly, I can only work on it in my spare time.

Senior programmer at 505 Games; former senior engine programmer at Sandbox Games
Worked on: Racecraft EsportRacecraft Coin-Op, Victory: The Age of Racing

User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

Yes, would be great.
I may eventually try again after some time, right now I got many other things to restore that will keep me busy.
Perhaps you could share some shader code, e.g. few lines and key places where what was added, before the PR (if that takes longer).

User avatar
TaaTT4
OGRE Contributor
OGRE Contributor
Posts: 267
Joined: Wed Apr 23, 2014 3:49 pm
Location: Bologna, Italy
x 75
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by TaaTT4 »

TaaTT4 wrote: Tue Jan 10, 2023 12:36 pm

If you're not in a hurry, I could try to create a PR.

Thanks to a quiet couple of days at work, it took me less than I thought. Enjoy: https://github.com/OGRECave/ogre-next/pull/358!

The Sample_Tutorial_Terrain shows how to enable/disable triplanar mapping via code (call setDetailTriplanar[Diffuse|Normal|Roughness|Metalness]Enabled). If you want to do this with a material script, you need to put "detail_triplanar_[diffuse|normal|roughness|metalness]": true in the related JSON file. Please note that the terrain example material bundled with OGRE doesn't assign any texture as a detail normal map.

Senior programmer at 505 Games; former senior engine programmer at Sandbox Games
Worked on: Racecraft EsportRacecraft Coin-Op, Victory: The Age of Racing

User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

Awesome, big thank you.

User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

Okay, so in addition to my questions mainly in here and one post above that,
I got a few more, mainly for editor now:

  • Can I set a shader property for some Items? I had glow for selected road segments this way before. How to do it (or other way) now?. I simply want to have some items have a different shader property value set from cpp.
  • I also had a second road material scheme for minimap preview. It was switched in:
    preViewportUpdate(const RenderTargetViewportEvent& evt) for the viewport that renders minimap road. It then was using other shader to generate some solid colors for bridges, pipes etc.
    I was also using this event in split screen for player viewports. How to do these things nowadays?
  • What would I need to add to have grass wind? I'm thinking of a new property for .any Pbs shaders. Can it then be set in .material scripts? Does this need extending Pbs cpp code (to forward its value to shader)? Or even own Hmls?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by dark_sylinc »

Crystal Hammer wrote: Tue Jan 17, 2023 8:24 pm
  • Can I set a shader property for some Items? I had glow for selected road segments this way before. How to do it (or other way) now?. I simply want to have some items have a different shader property value set from cpp.

See how HlmsColibri uses custom parameters to tag objects and thus conditionally define more shader properties for those objects.

Note that the value 6372 is arbitrary. It's just a magic number.

Crystal Hammer wrote: Tue Jan 17, 2023 8:24 pm
  • I also had a second road material scheme for minimap preview. It was switched in:
    preViewportUpdate(const RenderTargetViewportEvent& evt) for the viewport that renders minimap road. It then was using other shader to generate some solid colors for bridges, pipes etc.
    I was also using this event in split screen for player viewports. How to do these things nowadays?

We don't have material schemes anymore, but you can either:

  • Create duplicate objects w/ different materials and put them in their own RenderQueue IDs (that only gets rendered in the minimap pass with its own compositor node)

  • Overload Hlms::preparePassHash or HlmsListener::preparePassHash to define a custom property that follows an entirely different shader path

Crystal Hammer wrote: Tue Jan 17, 2023 8:24 pm
  • What would I need to add to have grass wind? I'm thinking of a new property for .any Pbs shaders. Can it then be set in .material scripts? Does this need extending Pbs cpp code (to forward its value to shader)? Or even own Hmls?

You'll have to define some custom_vs_preTransform or custom_vs_posExecution pieces to apply the shader.

And yes, given all the work you want to do (not just wind), extending HlmsPbs with a custom class (e.g. class MyHlmsPbs : public HlmsPbs) is highly recommended.

As for how to set it up on the scripts, you can overload HlmsPbsDatablock, and the constructor receives a HlmsParamVec with params you can parse.

Crystal Hammer wrote: Tue Jan 17, 2023 8:24 pm

Okay, so in addition to my questions mainly in here and one post above that,

I will urge you to fix that Debug assert where you get:

Code: Select all

Load ini file 'core_font.xml'
ResourceTrueTypeFont: Property 'SpaceWidth' in font 'hud.fps' is deprecated; remove it to use automatic calculation.
StuntRally3: ../../OgreMain/src/OgreHlmsManager.cpp:176: T* Ogre::HlmsManager::getBasicBlock(typename Ogre::vector<T>::type&, const T&) [with T = Ogre::HlmsBlendblock; Ogre::HlmsBasicBlock type = Ogre::BLOCK_BLEND; long unsigned int maxLimit = 4096; typename Ogre::vector<T>::type = std::vector<Ogre::HlmsBlendblock, std::allocator<Ogre::HlmsBlendblock> >]: Assertion `baseParams.mBlockType == type && "baseParams.mBlockType should always be BLOCK_MACRO or BLOCK_BLEND! " "You can ignore this assert,  but it usually indicates memory corruption" "(or you created the block without its default constructor)."' failed.
Aborted

Unless you tell me that you don't get asserts in debug builds anymore.

Because this assert is an indication that memory corruption is bound to happen. And once your memory is corrupted, anything can happen.

EDIT: As for the performance problems, use a profiler. Intel VTune, AMD uProf, Google Orbit, KDAB/hotspot. Any of them will do.
Once you identify & understand where your code is taking the most time, we can address what's going on and how to fix it.

User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

Thanks.
Yes I'll deal with Debug assert when I have some time and patience.
From remaining things, just wanted to know if there is a way for:

  • reflection cube to update less frequent (either skip frames, or less faces at once), i.e. not update all 6 faces each frame always.
  • set LOD camera for Terra, for each viewport (in split screen)? Or is the solution to create 1 Terra for each viewport, seems like a lot for this?
  • I'm also missing reflection from black materials. In real life even black cars have fully visible white clouds etc in reflection. Right now when I have a black or dark material, I also have very dark reflection (fresnel), barely visible.
  • One more thing, we had a parameter called fresnel bias or something, which was making reflections less intense looking perpendicular to surface, and much more intense when closer to parallel to surface. Is this possible or would I need to code this in shaders? Here is how it was before:

    Code: Select all

    		#if FRESNEL
    			float facing = 1.0 - max(abs(dot(-eyeDir, normal)), 0);
    			#if CAR_PAINT_MAP
    				float3 fSBP = shLerp(fresnelScaleBiasPower, fresnelScaleBiasPower2, glossiness);
    				reflectionFactor *= reflectiveness;
    			#else
    				float3 fSBP = fresnelScaleBiasPower;
    			#endif
    			reflectionFactor *= shSaturate(fSBP.y + fSBP.x * pow(facing, fSBP.z));
    		#else
    			float facing = reflAmount;
    			reflectionFactor *= reflAmount;
    		#endif
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by dark_sylinc »

Crystal Hammer wrote: Wed Jan 18, 2023 10:57 am
  • reflection cube to update less frequent (either skip frames, or less faces at once), i.e. not update all 6 faces each frame always.

I'm thinking a simple solution would be to use execution_mask:

Code: Select all

abstract target cubemap_target
{
	pass render_scene
	{
		load
		{
			all				clear
			clear_colour	0.2 0.4 0.6 1
		}
		store
		{
			//We DO care about the contents of depth for the depth compressor
			depth			store
			stencil			dont_care
		}
		
	overlays			off
	camera_cubemap_reorient true

	rq_first	0
	rq_last		250

	//We want very accurate shadows in the reflections and Ogre seems to
	//be unable to detect for each pass shadows should be recalculated,
	//so force it.
	shadows LocalCubemapsShadowNode recalculate

	profiling_id "Cubemap face pass"
}
}

compositor_node LocalCubemapProbeRendererNode
{
	in 0 cubemap

target cubemap	+X : cubemap_target { execution_mask 1 }
target cubemap	-X : cubemap_target { execution_mask 2 }
target cubemap	+Y : cubemap_target { execution_mask 4 }
target cubemap	-Y : cubemap_target { execution_mask 8 }
target cubemap	+Z : cubemap_target { execution_mask 16 }
target cubemap	-Z : cubemap_target { execution_mask 32 }
}

And in C++:

Code: Select all

compositorWorkspace->setExecutionMask( (1u << frameCount) );
frameCount = (frameCount + 1) % 6;

NOTE: CompositorWorkspace::setExecutionMask does not exist, but it can be trivially added to OgreNext (just setter for CompositorWorkspace::mExecutionMask).
Previously we did not support changing the execution mask after creating the Workspace, however the reason for this restriction disapeared in OgreNext 2.4 (we refactored how barriers work)

UPDATE: Added CompositorWorkspace::setExecutionMask.

- set LOD camera for Terra, for each viewport (in split screen)? Or is the solution to create 1 Terra for each viewport, seems like a lot for this?

You need to call Terra::update when the camera changes (either because you change the pointer, or the same camera changes position/rotation).

Crystal Hammer wrote: Wed Jan 18, 2023 10:57 am
  • One more thing, we had a parameter called fresnel bias or something, which was making reflections less intense looking perpendicular to surface, and much more intense when closer to parallel to surface. Is this possible or would I need to code this in shaders? Here is how it was before:

That's what Fresnel (F0 / HlmsPbsDatablock::setFresnel) is for. Metalness (in the metallic workflow) also has the same effect (though not just that).

User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

Okay, great.
One last question for now:

How do I get RenderingMetrics stats from all render passes (or just the one that does most)? Since I've split to have HUD in own pass (in compositor) I get only tiny values.

User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

Hmm seems I broke something else.
I tried with just 1 render pass, even without clear and still nothing.
I get 0 or low values for triangles, instances counts, all from RenderingMetrics.
I tried also putting this enable in various places earlier and later but nothing, still 0s.

Code: Select all

	RenderSystem *rs = mRoot->getRenderSystem();
	rs->setMetricsRecordingEnabled( true );

What I do now is calling setupCompositor every map load. I don't use the one in GraphicsSystem, only my own. Code is here.
I have also shadows from code, but without any shadows nothing changed.
And that MyGui custom pass in code but it was working with it before.

Any idea what could be wrong or why do I get 0s in RenderingMetrics?
If none I guess I should go back in history to check.

User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

BTW it is really confusing that if I comment e.g. this in .any:

Code: Select all

    // @property( hlms_fog )

it will still work and execute this line!
Have to delete it or drop @, but this is unexpected for me.

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

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by dark_sylinc »

I tried with just 1 render pass, even without clear and still nothing.

I suggest you just place a breakpoint in RenderSystem::_resetMetrics to see when or why it's getting called. You must be querying the metrics after the reset.

Additionally check if RenderSystem::_addMetrics gets inside the if() statement.

Crystal Hammer wrote: Thu Jan 26, 2023 8:02 pm

BTW it is really confusing that if I comment e.g. this in .any:

Code: Select all

    // @property( hlms_fog )

it will still work and execute this line!
Have to delete it or drop @, but this is unexpected for me.

The parser is basic in that sense; and not a formal parser. If you wish to comment it out you can do stuff like:

Code: Select all

@property( hlms_fog && 0 )

@property( hlms_fog && false )

// unset variables are evaluated to 0
@property( hlms_fog && unset_variable_name )

// i.e. add a typo because unset variables are evaluated to 0
@property( hlms_fogUNSET )
User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

Hi, it's been a while.
I updated to latest Ogre-Next git version (before I had it from Sep 2022).
Now I see huge counts for triangles and instances.
I narrowed it down to reflection cube map, which I add dynamically from code. Shadows, HUD, and Gui don't affect render stats values (also added from code).
So an example on a track with just 512 heightmap terrain I get:
0.28M - tris, 11 - mDrawCount, 22 - mInstanceCount,
and with reflection cube map this gets to:
1.8M - tris, 36 - mDrawCount, 70 - mInstanceCount.
Any chance of getting it back to normal?

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

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by dark_sylinc »

The numbers look normal (0.28M x 7 passes = 1.96M)

But there is a lod bias setting IIRC (I'm on my phone so I can't easily look at the code right now) which you can set to a lot more aggressive for the non-main passes (using a compositor listener)

User avatar
Crystal Hammer
Gnome
Posts: 317
Joined: Sat Jun 23, 2007 5:16 pm
x 77
Contact:

Re: Few serious questions for Ogre-Next, moving Stunt Rally

Post by Crystal Hammer »

Cool. But what I meant by normal, is: can I get those small values:
0.28M - tris, 11 - mDrawCount, 22 - mInstanceCount,
even if I'm rendering cubemap every frame?
Shadows aren't included in render stats, so I wouldn't expect rendered cubemaps either.
Same like in old Ogre.

Post Reply