I am pretty sure the answer is no, however I am currently seeing how much I could do with the HLMS customisation without changing any Ogre code (C++ or Shaders).
My goal is to add surface water shader 'pieces' for when it rains, and so I want to add a noise texture to define where puddles form. As I said I dont think this can currently be done with the HLMS listener, but could it be easily added? (NB This would NOT be a different texture per object) I could of course just generate some perlin noise on the fly, which actually would be preferable but this is an exercise to see what can be done, and hopefully might lead to some tutorials
[2.1] Adding custom texture to PBS HLMS
-
- OGRE Expert User
- Posts: 1227
- Joined: Thu Dec 11, 2008 7:56 pm
- Location: Bristol, UK
- x 157
-
- OGRE Team Member
- Posts: 5446
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1348
Re: [2.1] Adding custom texture to PBS HLMS
Yes, it can be done.
Override preparePassBuffer to set a property that would cause your shader template customizations to include these droplet codes.
Override shaderCacheEntryCreated so that in GLSL code, you can set your uniform samplers to the right texture unit.
Override hlmsTypeChanged to add the rain texture doing
And of course, override the custom_ps* pieces to actually insert your code where you need it.
I prefer using fixedTexUnit to a high value to avoid collisions, but not too high to prevent the driver from going haywire in performance (I personally pick a value of 10-11 and works fine). Note that OpenGL doesn't allow more than 16 texture units.
Override preparePassBuffer to set a property that would cause your shader template customizations to include these droplet codes.
Override shaderCacheEntryCreated so that in GLSL code, you can set your uniform samplers to the right texture unit.
Override hlmsTypeChanged to add the rain texture doing
Code: Select all
*commandBuffer->addCommand<CbTexture>() =
CbTexture( fixedTexUnit, true, texture.get(), samplerBlock );
I prefer using fixedTexUnit to a high value to avoid collisions, but not too high to prevent the driver from going haywire in performance (I personally pick a value of 10-11 and works fine). Note that OpenGL doesn't allow more than 16 texture units.
-
- OGRE Expert User
- Posts: 1227
- Joined: Thu Dec 11, 2008 7:56 pm
- Location: Bristol, UK
- x 157
Re: [2.1] Adding custom texture to PBS HLMS
Awesome . I was a little unsure about that listener function.
-
- OGRE Expert User
- Posts: 1148
- Joined: Sat Jul 06, 2013 10:59 pm
- Location: Chile
- x 169
Re: [2.1] Adding custom texture to PBS HLMS
how can I use setProperty in preparePassBuffer? do I have to inherit from Ogre::Hlms also?dark_sylinc wrote: Override preparePassBuffer to set a property that would cause your shader template customizations to include these droplet codes.