本文整理汇总了C++中MultiLine类的典型用法代码示例。如果您正苦于以下问题:C++ MultiLine类的具体用法?C++ MultiLine怎么用?C++ MultiLine使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MultiLine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processPix
void TerrainParallaxMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
MultiLine *meta = new MultiLine;
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
// We need the negative tangent space view vector
// as in parallax mapping we step towards the camera.
Var *negViewTS = (Var*)LangElement::find( "negViewTS" );
if ( !negViewTS )
{
Var *inNegViewTS = (Var*)LangElement::find( "outNegViewTS" );
if ( !inNegViewTS )
{
inNegViewTS = connectComp->getElement( RT_TEXCOORD );
inNegViewTS->setName( "outNegViewTS" );
inNegViewTS->setType( "vec3" );
}
negViewTS = new Var( "negViewTS", "vec3" );
meta->addStatement( new GenOp( " @ = normalize( @ );\r\n", new DecOp( negViewTS ), inNegViewTS ) );
}
// Get the rest of our inputs.
Var *detailInfo = _getDetailIdStrengthParallax();
Var *normalMap = _getNormalMapTex();
Var *texCoord = _getInDetailCoord( componentList );
// Call the library function to do the rest.
meta->addStatement( new GenOp( " @.xy += parallaxOffset( @, @.xy, @, @.z );\r\n",
texCoord, normalMap, texCoord, negViewTS, detailInfo ) );
output = meta;
}
示例2: processVert
void NormalsOutFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
// If we have normal maps then we can count
// on it to generate the world space normal.
if ( fd.features[MFT_NormalMap] )
return;
MultiLine *meta = new MultiLine;
output = meta;
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
Var *outNormal = connectComp->getElement( RT_TEXCOORD );
outNormal->setName( "wsNormal" );
outNormal->setStructName( "OUT" );
outNormal->setType( "vec3" );
outNormal->mapsToSampler = false;
// Find the incoming vertex normal.
Var *inNormal = (Var*)LangElement::find( "normal" );
if ( inNormal )
{
// Transform the normal to world space.
Var *objTrans = getObjTrans( componentList, fd.features[MFT_UseInstancing], meta );
meta->addStatement( new GenOp( " @ = tMul( @, normalize( vec4(@, 0.0) ) ).xyz;\r\n", outNormal, objTrans, inNormal ) );
}
else
{
// If we don't have a vertex normal... just pass the
// camera facing normal to the pixel shader.
meta->addStatement( new GenOp( " @ = float3( 0.0, 0.0, 1.0 );\r\n", outNormal ) );
}
}
示例3: processVert
void TerrainParallaxMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
if ( LangElement::find( "outNegViewTS" ) )
return;
MultiLine *meta = new MultiLine;
// Grab the input position.
Var *inPos = (Var*)LangElement::find( "inPosition" );
if ( !inPos )
inPos = (Var*)LangElement::find( "position" );
// Get the object space eye position and the
// object to tangent transform.
Var *eyePos = _getUniformVar( "eyePos", "vec3" , cspPotentialPrimitive );
Var *objToTangentSpace = getOutObjToTangentSpace( componentList, meta,fd );
// Now send the negative view vector in tangent space to the pixel shader.
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
Var *outNegViewTS = connectComp->getElement( RT_TEXCOORD );
outNegViewTS->setName( "outNegViewTS" );
outNegViewTS->setType( "vec3" );
meta->addStatement( new GenOp( " @ = @ * vec3( @ - @.xyz );\r\n",
outNegViewTS, objToTangentSpace, eyePos, inPos ) );
output = meta;
}
示例4: processPix
void TerrainLightMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
// grab connector texcoord register
Var *inTex = (Var*)LangElement::find( "texCoord" );
if ( !inTex )
return;
// Get the lightmap texture.
Var *lightMap = new Var;
lightMap->setType( "sampler2D" );
lightMap->setName( "lightMapTex" );
lightMap->uniform = true;
lightMap->sampler = true;
lightMap->constNum = Var::getTexUnitNum();
MultiLine *meta = new MultiLine;
// Find or create the lightMask value which is read by
// RTLighting to mask out the lights.
//
// The first light is always the sunlight so we apply
// the shadow mask to only the first channel.
//
Var *lightMask = (Var*)LangElement::find( "lightMask" );
if ( !lightMask )
{
lightMask = new Var( "lightMask", "vec4" );
meta->addStatement( new GenOp( " @ = vec4(1);\r\n", new DecOp( lightMask ) ) );
}
meta->addStatement( new GenOp( " @[0] = tex2D( @, @.xy ).r;\r\n", lightMask, lightMap, inTex ) );
output = meta;
}
示例5: getInTexCoord
void TerrainBaseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
// grab connector texcoord register
Var *texCoord = getInTexCoord( "texCoord", "vec3", true, componentList );
// We do nothing more if this is a prepass.
if ( fd.features.hasFeature( MFT_PrePassConditioner ) )
return;
// create texture var
Var *diffuseMap = new Var;
diffuseMap->setType( "sampler2D" );
diffuseMap->setName( "baseTexMap" );
diffuseMap->uniform = true;
diffuseMap->sampler = true;
diffuseMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
MultiLine *meta = new MultiLine;
Var *baseColor = new Var;
baseColor->setType( "vec4" );
baseColor->setName( "baseColor" );
meta->addStatement( new GenOp( " @ = tex2D( @, @.xy );\r\n", new DecOp( baseColor ), diffuseMap, texCoord ) );
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul ) ) );
output = meta;
}
示例6: getOutputTargetVarName
void TerrainAdditiveFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
Var *color = NULL;
Var *normal = NULL;
if (fd.features[MFT_DeferredTerrainDetailMap])
{
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) );
normal = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::DefaultTarget) );
}
else
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::DefaultTarget) );
Var *blendTotal = (Var*)LangElement::find( "blendTotal" );
if ( !color || !blendTotal )
return;
MultiLine *meta = new MultiLine;
meta->addStatement( new GenOp( " clip( @ - 0.0001 );\r\n", blendTotal ) );
meta->addStatement( new GenOp( " @.a = @;\r\n", color, blendTotal ) );
if (normal)
meta->addStatement(new GenOp(" @.a = @;\r\n", normal, blendTotal));
output = meta;
}
示例7: processPix
void TerrainBlankInfoMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd)
{
// search for material var
Var *material;
OutputTarget targ = RenderTarget1;
if (fd.features[MFT_isDeferred])
{
targ = RenderTarget2;
}
material = (Var*)LangElement::find(getOutputTargetVarName(targ));
MultiLine * meta = new MultiLine;
if (!material)
{
// create color var
material = new Var;
material->setType("fragout");
material->setName(getOutputTargetVarName(targ));
material->setStructName("OUT");
}
meta->addStatement(new GenOp(" @ = float4(0.0,0.0,0.0,0.0001);\r\n", material));
output = meta;
}
示例8: processPix
void ParaboloidVertTransformHLSL::processPix( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
MultiLine *meta = new MultiLine;
const bool isSinglePass = fd.features[ MFT_IsSinglePassParaboloid ];
if ( isSinglePass )
{
// Cull things on the back side of the map.
Var *isBack = connectComp->getElement( RT_TEXCOORD );
isBack->setName( "isBack" );
isBack->setStructName( "IN" );
isBack->setType( "float" );
meta->addStatement( new GenOp( " clip( abs( @ ) - 0.999 );\r\n", isBack ) );
}
// Cull pixels outside of the valid paraboloid.
Var *posXY = connectComp->getElement( RT_TEXCOORD );
posXY->setName( "posXY" );
posXY->setStructName( "IN" );
posXY->setType( "float2" );
meta->addStatement( new GenOp( " clip( 1.0 - abs(@.x) );\r\n", posXY ) );
output = meta;
}
示例9: getInTexCoord
void TerrainBaseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
// grab connector texcoord register
Var *texCoord = getInTexCoord( "texCoord", "vec3", true, componentList );
// create texture var
Var *diffuseMap = new Var;
diffuseMap->setType( "sampler2D" );
diffuseMap->setName( "baseTexMap" );
diffuseMap->uniform = true;
diffuseMap->sampler = true;
diffuseMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
MultiLine *meta = new MultiLine;
Var *baseColor = new Var;
baseColor->setType( "vec4" );
baseColor->setName( "baseColor" );
meta->addStatement( new GenOp( " @ = tex2D( @, @.xy );\r\n", new DecOp( baseColor ), diffuseMap, texCoord ) );
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", baseColor, baseColor));
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
if(fd.features.hasFeature(MFT_isDeferred))
{
target= ShaderFeature::RenderTarget1;
}
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul,NULL,target ) ) );
output = meta;
}
示例10: processVert
void EyeSpaceDepthOutHLSL::processVert( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
MultiLine *meta = new MultiLine;
output = meta;
// grab output
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
Var *outWSEyeVec = connectComp->getElement( RT_TEXCOORD );
outWSEyeVec->setName( "wsEyeVec" );
outWSEyeVec->setStructName( "OUT" );
// grab incoming vert position
Var *wsPosition = new Var( "depthPos", "float3" );
getWsPosition( componentList, fd.features[MFT_UseInstancing], meta, new DecOp( wsPosition ) );
Var *eyePos = (Var*)LangElement::find( "eyePosWorld" );
if( !eyePos )
{
eyePos = new Var;
eyePos->setType("float3");
eyePos->setName("eyePosWorld");
eyePos->uniform = true;
eyePos->constSortPos = cspPass;
}
meta->addStatement( new GenOp( " @ = float4( @.xyz - @, 1 );\r\n", outWSEyeVec, wsPosition, eyePos ) );
}
示例11: getProcessIndex
void TerrainMacroMapFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
const S32 detailIndex = getProcessIndex();
// Grab incoming texture coords... the base map feature
// made sure this was created.
Var *inTex = (Var*)LangElement::find( "texCoord" );
AssertFatal( inTex, "The texture coord is missing!" );
// Grab the input position.
Var *inPos = (Var*)LangElement::find( "inPosition" );
if ( !inPos )
inPos = (Var*)LangElement::find( "position" );
// Get the object space eye position.
Var *eyePos = _getUniformVar( "eyePos", "float3", cspPotentialPrimitive );
MultiLine *meta = new MultiLine;
// Get the distance from the eye to this vertex.
Var *dist = (Var*)LangElement::find( "macroDist" );
if ( !dist )
{
dist = new Var;
dist->setType( "float" );
dist->setName( "macroDist" );
meta->addStatement( new GenOp( " @ = distance( @.xyz, @ );\r\n",
new DecOp( dist ), inPos, eyePos ) );
}
// grab connector texcoord register
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
Var *outTex = connectComp->getElement( RT_TEXCOORD );
outTex->setName( String::ToString( "macroCoord%d", detailIndex ) );
outTex->setStructName( "OUT" );
outTex->setType( "float4" );
outTex->mapsToSampler = true;
// Get the detail scale and fade info.
Var *detScaleAndFade = new Var;
detScaleAndFade->setType( "float4" );
detScaleAndFade->setName( String::ToString( "macroScaleAndFade%d", detailIndex ) );
detScaleAndFade->uniform = true;
detScaleAndFade->constSortPos = cspPotentialPrimitive;
// Setup the detail coord.
meta->addStatement( new GenOp( " @.xyz = @ * @.xyx;\r\n", outTex, inTex, detScaleAndFade ) );
// And sneak the detail fade thru the w detailCoord.
meta->addStatement( new GenOp( " @.w = clamp( ( @.z - @ ) * @.w, 0.0, 1.0 );\r\n",
outTex, detScaleAndFade, dist, detScaleAndFade ) );
output = meta;
}
示例12: AssertFatal
void ParallaxFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
AssertFatal( GFX->getPixelShaderVersion() >= 2.0,
"ParallaxFeatGLSL::processVert - We don't support SM 1.x!" );
MultiLine *meta = new MultiLine;
// Add the texture coords.
getOutTexCoord( "texCoord",
"vec2",
true,
fd.features[MFT_TexAnim],
meta,
componentList );
// Grab the input position.
Var *inPos = (Var*)LangElement::find( "inPosition" );
if ( !inPos )
inPos = (Var*)LangElement::find( "position" );
// Get the object space eye position and the
// object to tangent space transform.
Var *eyePos = _getUniformVar( "eyePos", "vec3", cspPrimitive );
Var *objToTangentSpace = getOutObjToTangentSpace( componentList, meta, fd );
// Now send the negative view vector in tangent space to the pixel shader.
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
Var *outNegViewTS = connectComp->getElement( RT_TEXCOORD );
outNegViewTS->setName( "outNegViewTS" );
outNegViewTS->setStructName( "OUT" );
outNegViewTS->setType( "vec3" );
meta->addStatement( new GenOp( " @ = tMul( @, float3( @.xyz - @ ) );\r\n",
outNegViewTS, objToTangentSpace, inPos, eyePos ) );
// TODO: I'm at a loss at why i need to flip the binormal/y coord
// to get a good view vector for parallax. Lighting works properly
// with the TS matrix as is... but parallax does not.
//
// Someone figure this out!
//
meta->addStatement( new GenOp( " @.y = [email protected];\r\n", outNegViewTS, outNegViewTS ) );
// If we have texture anim matrix the tangent
// space view vector may need to be rotated.
Var *texMat = (Var*)LangElement::find( "texMat" );
if ( texMat )
{
meta->addStatement( new GenOp( " @ = tMul(@, float4(@,0)).xyz;\r\n",
outNegViewTS, texMat, outNegViewTS ) );
}
output = meta;
}
示例13: AssertFatal
void ParallaxFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
AssertFatal( GFX->getPixelShaderVersion() >= 2.0,
"ParallaxFeatGLSL::processPix - We don't support SM 1.x!" );
MultiLine *meta = new MultiLine;
// Order matters... get this first!
Var *texCoord = getInTexCoord( "texCoord", "vec2", true, componentList );
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
// We need the negative tangent space view vector
// as in parallax mapping we step towards the camera.
Var *negViewTS = (Var*)LangElement::find( "negViewTS" );
if ( !negViewTS )
{
Var *inNegViewTS = (Var*)LangElement::find( "outNegViewTS" );
if ( !inNegViewTS )
{
inNegViewTS = connectComp->getElement( RT_TEXCOORD );
inNegViewTS->setName( "outNegViewTS" );
inNegViewTS->setStructName( "IN" );
inNegViewTS->setType( "vec3" );
}
negViewTS = new Var( "negViewTS", "vec3" );
meta->addStatement( new GenOp( " @ = normalize( @ );\r\n", new DecOp( negViewTS ), inNegViewTS ) );
}
// Get the rest of our inputs.
Var *parallaxInfo = _getUniformVar( "parallaxInfo", "float", cspPotentialPrimitive );
Var *normalMap = getNormalMapTex();
// Call the library function to do the rest.
if (fd.features.hasFeature(MFT_IsDXTnm, getProcessIndex()))
{
meta->addStatement(new GenOp(" @.xy += parallaxOffsetDxtnm( @, @.xy, @, @ );\r\n",
texCoord, normalMap, texCoord, negViewTS, parallaxInfo));
}
else
{
meta->addStatement(new GenOp(" @.xy += parallaxOffset( @, @.xy, @, @ );\r\n",
texCoord, normalMap, texCoord, negViewTS, parallaxInfo));
}
// TODO: Fix second UV maybe?
output = meta;
}
示例14: GraphicsInitialize
/*
* Primordial root object creation and initialization function. A pointer
* to this function is passed to the object manager constructor.
*/
void GraphicsInitialize (RefList* root) {
Picture* pict = new Picture;
FullGraphic dfault;
InitPPaint();
root->Append(new RefList(pict));
dfault.FillBg(true);
dfault.SetColors(pblack, pwhite);
dfault.SetPattern(psolid);
dfault.SetBrush(psingle);
dfault.SetFont(pstdfont);
Line* line = new Line (0, 0, 75, 75, &dfault);
MultiLine* multiline = new MultiLine (x, y, 6, &dfault);
BSpline* spline = new BSpline (x, y, 6, &dfault);
Rect* rect = new Rect (0, 0, 100, 100, &dfault);
FillRect* frect = new FillRect (0, 0, 100, 100, &dfault);
Circle* circle = new Circle (0, 0, 50, &dfault);
FillCircle* fcircle = new FillCircle (0, 0, 50, &dfault);
Polygon* poly = new Polygon (x, y, 6, &dfault);
FillPolygon* fpoly = new FillPolygon (x, y, 6, &dfault);
ClosedBSpline* cspline = new ClosedBSpline (x, y, 6, &dfault);
FillBSpline* fspline = new FillBSpline (x, y, 6, &dfault);
Label* label = new Label ("Type 'q' to quit this program.", &dfault);
Stencil* stencil = new Stencil(new Bitmap(iv_bits, iv_width, iv_height));
RasterRect* raster = new RasterRect(CreateRaster());
line->Translate(0, 300);
multiline->Translate(100, 300);
spline->Translate(250, 300);
rect->Translate(100, 150);
frect->Translate(100, 0);
circle->Scale(1.0, 0.6);
circle->Translate(0, 150);
fcircle->Scale(1.0, 0.6);
poly->Translate(250, 150);
fpoly->Translate(250, 0);
cspline->Translate(400, 150);
fspline->Translate(400, 0);
label->Translate(350, 175);
stencil->Translate(400, 300);
raster->Scale(5, 5);
raster->Translate(350, 350);
pict->Append(line, multiline, spline, rect);
pict->Append(frect, circle, fcircle, poly);
pict->Append(fpoly, cspline, fspline, label);
pict->Append(stencil, raster);
}
示例15: GenOp
LangElement *ConditionerFeature::assignOutput( Var *unconditionedOutput, ShaderFeature::OutputTarget outputTarget /* = ShaderFeature::DefaultTarget*/ )
{
LangElement *assign;
MultiLine *meta = new MultiLine;
meta->addStatement( new GenOp( avar( "\r\n\r\n // output buffer format: %s\r\n", GFXStringTextureFormat[getBufferFormat()] ) ) );
// condition the output
Var *conditionedOutput = _conditionOutput( unconditionedOutput, meta );
// search for color var
Var *color = (Var*) LangElement::find( getOutputTargetVarName(outputTarget) );
if ( !color )
{
// create color var
color = new Var;
if(GFX->getAdapterType() == OpenGL)
{
color->setName( getOutputTargetVarName(outputTarget) );
color->setType( "vec4" );
DecOp* colDecl = new DecOp(color);
assign = new GenOp( "@ = vec4(@)", colDecl, conditionedOutput );
}
else
{
color->setType( "fragout" );
color->setName( getOutputTargetVarName(outputTarget) );
color->setStructName( "OUT" );
assign = new GenOp( "@ = @", color, conditionedOutput );
}
}
else
{
if (GFX->getAdapterType() == OpenGL)
assign = new GenOp( "@ = vec4(@)", color, conditionedOutput);
else
assign = new GenOp( "@ = @", color, conditionedOutput );
}
meta->addStatement( new GenOp( " @;\r\n", assign ) );
return meta;
}