mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-19 14:43:47 +00:00
Merge pull request #1055 from BeamNG/fix_cubemap
Fix ShaderGen cubemap feature.
This commit is contained in:
commit
5d5303cf6d
2 changed files with 9 additions and 24 deletions
|
|
@ -1682,7 +1682,7 @@ void ReflectCubeFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
cubeVertPos->setType( "vec3" );
|
||||
LangElement *cubeVertPosDecl = new DecOp( cubeVertPos );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = tMul(mat3( @ ), @).xyz;\r\n",
|
||||
meta->addStatement( new GenOp( " @ = tMul( @, float4(@,1)).xyz;\r\n",
|
||||
cubeVertPosDecl, cubeTrans, LangElement::find( "position" ) ) );
|
||||
|
||||
// cube normal
|
||||
|
|
@ -1694,6 +1694,9 @@ void ReflectCubeFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
meta->addStatement( new GenOp( " @ = ( tMul( (@), vec4(@, 0) ) ).xyz;\r\n",
|
||||
cubeNormDecl, cubeTrans, inNormal ) );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = bool(length(@)) ? normalize(@) : @;\r\n",
|
||||
cubeNormal, cubeNormal, cubeNormal, cubeNormal ) );
|
||||
|
||||
// grab the eye position
|
||||
Var *eyePos = (Var*)LangElement::find( "eyePosWorld" );
|
||||
if ( !eyePos )
|
||||
|
|
@ -1703,23 +1706,14 @@ void ReflectCubeFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
eyePos->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
// cube position
|
||||
Var * cubePos = new Var;
|
||||
cubePos->setName( "cubePos" );
|
||||
cubePos->setType( "vec3" );
|
||||
LangElement *cubePosDecl = new DecOp( cubePos );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = vec3( @[3][0], @[3][1], @[3][2] );\r\n",
|
||||
cubePosDecl, cubeTrans, cubeTrans, cubeTrans ) );
|
||||
|
||||
// eye to vert
|
||||
Var * eyeToVert = new Var;
|
||||
eyeToVert->setName( "eyeToVert" );
|
||||
eyeToVert->setType( "vec3" );
|
||||
LangElement *e2vDecl = new DecOp( eyeToVert );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = @ - ( @ - @ );\r\n",
|
||||
e2vDecl, cubeVertPos, eyePos, cubePos ) );
|
||||
meta->addStatement( new GenOp( " @ = @ - @;\r\n",
|
||||
e2vDecl, cubeVertPos, eyePos ) );
|
||||
|
||||
// grab connector texcoord register
|
||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
||||
|
|
|
|||
|
|
@ -1681,7 +1681,7 @@ void ReflectCubeFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
cubeVertPos->setType( "float3" );
|
||||
LangElement *cubeVertPosDecl = new DecOp( cubeVertPos );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = mul((float3x3)@, @).xyz;\r\n",
|
||||
meta->addStatement( new GenOp( " @ = mul(@, float4(@,1)).xyz;\r\n",
|
||||
cubeVertPosDecl, cubeTrans, LangElement::find( "position" ) ) );
|
||||
|
||||
// cube normal
|
||||
|
|
@ -1702,23 +1702,14 @@ void ReflectCubeFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
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
|
||||
Var * eyeToVert = new Var;
|
||||
eyeToVert->setName( "eyeToVert" );
|
||||
eyeToVert->setType( "float3" );
|
||||
LangElement *e2vDecl = new DecOp( eyeToVert );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = @ - ( @ - @ );\r\n",
|
||||
e2vDecl, cubeVertPos, eyePos, cubePos ) );
|
||||
meta->addStatement( new GenOp( " @ = @ - @;\r\n",
|
||||
e2vDecl, cubeVertPos, eyePos ) );
|
||||
|
||||
// grab connector texcoord register
|
||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue