mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 09:04:38 +00:00
Fix for Issue #94 for Cubemap render bug
This commit is contained in:
parent
9ed0f467d8
commit
eb2fd2bf5f
1 changed files with 50 additions and 42 deletions
|
|
@ -1661,18 +1661,8 @@ void ReflectCubeFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
}
|
}
|
||||||
|
|
||||||
// create cubeTrans
|
// create cubeTrans
|
||||||
Var *cubeTrans = new Var;
|
bool useInstancing = fd.features[MFT_UseInstancing];
|
||||||
cubeTrans->setType( "float3x3" );
|
Var *cubeTrans = getObjTrans( componentList, useInstancing, meta );
|
||||||
cubeTrans->setName( "cubeTrans" );
|
|
||||||
cubeTrans->uniform = true;
|
|
||||||
cubeTrans->constSortPos = cspPrimitive;
|
|
||||||
|
|
||||||
// create cubeEye position
|
|
||||||
Var *cubeEyePos = new Var;
|
|
||||||
cubeEyePos->setType( "float3" );
|
|
||||||
cubeEyePos->setName( "cubeEyePos" );
|
|
||||||
cubeEyePos->uniform = true;
|
|
||||||
cubeEyePos->constSortPos = cspPrimitive;
|
|
||||||
|
|
||||||
// cube vert position
|
// cube vert position
|
||||||
Var * cubeVertPos = new Var;
|
Var * cubeVertPos = new Var;
|
||||||
|
|
@ -1680,7 +1670,7 @@ void ReflectCubeFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
cubeVertPos->setType( "float3" );
|
cubeVertPos->setType( "float3" );
|
||||||
LangElement *cubeVertPosDecl = new DecOp( cubeVertPos );
|
LangElement *cubeVertPosDecl = new DecOp( cubeVertPos );
|
||||||
|
|
||||||
meta->addStatement( new GenOp( " @ = mul(@, @).xyz;\r\n",
|
meta->addStatement( new GenOp( " @ = mul((float3x3)@, @).xyz;\r\n",
|
||||||
cubeVertPosDecl, cubeTrans, LangElement::find( "position" ) ) );
|
cubeVertPosDecl, cubeTrans, LangElement::find( "position" ) ) );
|
||||||
|
|
||||||
// cube normal
|
// cube normal
|
||||||
|
|
@ -1692,14 +1682,32 @@ void ReflectCubeFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
meta->addStatement( new GenOp( " @ = normalize( mul(@, normalize(@)).xyz );\r\n",
|
meta->addStatement( new GenOp( " @ = normalize( mul(@, normalize(@)).xyz );\r\n",
|
||||||
cubeNormDecl, cubeTrans, inNormal ) );
|
cubeNormDecl, cubeTrans, inNormal ) );
|
||||||
|
|
||||||
|
// grab the eye position
|
||||||
|
Var *eyePos = (Var*)LangElement::find( "eyePosWorld" );
|
||||||
|
if ( !eyePos )
|
||||||
|
{
|
||||||
|
eyePos = new Var( "eyePosWorld", "float3" );
|
||||||
|
eyePos->uniform = true;
|
||||||
|
eyePos->constSortPos = cspPass;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cube position
|
||||||
|
Var * cubePos = new Var;
|
||||||
|
cubePos->setName( "cubePos" );
|
||||||
|
cubePos->setType( "float3" );
|
||||||
|
LangElement *cubePosDecl = new DecOp( cubePos );
|
||||||
|
|
||||||
|
meta->addStatement( new GenOp( " @ = float3( @[0][3], @[1][3], @[2][3] );\r\n",
|
||||||
|
cubePosDecl, cubeTrans, cubeTrans, cubeTrans ) );
|
||||||
|
|
||||||
// eye to vert
|
// eye to vert
|
||||||
Var * eyeToVert = new Var;
|
Var * eyeToVert = new Var;
|
||||||
eyeToVert->setName( "eyeToVert" );
|
eyeToVert->setName( "eyeToVert" );
|
||||||
eyeToVert->setType( "float3" );
|
eyeToVert->setType( "float3" );
|
||||||
LangElement *e2vDecl = new DecOp( eyeToVert );
|
LangElement *e2vDecl = new DecOp( eyeToVert );
|
||||||
|
|
||||||
meta->addStatement( new GenOp( " @ = @ - @;\r\n",
|
meta->addStatement( new GenOp( " @ = @ - ( @ - @ );\r\n",
|
||||||
e2vDecl, cubeVertPos, cubeEyePos ) );
|
e2vDecl, cubeVertPos, eyePos, cubePos ) );
|
||||||
|
|
||||||
// grab connector texcoord register
|
// grab connector texcoord register
|
||||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue