i currently porting my code from Ogre 1.9 to Ogre 1.10.10. If I try to create a shader with RTSS in DX11
and setting both Options setLightingEnabled(true) and setVertexColourTracking(Ogre::TVC_DIFFUSE) in my Pass,
i am getting this error.
From Ogre.log
Code: Select all
Ogre: High-level program '612cf422ed8f582b7e98591a476c3396_VS' is not supported: Cannot compile D3D11 high-level shader 612cf422ed8f582b7e98591a476c3396_VS Errors:
(58,2): warning X3206: 'FFP_Modulate': implicit truncation of vector type
(58,2): warning X3206: 'FFP_Modulate': implicit truncation of vector type
(58,2): error X3025: out parameters require l-value arguments (given argument is implicitly const, such as a global)
Code: Select all
//-----------------------------------------------------------------------------
// Program Type: Vertex shader
// Language: hlsl
// Created by Ogre RT Shader Generator. All rights reserved.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// PROGRAM DEPENDENCIES
//-----------------------------------------------------------------------------
#include "FFPLib_Transform.hlsl"
#include "FFPLib_Common.hlsl"
#include "FFPLib_Lighting.hlsl"
#include "FFPLib_Texturing.hlsl"
#include "FFPLib_Fog.hlsl"
//-----------------------------------------------------------------------------
// GLOBAL PARAMETERS
//-----------------------------------------------------------------------------
float4x4 worldviewproj_matrix;
float4x4 inverse_transpose_worldview_matrix;
float4 ambient_light_colour;
float4 surface_ambient_colour;
float4 surface_specular_colour;
float4 surface_emissive_colour;
float4 derived_scene_colour;
float surface_shininess;
float4 light_position_view_space0;
float4 light_diffuse1;
float4 gFogParams2;
//-----------------------------------------------------------------------------
// Function Name: main
// Function Desc: Vertex Program Entry point
//-----------------------------------------------------------------------------
void main
(
in float4 iPos_0 : POSITION,
in float4 iColor_0 : COLOR,
in float3 iNormal_0 : NORMAL,
out float4 oPos_0 : SV_Position,
out float4 oColor_0 : COLOR,
out float oTexcoord1_0 : TEXCOORD0
)
{
float4 lLocalParam_0;
FFP_Transform(worldviewproj_matrix, iPos_0, oPos_0);
FFP_Assign(iColor_0, oColor_0);
FFP_Construct(0.0, 0.0, 0.0, 0.0, lLocalParam_0);
FFP_Modulate(ambient_light_colour, iColor_0, oColor_0);
FFP_Add(surface_emissive_colour, oColor_0, oColor_0);
FFP_Modulate(iColor_0.xyz, light_diffuse1.xyz, light_diffuse1.xyz);
FFP_Light_Directional_Diffuse(inverse_transpose_worldview_matrix, iNormal_0, light_position_view_space0.xyz, light_diffuse1.xyz, oColor_0.xyz, oColor_0.xyz);
FFP_VertexFog_Exp(worldviewproj_matrix, iPos_0, gFogParams2, oTexcoord1_0);
}
Code: Select all
//create material...................
Ogre::MaterialManager& MatMgr = Ogre::MaterialManager::getSingleton();
auto MatResult = MatMgr.createOrRetrieve(MaterialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
if(MatResult.second)
{
Ogre::MaterialPtr MaterialBasis = Ogre::static_pointer_cast<Ogre::Material>(MatResult.first);
MaterialBasis->setCullingMode(Ogre::CULL_NONE);
MaterialBasis->compile();
Ogre::Pass* PassSurface = MaterialBasis->getBestTechnique()->getPass(0);
if(PassSurface)
{
// PassSurface->setLightingEnabled(false); // ok
// PassSurface->setVertexColourTracking(Ogre::TVC_DIFFUSE); // ok
//or
// PassSurface->setLightingEnabled(true); // ok
// PassSurface->setVertexColourTracking(Ogre::TVC_AMBIENT); // ok
// but not........
PassSurface->setLightingEnabled(true); // crash
PassSurface->setVertexColourTracking(Ogre::TVC_DIFFUSE); // crash
}
MaterialBasis->load();
//now make the shader................
Ogre::RTShader::ShaderGenerator* ShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
ShaderGenerator->createShaderBasedTechnique( MaterialName,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::MaterialManager::DEFAULT_SCHEME_NAME,
Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
//next line throws the exception............
ShaderGenerator->validateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, MaterialName);
}
After googling for error X3025. I guess that the RTSS is generating older code then version HLSL_4.0.
Setting the D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY could maybe solve the problem, but how to tell Ogre?
Is this a bug in RTSS?
Or am i complete wrong and setting setLightingEnabled(true) and setVertexColourTracking(Ogre::TVC_DIFFUSE) is a bad idea for some reasons?