Skip to content

Commit f4df626

Browse files
authored
v0.8.0 (#98)
2 parents 2655b42 + 1ba3c14 commit f4df626

File tree

5 files changed

+389
-1
lines changed

5 files changed

+389
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
66

77
The versions in this file adhere to [semantic versioning](https://semver.org/).
88

9+
## [0.8.0]
10+
11+
**FXC**
12+
- Added syntax highlighting for .fxc (Shader) files based off Vscode's HLSL definition enhanced with special FXC comment syntax
13+
914
## [0.7.0]
1015

1116
**VMT**

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ Checklist for features that are planned or already implemented.
7676
### SMD
7777
- [x] .smd highlighting
7878

79+
### FXC
80+
- [x] .fxc highlighting
81+
7982
## Planned
8083
This is what is planned for this extension. In case you wish to contribute, this is a good place to start.
8184

package.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "source-engine-support",
33
"displayName": "Source Engine Support",
44
"description": "Adds support for Source Engine file types and other commands",
5-
"version": "0.7.0",
5+
"version": "0.8.0",
66
"icon": "extension-icon-256.png",
77
"author": {
88
"name": "Stefan Heinz",
@@ -206,6 +206,15 @@
206206
"extensions": [
207207
".smd"
208208
]
209+
},
210+
{
211+
"id": "fxc",
212+
"aliases": [
213+
"FXC Shader"
214+
],
215+
"extensions": [
216+
".fxc"
217+
]
209218
}
210219
],
211220
"grammars": [
@@ -258,6 +267,11 @@
258267
"language": "smd",
259268
"scopeName": "source.smd",
260269
"path": "./syntaxes/smd.tmLanguage.json"
270+
},
271+
{
272+
"language": "fxc",
273+
"scopeName": "source.fxc",
274+
"path": "./syntaxes/fxc.tmLanguage.json"
261275
}
262276
],
263277
"commands": [

samples/shaders/Eyes_vs20.fxc

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
// From Source SDK 2013 https://github.com/ValveSoftware/source-sdk-2013/blob/master/sp/src/materialsystem/stdshaders/Eyes_vs20.fxc
2+
3+
//======= Copyright © 1996-2006, Valve Corporation, All rights reserved. ======
4+
// $SHADER_SPECIFIC_CONST_0 = eyeball origin
5+
// $SHADER_SPECIFIC_CONST_1 = eyeball up * 0.5
6+
// $SHADER_SPECIFIC_CONST_2 = iris projection U
7+
// $SHADER_SPECIFIC_CONST_3 = iris projection V
8+
// $SHADER_SPECIFIC_CONST_4 = glint projection U
9+
// $SHADER_SPECIFIC_CONST_5 = glint projection V
10+
//=============================================================================
11+
12+
// STATIC: "INTRO" "0..1"
13+
// STATIC: "HALFLAMBERT" "0..1"
14+
// STATIC: "USE_STATIC_CONTROL_FLOW" "0..1" [vs20]
15+
16+
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
17+
// DYNAMIC: "SKINNING" "0..1"
18+
// DYNAMIC: "DOWATERFOG" "0..1"
19+
// DYNAMIC: "DYNAMIC_LIGHT" "0..1"
20+
// DYNAMIC: "STATIC_LIGHT" "0..1"
21+
// DYNAMIC: "MORPHING" "0..1" [vs30]
22+
// DYNAMIC: "NUM_LIGHTS" "0..2" [vs20]
23+
24+
// If using static control flow on Direct3D, we should use the NUM_LIGHTS=0 combo
25+
// SKIP: $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) [vs20]
26+
27+
#include "vortwarp_vs20_helper.h"
28+
29+
static const int g_bSkinning = SKINNING ? true : false;
30+
static const int g_FogType = DOWATERFOG;
31+
static const bool g_bHalfLambert = HALFLAMBERT ? true : false;
32+
33+
const float3 cEyeOrigin : register( SHADER_SPECIFIC_CONST_0 );
34+
const float3 cHalfEyeballUp : register( SHADER_SPECIFIC_CONST_1 );
35+
const float4 cIrisProjectionU : register( SHADER_SPECIFIC_CONST_2 );
36+
const float4 cIrisProjectionV : register( SHADER_SPECIFIC_CONST_3 );
37+
const float4 cGlintProjectionU : register( SHADER_SPECIFIC_CONST_4 );
38+
const float4 cGlintProjectionV : register( SHADER_SPECIFIC_CONST_5 );
39+
#if INTRO
40+
const float4 const4 : register( SHADER_SPECIFIC_CONST_6 );
41+
#define g_Time const4.w
42+
#define modelOrigin const4.xyz
43+
#endif
44+
45+
#ifdef SHADER_MODEL_VS_3_0
46+
// NOTE: cMorphTargetTextureDim.xy = target dimensions,
47+
// cMorphTargetTextureDim.z = 4tuples/morph
48+
const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_7 );
49+
const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_8 );
50+
51+
sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 );
52+
#endif
53+
54+
struct VS_INPUT
55+
{
56+
float4 vPos : POSITION; // Position
57+
float4 vBoneWeights : BLENDWEIGHT; // Skin weights
58+
float4 vBoneIndices : BLENDINDICES; // Skin indices
59+
float4 vTexCoord0 : TEXCOORD0; // Base (sclera) texture coordinates
60+
61+
float3 vPosFlex : POSITION1; // Delta positions for flexing
62+
#ifdef SHADER_MODEL_VS_3_0
63+
float vVertexID : POSITION2;
64+
#endif
65+
};
66+
67+
struct VS_OUTPUT
68+
{
69+
float4 projPos : POSITION; // Projection-space position
70+
#if !defined( _X360 )
71+
float fog : FOG; // Fixed-function fog factor
72+
#endif
73+
float2 baseTC : TEXCOORD0; // Base texture coordinate
74+
float2 irisTC : TEXCOORD1; // Iris texture coordinates
75+
float2 glintTC : TEXCOORD2; // Glint texture coordinates
76+
float3 vColor : TEXCOORD3; // Vertex-lit color
77+
78+
float4 worldPos_projPosZ : TEXCOORD7; // Necessary for pixel fog
79+
80+
};
81+
82+
VS_OUTPUT main( const VS_INPUT v )
83+
{
84+
VS_OUTPUT o;
85+
86+
bool bDynamicLight = DYNAMIC_LIGHT ? true : false;
87+
bool bStaticLight = STATIC_LIGHT ? true : false;
88+
89+
float4 vPosition = v.vPos;
90+
float3 dummy = v.vPos.xyz; // dummy values that can't be optimized out
91+
92+
#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING
93+
ApplyMorph( v.vPosFlex, vPosition.xyz );
94+
#else
95+
ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, v.vVertexID, dummy, vPosition.xyz );
96+
#endif
97+
98+
// Transform the position and dummy normal (not doing the dummy normal causes invariance issues with the flashlight!)
99+
float3 worldNormal, worldPos;
100+
SkinPositionAndNormal(
101+
g_bSkinning,
102+
vPosition, dummy,
103+
v.vBoneWeights, v.vBoneIndices,
104+
worldPos, worldNormal );
105+
106+
#if INTRO
107+
WorldSpaceVertexProcess( g_Time, modelOrigin, worldPos, dummy, dummy, dummy );
108+
#endif
109+
110+
// Transform into projection space
111+
float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
112+
o.projPos = vProjPos;
113+
vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ );
114+
o.worldPos_projPosZ = float4( worldPos.xyz, vProjPos.z );
115+
116+
#if !defined( _X360 )
117+
// Set fixed-function fog factor
118+
o.fog = CalcFog( worldPos, vProjPos, g_FogType );
119+
#endif
120+
121+
// Normal = (Pos - Eye origin) - just step on dummy normal created above
122+
worldNormal = worldPos - cEyeOrigin;
123+
124+
// Normal -= 0.5f * (Normal dot Eye Up) * Eye Up
125+
float normalDotUp = -dot( worldNormal, cHalfEyeballUp) * 0.5f;
126+
worldNormal = normalize(normalDotUp * cHalfEyeballUp + worldNormal);
127+
128+
// Vertex lighting
129+
#if ( USE_STATIC_CONTROL_FLOW || defined ( SHADER_MODEL_VS_3_0 ) )
130+
o.vColor = DoLighting( worldPos, worldNormal, float3(0.0f, 0.0f, 0.0f), bStaticLight, bDynamicLight, g_bHalfLambert );
131+
#else
132+
o.vColor = DoLightingUnrolled( worldPos, worldNormal, float3(0.0f, 0.0f, 0.0f), bStaticLight, bDynamicLight, g_bHalfLambert, NUM_LIGHTS );
133+
#endif
134+
135+
// Texture 0 is the base texture
136+
// Texture 1 is a planar projection used for the iris
137+
// Texture 2 is a planar projection used for the glint
138+
o.baseTC = v.vTexCoord0;
139+
o.irisTC.x = dot( cIrisProjectionU, float4(worldPos, 1) );
140+
o.irisTC.y = dot( cIrisProjectionV, float4(worldPos, 1) );
141+
o.glintTC.x = dot( cGlintProjectionU, float4(worldPos, 1) );
142+
o.glintTC.y = dot( cGlintProjectionV, float4(worldPos, 1) );
143+
144+
return o;
145+
}

0 commit comments

Comments
 (0)