LT_SPOTLIGHT not lighting anything

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


fun3d
Gnoblar
Posts: 4
Joined: Sat Apr 18, 2020 7:06 pm
x 1

LT_SPOTLIGHT not lighting anything

Post by fun3d »

Me:
  • New to Ogre (trying to get 2.x up from ogre-next/master)
  • Not new to rendering engines, shaders, etc.
  • oxs / Metal
  • Have created a new material from scratch, vs and ps shaders, to force all pixels to red, that worked.
The setup:
  • OSX/ Metal
  • HEAD of ogre-next/master (7006f6e)
  • HlmsPbs
  • Very simple scene with a couple rendered cubes (Cube2.mesh from DebugPack with and without the default material removed with MeshTool)
  • Single LT_SPOTLIGHT
  • Set some ambient.
  • Don’t see any errors in ogre.log
I don’t have any problem getting the cubes to render with no light - they are just flat gray - no surprise. With LT_DIRECTIONAL I can see basic vertex shading when using LT_DIRECTIONAL. Switching to LT_SPOTLIGHT go back to flat, unlit look. The light (attached to another small cube) is placed between the camera and the target cubes and is rotated in all directions to check my math isn’t foolish.

Questions:
  • Is this is a shader issue?
  • Does the default Pbs shader render lighting?
  • Where or what is the default shader? (Samples/2.0/.../Hlms/Pbs/(Metal/Any)?
Any thoughts?
fun3d
Gnoblar
Posts: 4
Joined: Sat Apr 18, 2020 7:06 pm
x 1

Re: LT_SPOTLIGHT not lighting anything

Post by fun3d »

OK, I see the precompiled 100000000VertexShader_vs/PixelShader_ps.metal files in the working directory. So that's answers my question about the default shader.

Also, tired eyes overlooked the warnings for unused variables like ligthDir and spotCosAngle.

A little deeper dive into the shader, it looks like the implementation section is dependent on hlms_prepass..
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5502
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1370

Re: LT_SPOTLIGHT not lighting anything

Post by dark_sylinc »

Hi!

Your topic is the same problem as in another topic recently started.

You're missing a call to sceneManager->setForwardClustered (or alternative algorithm, sceneManager->setForward3D)

Spot and point lights only appear if any of these conditions is true:
  1. They're shadow casting lights and a shadow node is prepared (and if there's more shadow casting lights than shadow maps available, only the closest lights that are the closest to camera are picked up)
  2. Forward Clustered or F. 3D is enabled. Any shadow casting lights that wasn't picked for shadow casting will be used by forward clustered/3d instead
For further help if you encounter issues like this one:
  • The Samples have help descriptions that further explain these details (e.g. press F1 in PbsMaterials)
  • See the 2.1 FAQ
  • See the manual
Cheers!
Matias

Edit:
  • Where or what is the default shader? (Samples/2.0/.../Hlms/Pbs/(Metal/Any)?
The shaders are automatically generated by the Hlms system based on templates, which you seemed to figured out quickly.

The templates in Samples/Media/Hlms/Pbs/Any contain code used by all platforms & APIs, while Samples/Media/Hlms/Pbs/Metal contains code only used by Metal.
  • HlmsPbs::getDefaultPaths contains all the paths that are included
  • The Hlms will enumerate all files ending in "_piece_ps.any" and "_piece_ps.metal" and parse them. If a file ends in "_piece_vs.*" that means only parse it during Vertex Shader compilation, "_piece_all" means parse it in all stages, and so on
  • Templates are parsed in the order in which their folder paths were added. If the folder contains more than one file, the files are parsed in alphabetical order.
  • The last file to be parsed is always PixelShader_ps.metal (and VertexShader_ps.metal for the VS, and so on)
  • The generated files like 100000000VertexShader_vs/PixelShader_ps.metal are for debugging the final shader, Ogre does not actually need to dump them to disk. This behavior can be controlled via Hlms::setDebugOutputPath