Hello everyone!I use “Sample V2 mesh” demo to load a V1mesh(I have forgotten the source, but I have the impression that Ogre 1.18 is available).this V1mesh have two TEXTURE_COORDINATES,one of type is float1.this is shader.
Code: Select all
#version 430 core
#extension GL_ARB_shading_language_420pack: require
out gl_PerVertex
{
vec4 gl_Position;
};
layout(std140) uniform;
struct ShadowReceiverData
{
mat4 texViewProj;
vec2 shadowDepthRange;
float normalOffsetBias;
float padding;
vec4 invShadowMapSize;
};
struct Light
{
vec4 position;
vec4 diffuse;
vec3 specular;
};
struct AreaLight
{
vec4 position;
vec4 diffuse;
vec4 specular;
vec4 attenuation;
vec4 direction;
vec4 tangent;
vec4 doubleSided;
};
struct AreaLtcLight
{
vec4 position;
vec4 diffuse;
vec4 specular;
vec4 points[4];
};
layout( std140, binding = 0 ) uniform PassBuffer
{
mat4 viewProj;
mat4 view;
mat3 invViewMatCubemap;
vec4 pccVctMinDistance_invPccVctInvDistance_rightEyePixelStartX_envMapNumMipmaps;
vec4 aspectRatio_planarReflNumMips_unused2;
vec2 invWindowRes;
vec2 windowResolution;
Light lights[1];
}
passBuf;
vec3 xAxis( vec4 qQuat )
{
float fTy = 2.0 * qQuat.y;
float fTz = 2.0 * qQuat.z;
float fTwy = fTy * qQuat.w;
float fTwz = fTz * qQuat.w;
float fTxy = fTy * qQuat.x;
float fTxz = fTz * qQuat.x;
float fTyy = fTy * qQuat.y;
float fTzz = fTz * qQuat.z;
return vec3( 1.0-(fTyy+fTzz), fTxy+fTwz, fTxz-fTwy );
}
vec3 getNormalOffsetBias( vec3 worldNormal, vec3 viewSpaceNormal,
vec3 lightDir, float shadowMapTexSize,
float depthRange, float normalOffsetBias
)
{
float tmpNdotL = clamp( (dot( lightDir.xyz, vec3( viewSpaceNormal.xyz ) )), 0.0, 1.0 );
return ( ( 1.0f - tmpNdotL ) * normalOffsetBias * vec3( worldNormal.xyz ) * shadowMapTexSize );
}
vec3 getNormalOffsetBias( vec3 worldNormal, vec3 viewSpaceNormal,
vec3 lightDir, float shadowMapTexSize,
float depthRange, float normalOffsetBias
, vec2 minUV, vec2 maxUV )
{
float tmpNdotL = clamp( (dot( lightDir.xyz, vec3( viewSpaceNormal.xyz ) )), 0.0, 1.0 );
shadowMapTexSize /= maxUV.x - minUV.x;
return ( ( 1.0f - tmpNdotL ) * normalOffsetBias * vec3( worldNormal.xyz ) * shadowMapTexSize );
}
in vec4 vertex;
in vec4 qtangent;
in vec2 uv0;
in vec1 uv1;
in uint drawId;
out block
{
flat uint drawId;
vec3 pos;
vec3 normal;
vec2 uv0;
float1 uv1;
} outVs;
layout(std430, binding = 0) readonly restrict buffer _worldMatBuf { vec4 worldMatBuf[]; };
void main()
{
const vec4 qTangent = normalize( qtangent );
vec3 inputNormal = xAxis( qTangent );
mat3x4 worldMat = mat3x4( worldMatBuf[(drawId << 1u) << 2u], worldMatBuf[((drawId << 1u) << 2u)+1u], worldMatBuf[((drawId << 1u) << 2u)+2u] );
mat4 worldView = mat4( worldMatBuf[((drawId << 1u) + 1u) << 2u], worldMatBuf[(((drawId << 1u) + 1u) << 2u)+1u], worldMatBuf[(((drawId << 1u) + 1u) << 2u)+2u], worldMatBuf[(((drawId << 1u) + 1u) << 2u)+3u] );
vec4 worldPos = vec4( ((vertex) * (worldMat)).xyz, 1.0f );
outVs.pos = ((vertex) * (worldView)).xyz;
mat3 worldMat3x3 = mat3( worldView );
outVs.normal = ((inputNormal) * (worldMat3x3));
gl_Position = ((worldPos) * (passBuf.viewProj));
vec3 normalOffsetBias = vec3( 0, 0, 0 );
outVs.uv0 = uv0;
outVs.uv1 = uv1;
outVs.drawId = drawId;
}
error log is
": GLSL compile log: 100000003VertexShader_vs
: error C0000: syntax error, unexpected identifier, expecting '{' at token "uv1" (in vec1 uv1;)
: error C7506: OpenGL does not define the global type float1 (float1 uv1;)
: error C1503: undefined variable "uv1" (outVs.uv1 = uv1;)
"
Dose Ogre-Next not support float1 TEXTURE_COORDINATES?
I tried to fix it.So I add some code in calculateHashForV2.if itElements is VES_TEXTURE_COORDINATES and mType is VET_FLOAT1 then skip.
Code: Select all
uint16 Hlms::calculateHashForV2( Renderable *renderable )
{
// TODO: Account LOD
VertexArrayObject *vao = renderable->getVaos( VpNormal )[0];
const VertexBufferPackedVec &vertexBuffers = vao->getVertexBuffers();
uint numTexCoords = 0;
uint16 semIndex[VES_COUNT];
memset( semIndex, 0, sizeof( semIndex ) );
VertexBufferPackedVec::const_iterator itor = vertexBuffers.begin();
VertexBufferPackedVec::const_iterator endt = vertexBuffers.end();
while( itor != endt )
{
const VertexElement2Vec &vertexElements = ( *itor )->getVertexElements();
VertexElement2Vec::const_iterator itElements = vertexElements.begin();
VertexElement2Vec::const_iterator enElements = vertexElements.end();
while( itElements != enElements )
{
if( itElements->mSemantic == VES_TEXTURE_COORDINATES && itElements->mType == VET_FLOAT1 )
{
++itElements;
continue;
}
calculateHashForSemantic( itElements->mSemantic, itElements->mType,
semIndex[itElements->mSemantic - 1]++, numTexCoords );
++itElements;
}
++itor;
}
// We do not allow LODs with different operation types or vertex layouts
setProperty( kNoTid, HlmsPsoProp::InputLayoutId, vao->getInputLayoutId() );
return static_cast<uint16>( numTexCoords );
}
But it doesn't seem like a good idea, is there any other way?