本文整理汇总了C#中Axiom.Graphics.GpuProgramParameters类的典型用法代码示例。如果您正苦于以下问题:C# GpuProgramParameters类的具体用法?C# GpuProgramParameters怎么用?C# GpuProgramParameters使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GpuProgramParameters类属于Axiom.Graphics命名空间,在下文中一共展示了GpuProgramParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UniformParameter
public UniformParameter( GpuProgramParameters.AutoConstantType autoConstantType, Real autoConstantData, int size,
GpuProgramParameters.GpuConstantType type )
: base(
Parameter.AutoParameters[ autoConstantType ].Type, Parameter.AutoParameters[ autoConstantType ].Name,
SemanticType.Unknown, -1, ContentType.Unknown, size )
{
AutoShaderParameter parameterDef = Parameter.AutoParameters[ autoConstantType ];
_name = parameterDef.Name;
if ( autoConstantData != 0.0 )
{
_name += autoConstantData.ToString();
//replace possible illegal point character in name
_name = _name.Replace( '.', '_' );
}
_type = type;
_semantic = SemanticType.Unknown;
_index = -1;
_content = Parameter.ContentType.Unknown;
this.isAutoConstantReal = true;
this.isAutoConstantInt = false;
this.autoConstantType = autoConstantType;
this.autoConstantRealData = autoConstantData;
this.variability = (int)GpuProgramParameters.GpuParamVariability.Global;
this._params = null;
this.physicalIndex = -1;
_size = size;
}
示例2: BindParameters
public override void BindParameters(GpuProgramParameters parameters)
{
// activate the link program object
GLSLLinkProgram linkProgram = GLSLLinkProgramManager.Instance.ActiveLinkProgram;
// pass on parameters from params to program object uniforms
linkProgram.UpdateUniforms(parameters);
}
示例3: SetConstantFloatArray
public void SetConstantFloatArray()
{
float[] expected = new[] { (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom(), (float)Utility.SymmetricRandom() };
float[] actual;
GpuProgramParameters parameters = new GpuProgramParameters();
//var floatLogical = new GpuLogicalBufferStruct();
//parameters._setLogicalIndexes( floatLogical, new GpuLogicalBufferStruct() );
parameters.SetConstant( 0, expected );
Assert.IsTrue( parameters.GetFloatConstant( 0 ).isSet );
actual = parameters.GetFloatConstant( 0 ).val;
Assert.AreEqual( expected, actual );
}
示例4: BindParameters
/// <summary>
/// Binds named parameters to fp30 programs.
/// </summary>
/// <param name="parms"></param>
public override void BindParameters(GpuProgramParameters parms)
{
if(parms.HasFloatConstants) {
for(int index = 0; index < parms.FloatConstantCount; index++) {
string name = parms.GetNameByIndex(index);
if(name != null) {
GpuProgramParameters.FloatConstantEntry entry = parms.GetFloatConstant(index);
// send the params 4 at a time
Gl.glProgramNamedParameter4fvNV(programId, name.Length, name, entry.val);
}
}
}
}
示例5: BindParameters
/// <summary>
/// Called to pass parameters to the Nvparse program.
/// </summary>
/// <param name="parms"></param>
public override void BindParameters(GpuProgramParameters parms)
{
// Register combiners uses 2 constants per texture stage (0 and 1)
// We have stored these as (stage * 2) + const_index
if(parms.HasFloatConstants) {
for(int index = 0; index < parms.FloatConstantCount; index++) {
GpuProgramParameters.FloatConstantEntry entry = parms.GetFloatConstant(index);
if(entry.isSet) {
int combinerStage = Gl.GL_COMBINER0_NV + (index / 2);
int pname = Gl.GL_CONSTANT_COLOR0_NV + (index % 2);
// send the params 4 at a time
Gl.glCombinerStageParameterfvNV(combinerStage, pname, entry.val);
}
}
}
}
示例6: ResolveAutoParameterReal
/// <summary>
/// Resolve uniform auto constant parameter with associated real data of this program
/// </summary>
/// <param name="autoType"> The auto type of the desired parameter </param>
/// <param name="data"> The data to associate with the auto parameter </param>
/// <param name="size"> number of elements in the parameter </param>
/// <returns> parameter instance in case of that resolve operation succeeded, otherwise null </returns>
public UniformParameter ResolveAutoParameterReal( GpuProgramParameters.AutoConstantType autoType, Real data,
int size )
{
UniformParameter param = null;
//check if parameter already exists.
param = GetParameterByAutoType( autoType );
if ( param != null )
{
if ( param.IsAutoConstantRealParameter && param.AutoConstantRealData == data )
{
param.Size = Axiom.Math.Utility.Max( size, param.Size );
return param;
}
}
//Create new parameter
param = new UniformParameter( autoType, data, size );
AddParameter( param );
return param;
}
示例7: InitShadowDebugPass
private void InitShadowDebugPass()
{
Material matDebug = (Material)MaterialManager.Instance[ SHADOW_VOLUMES_MATERIAL ];
if ( matDebug == null )
{
// Create
matDebug =
(Material)
MaterialManager.Instance.Create( SHADOW_VOLUMES_MATERIAL,
ResourceGroupManager.InternalResourceGroupName );
this.shadowDebugPass = matDebug.GetTechnique( 0 ).GetPass( 0 );
this.shadowDebugPass.SetSceneBlending( SceneBlendType.Add );
this.shadowDebugPass.LightingEnabled = false;
this.shadowDebugPass.DepthWrite = false;
TextureUnitState t = this.shadowDebugPass.CreateTextureUnitState();
t.SetColorOperationEx(
LayerBlendOperationEx.Modulate,
LayerBlendSource.Manual,
LayerBlendSource.Current,
new ColorEx( 0.7f, 0.0f, 0.2f ) );
this.shadowDebugPass.CullingMode = CullingMode.None;
if ( this.targetRenderSystem.Capabilities.HasCapability( Capabilities.VertexPrograms ) )
{
ShadowVolumeExtrudeProgram.Initialize();
// Enable the (infinite) point light extruder for now, just to get some params
this.shadowDebugPass.SetVertexProgram(
ShadowVolumeExtrudeProgram.GetProgramName( ShadowVolumeExtrudeProgram.Programs.PointLight ) );
this.infiniteExtrusionParams = this.shadowDebugPass.VertexProgramParameters;
this.infiniteExtrusionParams.SetAutoConstant( 0, GpuProgramParameters.AutoConstantType.WorldViewProjMatrix );
this.infiniteExtrusionParams.SetAutoConstant( 4, GpuProgramParameters.AutoConstantType.LightPositionObjectSpace );
// Note ignored extra parameter - for compatibility with finite extrusion vertex program
this.infiniteExtrusionParams.SetAutoConstant( 5, GpuProgramParameters.AutoConstantType.ShadowExtrusionDistance );
}
matDebug.Compile();
}
else
{
this.shadowDebugPass = matDebug.GetTechnique( 0 ).GetPass( 0 );
if ( this.targetRenderSystem.Capabilities.HasCapability( Capabilities.VertexPrograms ) )
{
this.infiniteExtrusionParams = this.shadowDebugPass.VertexProgramParameters;
}
}
}
示例8: UpdateCustomGpuParameter
public void UpdateCustomGpuParameter( GpuProgramParameters.AutoConstantEntry entry, GpuProgramParameters gpuParams )
{
if ( customParams[ entry.Data ] != null )
{
gpuParams.SetConstant( entry.PhysicalIndex, (Vector4)customParams[ entry.Data ] );
}
}
示例9: BindProgramParameters
public override void BindProgramParameters( GpuProgramParameters parms, GpuProgramParameters.GpuParamVariability mask )
{
var type = programType;
// only supports float constants
var floatStruct = parms.FloatLogicalBufferStruct;
foreach ( var i in floatStruct.Map )
{
if ( ( i.Value.Variability & mask ) != 0 )
{
var logicalIndex = i.Key;
var pFloat = parms.GetFloatConstantList();
var ptr = i.Value.PhysicalIndex;
{
for ( var j = 0; j < i.Value.CurrentSize; j += 4 )
{
var x = pFloat[ ptr + j ];
var y = pFloat[ ptr + j + 1 ];
var z = pFloat[ ptr + j + 2 ];
var w = pFloat[ ptr + j + 3 ];
Gl.glProgramLocalParameter4fARB( type, logicalIndex, x, y, z, w );
++logicalIndex;
}
}
}
}
}
示例10: UpdateCustomGpuParameter
/// <summary>
/// Update a custom GpuProgramParameters constant which is derived from
/// information only this Renderable knows.
/// </summary>
/// <remarks>
/// This method allows a Renderable to map in a custom GPU program parameter
/// based on it's own data. This is represented by a GPU auto parameter
/// of AutoConstants.Custom, and to allow there to be more than one of these per
/// Renderable, the 'data' field on the auto parameter will identify
/// which parameter is being updated. The implementation of this method
/// must identify the parameter being updated, and call a 'SetConstant'
/// method on the passed in <see cref="GpuProgramParameters"/> object, using the details
/// provided in the incoming auto constant setting to identify the index
/// at which to set the parameter.
/// </remarks>
/// <param name="constant">The auto constant entry referring to the parameter being updated.</param>
/// <param name="parameters">The parameters object which this method should call to set the updated parameters.</param>
public void UpdateCustomGpuParameter(GpuProgramParameters.AutoConstantEntry constant, GpuProgramParameters parameters)
{
}
示例11: PopulateParameterNames
protected override void PopulateParameterNames( GpuProgramParameters parms )
{
parms.NamedConstants = ConstantDefinitions;
// Don't set logical / physical maps here, as we can't access parameters by logical index in GLHL.
}
示例12: UpdateUniforms
/// <summary>
/// Updates program object uniforms using data from GpuProgramParameters.
/// normally called by GLSLGpuProgram.BindParameters() just before rendering occurs.
/// </summary>
/// <param name="parameters">GPU Parameters to use to update the uniforms params.</param>
public void UpdateUniforms(GpuProgramParameters parameters)
{
for(int i = 0; i < uniformReferences.Count; i++) {
UniformReference uniformRef = (UniformReference)uniformReferences[i];
GpuProgramParameters.FloatConstantEntry currentFloatEntry = null;
GpuProgramParameters.IntConstantEntry currentIntEntry = null;
if(uniformRef.isFloat) {
currentFloatEntry = parameters.GetNamedFloatConstant(uniformRef.name);
if(currentFloatEntry != null) {
if(currentFloatEntry.isSet) {
switch(uniformRef.elementCount) {
case 1:
Gl.glUniform1fvARB(uniformRef.location, 1, currentFloatEntry.val);
break;
case 2:
Gl.glUniform2fvARB(uniformRef.location, 1, currentFloatEntry.val);
break;
case 3:
Gl.glUniform3fvARB(uniformRef.location, 1, currentFloatEntry.val);
break;
case 4:
Gl.glUniform4fvARB(uniformRef.location, 1, currentFloatEntry.val);
break;
} // end switch
}
}
}
else {
currentIntEntry = parameters.GetNamedIntConstant(uniformRef.name);
if(currentIntEntry != null) {
if(currentIntEntry.isSet) {
switch(uniformRef.elementCount) {
case 1:
Gl.glUniform1ivARB(uniformRef.location, 1, currentIntEntry.val);
break;
case 2:
Gl.glUniform2ivARB(uniformRef.location, 1, currentIntEntry.val);
break;
case 3:
Gl.glUniform3ivARB(uniformRef.location, 1, currentIntEntry.val);
break;
case 4:
Gl.glUniform4ivARB(uniformRef.location, 1, currentIntEntry.val);
break;
} // end switch
}
}
}
}
}
示例13: UpdateCustomGpuParameter
public void UpdateCustomGpuParameter(GpuProgramParameters.AutoConstantEntry constant, GpuProgramParameters parameters)
{
parameters.SetNamedConstant(_scaleFactorName, ScaleFactor);
parameters.SetNamedConstant(_fineBlockOriginName, FineBlockOrigin);
}
示例14: MapTypeAndElementSize
private void MapTypeAndElementSize(int cgType, bool isRegisterCombiner, GpuProgramParameters.GpuConstantDefinition def)
{
if ( isRegisterCombiner )
{
// register combiners are the only single-float entries in our buffer
def.ConstantType = GpuProgramParameters.GpuConstantType.Float1;
def.ElementSize = 1;
}
else
{
switch ( cgType )
{
case Cg.CG_FLOAT:
case Cg.CG_FLOAT1:
case Cg.CG_HALF:
case Cg.CG_HALF1:
def.ConstantType = GpuProgramParameters.GpuConstantType.Float1;
break;
case Cg.CG_FLOAT2:
case Cg.CG_HALF2:
def.ConstantType = GpuProgramParameters.GpuConstantType.Float2;
break;
case Cg.CG_FLOAT3:
case Cg.CG_HALF3:
def.ConstantType = GpuProgramParameters.GpuConstantType.Float3;
break;
case Cg.CG_FLOAT4:
case Cg.CG_HALF4:
def.ConstantType = GpuProgramParameters.GpuConstantType.Float4;
break;
case Cg.CG_FLOAT2x2:
case Cg.CG_HALF2x2:
def.ConstantType = GpuProgramParameters.GpuConstantType.Matrix_2X2;
break;
case Cg.CG_FLOAT2x3:
case Cg.CG_HALF2x3:
def.ConstantType = GpuProgramParameters.GpuConstantType.Matrix_2X3;
break;
case Cg.CG_FLOAT2x4:
case Cg.CG_HALF2x4:
def.ConstantType = GpuProgramParameters.GpuConstantType.Matrix_2X4;
break;
case Cg.CG_FLOAT3x2:
case Cg.CG_HALF3x2:
def.ConstantType = GpuProgramParameters.GpuConstantType.Matrix_3X2;
break;
case Cg.CG_FLOAT3x3:
case Cg.CG_HALF3x3:
def.ConstantType = GpuProgramParameters.GpuConstantType.Matrix_3X3;
break;
case Cg.CG_FLOAT3x4:
case Cg.CG_HALF3x4:
def.ConstantType = GpuProgramParameters.GpuConstantType.Matrix_3X4;
break;
case Cg.CG_FLOAT4x2:
case Cg.CG_HALF4x2:
def.ConstantType = GpuProgramParameters.GpuConstantType.Matrix_4X2;
break;
case Cg.CG_FLOAT4x3:
case Cg.CG_HALF4x3:
def.ConstantType = GpuProgramParameters.GpuConstantType.Matrix_4X3;
break;
case Cg.CG_FLOAT4x4:
case Cg.CG_HALF4x4:
def.ConstantType = GpuProgramParameters.GpuConstantType.Matrix_4X4;
break;
case Cg.CG_INT:
case Cg.CG_INT1:
def.ConstantType = GpuProgramParameters.GpuConstantType.Int1;
break;
case Cg.CG_INT2:
def.ConstantType = GpuProgramParameters.GpuConstantType.Int2;
break;
case Cg.CG_INT3:
def.ConstantType = GpuProgramParameters.GpuConstantType.Int3;
break;
case Cg.CG_INT4:
def.ConstantType = GpuProgramParameters.GpuConstantType.Int4;
break;
default:
def.ConstantType = GpuProgramParameters.GpuConstantType.Unknown;
break;
}
// Cg pads
def.ElementSize = GpuProgramParameters.GpuConstantDefinition.GetElementSize( def.ConstantType, true );
}
}
示例15: ChangePage
/// <summary>
///
/// </summary>
/// <param name="pageNum"></param>
protected void ChangePage( int pageNum )
{
if ( this.materialControlsContainer.Count == 0 )
{
return;
}
this.currentPage = ( pageNum == -1 ) ? ( this.currentPage + 1 )%this.numPages : pageNum;
string pageText = string.Format( "Parameters {0} / {1}", this.currentPage + 1, this.numPages );
( (Button)TrayManager.GetWidget( "PageButtonControl" ) ).Caption = pageText;
if ( this.activeMaterial != null && this.activeMaterial.SupportedTechniques.Count > 0 )
{
Technique currentTechnique = this.activeMaterial.SupportedTechniques[ 0 ];
if ( currentTechnique != null )
{
this.activePass = currentTechnique.GetPass( 0 );
if ( this.activePass != null )
{
if ( this.activePass.HasFragmentProgram )
{
this.activeFragmentProgram = this.activePass.FragmentProgram;
this.activeFragmentParameters = this.activePass.FragmentProgramParameters;
}
if ( this.activePass.HasVertexProgram )
{
this.activeVertexProgram = this.activePass.VertexProgram;
this.activeVertexParameters = this.activePass.VertexProgramParameters;
}
int activeControlCount = this.materialControlsContainer[ this.currentMaterial ].ShaderControlsCount;
int startControlIndex = this.currentPage*ControlsPerPage;
int numControls = activeControlCount - startControlIndex;
if ( numControls <= 0 )
{
this.currentPage = 0;
startControlIndex = 0;
numControls = activeControlCount;
}
for ( int i = 0; i < ControlsPerPage; i++ )
{
Slider shaderControlSlider = this.shaderControls[ i ];
if ( i < numControls )
{
shaderControlSlider.Show();
int controlIndex = startControlIndex + i;
ShaderControl activeShaderDef =
this.materialControlsContainer[ this.currentMaterial ].GetShaderControl( controlIndex );
shaderControlSlider.SetRange( activeShaderDef.MinVal, activeShaderDef.MaxVal, 50, false );
shaderControlSlider.Caption = activeShaderDef.Name;
shaderControlSlider.SliderMoved += new SliderMovedHandler( shaderControlSlider_SliderMoved );
float uniformVal = 0.0f;
switch ( activeShaderDef.Type )
{
case ShaderType.GpuVertex:
case ShaderType.GpuFragment:
{
GpuProgramParameters activeParameters = ( activeShaderDef.Type == ShaderType.GpuVertex )
? this.activeVertexParameters
: this.activeFragmentParameters;
if ( activeParameters != null )
{
throw new NotImplementedException( "Fix this" );
//int idx = activeParameters.GetParamIndex( activeShaderDef.ParamName );
//activeShaderDef.PhysicalIndex = idx;
//uniformVal = activeParameters.GetNamedFloatConstant( activeShaderDef.ParamName ).val[ activeShaderDef.ElementIndex ];
}
}
break;
case ShaderType.MatSpecular:
{
// get the specular values from the material pass
ColorEx oldSpec = this.activePass.Specular;
int x = activeShaderDef.ElementIndex;
uniformVal = x == 0 ? oldSpec.r : x == 1 ? oldSpec.g : x == 2 ? oldSpec.b : x == 3 ? oldSpec.a : 0;
}
break;
case ShaderType.MatDiffuse:
{
// get the specular values from the material pass
ColorEx oldSpec = this.activePass.Diffuse;
int x = activeShaderDef.ElementIndex;
uniformVal = x == 0 ? oldSpec.r : x == 1 ? oldSpec.g : x == 2 ? oldSpec.b : x == 3 ? oldSpec.a : 0;
}
break;
case ShaderType.MatAmbient:
{
// get the specular values from the material pass
ColorEx oldSpec = this.activePass.Ambient;
int x = activeShaderDef.ElementIndex;
//.........这里部分代码省略.........