Init
This commit is contained in:
111
physx/samples/sampleframework/media/shaders/vertex/cmd_dx11.bat
Normal file
111
physx/samples/sampleframework/media/shaders/vertex/cmd_dx11.bat
Normal file
@ -0,0 +1,111 @@
|
||||
::
|
||||
:: Redistribution and use in source and binary forms, with or without
|
||||
:: modification, are permitted provided that the following conditions
|
||||
:: are met:
|
||||
:: * Redistributions of source code must retain the above copyright
|
||||
:: notice, this list of conditions and the following disclaimer.
|
||||
:: * Redistributions in binary form must reproduce the above copyright
|
||||
:: notice, this list of conditions and the following disclaimer in the
|
||||
:: documentation and/or other materials provided with the distribution.
|
||||
:: * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
:: contributors may be used to endorse or promote products derived
|
||||
:: from this software without specific prior written permission.
|
||||
::
|
||||
:: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
:: EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
:: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
:: PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
:: CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
:: EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
:: PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
:: PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
:: OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
:: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
:: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
::
|
||||
:: Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
cd ../../
|
||||
mkdir compiledshaders
|
||||
cd compiledshaders
|
||||
mkdir dx11feature11
|
||||
cd dx11feature11
|
||||
mkdir vertex
|
||||
mkdir geometry
|
||||
cd ..
|
||||
mkdir dx11feature9
|
||||
cd dx11feature9
|
||||
mkdir vertex
|
||||
cd ../../shaders/vertex
|
||||
|
||||
CALL :SHADER staticmesh
|
||||
CALL :SHADER mouse
|
||||
CALL :SHADER particle_fog
|
||||
CALL :SHADER pointsprite
|
||||
CALL :SHADER pointsprite2
|
||||
CALL :SHADER screenquad
|
||||
CALL :SHADER skeletalmesh_1bone
|
||||
CALL :SHADER skeletalmesh_4bone
|
||||
CALL :SHADER staticmesh
|
||||
CALL :SHADER text
|
||||
CALL :SHADER turbulencesprites
|
||||
CALL :GEOMETRYSHADER pointsprite
|
||||
exit /b
|
||||
|
||||
:SHADER
|
||||
|
||||
CALL :COMPILE %1 %1
|
||||
set inputDef=/DUSE_POSITION=1 /DUSE_COLOR=1
|
||||
set inputDefName=POSITION_COLOR
|
||||
CALL :INPUT_COMPILE %1 %1 %inputDefName%
|
||||
set inputDef=/DUSE_POSITION=1 /DUSE_COLOR=1 /DUSE_TEXCOORD0=1
|
||||
set inputDefName=POSITION_COLOR_TEXCOORD0
|
||||
CALL :INPUT_COMPILE %1 %1 %inputDefName%
|
||||
set inputDef=/DUSE_POSITION=1 /DUSE_NORMAL=1 /DUSE_TEXCOORD0=1
|
||||
set inputDefName=POSITION_NORMAL_TEXCOORD0
|
||||
CALL :INPUT_COMPILE %1 %1 %inputDefName%
|
||||
set inputDef=/DUSE_POSITION=1 /DUSE_NORMAL=1 /DUSE_TEXCOORD0=1
|
||||
set inputDefName=TEXCOORD0_POSITION_NORMAL
|
||||
CALL :INPUT_COMPILE %1 %1 %inputDefName%
|
||||
set inputDef=/DUSE_POSITION=1 /DUSE_NORMAL=1 /DUSE_TEXCOORD0=1 /DUSE_COLOR=1
|
||||
set inputDefName=NORMAL_TEXCOORD0_POSITION_COLOR
|
||||
CALL :INPUT_COMPILE %1 %1 %inputDefName%
|
||||
set inputDef=/DUSE_POSITION=1 /DUSE_NORMAL=1 /DUSE_COLOR=1
|
||||
set inputDefName=POSITION_COLOR_NORMAL
|
||||
CALL :INPUT_COMPILE %1 %1 %inputDefName%
|
||||
exit /b
|
||||
|
||||
:GEOMETRYSHADER
|
||||
|
||||
CALL :GEOMETRYCOMPILE %1 %1
|
||||
exit /b
|
||||
|
||||
:COMPILE
|
||||
set definesdx9=/DRENDERER_VERTEX=1 /DRENDERER_D3D11=1 /DPX_WINDOWS=1 /DRENDERER_INSTANCED=0 /DRENDERER_DISPLACED=0 /DENABLE_VFACE=0 /DENABLE_VFACE_SCALE=0 /DRENDERER_WIN8ARM=1 /DENABLE_TESSELLATION=0 /DADAPTIVE_TESSELLATION=0 /DSEMANTIC_TANGENT=TANGENT /DUSE_ALL=1
|
||||
set definesdx11=/DRENDERER_VERTEX=1 /DRENDERER_D3D11=1 /DPX_WINDOWS=1 /DRENDERER_INSTANCED=0 /DRENDERER_DISPLACED=0 /DENABLE_VFACE=1 /DENABLE_VFACE_SCALE=1 /DENABLE_TESSELLATION=0 /DADAPTIVE_TESSELLATION=0 /DSEMANTIC_TANGENT=TANGENT /DUSE_ALL=1
|
||||
|
||||
"fxc.exe" /E"vmain" /Zpr /Gec /I"../include" %definesdx9% /Fo"../../compiledshaders/dx11feature9/vertex/%2.cg.cso" /T vs_4_0_level_9_1 /nologo %1.cg
|
||||
if errorlevel 1 pause
|
||||
"fxc.exe" /E"vmain" /Zpr /Gec /I"../include" %definesdx11% /Fo"../../compiledshaders/dx11feature11/vertex/%2.cg.cso" /T vs_4_0 /nologo %1.cg
|
||||
if errorlevel 1 pause
|
||||
exit /b
|
||||
|
||||
:INPUT_COMPILE
|
||||
set definesdx9=/DRENDERER_VERTEX=1 /DRENDERER_D3D11=1 /DPX_WINDOWS=1 /DRENDERER_INSTANCED=0 /DRENDERER_DISPLACED=0 /DENABLE_VFACE=0 /DENABLE_VFACE_SCALE=0 /DRENDERER_WIN8ARM=1 /DENABLE_TESSELLATION=0 /DADAPTIVE_TESSELLATION=0 /DSEMANTIC_TANGENT=TANGENT
|
||||
set definesdx11=/DRENDERER_VERTEX=1 /DRENDERER_D3D11=1 /DPX_WINDOWS=1 /DRENDERER_INSTANCED=0 /DRENDERER_DISPLACED=0 /DENABLE_VFACE=1 /DENABLE_VFACE_SCALE=1 /DENABLE_TESSELLATION=0 /DADAPTIVE_TESSELLATION=0 /DSEMANTIC_TANGENT=TANGENT
|
||||
|
||||
"fxc.exe" /E"vmain" /Zpr /Gec /I"../include" %definesdx9% %inputDef% /Fo"../../compiledshaders/dx11feature9/vertex/%2.cg_%3.cso" /T vs_4_0_level_9_1 /nologo %1.cg
|
||||
if errorlevel 1 pause
|
||||
"fxc.exe" /E"vmain" /Zpr /Gec /I"../include" %definesdx11% %inputDef% /Fo"../../compiledshaders/dx11feature11/vertex/%2.cg_%3.cso" /T vs_4_0 /nologo %1.cg
|
||||
if errorlevel 1 pause
|
||||
exit /b
|
||||
|
||||
:GEOMETRYCOMPILE
|
||||
set definesdx11=/DRENDERER_GEOMETRY=1 /DRENDERER_D3D11=1 /DPX_WINDOWS=1 /DSEMANTIC_TANGENT=TANGENT /DUSE_ALL=1
|
||||
|
||||
"fxc.exe" /E"gmain" /Zpr /Gec /I"../include" %definesdx11% /Fo"../../compiledshaders/dx11feature11/geometry/%2.cg.cso" /T gs_4_0 /nologo %1.cg
|
||||
if errorlevel 1 pause
|
||||
exit /b
|
||||
|
||||
set definesdx9=
|
||||
set definesdx11=
|
||||
@ -0,0 +1,19 @@
|
||||
uniform mat4 g_modelViewMatrix;
|
||||
uniform mat4 g_projMatrix;
|
||||
|
||||
attribute vec3 position_attr;
|
||||
attribute vec3 normal_attr;
|
||||
attribute vec2 texcoord0_attr;
|
||||
|
||||
varying vec2 texcoord0;
|
||||
varying vec4 lighting;
|
||||
varying vec4 normal;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = g_projMatrix * g_modelViewMatrix * vec4(position_attr, 1.0);
|
||||
normal = normalize(g_modelViewMatrix * vec4(normal_attr, 0.0));
|
||||
float lighting_scalar = clamp(normal.z, 0.4, 1.0);
|
||||
lighting = vec4(lighting_scalar, lighting_scalar, lighting_scalar, 1.0);
|
||||
texcoord0 = texcoord0_attr;
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
uniform mat4 g_viewMatrix;
|
||||
uniform mat4 g_modelMatrix;
|
||||
uniform mat4 g_projMatrix;
|
||||
|
||||
attribute float psize;
|
||||
attribute vec3 position_attr;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = g_projMatrix * g_viewMatrix * vec4(position_attr, 1.0);
|
||||
gl_PointSize = (700.0 / gl_Position.w);
|
||||
}
|
||||
|
||||
@ -0,0 +1,76 @@
|
||||
//const vec2 offsets[4] = vec2[4] { vec2(1, 1), vec2(-1, 1), vec2(-1, -1), vec2(1, -1) };
|
||||
//const vec2 tc[4] = vec2[4] { vec2(1, 1), vec2(0, 1), vec2(0, 0), vec2(1, 0) };
|
||||
|
||||
uniform float windowWidth;
|
||||
uniform float particleSizeScale;
|
||||
|
||||
uniform mat4 g_viewMatrix;
|
||||
uniform mat4 g_modelMatrix;
|
||||
uniform mat4 g_projMatrix;
|
||||
|
||||
attribute vec4 color_attr;
|
||||
attribute float psize;
|
||||
attribute vec3 position_attr;
|
||||
attribute vec2 texcoord0_attr;
|
||||
attribute vec2 texcoord1_attr;
|
||||
attribute vec2 texcoord2_attr;
|
||||
attribute vec2 texcoord3_attr;
|
||||
|
||||
varying vec4 color;
|
||||
varying vec2 texcoord0;
|
||||
varying vec2 texcoord1;
|
||||
varying vec2 texcoord2;
|
||||
varying vec2 texcoord3;
|
||||
|
||||
/*
|
||||
float clampedGraph(float value, float vmin, float vmax)
|
||||
{
|
||||
return saturate((value - vmin) / (vmax-vmin));
|
||||
}
|
||||
*/
|
||||
void main()
|
||||
{
|
||||
|
||||
mat4 modelMatrix;
|
||||
#if RENDERER_INSTANCED
|
||||
modelMatrix = transpose(vec4x4(vec4(instanceNormalX, 0), vec4(instanceNormalY, 0), vec4(instanceNormalZ, 0), vec4(instanceOffset, 1)));
|
||||
#else
|
||||
modelMatrix = g_modelMatrix;
|
||||
#endif
|
||||
|
||||
int index = int(texcoord2_attr.x);
|
||||
vec2 offset;
|
||||
switch (index)
|
||||
{
|
||||
case 0: offset = vec2(1, 1); break;
|
||||
case 1: offset = vec2(-1, 1); break;
|
||||
case 2: offset = vec2(-1, -1); break;
|
||||
case 3: offset = vec2(1, -1); break;
|
||||
}
|
||||
|
||||
vec4 viewPos = g_viewMatrix * vec4(position_attr, 1.0);
|
||||
viewPos.xy = viewPos.xy - offset.xy * texcoord2_attr.y;
|
||||
vec4 screenSpacePosition = g_projMatrix * viewPos;
|
||||
vec3 worldSpacePosition = (g_modelMatrix * vec4(position_attr, 1.0)).xyz;
|
||||
|
||||
gl_Position = screenSpacePosition;
|
||||
/*
|
||||
float3 tbz = normalize(g_eyePosition - vout.params.worldSpacePosition);
|
||||
float3 tbx = cross(float3(0,1,0), tbz);
|
||||
|
||||
vout.params.worldSpaceNormal = tbz;//normalize(mul(modelMatrix, vec4(localSpaceNormal, 0)).xyz);
|
||||
vout.params.worldSpaceTangent = tbx;//normalize(mul(g_modelMatrix, vec4(localSpaceTangent, 0)).xyz);
|
||||
vout.params.worldSpaceBinormal = cross(vout.params.worldSpaceNormal, vout.params.worldSpaceTangent);
|
||||
|
||||
float3x3 tangentBasis = float3x3(vout.params.worldSpaceTangent, vout.params.worldSpaceBinormal, vout.params.worldSpaceNormal);
|
||||
vout.params.worldSpaceBinormal = mul(tangentBasis, g_lightDirection);
|
||||
*/
|
||||
texcoord0 = (offset + vec2(1,1)) * 0.5;//tc[index];
|
||||
texcoord1 = texcoord1_attr;
|
||||
texcoord2 = texcoord2_attr;
|
||||
texcoord3 = texcoord3_attr;
|
||||
// vout.params.color = vertexColor;
|
||||
color = color_attr;
|
||||
|
||||
//gl_PointSize = (g_projMatrix[0][0] / screenSpacePosition.w) * (windowWidth / 2.0) * psize * particleSizeScale;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
uniform mat4 g_modelViewMatrix;
|
||||
uniform mat4 g_projMatrix;
|
||||
|
||||
attribute vec3 position_attr;
|
||||
attribute vec4 color_attr;
|
||||
attribute vec2 texcoord0_attr;
|
||||
|
||||
varying vec2 texcoord0;
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position_attr, 1.0);
|
||||
texcoord0 = texcoord0_attr;
|
||||
color = color_attr;
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
#define MAX_BONES 50
|
||||
uniform mat4 g_boneMatrices[MAX_BONES];
|
||||
|
||||
uniform mat4 g_modelViewMatrix;
|
||||
uniform mat4 g_projMatrix;
|
||||
attribute float boneIndex_attr;
|
||||
attribute vec3 position_attr;
|
||||
attribute vec3 normal_attr;
|
||||
attribute vec2 texcoord0_attr;
|
||||
|
||||
varying vec4 color;
|
||||
varying vec2 texcoord0;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
int bi = int(boneIndex_attr);
|
||||
gl_Position = g_projMatrix * g_modelViewMatrix * g_boneMatrices[bi] * vec4(position_attr, 1.0);
|
||||
vec4 normal2 = normalize(g_modelViewMatrix * g_boneMatrices[bi] * vec4(normal_attr, 0.0));
|
||||
color = clamp(normal2.z, 0.2, 1.0) * vec4(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
texcoord0 = texcoord0_attr;
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
uniform mat4 g_modelViewMatrix;
|
||||
uniform mat4 g_projMatrix;
|
||||
|
||||
attribute vec3 position_attr;
|
||||
attribute vec3 normal_attr;
|
||||
attribute vec2 texcoord0_attr;
|
||||
|
||||
varying vec2 texcoord0;
|
||||
varying vec4 lighting;
|
||||
varying vec4 normal;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = g_projMatrix * g_modelViewMatrix * vec4(position_attr, 1.0);
|
||||
normal = normalize(g_modelViewMatrix * vec4(normal_attr, 0.0));
|
||||
float lighting_scalar = clamp(normal.z, 0.4, 1.0);
|
||||
lighting = vec4(lighting_scalar, lighting_scalar, lighting_scalar, 1.0);
|
||||
texcoord0 = texcoord0_attr;
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
attribute vec3 position_attr;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position_attr, 1.0);
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
uniform mat4 g_modelMatrix;
|
||||
|
||||
attribute vec3 position_attr;
|
||||
attribute vec2 texcoord0_attr;
|
||||
|
||||
varying vec2 texcoord0;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(position_attr, 1.0) + g_modelMatrix[0];
|
||||
texcoord0 = texcoord0_attr;
|
||||
}
|
||||
19
physx/samples/sampleframework/media/shaders/vertex/lines.cg
Normal file
19
physx/samples/sampleframework/media/shaders/vertex/lines.cg
Normal file
@ -0,0 +1,19 @@
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
|
||||
struct VertexOut
|
||||
{
|
||||
float4 screenSpacePosition : POSITION;
|
||||
half4 color : COLOR;
|
||||
};
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(half4, vertexColor, COLOR))
|
||||
{
|
||||
VertexOut vout;
|
||||
float4x4 vpm = mul(g_projMatrix, g_viewMatrix);
|
||||
vout.screenSpacePosition = mul(vpm, localSpacePosition);
|
||||
vout.color = vertexColor;
|
||||
|
||||
return vout;
|
||||
}
|
||||
58
physx/samples/sampleframework/media/shaders/vertex/mouse.cg
Normal file
58
physx/samples/sampleframework/media/shaders/vertex/mouse.cg
Normal file
@ -0,0 +1,58 @@
|
||||
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
|
||||
struct VertexOut
|
||||
{
|
||||
FragmentParameters params;
|
||||
float4 screenSpacePosition : POSITION;
|
||||
};
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(float4, localSpaceTangent, SEMANTIC_TANGENT)
|
||||
__in_opt(float4, vertexTexcoord0, TEXCOORD0)
|
||||
__in_opt(float4, vertexTexcoord1, TEXCOORD1)
|
||||
__in_opt(float4, vertexTexcoord2, TEXCOORD2)
|
||||
__in_opt(float4, vertexTexcoord3, TEXCOORD3)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
#if RENDERER_INSTANCED
|
||||
, __in(float3, instanceOffset, SEMANTIC_INSTANCE_T)
|
||||
, __in(float3, instanceNormalX, SEMANTIC_INSTANCE_X)
|
||||
, __in(float3, instanceNormalY, SEMANTIC_INSTANCE_Y)
|
||||
, __in(float3, instanceNormalZ, SEMANTIC_INSTANCE_Z)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
VertexOut vout;
|
||||
|
||||
float4x4 modelMatrix;
|
||||
#if RENDERER_INSTANCED
|
||||
modelMatrix = mul(g_modelMatrix, transpose(float4x4(float4(instanceNormalX, 0), float4(instanceNormalY, 0), float4(instanceNormalZ, 0), float4(instanceOffset, 1))));
|
||||
#else
|
||||
modelMatrix = g_modelMatrix;
|
||||
#endif
|
||||
|
||||
float4x4 mvm = mul(g_viewMatrix, modelMatrix);
|
||||
float4 epos = mul( mvm, localSpacePosition );
|
||||
float4x4 mvpm = mul(g_projMatrix, mvm);
|
||||
vout.screenSpacePosition = mul(mvpm, localSpacePosition);
|
||||
|
||||
vout.params.worldSpacePosition = mul(modelMatrix, localSpacePosition).xyz;
|
||||
vout.params.worldSpaceNormal = normalize(mul(modelMatrix, float4(localSpaceNormal, 0)).xyz);
|
||||
vout.params.worldSpaceTangent = normalize(mul(modelMatrix, float4(localSpaceTangent.xyz, 0)).xyz);
|
||||
vout.params.worldSpaceBinormal = cross(vout.params.worldSpaceNormal, vout.params.worldSpaceTangent) * localSpaceTangent.w;
|
||||
|
||||
vout.params.texcoord0 = vertexTexcoord0;
|
||||
vout.params.texcoord1 = vertexTexcoord1;
|
||||
vout.params.texcoord2 = vertexTexcoord2;
|
||||
#if !defined (RENDERER_WIN8ARM)
|
||||
vout.params.texcoord3 = vertexTexcoord3;
|
||||
#endif
|
||||
vout.params.color = vertexColor;
|
||||
|
||||
vout.screenSpacePosition.w = epos.z;
|
||||
vout.screenSpacePosition.xy *= epos.z;
|
||||
|
||||
return vout;
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
|
||||
struct VertexOut
|
||||
{
|
||||
FragmentParameters params;
|
||||
float4 screenSpacePosition : POSITION;
|
||||
float pointSize : PSIZE;
|
||||
};
|
||||
|
||||
BEGIN_CBUFFER(cbParticlesFog)
|
||||
CONST_TYPE float windowWidth;
|
||||
END_CBUFFER(cbParticlesFog)
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(float4, localSpaceTangent, SEMANTIC_TANGENT)
|
||||
__in_opt(float4, vertexTexcoord0, TEXCOORD0)
|
||||
__in_opt(float4, vertexTexcoord1, TEXCOORD1)
|
||||
__in_opt(float4, vertexTexcoord2, TEXCOORD2)
|
||||
__in_opt(float4, vertexTexcoord3, TEXCOORD3)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
#if RENDERER_INSTANCED
|
||||
, __in(float3, instanceOffset, SEMANTIC_INSTANCE_T)
|
||||
, __in(float3, instanceNormalX, SEMANTIC_INSTANCE_X)
|
||||
, __in(float3, instanceNormalY, SEMANTIC_INSTANCE_Y)
|
||||
, __in(float3, instanceNormalZ, SEMANTIC_INSTANCE_Z)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
VertexOut vout;
|
||||
|
||||
float4x4 modelMatrix;
|
||||
#if RENDERER_INSTANCED
|
||||
modelMatrix = transpose(float4x4(float4(instanceNormalX, 0), float4(instanceNormalY, 0), float4(instanceNormalZ, 0), float4(instanceOffset, 1)));
|
||||
#else
|
||||
modelMatrix = g_modelMatrix;
|
||||
#endif
|
||||
|
||||
float4x4 mvm = mul(g_viewMatrix, modelMatrix);
|
||||
float4x4 mvpm = mul(g_projMatrix, mvm);
|
||||
vout.screenSpacePosition = mul(mvpm, localSpacePosition);
|
||||
|
||||
vout.params.worldSpacePosition = mul(g_modelMatrix, localSpacePosition).xyz;
|
||||
vout.params.worldSpaceNormal = normalize(mul(modelMatrix, float4(localSpaceNormal, 0)).xyz);
|
||||
vout.params.worldSpaceTangent = normalize(mul(g_modelMatrix, float4(localSpaceTangent.xyz, 0)).xyz);
|
||||
vout.params.worldSpaceBinormal = cross(vout.params.worldSpaceNormal, vout.params.worldSpaceTangent) * localSpaceTangent.w;
|
||||
|
||||
vout.params.texcoord0 = vertexTexcoord0;
|
||||
vout.params.texcoord1 = vertexTexcoord1;
|
||||
vout.params.texcoord2 = vertexTexcoord2;
|
||||
#if !defined (RENDERER_WIN8ARM)
|
||||
vout.params.texcoord3 = vertexTexcoord3;
|
||||
#endif
|
||||
vout.params.color = vertexTexcoord1;
|
||||
|
||||
// saturate density range...
|
||||
const float minDensity = 900;
|
||||
const float maxDensity = 2500;
|
||||
vout.params.color.r = sqrt(saturate((vout.params.color.r - minDensity) / (maxDensity-minDensity)));
|
||||
|
||||
vout.pointSize = (g_projMatrix[0][0] / vout.screenSpacePosition.w) * (windowWidth / 2.0) * 1.0;// * (1-0.5*vout.params.color.r);
|
||||
|
||||
return vout;
|
||||
}
|
||||
@ -0,0 +1,165 @@
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
|
||||
struct VertexOut
|
||||
{
|
||||
FragmentParameters params;
|
||||
#if defined(RENDERER_D3D11) && !defined(RENDERER_WIN8ARM)
|
||||
float4 screenSpacePosition : SV_POSITION;
|
||||
float4 rotScaleXScaleY : SEMANTIC_SPRITE_ROT_SCALEX_SCALEY;
|
||||
#else
|
||||
float4 screenSpacePosition : POSITION;
|
||||
#endif
|
||||
float pointSize : PSIZE;
|
||||
};
|
||||
|
||||
BEGIN_CBUFFER(cbPointSprite)
|
||||
CONST_TYPE float windowWidth;
|
||||
CONST_TYPE float particleSize;
|
||||
CONST_TYPE int hasRotation;
|
||||
CONST_TYPE int hasScale;
|
||||
#if USE_VTF
|
||||
CONST_TYPE sampler2D positionTexture;
|
||||
CONST_TYPE sampler2D colorTexture;
|
||||
CONST_TYPE sampler2D transformTexture;
|
||||
CONST_TYPE float vertexTextureWidth;
|
||||
CONST_TYPE float vertexTextureHeight;
|
||||
#endif
|
||||
END_CBUFFER(cbPointSprite)
|
||||
|
||||
VertexOut vmain(
|
||||
#if USE_VTF
|
||||
__in(float, particleIndex, POSITION)
|
||||
#else
|
||||
__in(float4, localSpacePosition, POSITION)
|
||||
#endif
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(float4, localSpaceTangent, SEMANTIC_TANGENT)
|
||||
__in_opt(float4, vertexTexcoord0, TEXCOORD0)
|
||||
__in_opt(float4, vertexTexcoord1, TEXCOORD1)
|
||||
__in_opt(float4, vertexTexcoord2, TEXCOORD2)
|
||||
__in_opt(float4, vertexTexcoord3, TEXCOORD3)
|
||||
#if RENDERER_INSTANCED
|
||||
, __in(float3, instanceOffset, SEMANTIC_INSTANCE_T)
|
||||
, __in(float3, instanceNormalX, SEMANTIC_INSTANCE_X)
|
||||
, __in(float3, instanceNormalY, SEMANTIC_INSTANCE_Y)
|
||||
, __in(float3, instanceNormalZ, SEMANTIC_INSTANCE_Z)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
VertexOut vout;
|
||||
|
||||
#if defined(USE_VTF)
|
||||
float f = floor(particleIndex/vertexTextureWidth);
|
||||
float4 tcx = float4((particleIndex - f * vertexTextureWidth) / vertexTextureWidth, f / vertexTextureHeight, 0, 0);
|
||||
float4 pos = tex2Dlod(positionTexture, tcx);
|
||||
#else
|
||||
float4 pos = localSpacePosition;
|
||||
#endif
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
float4x4 modelMatrix;
|
||||
#if RENDERER_INSTANCED
|
||||
modelMatrix = mul(g_modelMatrix, transpose(float4x4(float4(instanceNormalX, 0), float4(instanceNormalY, 0), float4(instanceNormalZ, 0), float4(instanceOffset, 1))));
|
||||
#else
|
||||
modelMatrix = g_modelMatrix;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
float4x4 mvm = mul(g_viewMatrix, modelMatrix);
|
||||
float4x4 mvpm = mul(g_projMatrix, mvm);
|
||||
vout.screenSpacePosition = mul(mvpm, pos);
|
||||
vout.params.worldSpacePosition = mul(modelMatrix, pos).xyz;
|
||||
#else
|
||||
vout.screenSpacePosition = mul(g_MVP, pos);
|
||||
vout.params.worldSpacePosition = mul(g_modelMatrix, pos).xyz;
|
||||
#endif
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
float3 tbz = normalize(vout.params.worldSpacePosition - g_eyePosition);
|
||||
float3 tbx = cross(float3(0,1,0), tbz);
|
||||
|
||||
vout.params.worldSpaceNormal = tbz;//normalize(mul(modelMatrix, float4(localSpaceNormal, 0)).xyz);
|
||||
vout.params.worldSpaceTangent = tbx;//normalize(mul(g_modelMatrix, float4(localSpaceTangent.xyz, 0)).xyz);
|
||||
vout.params.worldSpaceBinormal = cross(vout.params.worldSpaceNormal, vout.params.worldSpaceTangent) * localSpaceTangent.w;
|
||||
#else
|
||||
#if !defined(PASS_UNLIT)
|
||||
float3 tbz = normalize(vout.params.worldSpacePosition - g_eyePosition);
|
||||
vout.params.worldSpaceNormal = tbz;//normalize(mul(modelMatrix, float4(localSpaceNormal, 0)).xyz);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vout.params.texcoord0 = vertexTexcoord0;
|
||||
#if !defined(GLSL_COMPILER)
|
||||
vout.params.texcoord1 = vertexTexcoord1;
|
||||
vout.params.texcoord2 = vertexTexcoord2;
|
||||
#if !defined (RENDERER_WIN8ARM)
|
||||
vout.params.texcoord3 = vertexTexcoord3;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(USE_VTF)
|
||||
vout.params.color = swizzle((half4)tex2Dlod(colorTexture, tcx));
|
||||
#else
|
||||
vout.params.color = swizzle(vertexColor);
|
||||
#endif
|
||||
|
||||
#if defined(RENDERER_D3D11) && !defined(RENDERER_WIN8ARM)
|
||||
vout.pointSize = particleSize * .75;
|
||||
vout.rotScaleXScaleY = float4(hasRotation ? vertexTexcoord3.x : 0,
|
||||
hasScale ? localSpaceTangent.xy : float2(1,1),
|
||||
0);
|
||||
#else
|
||||
vout.pointSize = (g_projMatrix[0][0] / vout.screenSpacePosition.w) * windowWidth * particleSize * .5;
|
||||
#endif
|
||||
return vout;
|
||||
}
|
||||
|
||||
#if defined(RENDERER_D3D11) && !defined(RENDERER_WIN8ARM)
|
||||
|
||||
struct GeomOut
|
||||
{
|
||||
FragmentParameters params;
|
||||
float4 screenSpacePosition : SV_POSITION;
|
||||
float pointSize : PSIZE;
|
||||
};
|
||||
|
||||
[maxvertexcount(4)]
|
||||
void gmain( point VertexOut sprite[1], inout TriangleStream<GeomOut> triStream )
|
||||
{
|
||||
GeomOut v;
|
||||
v.params = sprite[0].params;
|
||||
v.pointSize = sprite[0].pointSize;
|
||||
|
||||
const float4 pos = sprite[0].screenSpacePosition;
|
||||
const float rad = sprite[0].pointSize;
|
||||
const float theta = sprite[0].rotScaleXScaleY[0];
|
||||
const float radX = sprite[0].rotScaleXScaleY[1] * rad;
|
||||
const float radY = sprite[0].rotScaleXScaleY[2] * rad;
|
||||
|
||||
float sinTheta, cosTheta;
|
||||
sincos(theta, sinTheta, cosTheta);
|
||||
const float2x2 rot = {cosTheta, -sinTheta,
|
||||
sinTheta, cosTheta};
|
||||
|
||||
v.screenSpacePosition = pos + float4(mul(rot, float2(-radX, -radY)), 0, 0);
|
||||
v.params.texcoord0 = float4(0,1,0,0);
|
||||
triStream.Append(v);
|
||||
|
||||
v.screenSpacePosition = pos + float4(mul(rot, float2(-radX, radY)), 0, 0);
|
||||
v.params.texcoord0 = float4(0,0,0,0);
|
||||
triStream.Append(v);
|
||||
|
||||
v.screenSpacePosition = pos + float4(mul(rot, float2( radX, -radY)), 0, 0);
|
||||
v.params.texcoord0 = float4(1,1,0,0);
|
||||
triStream.Append(v);
|
||||
|
||||
v.screenSpacePosition = pos + float4(mul(rot, float2( radX, radY)), 0, 0);
|
||||
v.params.texcoord0 = float4(1,0,0,0);
|
||||
triStream.Append(v);
|
||||
|
||||
triStream.RestartStrip();
|
||||
}
|
||||
#endif
|
||||
@ -0,0 +1,76 @@
|
||||
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
|
||||
struct VertexOut
|
||||
{
|
||||
FragmentParameters params;
|
||||
#if defined(RENDERER_D3D11) && !defined(RENDERER_WIN8ARM)
|
||||
// D3D11 Required input for geometry shader
|
||||
float4 screenSpacePosition : SV_POSITION;
|
||||
#else
|
||||
float4 screenSpacePosition : POSITION;
|
||||
#endif
|
||||
float pointSize : PSIZE;
|
||||
};
|
||||
|
||||
BEGIN_CBUFFER(cbPointSprite)
|
||||
CONST_TYPE float windowWidth;
|
||||
CONST_TYPE float particleSize;
|
||||
END_CBUFFER(cbPointSprite)
|
||||
|
||||
float clampedGraph(float value, float vmin, float vmax)
|
||||
{
|
||||
return saturate((value - vmin) / (vmax-vmin));
|
||||
}
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(float4, localSpaceTangent, SEMANTIC_TANGENT)
|
||||
__in_opt(float4, vertexTexcoord0, TEXCOORD0)
|
||||
__in_opt(float4, vertexTexcoord1, TEXCOORD1)
|
||||
__in_opt(float4, vertexTexcoord2, TEXCOORD2)
|
||||
__in_opt(float4, vertexTexcoord3, TEXCOORD3)
|
||||
#if RENDERER_INSTANCED
|
||||
, __in(float3, instanceOffset, SEMANTIC_INSTANCE_T)
|
||||
, __in(float3, instanceNormalX, SEMANTIC_INSTANCE_X)
|
||||
, __in(float3, instanceNormalY, SEMANTIC_INSTANCE_Y)
|
||||
, __in(float3, instanceNormalZ, SEMANTIC_INSTANCE_Z)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
VertexOut vout;
|
||||
|
||||
float4x4 modelMatrix;
|
||||
#if RENDERER_INSTANCED
|
||||
modelMatrix = transpose(float4x4(float4(instanceNormalX, 0), float4(instanceNormalY, 0), float4(instanceNormalZ, 0), float4(instanceOffset, 1)));
|
||||
#else
|
||||
modelMatrix = g_modelMatrix;
|
||||
#endif
|
||||
|
||||
float4x4 mvm = mul(g_viewMatrix, modelMatrix);
|
||||
float4x4 mvpm = mul(g_projMatrix, mvm);
|
||||
vout.screenSpacePosition = mul(mvpm, localSpacePosition);
|
||||
|
||||
vout.params.worldSpacePosition = mul(modelMatrix, localSpacePosition).xyz;
|
||||
|
||||
float3 tbz = normalize(vout.params.worldSpacePosition - g_eyePosition);
|
||||
float3 tbx = cross(float3(0,1,0), tbz);
|
||||
|
||||
vout.params.worldSpaceNormal = tbz;//normalize(mul(modelMatrix, float4(localSpaceNormal, 0)).xyz);
|
||||
vout.params.worldSpaceTangent = tbx;//normalize(mul(g_modelMatrix, float4(localSpaceTangent.xyz, 0)).xyz);
|
||||
vout.params.worldSpaceBinormal = cross(vout.params.worldSpaceNormal, vout.params.worldSpaceTangent) * localSpaceTangent.w;
|
||||
|
||||
vout.params.texcoord0 = vertexTexcoord0;
|
||||
vout.params.texcoord1 = vertexTexcoord1;
|
||||
vout.params.texcoord2 = vertexTexcoord2;
|
||||
#if !defined (RENDERER_WIN8ARM)
|
||||
vout.params.texcoord3 = vertexTexcoord3;
|
||||
#endif
|
||||
vout.params.color = vertexColor;
|
||||
|
||||
vout.pointSize = (particleSize * particleSize) / (vout.screenSpacePosition.w * vout.screenSpacePosition.w);
|
||||
|
||||
return vout;
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
|
||||
struct VertexOut
|
||||
{
|
||||
float4 screenSpacePosition : POSITION;
|
||||
half4 color : COLOR;
|
||||
};
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL))
|
||||
{
|
||||
VertexOut vout;
|
||||
float4x4 vpm = mul(g_projMatrix, g_viewMatrix);
|
||||
vout.screenSpacePosition = mul(vpm, localSpacePosition);
|
||||
vout.screenSpacePosition.z -= 0.005; // hack to avoid z-fighting
|
||||
vout.color = vertexColor;
|
||||
return vout;
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
|
||||
struct VertexOut
|
||||
{
|
||||
float4 screenSpacePosition : POSITION;
|
||||
float3 worldSpacePosition : TEXCOORD1;
|
||||
float3 worldSpaceNormal : TEXCOORD2;
|
||||
half4 color : COLOR;
|
||||
};
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(half4, vertexColor, COLOR))
|
||||
{
|
||||
VertexOut vout;
|
||||
float4x4 vpm = mul(g_projMatrix, g_viewMatrix);
|
||||
vout.screenSpacePosition = mul(vpm, localSpacePosition);
|
||||
vout.screenSpacePosition.z -= 0.005; // hack to avoid z-fighting
|
||||
vout.worldSpaceNormal = localSpaceNormal;
|
||||
vout.worldSpacePosition = localSpacePosition.xyz;
|
||||
vout.color = vertexColor;
|
||||
|
||||
return vout;
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
|
||||
// Parameters passed from the vertex shader to the fragment shader.
|
||||
struct QuadFragmentParameters
|
||||
{
|
||||
float4 worldSpacePosition : TEXCOORD4;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
half4 color : COLOR;
|
||||
};
|
||||
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
|
||||
struct VertexOut
|
||||
{
|
||||
QuadFragmentParameters params;
|
||||
float4 screenSpacePosition : POSITION;
|
||||
};
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(float4, localSpaceTangent, SEMANTIC_TANGENT)
|
||||
__in_opt(float4, vertexTexcoord0, TEXCOORD0)
|
||||
__in_opt(float4, vertexTexcoord1, TEXCOORD1)
|
||||
__in_opt(float4, vertexTexcoord2, TEXCOORD2)
|
||||
__in_opt(float4, vertexTexcoord3, TEXCOORD3))
|
||||
{
|
||||
VertexOut vout;
|
||||
|
||||
vout.screenSpacePosition = float4(mul(g_viewMatrix2D, float4(localSpacePosition.xyz,1)).xyz, localSpacePosition.w);
|
||||
vout.params.worldSpacePosition = vout.screenSpacePosition;
|
||||
vout.params.texcoord0 = vertexTexcoord0.xy;
|
||||
vout.params.color = vertexColor;
|
||||
|
||||
return vout;
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
#include <tessellation.cg>
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(float4, localSpaceTangent, SEMANTIC_TANGENT)
|
||||
__in_opt(float4, vertexTexcoord0, TEXCOORD0)
|
||||
__in_opt(float4, vertexTexcoord1, TEXCOORD1)
|
||||
__in_opt(float4, vertexTexcoord2, TEXCOORD2)
|
||||
__in_opt(float4, vertexTexcoord3, TEXCOORD3)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
, __in(int, boneIndex, SEMANTIC_BONEINDEX)
|
||||
#if RENDERER_DISPLACED
|
||||
__in_opt(uint, vertexFlagsDisp, SEMANTIC_DISPLACEMENT_FLAGS)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
VertexOut vout;
|
||||
|
||||
#if defined USE_VTF
|
||||
float4x4 boneMatrix;
|
||||
const float boneTextureIdx = ((float)boneIndex + 0.5f) / g_boneTextureHeight;
|
||||
boneMatrix[0] = tex2Dlod(g_boneTexture, float4(0.5f / 4.f, boneTextureIdx, 0, 0));
|
||||
boneMatrix[1] = tex2Dlod(g_boneTexture, float4(1.5f / 4.f, boneTextureIdx, 0, 0));
|
||||
boneMatrix[2] = tex2Dlod(g_boneTexture, float4(2.5f / 4.f, boneTextureIdx, 0, 0));
|
||||
boneMatrix[3] = tex2Dlod(g_boneTexture, float4(3.5f / 4.f, boneTextureIdx, 0, 0));
|
||||
#else
|
||||
float4x4 boneMatrix = g_boneMatrices[boneIndex];
|
||||
#endif
|
||||
|
||||
float4 skinnedPosition = mul(boneMatrix, localSpacePosition);
|
||||
float3 skinnedNormal = mul(boneMatrix, float4(localSpaceNormal, 0)).xyz;
|
||||
#if !defined(GLSL_COMPILER)
|
||||
float3 skinnedTangent = mul(boneMatrix, float4(localSpaceTangent.xyz, 0)).xyz;
|
||||
#endif
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
float4x4 mvpm = mul(g_projMatrix, g_modelViewMatrix); // TODO: should use g_modelViewProjMatrix....
|
||||
vout.screenSpacePosition = mul(mvpm, skinnedPosition);
|
||||
#else
|
||||
vout.screenSpacePosition = mul(g_MVP, skinnedPosition);
|
||||
#endif
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
vout.params.worldSpacePosition = mul(g_modelMatrix, skinnedPosition).xyz;
|
||||
vout.params.worldSpaceNormal = normalize(mul(g_modelMatrix, float4(skinnedNormal, 0)).xyz);
|
||||
vout.params.worldSpaceTangent = normalize(mul(g_modelMatrix, float4(skinnedTangent, 0)).xyz);
|
||||
vout.params.worldSpaceBinormal = cross(vout.params.worldSpaceTangent, vout.params.worldSpaceNormal) * localSpaceTangent.w;
|
||||
#else
|
||||
vout.params.worldSpacePosition = mul(g_modelMatrix, skinnedPosition).xyz;
|
||||
vout.params.worldSpaceNormal = normalize(mul(g_modelMatrix, float4(skinnedNormal, 0)).xyz);
|
||||
#endif
|
||||
|
||||
vout.params.texcoord0 = vertexTexcoord0;
|
||||
vout.params.texcoord1 = vertexTexcoord1;
|
||||
vout.params.texcoord2 = vertexTexcoord2;
|
||||
#if !defined (RENDERER_WIN8ARM)
|
||||
vout.params.texcoord3 = vertexTexcoord3;
|
||||
#endif
|
||||
vout.params.color = swizzle(vertexColor);
|
||||
|
||||
#if RENDERER_DISPLACED
|
||||
vout.localPosition = localSpacePosition;
|
||||
vout.flagsDisp = vertexFlagsDisp;
|
||||
float4x4 modelBoneMatrix = mul(g_modelMatrix, boneMatrix);
|
||||
vout.modelMatrix[0] = modelBoneMatrix[0];
|
||||
vout.modelMatrix[1] = modelBoneMatrix[1];
|
||||
vout.modelMatrix[2] = modelBoneMatrix[2];
|
||||
vout.modelMatrix[3] = modelBoneMatrix[3];
|
||||
#endif
|
||||
|
||||
return vout;
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
|
||||
struct VertexOut
|
||||
{
|
||||
FragmentParameters params;
|
||||
float4 screenSpacePosition : POSITION;
|
||||
};
|
||||
|
||||
float4x4 accumulate_skin(float4 boneIndices0,
|
||||
float4 boneWeights0)
|
||||
{
|
||||
float4x4 result = boneWeights0.x * g_boneMatrices[boneIndices0.x];
|
||||
result = result + boneWeights0.y * g_boneMatrices[boneIndices0.y];
|
||||
result = result + boneWeights0.z * g_boneMatrices[boneIndices0.z];
|
||||
result = result + boneWeights0.w * g_boneMatrices[boneIndices0.w];
|
||||
return result;
|
||||
}
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(float4, localSpaceTangent, SEMANTIC_TANGENT)
|
||||
__in_opt(float4, vertexTexcoord0, TEXCOORD0)
|
||||
__in_opt(float4, vertexTexcoord1, TEXCOORD1)
|
||||
__in_opt(float4, vertexTexcoord2, TEXCOORD2)
|
||||
__in_opt(float4, vertexTexcoord3, TEXCOORD3)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
, __in(int4, boneIndices, TEXCOORD6)
|
||||
, __in(float4, boneWeights, TEXCOORD7))
|
||||
{
|
||||
VertexOut vout;
|
||||
|
||||
float4x4 boneMatrix = accumulate_skin(boneIndices, boneWeights);
|
||||
float4 skinnedPosition = mul(boneMatrix, localSpacePosition);
|
||||
float3 skinnedNormal = (mul(boneMatrix, float4(localSpaceNormal, 0))).xyz;
|
||||
#if !defined(GLSL_COMPILER)
|
||||
float3 skinnedTangent = (mul(boneMatrix, float4(localSpaceTangent.xyz, 0))).xyz;
|
||||
#endif
|
||||
|
||||
skinnedPosition.w = 1;
|
||||
skinnedNormal = normalize(skinnedNormal);
|
||||
#if !defined(GLSL_COMPILER)
|
||||
skinnedTangent = normalize(skinnedTangent);
|
||||
#endif
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
float4x4 mvpm = mul(g_projMatrix, g_modelViewMatrix); // TODO: should use g_modelViewProjMatrix....
|
||||
vout.screenSpacePosition = mul(mvpm, skinnedPosition);
|
||||
#else
|
||||
vout.screenSpacePosition = mul(g_MVP, skinnedPosition);
|
||||
#endif
|
||||
|
||||
vout.params.worldSpacePosition = mul(g_modelMatrix, skinnedPosition).xyz;
|
||||
vout.params.worldSpaceNormal = normalize(mul(g_modelMatrix, float4(skinnedNormal, 0)).xyz);
|
||||
#if !defined(GLSL_COMPILER)
|
||||
vout.params.worldSpaceTangent = normalize(mul(g_modelMatrix, float4(skinnedTangent, 0)).xyz);
|
||||
vout.params.worldSpaceBinormal = cross(vout.params.worldSpaceNormal, vout.params.worldSpaceTangent) * localSpaceTangent.w;
|
||||
#endif
|
||||
|
||||
vout.params.texcoord0 = vertexTexcoord0;
|
||||
vout.params.texcoord1 = vertexTexcoord1;
|
||||
vout.params.texcoord2 = vertexTexcoord2;
|
||||
#if !defined (RENDERER_WIN8ARM)
|
||||
vout.params.texcoord3 = vertexTexcoord3;
|
||||
#endif
|
||||
vout.params.color = swizzle(vertexColor);
|
||||
|
||||
return vout;
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
#include <tessellation.cg>
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(float4, localSpaceTangent, SEMANTIC_TANGENT)
|
||||
__in_opt(float4, vertexTexcoord0, TEXCOORD0)
|
||||
__in_opt(float4, vertexTexcoord1, TEXCOORD1)
|
||||
__in_opt(float4, vertexTexcoord2, TEXCOORD2)
|
||||
__in_opt(float4, vertexTexcoord3, TEXCOORD3)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
#if RENDERER_INSTANCED
|
||||
, __in(float3, instanceOffset, SEMANTIC_INSTANCE_T)
|
||||
, __in(float3, instanceNormalX, SEMANTIC_INSTANCE_X)
|
||||
, __in(float3, instanceNormalY, SEMANTIC_INSTANCE_Y)
|
||||
, __in(float3, instanceNormalZ, SEMANTIC_INSTANCE_Z)
|
||||
__in_opt(float2, instanceUVOffset, SEMANTIC_INSTANCE_UV)
|
||||
__in_opt(float3, instanceLocalOffset, SEMANTIC_INSTANCE_LOCAL)
|
||||
#endif
|
||||
#if RENDERER_DISPLACED
|
||||
__in_opt(uint, vertexFlagsDisp, SEMANTIC_DISPLACEMENT_FLAGS)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
VertexOut vout;
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
float4x4 modelMatrix;
|
||||
#if RENDERER_INSTANCED
|
||||
modelMatrix = mul(g_modelMatrix, transpose(float4x4(float4(instanceNormalX, 0), float4(instanceNormalY, 0), float4(instanceNormalZ, 0), float4(instanceOffset, 1))));
|
||||
#else
|
||||
modelMatrix = g_modelMatrix;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
float4x4 mvm = mul(g_viewMatrix, modelMatrix);
|
||||
float4x4 mvpm = mul(g_projMatrix, mvm);
|
||||
vout.screenSpacePosition = mul(mvpm, localSpacePosition);
|
||||
#else
|
||||
vout.screenSpacePosition = mul(g_MVP, localSpacePosition);
|
||||
#endif
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
vout.params.worldSpacePosition = mul(modelMatrix, localSpacePosition).xyz;
|
||||
vout.params.worldSpaceNormal = normalize(mul(modelMatrix, float4(localSpaceNormal, 0)).xyz);
|
||||
vout.params.worldSpaceTangent = normalize(mul(modelMatrix, float4(localSpaceTangent.xyz, 0)).xyz);
|
||||
vout.params.worldSpaceBinormal = cross(vout.params.worldSpaceNormal, vout.params.worldSpaceTangent) * localSpaceTangent.w;
|
||||
#else
|
||||
vout.params.worldSpacePosition = mul(g_modelMatrix, localSpacePosition).xyz;
|
||||
vout.params.worldSpaceNormal = float4(0,1,0,0);
|
||||
#endif
|
||||
#if RENDERER_INSTANCED
|
||||
vout.params.texcoord0 = vertexTexcoord0 + float4(instanceUVOffset, 0, 0);
|
||||
#else
|
||||
vout.params.texcoord0 = vertexTexcoord0;
|
||||
#endif
|
||||
#if !defined(GLSL_COMPILER)
|
||||
vout.params.texcoord1 = vertexTexcoord1;
|
||||
vout.params.texcoord2 = vertexTexcoord2;
|
||||
#if !defined (RENDERER_WIN8ARM)
|
||||
vout.params.texcoord3 = vertexTexcoord3;
|
||||
#endif
|
||||
#endif
|
||||
vout.params.color = vertexColor;
|
||||
|
||||
#if RENDERER_DISPLACED
|
||||
vout.localPosition = localSpacePosition;
|
||||
#if RENDERER_INSTANCED
|
||||
vout.localPosition += instanceLocalOffset;
|
||||
#endif
|
||||
vout.flagsDisp = vertexFlagsDisp;
|
||||
vout.modelMatrix[0] = modelMatrix[0];
|
||||
vout.modelMatrix[1] = modelMatrix[1];
|
||||
vout.modelMatrix[2] = modelMatrix[2];
|
||||
vout.modelMatrix[3] = modelMatrix[3];
|
||||
#endif
|
||||
|
||||
return vout;
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
#include <tessellation.cg>
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(float4, localSpaceTangent, SEMANTIC_TANGENT)
|
||||
__in_opt(float4, vertexTexcoord0, TEXCOORD0)
|
||||
__in_opt(float4, vertexTexcoord1, TEXCOORD1)
|
||||
__in_opt(float4, vertexTexcoord2, TEXCOORD2)
|
||||
__in_opt(float4, vertexTexcoord3, TEXCOORD3)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
#if RENDERER_INSTANCED
|
||||
, __in(float3, instanceOffset, SEMANTIC_INSTANCE_T)
|
||||
, __in(float3, instanceNormalX, SEMANTIC_INSTANCE_X)
|
||||
, __in(float3, instanceNormalY, SEMANTIC_INSTANCE_Y)
|
||||
, __in(float3, instanceNormalZ, SEMANTIC_INSTANCE_Z)
|
||||
__in_opt(float2, instanceUVOffset, SEMANTIC_INSTANCE_UV)
|
||||
__in_opt(float3, instanceLocalOffset, SEMANTIC_INSTANCE_LOCAL)
|
||||
#endif
|
||||
#if RENDERER_DISPLACED
|
||||
__in_opt(uint, vertexFlagsDisp, SEMANTIC_DISPLACEMENT_FLAGS)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
VertexOut vout;
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
float4x4 modelMatrix;
|
||||
#if RENDERER_INSTANCED
|
||||
modelMatrix = mul(g_modelMatrix, transpose(float4x4(float4(instanceNormalX, 0), float4(instanceNormalY, 0), float4(instanceNormalZ, 0), float4(instanceOffset, 1))));
|
||||
#else
|
||||
modelMatrix = g_modelMatrix;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
float4x4 mvm = mul(g_viewMatrix, modelMatrix);
|
||||
float4x4 mvpm = mul(g_projMatrix, mvm);
|
||||
vout.screenSpacePosition = mul(mvpm, localSpacePosition);
|
||||
#else
|
||||
vout.screenSpacePosition = mul(g_MVP, localSpacePosition);
|
||||
#endif
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
vout.params.worldSpacePosition = mul(modelMatrix, localSpacePosition).xyz;
|
||||
vout.params.worldSpaceNormal = normalize(mul(modelMatrix, float4(localSpaceNormal, 0)).xyz);
|
||||
vout.params.worldSpaceTangent = normalize(mul(modelMatrix, float4(localSpaceTangent.xyz, 0)).xyz);
|
||||
vout.params.worldSpaceBinormal = cross(vout.params.worldSpaceNormal, vout.params.worldSpaceTangent) * localSpaceTangent.w;
|
||||
#else
|
||||
vout.params.worldSpacePosition = mul(g_modelMatrix, localSpacePosition).xyz;
|
||||
vout.params.worldSpaceNormal = normalize(mul(g_modelMatrix, float4(localSpaceNormal, 0)).xyz);
|
||||
#endif
|
||||
#if RENDERER_INSTANCED
|
||||
vout.params.texcoord0 = vertexTexcoord0 + float4(instanceUVOffset, 0, 0);
|
||||
#else
|
||||
vout.params.texcoord0 = vertexTexcoord0;
|
||||
#endif
|
||||
#if !defined(GLSL_COMPILER)
|
||||
vout.params.texcoord1 = vertexTexcoord1;
|
||||
vout.params.texcoord2 = vertexTexcoord2;
|
||||
#if !defined (RENDERER_WIN8ARM)
|
||||
vout.params.texcoord3 = vertexTexcoord3;
|
||||
#endif
|
||||
#endif
|
||||
vout.params.color = swizzle(vertexColor);
|
||||
|
||||
#if RENDERER_DISPLACED
|
||||
vout.localPosition = localSpacePosition;
|
||||
#if RENDERER_INSTANCED
|
||||
vout.localPosition += instanceLocalOffset;
|
||||
#endif
|
||||
vout.flagsDisp = vertexFlagsDisp;
|
||||
vout.modelMatrix[0] = modelMatrix[0];
|
||||
vout.modelMatrix[1] = modelMatrix[1];
|
||||
vout.modelMatrix[2] = modelMatrix[2];
|
||||
vout.modelMatrix[3] = modelMatrix[3];
|
||||
#endif
|
||||
|
||||
return vout;
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
#include <tessellation.cg>
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(float4, localSpaceTangent, SEMANTIC_TANGENT)
|
||||
__in_opt(float4, vertexTexcoord0, TEXCOORD0)
|
||||
__in_opt(float4, vertexTexcoord1, TEXCOORD1)
|
||||
__in_opt(float4, vertexTexcoord2, TEXCOORD2)
|
||||
__in_opt(float4, vertexTexcoord3, TEXCOORD3)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
#if RENDERER_INSTANCED
|
||||
, __in(float3, instanceOffset, SEMANTIC_INSTANCE_T)
|
||||
, __in(float3, instanceNormalX, SEMANTIC_INSTANCE_X)
|
||||
, __in(float3, instanceNormalY, SEMANTIC_INSTANCE_Y)
|
||||
, __in(float3, instanceNormalZ, SEMANTIC_INSTANCE_Z)
|
||||
__in_opt(float2, instanceUVOffset, SEMANTIC_INSTANCE_UV)
|
||||
__in_opt(float3, instanceLocalOffset, SEMANTIC_INSTANCE_LOCAL)
|
||||
#endif
|
||||
#if RENDERER_DISPLACED
|
||||
__in_opt(uint, vertexFlagsDisp, SEMANTIC_DISPLACEMENT_FLAGS)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
VertexOut vout;
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
float4x4 modelMatrix;
|
||||
#if RENDERER_INSTANCED
|
||||
modelMatrix = mul(g_modelMatrix, transpose(float4x4(float4(instanceNormalX, 0), float4(instanceNormalY, 0), float4(instanceNormalZ, 0), float4(instanceOffset, 1))));
|
||||
#else
|
||||
modelMatrix = g_modelMatrix;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
float4x4 mvm = mul(g_viewMatrix, modelMatrix);
|
||||
float4x4 mvpm = mul(g_projMatrix, mvm);
|
||||
vout.screenSpacePosition = mul(mvpm, localSpacePosition);
|
||||
#else
|
||||
vout.screenSpacePosition = mul(g_MVP, localSpacePosition);
|
||||
#endif
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
vout.params.worldSpacePosition = mul(modelMatrix, localSpacePosition).xyz;
|
||||
vout.params.worldSpaceNormal = float4(0,1,0,0); //normalize(mul(modelMatrix, float4(localSpaceNormal, 0)).xyz);
|
||||
vout.params.worldSpaceTangent = normalize(mul(modelMatrix, float4(localSpaceTangent.xyz, 0)).xyz);
|
||||
vout.params.worldSpaceBinormal = cross(vout.params.worldSpaceNormal, vout.params.worldSpaceTangent) * localSpaceTangent.w;
|
||||
#else
|
||||
vout.params.worldSpacePosition = mul(g_modelMatrix, localSpacePosition).xyz;
|
||||
vout.params.worldSpaceNormal = float4(0,1,0,0); //normalize(mul(g_modelMatrix, float4(localSpaceNormal, 0)).xyz);
|
||||
#endif
|
||||
#if RENDERER_INSTANCED
|
||||
vout.params.texcoord0 = vertexTexcoord0 + float4(instanceUVOffset, 0, 0);
|
||||
#else
|
||||
vout.params.texcoord0 = vertexTexcoord0;
|
||||
vout.params.texcoord1 = vertexTexcoord1;
|
||||
#endif
|
||||
#if !defined(GLSL_COMPILER)
|
||||
vout.params.texcoord1 = vertexTexcoord1;
|
||||
vout.params.texcoord2 = vertexTexcoord2;
|
||||
#if !defined (RENDERER_WIN8ARM)
|
||||
vout.params.texcoord3 = vertexTexcoord3;
|
||||
#endif
|
||||
#endif
|
||||
vout.params.color = vertexColor;
|
||||
|
||||
#if RENDERER_DISPLACED
|
||||
vout.localPosition = localSpacePosition;
|
||||
#if RENDERER_INSTANCED
|
||||
vout.localPosition += instanceLocalOffset;
|
||||
#endif
|
||||
vout.flagsDisp = vertexFlagsDisp;
|
||||
vout.modelMatrix[0] = modelMatrix[0];
|
||||
vout.modelMatrix[1] = modelMatrix[1];
|
||||
vout.modelMatrix[2] = modelMatrix[2];
|
||||
vout.modelMatrix[3] = modelMatrix[3];
|
||||
#endif
|
||||
|
||||
return vout;
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
#include <tessellation.cg>
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(float4, localSpaceTangent, SEMANTIC_TANGENT)
|
||||
__in_opt(float4, vertexTexcoord0, TEXCOORD0)
|
||||
__in_opt(float4, vertexTexcoord1, TEXCOORD1)
|
||||
__in_opt(float4, vertexTexcoord2, TEXCOORD2)
|
||||
__in_opt(float4, vertexTexcoord3, TEXCOORD3)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
#if RENDERER_INSTANCED
|
||||
, __in(float4, instanceTCol0, SEMANTIC_INSTANCE_T)
|
||||
, __in(float4, instanceTCol1, SEMANTIC_INSTANCE_X)
|
||||
, __in(float4, instanceTCol2, SEMANTIC_INSTANCE_Y)
|
||||
, __in(float4, instanceTCol3, SEMANTIC_INSTANCE_Z)
|
||||
__in_opt(float2, instanceUVOffset, SEMANTIC_INSTANCE_UV)
|
||||
__in_opt(float3, instanceLocalOffset, SEMANTIC_INSTANCE_LOCAL)
|
||||
#endif
|
||||
#if RENDERER_DISPLACED
|
||||
__in_opt(uint, vertexFlagsDisp, SEMANTIC_DISPLACEMENT_FLAGS)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
VertexOut vout;
|
||||
|
||||
float4x4 modelMatrix;
|
||||
#if RENDERER_INSTANCED
|
||||
modelMatrix = mul(g_modelMatrix, transpose(float4x4(instanceTCol0, instanceTCol1, instanceTCol2, instanceTCol3)));
|
||||
#else
|
||||
modelMatrix = g_modelMatrix;
|
||||
#endif
|
||||
|
||||
float4x4 mvm = mul(g_viewMatrix, modelMatrix);
|
||||
float4x4 mvpm = mul(g_projMatrix, mvm);
|
||||
vout.screenSpacePosition = mul(mvpm, localSpacePosition);
|
||||
|
||||
vout.params.worldSpacePosition = mul(modelMatrix, localSpacePosition).xyz;
|
||||
vout.params.worldSpaceNormal = normalize(mul(modelMatrix, float4(localSpaceNormal, 0)).xyz);
|
||||
vout.params.worldSpaceTangent = normalize(mul(modelMatrix, float4(localSpaceTangent.xyz, 0)).xyz);
|
||||
vout.params.worldSpaceBinormal = cross(vout.params.worldSpaceNormal, vout.params.worldSpaceTangent) * localSpaceTangent.w;
|
||||
|
||||
#if RENDERER_INSTANCED
|
||||
vout.params.texcoord0 = vertexTexcoord0 + float4(instanceUVOffset, 0, 0);
|
||||
#else
|
||||
vout.params.texcoord0 = vertexTexcoord0;
|
||||
#endif
|
||||
vout.params.texcoord1 = vertexTexcoord1;
|
||||
vout.params.texcoord2 = vertexTexcoord2;
|
||||
#if !defined (RENDERER_WIN8ARM)
|
||||
vout.params.texcoord3 = vertexTexcoord3;
|
||||
#endif
|
||||
vout.params.color = vertexColor;
|
||||
|
||||
#if RENDERER_DISPLACED
|
||||
vout.localPosition = localSpacePosition;
|
||||
#if RENDERER_INSTANCED
|
||||
vout.localPosition += instanceLocalOffset;
|
||||
#endif
|
||||
vout.flagsDisp = vertexFlagsDisp;
|
||||
vout.modelMatrix[0] = modelMatrix[0];
|
||||
vout.modelMatrix[1] = modelMatrix[1];
|
||||
vout.modelMatrix[2] = modelMatrix[2];
|
||||
vout.modelMatrix[3] = modelMatrix[3];
|
||||
#endif
|
||||
|
||||
return vout;
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
#include <tessellation.cg>
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(float4, localSpaceTangent, SEMANTIC_TANGENT)
|
||||
__in_opt(float4, vertexTexcoord0, TEXCOORD0)
|
||||
__in_opt(float4, vertexTexcoord1, TEXCOORD1)
|
||||
__in_opt(float4, vertexTexcoord2, TEXCOORD2)
|
||||
__in_opt(float4, vertexTexcoord3, TEXCOORD3)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
#if RENDERER_INSTANCED
|
||||
, __in(float3, instanceOffset, SEMANTIC_INSTANCE_T)
|
||||
, __in(float3, instanceNormalX, SEMANTIC_INSTANCE_X)
|
||||
, __in(float3, instanceNormalY, SEMANTIC_INSTANCE_Y)
|
||||
, __in(float3, instanceNormalZ, SEMANTIC_INSTANCE_Z)
|
||||
__in_opt(float2, instanceUVOffset, SEMANTIC_INSTANCE_UV)
|
||||
__in_opt(float3, instanceLocalOffset, SEMANTIC_INSTANCE_LOCAL)
|
||||
#endif
|
||||
#if RENDERER_DISPLACED
|
||||
__in_opt(uint, vertexFlagsDisp, SEMANTIC_DISPLACEMENT_FLAGS)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
VertexOut vout;
|
||||
|
||||
vout.screenSpacePosition = 0;
|
||||
vout.params.worldSpacePosition = 0;
|
||||
vout.params.worldSpaceNormal = 0;
|
||||
vout.params.worldSpaceTangent = 0;
|
||||
vout.params.worldSpaceBinormal = 0;
|
||||
vout.params.texcoord0 = 0;
|
||||
vout.params.texcoord1 = 0;
|
||||
vout.params.texcoord2 = 0;
|
||||
#if !defined (RENDERER_WIN8ARM)
|
||||
vout.params.texcoord3 = 0;
|
||||
#endif
|
||||
vout.params.color = 0;
|
||||
|
||||
//#if !defined(GLSL_COMPILER)
|
||||
float4x4 modelMatrix;
|
||||
#if RENDERER_INSTANCED
|
||||
modelMatrix = mul(g_modelMatrix, transpose(float4x4(float4(instanceNormalX, 0), float4(instanceNormalY, 0), float4(instanceNormalZ, 0), float4(instanceOffset, 1))));
|
||||
#else
|
||||
modelMatrix = g_modelMatrix;
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
float4x4 mvm = mul(g_viewMatrix, modelMatrix);
|
||||
#if !defined(GLSL_COMPILER)
|
||||
float4x4 mvpm = mul(g_projMatrix, mvm);
|
||||
vout.screenSpacePosition = mul(mvpm, localSpacePosition);
|
||||
#else
|
||||
vout.screenSpacePosition = mul(g_MVP, localSpacePosition);
|
||||
#endif
|
||||
|
||||
#if !defined(GLSL_COMPILER)
|
||||
vout.params.worldSpacePosition = mul(modelMatrix, localSpacePosition).xyz;
|
||||
vout.params.worldSpaceNormal = normalize(mul(modelMatrix, float4(localSpaceNormal, 0)).xyz);
|
||||
vout.params.worldSpaceTangent = normalize(mul(modelMatrix, float4(localSpaceTangent.xyz, 0)).xyz);
|
||||
vout.params.worldSpaceBinormal = cross(vout.params.worldSpaceNormal, vout.params.worldSpaceTangent) * localSpaceTangent.w;
|
||||
#else
|
||||
vout.params.worldSpacePosition = mul(g_modelMatrix, localSpacePosition).xyz;
|
||||
vout.params.worldSpaceNormal = normalize(mul(g_modelMatrix, float4(localSpaceNormal, 0)).xyz);
|
||||
#endif
|
||||
#if RENDERER_INSTANCED
|
||||
vout.params.texcoord0 = vertexTexcoord0 + float4(instanceUVOffset, 0, 0);
|
||||
#else
|
||||
vout.params.texcoord0 = vertexTexcoord0;
|
||||
float4 v = normalize(mul(mvm, localSpacePosition));
|
||||
float4 n = normalize(mul(mvm, float4(localSpaceNormal, 0)));
|
||||
float3 r = reflect(v.xyz, n.xyz);
|
||||
float m = sqrt(2 * (r.z + 1));
|
||||
vout.params.texcoord1 = float4(r.x/m + 0.5, r.y/m + 0.5, 0.0, 0.0) * 0.5;
|
||||
#endif
|
||||
#if !defined(GLSL_COMPILER)
|
||||
vout.params.texcoord2 = vertexTexcoord2;
|
||||
#if !defined (RENDERER_WIN8ARM)
|
||||
vout.params.texcoord3 = vertexTexcoord3;
|
||||
#endif
|
||||
#endif
|
||||
vout.params.color = swizzle(vertexColor);
|
||||
|
||||
#if RENDERER_DISPLACED
|
||||
vout.localPosition = localSpacePosition;
|
||||
#if RENDERER_INSTANCED
|
||||
vout.localPosition += instanceLocalOffset;
|
||||
#endif
|
||||
vout.flagsDisp = vertexFlagsDisp;
|
||||
vout.modelMatrix[0] = modelMatrix[0];
|
||||
vout.modelMatrix[1] = modelMatrix[1];
|
||||
vout.modelMatrix[2] = modelMatrix[2];
|
||||
vout.modelMatrix[3] = modelMatrix[3];
|
||||
#endif
|
||||
|
||||
return vout;
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
struct VertexOut
|
||||
{
|
||||
float4 screenSpacePosition : POSITION;
|
||||
};
|
||||
|
||||
VertexOut vmain(float4 localSpacePosition : POSITION)
|
||||
{
|
||||
VertexOut vout;
|
||||
vout.screenSpacePosition = localSpacePosition;
|
||||
return vout;
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
// Parameters passed from the vertex shader to the fragment shader.
|
||||
struct FragmentParameters
|
||||
{
|
||||
float4 worldSpacePosition : TEXCOORD4;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
half4 color : COLOR;
|
||||
};
|
||||
|
||||
#include <globals.cg>
|
||||
|
||||
struct VertexOut
|
||||
{
|
||||
FragmentParameters params;
|
||||
float4 screenSpacePosition : POSITION;
|
||||
};
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
__in_opt(float4, texcoord0, TEXCOORD0))
|
||||
{
|
||||
VertexOut vout;
|
||||
|
||||
vout.screenSpacePosition = localSpacePosition + g_modelMatrix[0];
|
||||
vout.params.worldSpacePosition = localSpacePosition;
|
||||
vout.params.texcoord0 = texcoord0.xy;
|
||||
vout.params.color = vertexColor;
|
||||
return vout;
|
||||
}
|
||||
35
physx/samples/sampleframework/media/shaders/vertex/text.cg
Normal file
35
physx/samples/sampleframework/media/shaders/vertex/text.cg
Normal file
@ -0,0 +1,35 @@
|
||||
// Parameters passed from the vertex shader to the fragment shader.
|
||||
struct TextFragmentParameters
|
||||
{
|
||||
float4 worldSpacePosition : TEXCOORD4;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
half4 color : COLOR;
|
||||
};
|
||||
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
|
||||
struct VertexOut
|
||||
{
|
||||
TextFragmentParameters params;
|
||||
float4 screenSpacePosition : POSITION;
|
||||
};
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(float4, localSpaceTangent, SEMANTIC_TANGENT)
|
||||
__in_opt(float4, vertexTexcoord0, TEXCOORD0)
|
||||
__in_opt(float4, vertexTexcoord1, TEXCOORD1)
|
||||
__in_opt(float4, vertexTexcoord2, TEXCOORD2)
|
||||
__in_opt(float4, vertexTexcoord3, TEXCOORD3))
|
||||
{
|
||||
VertexOut vout;
|
||||
vout.screenSpacePosition = float4(mul(g_viewMatrix2D, float4(localSpacePosition.xyz,1)).xyz, localSpacePosition.w);
|
||||
vout.params.worldSpacePosition = vout.screenSpacePosition;
|
||||
vout.params.texcoord0 = vertexTexcoord0.xy;
|
||||
vout.params.color = vertexColor;
|
||||
|
||||
return vout;
|
||||
}
|
||||
|
||||
@ -0,0 +1,72 @@
|
||||
|
||||
#include <config.cg>
|
||||
#include <globals.cg>
|
||||
|
||||
struct VertexOut
|
||||
{
|
||||
FragmentParameters params;
|
||||
float4 screenSpacePosition : POSITION;
|
||||
};
|
||||
|
||||
VertexOut vmain(__in(float4, localSpacePosition, POSITION)
|
||||
__in_opt(half4, vertexColor, COLOR)
|
||||
__in_opt(float3, localSpaceNormal, NORMAL)
|
||||
__in_opt(float4, localSpaceTangent, SEMANTIC_TANGENT)
|
||||
__in_opt(float4, vertexTexcoord0, TEXCOORD0)
|
||||
__in_opt(float4, vertexTexcoord1, TEXCOORD1)
|
||||
__in_opt(float4, vertexTexcoord2, TEXCOORD2)
|
||||
__in_opt(float4, vertexTexcoord3, TEXCOORD3)
|
||||
, __in(float3, instancePosition, TEXCOORD8)
|
||||
, __in(float4, instanceVelocity, TEXCOORD9)
|
||||
)
|
||||
{
|
||||
VertexOut vout;
|
||||
|
||||
float4x4 modelMatrix = g_modelMatrix;
|
||||
/*
|
||||
#if RENDERER_INSTANCED
|
||||
modelMatrix = transpose(float4x4(float4(instanceNormalX, 0), float4(instanceNormalY, 0), float4(instanceNormalZ, 0), float4(instanceOffset, 1)));
|
||||
#else
|
||||
modelMatrix = g_modelMatrix;
|
||||
#endif*/
|
||||
|
||||
float4 worldSpacePos = float4(0.05,0.05,0.05,1)*localSpacePosition.xyzw;//mul( modelMatrix, localSpacePosition);
|
||||
|
||||
worldSpacePos.xyz += instancePosition.xyz;
|
||||
|
||||
|
||||
float4x4 vpm = mul(g_projMatrix, g_viewMatrix);
|
||||
vout.screenSpacePosition = mul(vpm, worldSpacePos);
|
||||
|
||||
vout.params.worldSpacePosition = mul(modelMatrix, localSpacePosition).xyz;
|
||||
vout.params.worldSpaceNormal = normalize(mul(modelMatrix, float4(localSpaceNormal, 0)).xyz);
|
||||
vout.params.worldSpaceTangent = normalize(mul(modelMatrix, float4(localSpaceTangent.xyz, 0)).xyz);
|
||||
vout.params.worldSpaceBinormal = cross(vout.params.worldSpaceNormal, vout.params.worldSpaceTangent) * localSpaceTangent.w;
|
||||
|
||||
vout.params.texcoord0 = vertexTexcoord0;
|
||||
vout.params.texcoord1 = vertexTexcoord1;
|
||||
vout.params.texcoord2 = vertexTexcoord2;
|
||||
#if !defined (RENDERER_WIN8ARM)
|
||||
vout.params.texcoord3 = vertexTexcoord3;
|
||||
#endif
|
||||
|
||||
/*
|
||||
vout.params.color.xyz = saturate((instanceVelocity.xyz / float3(6,6,6)) + float3(1,1,1));
|
||||
vout.params.color.w = 1;
|
||||
|
||||
if(instanceVelocity.w > 0.75)
|
||||
vout.params.color *= float4(1,0,0,1);
|
||||
else if(instanceVelocity.w > 0.5)
|
||||
vout.params.color *= float4(1,0,1,1);
|
||||
else if(instanceVelocity.w > 0.25)
|
||||
vout.params.color *= float4(0,1,1,1);
|
||||
else
|
||||
vout.params.color *= float4(0,0,1,1);
|
||||
|
||||
*/
|
||||
//simpler colors for debugging
|
||||
vout.params.color.xyz = float3(1*instanceVelocity.w,0,0);
|
||||
vout.params.color.w = 1;
|
||||
|
||||
return vout;
|
||||
}
|
||||
Reference in New Issue
Block a user