mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Full Template for ticket #1
This commit is contained in:
parent
74f265b3b3
commit
f439dc8dcd
2150 changed files with 286240 additions and 0 deletions
45
Templates/Full/game/shaders/common/terrain/blendP.hlsl
Normal file
45
Templates/Full/game/shaders/common/terrain/blendP.hlsl
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "terrain.hlsl"
|
||||
|
||||
struct ConnectData
|
||||
{
|
||||
float4 hpos : POSITION;
|
||||
float2 layerCoord : TEXCOORD0;
|
||||
float2 texCoord : TEXCOORD1;
|
||||
};
|
||||
|
||||
float4 main( ConnectData IN,
|
||||
uniform sampler2D layerTex : register(S0),
|
||||
uniform sampler2D textureMap : register(S1),
|
||||
uniform float texId,
|
||||
uniform float layerSize ) : COLOR
|
||||
{
|
||||
float4 layerSample = round( tex2D( layerTex, IN.layerCoord ) * 255.0f );
|
||||
|
||||
float blend = calcBlend( texId, IN.layerCoord, layerSize, layerSample );
|
||||
|
||||
clip( blend - 0.0001 );
|
||||
|
||||
return float4( tex2D( textureMap, IN.texCoord ).rgb, blend );
|
||||
}
|
||||
49
Templates/Full/game/shaders/common/terrain/blendV.hlsl
Normal file
49
Templates/Full/game/shaders/common/terrain/blendV.hlsl
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/// The vertex shader used in the generation and caching of the
|
||||
/// base terrain texture.
|
||||
|
||||
struct VertData
|
||||
{
|
||||
float3 position : POSITION;
|
||||
float2 texCoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct ConnectData
|
||||
{
|
||||
float4 hpos : POSITION;
|
||||
float2 layerCoord : TEXCOORD0;
|
||||
float2 texCoord : TEXCOORD1;
|
||||
};
|
||||
|
||||
ConnectData main( VertData IN,
|
||||
uniform float2 texScale : register(C0) )
|
||||
{
|
||||
ConnectData OUT;
|
||||
|
||||
OUT.hpos = float4( IN.position.xyz, 1 );
|
||||
OUT.layerCoord = IN.texCoord;
|
||||
OUT.texCoord = IN.texCoord * texScale;
|
||||
|
||||
return OUT;
|
||||
}
|
||||
44
Templates/Full/game/shaders/common/terrain/gl/blendP.glsl
Normal file
44
Templates/Full/game/shaders/common/terrain/gl/blendP.glsl
Normal 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "../terrain.glsl"
|
||||
#include "../../gl/hlslCompat.glsl"
|
||||
|
||||
varying vec2 layerCoord;
|
||||
varying vec2 texCoord;
|
||||
|
||||
uniform sampler2D layerTex;
|
||||
uniform sampler2D textureMap;
|
||||
uniform float texId;
|
||||
uniform float layerSize;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 layerSample = round(texture2D( layerTex, layerCoord ) * 255.0);
|
||||
|
||||
float blend = calcBlend( texId, layerCoord, layerSize, layerSample );
|
||||
|
||||
if(blend - 0.0001 < 0.0)
|
||||
discard;
|
||||
|
||||
gl_FragColor = vec4( texture2D( textureMap, texCoord ).rgb, blend );
|
||||
}
|
||||
36
Templates/Full/game/shaders/common/terrain/gl/blendV.glsl
Normal file
36
Templates/Full/game/shaders/common/terrain/gl/blendV.glsl
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/// The vertex shader used in the generation and caching of the
|
||||
/// base terrain texture.
|
||||
|
||||
varying vec2 layerCoord;
|
||||
varying vec2 texCoord;
|
||||
|
||||
uniform vec2 texScale;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(gl_Vertex.xyz, 1.0);
|
||||
layerCoord = gl_MultiTexCoord0.st;
|
||||
texCoord = gl_MultiTexCoord0.st * texScale;
|
||||
}
|
||||
50
Templates/Full/game/shaders/common/terrain/terrain.glsl
Normal file
50
Templates/Full/game/shaders/common/terrain/terrain.glsl
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
float calcBlend( float texId, vec2 layerCoord, float layerSize, vec4 layerSample )
|
||||
{
|
||||
// This is here to disable the blend if none of
|
||||
// the neighbors equal the current id.
|
||||
//
|
||||
// We depend on the input layer samples being
|
||||
// rounded to the correct integer ids.
|
||||
//
|
||||
vec4 diff = clamp( abs( layerSample - texId ), 0.0, 1.0 );
|
||||
float noBlend = float(any( bvec4(1 - diff) ));
|
||||
|
||||
// Use step to see if any of the layer samples
|
||||
// match the current texture id.
|
||||
vec4 factors = step( texId, layerSample );
|
||||
|
||||
// This is a custom bilinear filter.
|
||||
|
||||
vec2 uv = layerCoord * layerSize;
|
||||
vec2 xy = floor( uv );
|
||||
vec2 ratio = uv - xy;
|
||||
vec2 opposite = 1 - ratio;
|
||||
|
||||
float blend = ( factors.b * opposite.x + factors.g * ratio.x ) * opposite.y +
|
||||
( factors.r * opposite.x + factors.a * ratio.x ) * ratio.y;
|
||||
|
||||
return noBlend * blend;
|
||||
}
|
||||
51
Templates/Full/game/shaders/common/terrain/terrain.hlsl
Normal file
51
Templates/Full/game/shaders/common/terrain/terrain.hlsl
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
float calcBlend( float texId, float2 layerCoord, float layerSize, float4 layerSample )
|
||||
{
|
||||
// This is here to disable the blend if none of
|
||||
// the neighbors equal the current id.
|
||||
//
|
||||
// We depend on the input layer samples being
|
||||
// rounded to the correct integer ids.
|
||||
//
|
||||
float4 diff = saturate( abs( layerSample - texId ) );
|
||||
float noBlend = any( 1 - diff );
|
||||
|
||||
// Use step to see if any of the layer samples
|
||||
// match the current texture id.
|
||||
float4 factors = step( texId, layerSample );
|
||||
|
||||
// This is a custom bilinear filter.
|
||||
|
||||
float2 uv = layerCoord * layerSize;
|
||||
float2 xy = floor( uv );
|
||||
float2 ratio = uv - xy;
|
||||
float2 opposite = 1 - ratio;
|
||||
|
||||
// NOTE: This will optimize down to two lerp operations.
|
||||
float blend = ( factors.b * opposite.x + factors.g * ratio.x ) * opposite.y +
|
||||
( factors.r * opposite.x + factors.a * ratio.x ) * ratio.y;
|
||||
|
||||
return noBlend * blend;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue