Script integration for Ribbons

This commit is contained in:
LukasPJ 2014-09-18 21:49:25 +02:00
parent a8a141e73c
commit 35f88a77b1
21 changed files with 458 additions and 0 deletions

View file

@ -0,0 +1,48 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// This material should work fine for uniformly colored ribbons.
//Basic ribbon shader/////////////////////////////////////////////
new ShaderData( basicRibbonShader )
{
DXVertexShaderFile = "shaders/common/ribbons/basicRibbonShaderV.hlsl";
DXPixelShaderFile = "shaders/common/ribbons/basicRibbonShaderP.hlsl";
pixVersion = 2.0;
};
singleton CustomMaterial( basicRibbonMat )
{
shader = basicRibbonShader;
version = 2.0;
emissive[0] = true;
doubleSided = true;
translucent = true;
BlendOp = AddAlpha;
translucentBlendOp = AddAlpha;
preload = true;
};

View file

@ -0,0 +1,23 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
exec("./ribbons.cs");

View file

@ -0,0 +1,44 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
datablock RibbonNodeData(DefaultRibbonNodeData)
{
timeMultiple = 1.0;
};
//ribbon data////////////////////////////////////////
datablock RibbonData(basicRibbon)
{
size[0] = 0.5;
color[0] = "1.0 0.0 0.0 1.0";
position[0] = 0.0;
size[1] = 0.0;
color[1] = "1.0 0.0 0.0 0.0";
position[1] = 1.0;
RibbonLength = 40;
fadeAwayStep = 0.1;
UseFadeOut = true;
RibbonMaterial = basicRibbonMat;
};

View file

@ -34,6 +34,7 @@ function onServerCreated()
// Load up any objects or datablocks saved to the editor managed scripts
%datablockFiles = new ArrayObject();
%datablockFiles.add( "art/ribbons/ribbonExec.cs" );
%datablockFiles.add( "art/particles/managedParticleData.cs" );
%datablockFiles.add( "art/particles/managedParticleEmitterData.cs" );
%datablockFiles.add( "art/decals/managedDecalData.cs" );

View file

@ -144,6 +144,7 @@ function onServerCreated()
// Load up any objects or datablocks saved to the editor managed scripts
%datablockFiles = new ArrayObject();
%datablockFiles.add( "art/ribbons/ribbonExec.cs" );
%datablockFiles.add( "art/particles/managedParticleData.cs" );
%datablockFiles.add( "art/particles/managedParticleEmitterData.cs" );
%datablockFiles.add( "art/decals/managedDecalData.cs" );

View file

@ -0,0 +1,18 @@
#define IN_HLSL
#include "../common/shdrConsts.h"
struct v2f
{
float2 texCoord : TEXCOORD0;
float2 shiftdata : TEXCOORD1;
float4 color : COLOR0;
};
float4 main(v2f IN) : COLOR0
{
float fade = 1.0 - abs(IN.shiftdata.y - 0.5) * 2.0;
IN.color.xyz = IN.color.xyz + pow(fade, 4) / 10;
IN.color.a = IN.color.a * fade;
return IN.color;
}

View file

@ -0,0 +1,34 @@
#define IN_HLSL
#include "../common/shdrConsts.h"
struct a2v
{
float2 texCoord : TEXCOORD0;
float2 shiftdata : TEXCOORD1;
float3 normal : NORMAL;
float4 position : POSITION;
float4 color : COLOR0;
};
struct v2f
{
float4 hpos : POSITION;
float2 texCoord : TEXCOORD0;
float2 shiftdata : TEXCOORD1;
float4 color : COLOR0;
};
uniform float4x4 modelview;
uniform float3 eyePos;
v2f main(a2v IN)
{
v2f OUT;
OUT.hpos = mul(modelview, IN.position);
OUT.color = IN.color;
OUT.texCoord = IN.texCoord;
OUT.shiftdata = IN.shiftdata;
return OUT;
}

View file

@ -862,6 +862,14 @@ function ObjectBuilderGui::buildParticleEmitterNode(%this)
%this.process();
}
function ObjectBuilderGui::buildRibbonNode(%this)
{
%this.objectClassName = "RibbonNode";
%this.addField("dataBlock", "TypeDataBlock", "datablock", "RibbonNodeData");
%this.addField("ribbon", "TypeDataBlock", "Ribbon data", "RibbonData");
%this.process();
}
function ObjectBuilderGui::buildParticleSimulation(%this)
{
%this.objectClassName = "ParticleSimulation";

View file

@ -46,6 +46,7 @@ function EWCreatorWindow::init( %this )
%this.registerMissionObject( "SFXEmitter", "Sound Emitter" );
%this.registerMissionObject( "Precipitation" );
%this.registerMissionObject( "ParticleEmitterNode", "Particle Emitter" );
%this.registerMissionObject( "RibbonNode", "Ribbon" );
// Legacy features. Users should use Ground Cover and the Forest Editor.
//%this.registerMissionObject( "fxShapeReplicator", "Shape Replicator" );

View file

@ -0,0 +1,77 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
// This material should work fine for uniformly colored ribbons.
//Basic ribbon shader/////////////////////////////////////////////
new ShaderData( basicRibbonShader )
{
DXVertexShaderFile = "shaders/common/ribbons/basicRibbonShaderV.hlsl";
DXPixelShaderFile = "shaders/common/ribbons/basicRibbonShaderP.hlsl";
pixVersion = 2.0;
};
singleton CustomMaterial( basicRibbonMat )
{
shader = basicRibbonShader;
version = 2.0;
emissive[0] = true;
doubleSided = true;
translucent = true;
BlendOp = AddAlpha;
translucentBlendOp = AddAlpha;
preload = true;
};
// This material can render a texture on top of a ribbon.
//Texture ribbon shader/////////////////////////////////////////////
new ShaderData( texRibbonShader )
{
DXVertexShaderFile = "shaders/common/ribbons/texRibbonShaderV.hlsl";
DXPixelShaderFile = "shaders/common/ribbons/texRibbonShaderP.hlsl";
pixVersion = 2.0;
};
singleton CustomMaterial( texRibbonMat )
{
shader = texRibbonShader;
version = 2.0;
emissive[0] = true;
doubleSided = true;
translucent = true;
BlendOp = AddAlpha;
translucentBlendOp = AddAlpha;
sampler["ribTex"] = "art/ribbons/ribTex.png";
preload = true;
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View file

@ -0,0 +1,23 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
exec("./ribbons.cs");

View file

@ -0,0 +1,63 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
datablock RibbonNodeData(DefaultRibbonNodeData)
{
timeMultiple = 1.0;
};
//ribbon data////////////////////////////////////////
datablock RibbonData(basicRibbon)
{
size[0] = 0.5;
color[0] = "1.0 0.0 0.0 1.0";
position[0] = 0.0;
size[1] = 0.0;
color[1] = "1.0 0.0 0.0 0.0";
position[1] = 1.0;
RibbonLength = 40;
fadeAwayStep = 0.1;
UseFadeOut = true;
RibbonMaterial = basicRibbonMat;
};
datablock RibbonData(texRibbon)
{
RibbonMaterial = texRibbonMat;
size[0] = 0.5;
color[0] = "1.0 1.0 1.0 1.0";
position[0] = 0.0;
size[1] = 0.5;
color[1] = "1.0 1.0 1.0 1.0";
position[1] = 1.0;
RibbonLength = 40;
fadeAwayStep = 0.1;
UseFadeOut = true;
tileScale = 1;
fixedTexCoords = true;
TexcoordsRelativeToDistance = true;
};

View file

@ -34,6 +34,7 @@ function onServerCreated()
// Load up any objects or datablocks saved to the editor managed scripts
%datablockFiles = new ArrayObject();
%datablockFiles.add( "art/ribbons/ribbonExec.cs" );
%datablockFiles.add( "art/particles/managedParticleData.cs" );
%datablockFiles.add( "art/particles/managedParticleEmitterData.cs" );
%datablockFiles.add( "art/decals/managedDecalData.cs" );

View file

@ -50,6 +50,7 @@ function onServerCreated()
// Load up any objects or datablocks saved to the editor managed scripts
%datablockFiles = new ArrayObject();
%datablockFiles.add( "art/ribbons/ribbonExec.cs" );
%datablockFiles.add( "art/particles/managedParticleData.cs" );
%datablockFiles.add( "art/particles/managedParticleEmitterData.cs" );
%datablockFiles.add( "art/decals/managedDecalData.cs" );

View file

@ -0,0 +1,18 @@
#define IN_HLSL
#include "../common/shdrConsts.h"
struct v2f
{
float2 texCoord : TEXCOORD0;
float2 shiftdata : TEXCOORD1;
float4 color : COLOR0;
};
float4 main(v2f IN) : COLOR0
{
float fade = 1.0 - abs(IN.shiftdata.y - 0.5) * 2.0;
IN.color.xyz = IN.color.xyz + pow(fade, 4) / 10;
IN.color.a = IN.color.a * fade;
return IN.color;
}

View file

@ -0,0 +1,34 @@
#define IN_HLSL
#include "../common/shdrConsts.h"
struct a2v
{
float2 texCoord : TEXCOORD0;
float2 shiftdata : TEXCOORD1;
float3 normal : NORMAL;
float4 position : POSITION;
float4 color : COLOR0;
};
struct v2f
{
float4 hpos : POSITION;
float2 texCoord : TEXCOORD0;
float2 shiftdata : TEXCOORD1;
float4 color : COLOR0;
};
uniform float4x4 modelview;
uniform float3 eyePos;
v2f main(a2v IN)
{
v2f OUT;
OUT.hpos = mul(modelview, IN.position);
OUT.color = IN.color;
OUT.texCoord = IN.texCoord;
OUT.shiftdata = IN.shiftdata;
return OUT;
}

View file

@ -0,0 +1,20 @@
#define IN_HLSL
#include "../common/shdrConsts.h"
#include "shaders/common/torque.hlsl"
uniform sampler2D ribTex : register(S0);
struct v2f
{
float2 texCoord : TEXCOORD0;
float2 shiftdata : TEXCOORD1;
float4 color : COLOR0;
};
float4 main(v2f IN) : COLOR0
{
float4 Tex = tex2D(ribTex,IN.texCoord);
Tex.a *= IN.color.a;
return hdrEncode(Tex);
}

View file

@ -0,0 +1,34 @@
#define IN_HLSL
#include "../common/shdrConsts.h"
struct a2v
{
float2 texCoord : TEXCOORD0;
float2 shiftdata : TEXCOORD1;
float3 normal : NORMAL;
float4 position : POSITION;
float4 color : COLOR0;
};
struct v2f
{
float4 hpos : POSITION;
float2 texCoord : TEXCOORD0;
float2 shiftdata : TEXCOORD1;
float4 color : COLOR0;
};
uniform float4x4 modelview;
uniform float3 eyePos;
v2f main(a2v IN)
{
v2f OUT;
OUT.hpos = mul(modelview, IN.position);
OUT.color = IN.color;
OUT.texCoord = IN.texCoord;
OUT.shiftdata = IN.shiftdata;
return OUT;
}

View file

@ -862,6 +862,14 @@ function ObjectBuilderGui::buildParticleEmitterNode(%this)
%this.process();
}
function ObjectBuilderGui::buildRibbonNode(%this)
{
%this.objectClassName = "RibbonNode";
%this.addField("dataBlock", "TypeDataBlock", "datablock", "RibbonNodeData");
%this.addField("ribbon", "TypeDataBlock", "Ribbon data", "RibbonData");
%this.process();
}
function ObjectBuilderGui::buildParticleSimulation(%this)
{
%this.objectClassName = "ParticleSimulation";

View file

@ -46,6 +46,7 @@ function EWCreatorWindow::init( %this )
%this.registerMissionObject( "SFXEmitter", "Sound Emitter" );
%this.registerMissionObject( "Precipitation" );
%this.registerMissionObject( "ParticleEmitterNode", "Particle Emitter" );
%this.registerMissionObject( "RibbonNode", "Ribbon" );
// Legacy features. Users should use Ground Cover and the Forest Editor.
//%this.registerMissionObject( "fxShapeReplicator", "Shape Replicator" );