Hi, all!
How can I flip UVs by Y when Vulkan is used and not flip
when OpenGL is used? Need to support both.
Ogre Version: master branch
Operating System: Ubuntu 22.04
Render System: GL ES 2.0, Vulkan
Hi, all!
How can I flip UVs by Y when Vulkan is used and not flip
when OpenGL is used? Need to support both.
Ogre Version: master branch
Operating System: Ubuntu 22.04
Render System: GL ES 2.0, Vulkan
For my water I use reflection, and then I do need to flip the projection coords between OpenGL and Direct3D, maybe this will also help in your scenario?
I use this in the shader material:
Code: Select all
default_params
{
param_named_auto renderTargetFlipping render_target_flipping
}
Then in the hlsl code I use this:
Code: Select all
float renderTargetFlipping;
float4 main_ps( float4 projectionCoord : TEXCOORD0 ) : COLOR0
{
float2 projectionUV = projectionCoord.xy / projectionCoord.w;
projectionUV.y = (1.0 - saturate(renderTargetFlipping)) + renderTargetFlipping * projectionUV.y;
Otherwise, you could simply add your own parameter and then just set it in code:
Code: Select all
param_named flipUVY float 1.0
You could also use a shared parameter for it, in the shader material:
Code: Select all
shared_params_ref FlipParams
In C++:
Code: Select all
GpuSharedParametersPtr tmpGpuSharedParameters = GpuProgramManager::getSingleton().createSharedParameters("FlipParams");
tmpGpuSharedParameters->addConstantDefinition("flipUVY", GCT_FLOAT);
if(IsUsingVulkan)
tmpGpuSharedParameters->setNamedConstant("flipUVY", 1.0f);
else
tmpGpuSharedParameters->setNamedConstant("flipUVY", -1.0f);
And then simply just add it normally in the shader itself:
Code: Select all
float flipUVY;
My project: https://imagindar.com/
Thanks a lot!
looks like renderTargetFlipping works in reverse for me
ifdef is good too, thanks!