|
|
@ -9,6 +9,8 @@
|
|
|
|
#define NEED_DEPTH
|
|
|
|
#define NEED_DEPTH
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define NUM_LIGHTS 8
|
|
|
|
|
|
|
|
|
|
|
|
#define HAS_VERTEXCOLOR @shPropertyBool(has_vertex_colour)
|
|
|
|
#define HAS_VERTEXCOLOR @shPropertyBool(has_vertex_colour)
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SH_VERTEX_SHADER
|
|
|
|
#ifdef SH_VERTEX_SHADER
|
|
|
@ -18,10 +20,15 @@
|
|
|
|
shInput(float2, uv0)
|
|
|
|
shInput(float2, uv0)
|
|
|
|
shOutput(float2, UV)
|
|
|
|
shOutput(float2, UV)
|
|
|
|
shNormalInput(float4)
|
|
|
|
shNormalInput(float4)
|
|
|
|
shOutput(float4, normalPassthrough)
|
|
|
|
|
|
|
|
#ifdef NEED_DEPTH
|
|
|
|
#ifdef NEED_DEPTH
|
|
|
|
shOutput(float, depthPassthrough)
|
|
|
|
shOutput(float, depthPassthrough)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if LIGHTING
|
|
|
|
|
|
|
|
shOutput(float3, normalPassthrough)
|
|
|
|
|
|
|
|
shOutput(float3, objSpacePositionPassthrough)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if HAS_VERTEXCOLOR
|
|
|
|
#if HAS_VERTEXCOLOR
|
|
|
|
shColourInput(float4)
|
|
|
|
shColourInput(float4)
|
|
|
|
shOutput(float4, colorPassthrough)
|
|
|
|
shOutput(float4, colorPassthrough)
|
|
|
@ -30,11 +37,15 @@
|
|
|
|
{
|
|
|
|
{
|
|
|
|
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
|
|
|
shOutputPosition = shMatrixMult(wvp, shInputPosition);
|
|
|
|
UV = uv0;
|
|
|
|
UV = uv0;
|
|
|
|
normalPassthrough = normal;
|
|
|
|
normalPassthrough = normal.xyz;
|
|
|
|
#ifdef NEED_DEPTH
|
|
|
|
#ifdef NEED_DEPTH
|
|
|
|
depthPassthrough = shOutputPosition.z;
|
|
|
|
depthPassthrough = shOutputPosition.z;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if LIGHTING
|
|
|
|
|
|
|
|
objSpacePositionPassthrough = shInputPosition.xyz;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if HAS_VERTEXCOLOR
|
|
|
|
#if HAS_VERTEXCOLOR
|
|
|
|
colorPassthrough = colour;
|
|
|
|
colorPassthrough = colour;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -48,7 +59,6 @@
|
|
|
|
#if MRT
|
|
|
|
#if MRT
|
|
|
|
shDeclareMrtOutput(1)
|
|
|
|
shDeclareMrtOutput(1)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
shInput(float4, normalPassthrough)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef NEED_DEPTH
|
|
|
|
#ifdef NEED_DEPTH
|
|
|
|
shInput(float, depthPassthrough)
|
|
|
|
shInput(float, depthPassthrough)
|
|
|
@ -56,6 +66,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
shUniform(float far) @shAutoConstant(far, far_clip_distance)
|
|
|
|
shUniform(float far) @shAutoConstant(far, far_clip_distance)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if LIGHTING
|
|
|
|
|
|
|
|
shInput(float3, normalPassthrough)
|
|
|
|
|
|
|
|
shInput(float3, objSpacePositionPassthrough)
|
|
|
|
|
|
|
|
shUniform(float4 lightAmbient) @shAutoConstant(lightAmbient, ambient_light_colour)
|
|
|
|
|
|
|
|
shUniform(float passIteration) @shAutoConstant(passIteration, pass_iteration_number)
|
|
|
|
|
|
|
|
shUniform(float4 materialAmbient) @shAutoConstant(materialAmbient, surface_ambient_colour)
|
|
|
|
|
|
|
|
shUniform(float4 materialDiffuse) @shAutoConstant(materialDiffuse, surface_diffuse_colour)
|
|
|
|
|
|
|
|
shUniform(float4 materialEmissive) @shAutoConstant(materialEmissive, surface_emissive_colour)
|
|
|
|
|
|
|
|
@shForeach(NUM_LIGHTS)
|
|
|
|
|
|
|
|
shUniform(float4 lightPosObjSpace@shIterator) @shAutoConstant(lightPosObjSpace@shIterator, light_position_object_space, @shIterator)
|
|
|
|
|
|
|
|
shUniform(float4 lightAttenuation@shIterator) @shAutoConstant(lightAttenuation@shIterator, light_attenuation, @shIterator)
|
|
|
|
|
|
|
|
shUniform(float4 lightDiffuse@shIterator) @shAutoConstant(lightDiffuse@shIterator, light_diffuse_colour, @shIterator)
|
|
|
|
|
|
|
|
@shEndForeach
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if FOG
|
|
|
|
#if FOG
|
|
|
|
shUniform(float3 fogColor) @shAutoConstant(fogColor, fog_colour)
|
|
|
|
shUniform(float3 fogColor) @shAutoConstant(fogColor, fog_colour)
|
|
|
|
shUniform(float4 fogParams) @shAutoConstant(fogParams, fog_params)
|
|
|
|
shUniform(float4 fogParams) @shAutoConstant(fogParams, fog_params)
|
|
|
@ -66,9 +91,29 @@
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
SH_START_PROGRAM
|
|
|
|
SH_START_PROGRAM
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//shOutputColor(0) = float4((normalize(normalPassthrough.xyz)+float3(1.0,1.0,1.0)) / 2.f, 1.0);
|
|
|
|
|
|
|
|
shOutputColor(0) = shSample(diffuseMap, UV);
|
|
|
|
shOutputColor(0) = shSample(diffuseMap, UV);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if LIGHTING
|
|
|
|
|
|
|
|
float3 normal = normalize(normalPassthrough);
|
|
|
|
|
|
|
|
float3 lightDir, diffuse;
|
|
|
|
|
|
|
|
float d;
|
|
|
|
|
|
|
|
float3 ambient = materialAmbient.xyz * lightAmbient.xyz;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@shForeach(NUM_LIGHTS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lightDir = lightPosObjSpace@shIterator.xyz - (objSpacePositionPassthrough.xyz * lightPosObjSpace@shIterator.w);
|
|
|
|
|
|
|
|
d = length(lightDir);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lightDir = normalize(lightDir);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
diffuse += materialDiffuse.xyz * lightDiffuse@shIterator.xyz * (1.0 / ((lightAttenuation@shIterator.y) + (lightAttenuation@shIterator.z * d) + (lightAttenuation@shIterator.w * d * d))) * max(dot(normal, lightDir), 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@shEndForeach
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shOutputColor(0).xyz *= (ambient + diffuse + materialEmissive.xyz);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if HAS_VERTEXCOLOR
|
|
|
|
#if HAS_VERTEXCOLOR
|
|
|
|
shOutputColor(0).xyz *= colorPassthrough.xyz;
|
|
|
|
shOutputColor(0).xyz *= colorPassthrough.xyz;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|