Here is the code I write:
[spoiler]
uniform vec4 g_vDiffuseMaterial : MATDIFFUSE;
uniform vec4 g_vEmissiveMaterial : MATEMISSIVE;
uniform vec4 g_vSpecularMaterial : MATSPECULAR;
uniform float g_fReflectivity : REFLECTIVITY;
#ifndef LSE_VERTEX_LIGHTING
uniform float g_fPower : MATPOWER;
uniform vec4 g_vRoughness : ROUGHNESS;
uniform vec4 g_vAshikFactors : ASHIKFACTORS;
uniform vec4 g_vDirLightDirs[LSE_MAX_LIGHTS] : DIRLIGHTDIRS;
uniform vec4 g_vDirLightColors[LSE_MAX_LIGHTS] : DIRLIGHTDIFFUSES;
uniform vec4 g_vPointLightPos[LSE_MAX_LIGHTS] : POINTLIGHTPOS;
uniform vec4 g_vPointLightColors[LSE_MAX_LIGHTS] : POINTLIGHTDIFFUSES;
uniform float g_vPointLightSizes[LSE_MAX_LIGHTS] : POINTLIGHTSIZES;
#endif // #ifndef LSE_VERTEX_LIGHTING
LSE_TEX_UNIFORMS
#include "LSDAshikhminShirley.lssl"
#include "LSDBlinnPhong.lssl"
#include "LSDCookTorrance.lssl"
#include "LSDEpic.lssl"
#include "LSDFresnel.lssl"
#include "LSDLightArgs.lssl"
#include "LSDOrenNayar.lssl"
#define LSE_PREMULTIPLY_ALPHA
#define LSE_LINEAR2SRGB( VAL ) (VAL) <= 0.0031308 ? (VAL) * 12.92 : 1.055 * pow( (VAL), 1.0f / 2.4 ) - 0.055
void Main( out vec4 _vOutColor : COLOR,
lse_MainPsInputs,
in vec4 _vInViewPos : LSE_TEXCOORD_USER0,
in bool _bIsFrontFace : ISFRONTFACE ) {
LSE_TEX_STORES // Ensures each texture is read only once.
[/spoiler]
Output in GLSL:
[spoiler]
in vec4 LSG_VERT_OUT_PIXEL_IN_386_1/*_vInViewPos*/;
in vec3 LSG_VERT_OUT_PIXEL_IN_377_0/*_vInBinormal*/;
in vec3 LSG_VERT_OUT_PIXEL_IN_385_0/*_vInTangent*/;
in vec2 LSG_VERT_OUT_PIXEL_IN_386_0/*_vInTexCoord0*/;
in vec3 LSG_VERT_OUT_PIXEL_IN_381_0/*_vInNormal*/;
in vec4 LSG_VERT_OUT_PIXEL_IN_382_0/*_vInPosition*/;
out vec4 _vOutColor;
#line 0 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
uniform vec4 g_vDiffuseMaterial;
#line 1 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
uniform vec4 g_vEmissiveMaterial;
#line 2 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
uniform vec4 g_vSpecularMaterial;
#line 3 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
uniform float g_fReflectivity;
#line 5 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
uniform float g_fPower;
#line 6 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
uniform vec4 g_vRoughness;
#line 7 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
uniform vec4 g_vAshikFactors;
#line 9 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
uniform vec4 g_vDirLightDirs[8];
#line 10 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
uniform vec4 g_vDirLightColors[8];
#line 12 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
uniform vec4 g_vPointLightPos[8];
#line 13 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
uniform vec4 g_vPointLightColors[8];
#line 14 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
uniform float g_vPointLightSizes[8];
#line 16 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
uniform sampler2D g_tTex2d1;
#line 16 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 16 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
uniform sampler2D g_tTex2d0;
#line 16 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 13 // e:/My Projects/LSEngine/LSTest/Data/LSDFresnel.lssl
#line 17 // e:/My Projects/LSEngine/LSTest/Data/LSDFresnel.lssl
#line 21 // e:/My Projects/LSEngine/LSTest/Data/LSDFresnel.lssl
float SchlickFresnel_SG(float _F0,float _fU){
{
return (_F0+((1.0-_F0)*exp2((((_fU*-5.5547300000000002)-6.9831599999999998)*_fU))));}
}
#line 5 // e:/My Projects/LSEngine/LSTest/Data/LSDSqr.lssl
float Sqr(float _fF){
{
return (_fF*_fF);}
}
SKIP
#line 196 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
void main(){
{
#line 72 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vec4 vTex0=vec4(texture(g_tTex2d0,LSG_VERT_OUT_PIXEL_IN_386_0/*_vInTexCoord0*/));
#line 72 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vec4 vTex1=vec4(texture(g_tTex2d1,LSG_VERT_OUT_PIXEL_IN_386_0/*_vInTexCoord0*/));
[/spoiler]
Output in Direct3D 9 HLSL:
[spoiler]
#line 0 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vector<float,4>g_vDiffuseMaterial;
#line 1 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vector<float,4>g_vEmissiveMaterial;
#line 2 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vector<float,4>g_vSpecularMaterial;
#line 3 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
float g_fReflectivity;
#line 5 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
float g_fPower;
#line 6 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vector<float,4>g_vRoughness;
#line 7 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vector<float,4>g_vAshikFactors;
#line 9 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vector<float,4>g_vDirLightDirs[8];
#line 10 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vector<float,4>g_vDirLightColors[8];
#line 12 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vector<float,4>g_vPointLightPos[8];
#line 13 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vector<float,4>g_vPointLightColors[8];
#line 14 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
float g_vPointLightSizes[8];
#line 16 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
sampler2D g_tTex2d1:register(s1);
#line 16 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 16 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
sampler2D g_tTex2d0:register(s0);
#line 16 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 13 // e:/My Projects/LSEngine/LSTest/Data/LSDFresnel.lssl
#line 17 // e:/My Projects/LSEngine/LSTest/Data/LSDFresnel.lssl
#line 21 // e:/My Projects/LSEngine/LSTest/Data/LSDFresnel.lssl
float SchlickFresnel_SG(float _F0,float _fU){
{
return (_F0+((1.0-_F0)*exp2((((_fU*-5.5547300000000002)-6.9831599999999998)*_fU))));}
}
#line 5 // e:/My Projects/LSEngine/LSTest/Data/LSDSqr.lssl
float Sqr(float _fF){
{
return (_fF*_fF);}
}
SKIP
#line 195 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
void Main(out vector<float,4>_vOutColor:COLOR0,in vector<float,4>_vInPosition:POSITION0,in vector<float,3>_vInNormal:NORMAL0,in vector<float,2>_vInTexCoord0:TEXCOORD0,in vector<float,3>_vInTangent:TANGENT0,in vector<float,3>_vInBinormal:BINORMAL0,in vector<float,4>_vInViewPos:TEXCOORD1,in bool _bIsFrontFace:VFACE){
{
#line 71 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vector<float,4>vTex0=tex2D(g_tTex2d0,_vInTexCoord0);
#line 71 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vector<float,4>vTex1=tex2D(g_tTex2d1,_vInTexCoord0);
[/spoiler]
Direct3D 11 HLSL:
[spoiler]
Texture2D g_tTex2d1:register(t1);
SamplerState g_sSampler1:register(s1);
Texture2D g_tTex2d0:register(t0);
SamplerState g_sSampler0:register(s0);
cbuffer cb0:register(b0){
vector<float,4>g_vDiffuseMaterial:packoffset(c0.x);
vector<float,4>g_vSpecularMaterial:packoffset(c1.x);
float g_fPower:packoffset(c2.x);
vector<float,4>g_vRoughness:packoffset(c3.x);
vector<float,4>g_vAshikFactors:packoffset(c4.x);
};
cbuffer cb1:register(b1){
vector<float,4>g_vDirLightDirs[8]:packoffset(c0.x);
vector<float,4>g_vPointLightPos[8]:packoffset(c8.x);
};
cbuffer cb2:register(b2){
};
cbuffer cb3:register(b3){
vector<float,4>g_vDirLightColors[8]:packoffset(c0.x);
vector<float,4>g_vPointLightColors[8]:packoffset(c8.x);
float g_vPointLightSizes[8]:packoffset(c16.x);
};
#line 0 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 1 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 2 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 3 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 5 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 6 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 7 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 9 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 10 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 12 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 13 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 14 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 16 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 16 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 16 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 16 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
;
#line 13 // e:/My Projects/LSEngine/LSTest/Data/LSDFresnel.lssl
#line 17 // e:/My Projects/LSEngine/LSTest/Data/LSDFresnel.lssl
#line 21 // e:/My Projects/LSEngine/LSTest/Data/LSDFresnel.lssl
float SchlickFresnel_SG(float _F0,float _fU){
{
return (_F0+((1.0-_F0)*exp2((((_fU*-5.5547300000000002)-6.9831599999999998)*_fU))));}
}
#line 5 // e:/My Projects/LSEngine/LSTest/Data/LSDSqr.lssl
float Sqr(float _fF){
{
return (_fF*_fF);}
}
SKIP
#line 196 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
void Main(out vector<float,4>_vOutColor:SV_Target0,in vector<float,4>_vInPosition:SV_POSITION0,in vector<float,3>_vInNormal:NORMAL0,in vector<float,2>_vInTexCoord0:TEXCOORD0,in vector<float,3>_vInTangent:TANGENT0,in vector<float,3>_vInBinormal:BINORMAL0,in vector<float,4>_vInViewPos:TEXCOORD1,in bool _bIsFrontFace:SV_ISFRONTFACE){
{
#line 72 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vector<float,4>vTex0=g_tTex2d0.Sample(g_sSampler0,_vInTexCoord0);
#line 72 // e:/My Projects/LSEngine/LSTest/Data/LSDPixelForwardDefaultPS.lssl
vector<float,4>vTex1=g_tTex2d1.Sample(g_sSampler1,_vInTexCoord0);
[/spoiler]
LSE_TEX_UNIFORMS is a macro generated by the engine. It expands to define each sampler/texture the model will access, but you are of course free to either not use it at all or manually define your own textures/samplers.
Basically the language itself is just a standard shading language, and the engine then also adds a ton of pre-defined macros you can use at your leisure. This includes lse_MainPsInputs and lse_MainVsInputs, which will define a position, normal, binormal, tangent, vertex color, etc., based on the flags you set when you use the model shader manager to create your shaders (by default the flags are set to match the model’s vertex buffer).
You can see a lot of #line pragmas with nothing following them. Unreferenced functions and globals are removed.
L. Spiro