objectshader refactor - part 2

This commit is contained in:
turanszkij
2016-02-10 23:20:06 +01:00
parent 24d6df4dfe
commit eee6eeeaf3
18 changed files with 153 additions and 290 deletions
+9 -9
View File
@@ -1858,9 +1858,6 @@
<None Include="imageHF.hlsli">
<Filter>shaders\headers</Filter>
</None>
<None Include="lightHF.hlsli">
<Filter>shaders\headers</Filter>
</None>
<None Include="normalsCompressHF.hlsli">
<Filter>shaders\headers</Filter>
</None>
@@ -1913,6 +1910,9 @@
<None Include="objectHF.hlsli">
<Filter>shaders\object</Filter>
</None>
<None Include="lightHF.hlsli">
<Filter>shaders\lighting</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="..\features.txt" />
@@ -1983,12 +1983,6 @@
<FxCompile Include="trailVS.hlsl">
<Filter>shaders</Filter>
</FxCompile>
<FxCompile Include="waterPS.hlsl">
<Filter>shaders</Filter>
</FxCompile>
<FxCompile Include="waterVS.hlsl">
<Filter>shaders</Filter>
</FxCompile>
<FxCompile Include="grassL0GS.hlsl">
<Filter>shaders\grass</Filter>
</FxCompile>
@@ -2178,6 +2172,12 @@
<FxCompile Include="objectVS10.hlsl">
<Filter>shaders\object</Filter>
</FxCompile>
<FxCompile Include="waterPS.hlsl">
<Filter>shaders\object</Filter>
</FxCompile>
<FxCompile Include="waterVS.hlsl">
<Filter>shaders\object</Filter>
</FxCompile>
</ItemGroup>
<ItemGroup>
<Image Include="fonts\basic.dds">
+2 -2
View File
@@ -88,8 +88,8 @@ inline float dirLight(in float3 pos3D, in float3 normal, inout float4 color, in
// MACROS
#define DEFERRED_DIRLIGHT_MAIN \
float lighting = dirLight(pos3D,normal,color,toonshaded); \
float lighting = dirLight(P,N,color,toonshaded); \
color.rgb *= lighting; \
applySpecular(color, color*lighting, normal, eyevector, g_xDirLight_direction.xyz, 1, specular_power, specular, toonshaded);
applySpecular(color, color*lighting, N, V, g_xDirLight_direction.xyz, 1, specular_power, specular, toonshaded);
#endif // _DIRLIGHT_HF_
+3 -3
View File
@@ -33,10 +33,10 @@ static const float specularMaximumIntensity = 1;
float4 material = texture_gbuffer2.SampleLevel(sampler_point_clamp,screenPos,0); \
float specular = material.w*specularMaximumIntensity; \
uint specular_power = material.z; \
float3 normal = norU.xyz; \
float3 N = norU.xyz; \
bool toonshaded = isToon(norU.w); \
float3 pos3D = getPosition(screenPos, depth); \
float3 eyevector = normalize(g_xCamera_CamPos - pos3D.xyz);
float3 P = getPosition(screenPos, depth); \
float3 V = normalize(P - g_xCamera_CamPos);
#define DEFERREDLIGHT_RETURN \
return max(unshaded? 1 : color, 0.0f);
+44 -9
View File
@@ -37,7 +37,7 @@ struct PixelInputType
float ao : AMBIENT_OCCLUSION;
nointerpolation float dither : DITHER;
nointerpolation float3 instanceColor : INSTANCECOLOR;
float3 nor2D : NORMAL2D;
float2 nor2D : NORMAL2D;
};
struct PixelOutputType
@@ -58,11 +58,10 @@ inline void BaseColorMapping(in float2 UV, inout float4 baseColor)
}
}
inline void NormalMapping(in float2 UV, in float3 V, inout float3 N)
inline void NormalMapping(in float2 UV, in float3 V, inout float3 N, inout float3 bumpColor)
{
if (g_xMat_hasNor)
{
float3 bumpColor = 0;
float4 nortex = xNormalMap.Sample(sampler_aniso_wrap, UV);
float3x3 tangentFrame = compute_tangent_frame(N, V, -UV);
bumpColor = 2.0f * nortex.rgb - 1.0f;
@@ -87,6 +86,14 @@ inline void PlanarReflection(in float2 UV, in float2 reflectionUV, in float3 N,
}
}
inline void Refraction(in float2 ScreenCoord, in float2 normal2D, in float3 bumpColor, inout float4 baseColor)
{
float2 perturbatedRefrTexCoords = ScreenCoord.xy + (normal2D + bumpColor.rg) * g_xMat_refractionIndex;
float4 refractiveColor = (xRefraction.SampleLevel(sampler_linear_clamp, perturbatedRefrTexCoords, 0));
baseColor.rgb = lerp(refractiveColor.rgb, baseColor.rgb, baseColor.a);
baseColor.a = 1;
}
// #define ENVMAP_CAMERA_BLEND
inline void EnvironmentReflection(in float3 N, in float3 V, in float3 P, in float roughness, in float metalness, in float4 specularColor,
inout float4 color)
@@ -116,6 +123,14 @@ inline void EnvironmentReflection(in float3 N, in float3 V, in float3 P, in floa
color.rgb += envCol.rgb * specularColor.rgb * metalness;
}
inline void DirectionalLight(in float3 N, in float3 V, in float4 specularColor, inout float4 baseColor)
{
float3 light = saturate(dot(g_xWorld_SunDir.xyz, N));
light = clamp(light, g_xWorld_Ambient.rgb, 1);
baseColor.rgb *= light*g_xWorld_SunColor.rgb;
applySpecular(baseColor, g_xWorld_SunColor, N, V, g_xWorld_SunDir.xyz, 1, g_xMat_specular_power, specularColor.a, 0);
}
// MACROS
////////////
@@ -131,16 +146,18 @@ inline void EnvironmentReflection(in float3 N, in float3 V, in float3 P, in floa
float2 refUV = float2(1, -1)*PSIn.ReflectionMapSamplingPos.xy / PSIn.ReflectionMapSamplingPos.w / 2.0f + 0.5f; \
float2 ScreenCoord = float2(1, -1) * PSIn.pos2D.xy / PSIn.pos2D.w / 2.0f + 0.5f; \
float2 ScreenCoordPrev = float2(1, -1)*PSIn.pos2DPrev.xy / PSIn.pos2DPrev.w / 2.0f + 0.5f; \
float depth = PSIn.pos.z / PSIn.pos.w; \
float lineardepth = PSIn.pos2D.z; \
float depth = PSIn.pos2D.z / PSIn.pos2D.w; \
float3 bumpColor = 0; \
float4 baseColor = g_xMat_diffuseColor * float4(PSIn.instanceColor, 1); \
BaseColorMapping(UV, baseColor);
#define OBJECT_PS_MISC \
clip(dither(PSIn.pos.xy) - PSIn.dither); \
BaseColorMapping(UV, baseColor); \
ALPHATEST(baseColor.a)
#define OBJECT_PS_DITHER \
clip(dither(PSIn.pos.xy) - PSIn.dither); \
#define OBJECT_PS_NORMALMAPPING \
NormalMapping(UV, V, N);
NormalMapping(UV, V, N, bumpColor);
#define OBJECT_PS_SPECULARMAPPING \
SpecularMapping(UV, specularColor);
@@ -151,6 +168,21 @@ inline void EnvironmentReflection(in float3 N, in float3 V, in float3 P, in floa
#define OBJECT_PS_PLANARREFLECTIONS \
PlanarReflection(PSIn.tex, refUV, N, baseColor);
#define OBJECT_PS_REFRACTION \
Refraction(ScreenCoord, PSIn.nor2D, bumpColor, baseColor);
#define OBJECT_PS_DEGAMMA \
baseColor = pow(abs(baseColor), GAMMA);
#define OBJECT_PS_GAMMA \
baseColor = pow(abs(baseColor*(1 + g_xMat_emissive)), INV_GAMMA);
#define OBJECT_PS_FOG \
baseColor.rgb = applyFog(baseColor.rgb, getFog(getLinearDepth(depth)));
#define OBJECT_PS_DIRECTIONALLIGHT \
DirectionalLight(N, V, specularColor, baseColor);
#define OBJECT_PS_OUT_GBUFFER \
bool unshaded = g_xMat_shadeless; \
float properties = unshaded ? RT_UNSHADED : 0.0f; \
@@ -160,4 +192,7 @@ inline void EnvironmentReflection(in float3 N, in float3 V, in float3 P, in floa
Out.vel = float4(ScreenCoord - ScreenCoordPrev, g_xMat_specular_power, specularColor.a); \
return Out;
#define OBJECT_PS_OUT_FORWARD \
return baseColor;
#endif // _OBJECTSHADER_HF_
+2 -2
View File
@@ -2,9 +2,9 @@
PixelOutputType main(PixelInputType PSIn)
{
OBJECT_PS_MAKE
OBJECT_PS_DITHER
OBJECT_PS_MISC
OBJECT_PS_MAKE
OBJECT_PS_NORMALMAPPING
+1 -7
View File
@@ -4,13 +4,7 @@
float4 main(PixelInputType PSIn) : SV_TARGET
{
float4 baseColor = float4(0,0,0,0);
if(g_xMat_hasTex) {
baseColor = xTextureMap.Sample(sampler_aniso_wrap,PSIn.tex);
}
ALPHATEST(baseColor.a)
OBJECT_PS_MAKE
return float4(0, 0, 0, 1);
}
+10 -56
View File
@@ -1,69 +1,23 @@
#include "objectHF.hlsli"
float4 main(PixelInputType PSIn) : SV_TARGET
{
clip(dither(PSIn.pos.xy) - PSIn.dither);
OBJECT_PS_DITHER
float4 baseColor = g_xMat_diffuseColor;
float depth = PSIn.pos2D.z;
OBJECT_PS_MAKE
PSIn.tex *= g_xMat_texMulAdd.xy;
PSIn.tex += g_xMat_texMulAdd.zw;
OBJECT_PS_NORMALMAPPING
if (g_xMat_hasTex) {
baseColor *= xTextureMap.Sample(sampler_aniso_wrap, PSIn.tex);
}
baseColor.rgb *= PSIn.instanceColor;
OBJECT_PS_SPECULARMAPPING
ALPHATEST(baseColor.a)
OBJECT_PS_DEGAMMA
if (!g_xMat_shadeless.x)
{
float4 spec = g_xMat_specular;
float3 normal = normalize(PSIn.nor);
float3 eyevector = normalize(g_xCamera_CamPos - PSIn.pos3D);
OBJECT_PS_DIRECTIONALLIGHT
baseColor = pow(abs(baseColor), GAMMA);
//NORMALMAP
float3 bumpColor = 0;
if (g_xMat_hasNor){
float4 nortex = xNormalMap.Sample(sampler_aniso_wrap, PSIn.tex);
if (nortex.a>0){
float3x3 tangentFrame = compute_tangent_frame(normal, eyevector, -PSIn.tex.xy);
bumpColor = 2.0f * nortex.rgb - 1.0f;
//bumpColor.g*=-1;
normal = normalize(mul(bumpColor, tangentFrame));
}
}
OBJECT_PS_GAMMA
OBJECT_PS_FOG
spec = lerp(spec, xSpecularMap.Sample(sampler_aniso_wrap, PSIn.tex).r, g_xMat_hasSpe);
//ENVIROMENT MAP
float4 envCol = 0;
{
uint mip = 0;
float2 size;
float mipLevels;
texture_env_global.GetDimensions(mip, size.x, size.y, mipLevels);
float3 ref = normalize(reflect(-eyevector, normal));
envCol = texture_env_global.SampleLevel(sampler_linear_clamp, ref, (1 - smoothstep(0, 128, g_xMat_specular_power))*mipLevels);
baseColor = lerp(baseColor, envCol, g_xMat_metallic*spec);
}
float3 light = saturate( dot(g_xWorld_SunDir.xyz,normalize(PSIn.nor)) );
light=clamp(light, g_xWorld_Ambient.rgb,1);
baseColor.rgb *= light*g_xWorld_SunColor.rgb;
applySpecular(baseColor, g_xWorld_SunColor, normal, eyevector, g_xWorld_SunDir.xyz, 1, g_xMat_specular_power, spec.a, 0);
baseColor = pow(abs(baseColor*(1 + g_xMat_emissive)), INV_GAMMA);
baseColor.rgb = applyFog(baseColor.rgb, getFog(getLinearDepth(depth / PSIn.pos2D.w)));
}
return baseColor;
OBJECT_PS_OUT_FORWARD
}
+1 -1
View File
@@ -4,6 +4,6 @@
float4 main(PixelInputType PSIn) : SV_TARGET
{
return g_xMat_diffuseColor;
return g_xMat_diffuseColor * float4(PSIn.instanceColor,1);
}
+2 -11
View File
@@ -4,18 +4,9 @@
float4 main(PixelInputType PSIn) : SV_TARGET
{
float4 baseColor = g_xMat_diffuseColor;
PSIn.tex *= g_xMat_texMulAdd.xy;
PSIn.tex += g_xMat_texMulAdd.zw;
if(g_xMat_hasTex) {
baseColor *= xTextureMap.Sample(sampler_aniso_wrap,PSIn.tex);
}
baseColor.rgb *= PSIn.instanceColor;
ALPHATEST(baseColor.a)
OBJECT_PS_DITHER
OBJECT_PS_MAKE
return baseColor*(1 + g_xMat_emissive);
}
+10 -66
View File
@@ -3,79 +3,23 @@
float4 main( PixelInputType PSIn) : SV_TARGET
{
float3 normal = normalize(PSIn.nor);
//uint mat = PSIn.mat;
float4 spec = g_xMat_specular;
float4 baseColor = g_xMat_diffuseColor;
OBJECT_PS_MAKE
PSIn.tex *= g_xMat_texMulAdd.xy;
PSIn.tex += g_xMat_texMulAdd.zw;
[branch]if(g_xMat_hasTex){
baseColor *= xTextureMap.Sample(sampler_aniso_wrap, PSIn.tex);
}
baseColor.rgb *= PSIn.instanceColor;
OBJECT_PS_NORMALMAPPING
ALPHATEST(baseColor.a)
OBJECT_PS_REFRACTION
float3 eyevector = normalize(g_xCamera_CamPos - PSIn.pos3D);
float2 screenPos;
screenPos.x = PSIn.pos2D.x/PSIn.pos2D.w/2.0f + 0.5f;
screenPos.y = -PSIn.pos2D.y/PSIn.pos2D.w/2.0f + 0.5f;
OBJECT_PS_DEGAMMA
OBJECT_PS_SPECULARMAPPING
//NORMALMAP
float3 bumpColor=0;
if(g_xMat_hasNor){
float4 nortex = xNormalMap.Sample(sampler_aniso_wrap,PSIn.tex);
if(nortex.a>0){
float3x3 tangentFrame = compute_tangent_frame(normal, eyevector, -PSIn.tex.xy);
bumpColor = 2.0f * nortex.rgb - 1.0f;
//bumpColor.g*=-1;
normal = normalize(mul(bumpColor, tangentFrame));
}
}
OBJECT_PS_ENVIRONMENTMAPPING
OBJECT_PS_DIRECTIONALLIGHT
//ENVIROMENT MAP
float4 envCol=0;
{
uint mip=0;
float2 size;
float mipLevels;
texture_env_global.GetDimensions(mip,size.x,size.y,mipLevels);
OBJECT_PS_GAMMA
float3 ref = normalize(reflect(-eyevector, normal));
envCol = texture_env_global.SampleLevel(sampler_linear_clamp,ref,(1-smoothstep(0,128, g_xMat_specular_power))*mipLevels);
baseColor = lerp(baseColor,envCol, g_xMat_metallic*spec);
}
//REFRACTION
float2 perturbatedRefrTexCoords = screenPos.xy + (normalize(PSIn.nor2D).rg + bumpColor.rg) * g_xMat_refractionIndex;
float4 refractiveColor = (xRefraction.SampleLevel(sampler_linear_clamp, perturbatedRefrTexCoords, 0));
baseColor.rgb=lerp(refractiveColor.rgb,baseColor.rgb,baseColor.a);
baseColor.rgb=pow(abs(baseColor.rgb),GAMMA);
baseColor.a=1;
float depth = PSIn.pos2D.z;
OBJECT_PS_FOG
//SPECULAR
if(g_xMat_hasSpe && !g_xMat_shadeless){
spec = xSpecularMap.Sample(sampler_aniso_wrap, PSIn.tex);
}
[branch]if(!g_xMat_shadeless.x){
baseColor.rgb*=clamp( saturate( abs(dot(g_xWorld_SunDir.xyz,PSIn.nor)) * g_xWorld_SunColor.rgb ), g_xWorld_Ambient.rgb,1 );
applySpecular(baseColor, g_xWorld_SunColor, normal, eyevector, g_xWorld_SunDir.xyz, 1, g_xMat_specular_power, spec.w, 0);
}
baseColor.rgb = pow(abs(baseColor.rgb*(1 + g_xMat_emissive)), INV_GAMMA);
baseColor.rgb = applyFog(baseColor.rgb,getFog(getLinearDepth(depth/PSIn.pos2D.w)));
return baseColor;
OBJECT_PS_OUT_FORWARD
}
+1 -1
View File
@@ -47,7 +47,7 @@ PixelInputType main(Input input)
Out.pos3D = pos.xyz;
Out.tex = input.tex.xy;
Out.nor = normalize(normal);
Out.nor2D = mul(Out.nor.xyz, (float3x3)g_xCamera_VP);
Out.nor2D = mul(Out.nor.xyz, (float3x3)g_xCamera_VP).xy;
Out.ReflectionMapSamplingPos = mul(pos, g_xCamera_ReflVP);
+1 -1
View File
@@ -39,7 +39,7 @@ PixelInputType main(Input input)
Out.pos3D = pos.xyz;
Out.tex = input.tex.xy;
Out.nor = normalize(normal);
Out.nor2D = float3(0,0,0);
Out.nor2D = float2(0,0);
Out.ReflectionMapSamplingPos = float4(0,0,0,0);
+2 -2
View File
@@ -8,9 +8,9 @@ float4 main(VertexToPixel PSIn) : SV_TARGET
float3 lightDir;
float attenuation;
float lightInt = pointLight(pos3D, normal, lightDir, attenuation, toonshaded);
float lightInt = pointLight(P, N, lightDir, attenuation, toonshaded);
color *= lightInt;
applySpecular(color, color * lightInt, normal, eyevector, lightDir, 1, specular_power, specular, toonshaded);
applySpecular(color, color * lightInt, N, V, lightDir, 1, specular_power, specular, toonshaded);
color *= attenuation;
DEFERREDLIGHT_RETURN
+3 -21
View File
@@ -4,36 +4,18 @@
#include "toonHF.hlsli"
#include "gammaHF.hlsli"
inline void applySpecular(inout float4 color, in float4 lightColor, in float3 normal, in float3 eyevector, in float3 lightDir
inline void applySpecular(inout float4 color, in float4 lightColor, in float3 N, in float3 V, in float3 lightDir
, in float fresnelValue, in int specular_power, in float intensity, in bool toonshaded)
{
if(specular_power){
//float3 reflectionVector = reflect(lightDir.xyz, normal.xyz);
//float spec = dot((reflectionVector), eyevector);
//spec = pow(saturate(-spec), specular_power)*intensity;
//color.rgb += (lightColor.rgb * spec);
//color.rgb*=1+spec;
////color.a=spec;
float3 reflectionVector = normalize(lightDir.xyz + eyevector.xyz);
float spec = saturate( dot(reflectionVector, normal) );
float3 reflectionVector = normalize(lightDir.xyz - V.xyz);
float spec = saturate( dot(reflectionVector, N) );
spec = pow(spec, specular_power)*intensity;
if(toonshaded) toon(spec);
color.rgb += (lightColor.rgb * spec);
color.rgb*=pow(abs(1+spec),GAMMA);
//float3 h = normalize(lightDir.xyz + eyevector.xyz); // Half-vector.
//float specBase = saturate(dot(normal.xyz, h)); // Regular spec.
//float fresnel = 1.0 - dot(eyevector, h); // Caculate fresnel.
//fresnel = pow(fresnel, 5.0);
//fresnel += fresnelValue * (1.0 - fresnel);
//float finalSpec = pow(specBase, specular_power) * intensity * fresnel;
//color.rgb += lightColor.rgb * finalSpec;
//color.rgb *= 1+finalSpec;
}
}
+2 -2
View File
@@ -8,9 +8,9 @@ float4 main(VertexToPixel PSIn) : SV_TARGET
float attenuation;
float3 lightToPixel;
float lightInt = spotLight(pos3D, normal, attenuation, lightToPixel, toonshaded);
float lightInt = spotLight(P, N, attenuation, lightToPixel, toonshaded);
color *= lightInt;
applySpecular(color, color * lightInt, normal, eyevector, lightToPixel, 1, specular_power, specular, toonshaded);
applySpecular(color, color * lightInt, N, V, lightToPixel, 1, specular_power, specular, toonshaded);
color *= attenuation;
DEFERREDLIGHT_RETURN
+48 -85
View File
@@ -5,100 +5,63 @@
#include "specularHF.hlsli"
#include "globals.hlsli"
//Texture2D<float> xDepthMap:register(t7);
//Texture2D<float4> xRippleMap:register(t8);
float4 main( PixelInputType PSIn) : SV_TARGET
float4 main(PixelInputType PSIn) : SV_TARGET
{
PixelOutputType Out = (PixelOutputType)0;
OBJECT_PS_MAKE
float3 normal = normalize(PSIn.nor);
float4 spec = g_xMat_specular;
float4 baseColor = float4(0,0,0,1);
OBJECT_PS_SPECULARMAPPING
baseColor.a = 1;
//NORMALMAP
float2 bumpColor0=0;
float2 bumpColor1=0;
float2 bumpColor2=0;
if(g_xMat_hasNor){
float3x3 tangentFrame = compute_tangent_frame(N, V, -PSIn.tex);
bumpColor0 = 2.0f * xNormalMap.Sample(sampler_aniso_wrap,PSIn.tex - g_xMat_texMulAdd.ww).rg - 1.0f;
bumpColor1 = 2.0f * xNormalMap.Sample(sampler_aniso_wrap,PSIn.tex + g_xMat_texMulAdd.zw).rg - 1.0f;
bumpColor2 = xWaterRipples.Sample(sampler_aniso_wrap,ScreenCoord).rg;
bumpColor= float3( bumpColor0+bumpColor1+bumpColor2,1 ) * g_xMat_refractionIndex;
N = normalize(mul(normalize(bumpColor), tangentFrame));
}
//REFLECTION
float2 RefTex = float2(1, -1)*PSIn.ReflectionMapSamplingPos.xy / PSIn.ReflectionMapSamplingPos.w / 2.0f + 0.5f;
float4 reflectiveColor = xReflection.SampleLevel(sampler_linear_mirror,RefTex+bumpColor.rg,0);
PSIn.tex *= g_xMat_texMulAdd.xy;
float3 eyevector = normalize(g_xCamera_CamPos - PSIn.pos3D);
float2 screenPos;
screenPos.x = PSIn.pos2D.x/PSIn.pos2D.w/2.0f + 0.5f;
screenPos.y = -PSIn.pos2D.y/PSIn.pos2D.w/2.0f + 0.5f;
//REFRACTION
float2 perturbatedRefrTexCoords = ScreenCoord.xy + bumpColor.rg;
float refDepth = (texture_lineardepth.Sample(sampler_linear_mirror, ScreenCoord));
float3 refractiveColor = xRefraction.SampleLevel(sampler_linear_mirror, perturbatedRefrTexCoords, 0).rgb;
float eyeDot = dot(N, -V);
float mod = saturate(0.05*(refDepth- lineardepth));
float3 dullColor = lerp(refractiveColor, g_xMat_diffuseColor.rgb, saturate(eyeDot));
refractiveColor = lerp(refractiveColor, dullColor, mod).rgb;
//FRESNEL TERM
float fresnelTerm = abs(eyeDot);
baseColor.rgb = lerp(reflectiveColor.rgb, refractiveColor, fresnelTerm);
//NORMALMAP
float2 bumpColor0=0;
float2 bumpColor1=0;
float2 bumpColor2=0;
float3 bumpColor=0;
if(g_xMat_hasNor){
float3x3 tangentFrame = compute_tangent_frame(normal, eyevector, -PSIn.tex);
bumpColor0 = 2.0f * xNormalMap.Sample(sampler_aniso_wrap,PSIn.tex - g_xMat_texMulAdd.ww).rg - 1.0f;
bumpColor1 = 2.0f * xNormalMap.Sample(sampler_aniso_wrap,PSIn.tex + g_xMat_texMulAdd.zw).rg - 1.0f;
bumpColor2 = xWaterRipples.Sample(sampler_aniso_wrap,screenPos).rg;
bumpColor= float3( bumpColor0+bumpColor1+bumpColor2,1 ) * g_xMat_refractionIndex;
normal = normalize(mul(normalize(bumpColor), tangentFrame));
//normal = (bumpColor.x * PSIn.tan) + (bumpColor.y * PSIn.bin) + (bumpColor.z * PSIn.nor);
//normal = normalize(normal);
}
////ENVIROMENT MAP
//float3 ref = (reflect(-eyevector, normal));
//float3 skyColor = enviroTex.Sample(texSampler,ref).rgb;
//REFLECTION
float2 RefTex;
RefTex.x = PSIn.ReflectionMapSamplingPos.x/PSIn.ReflectionMapSamplingPos.w/2.0f + 0.5f;
RefTex.y = -PSIn.ReflectionMapSamplingPos.y/PSIn.ReflectionMapSamplingPos.w/2.0f + 0.5f;
float4 reflectiveColor = xReflection.SampleLevel(sampler_linear_mirror,RefTex+bumpColor.rg,0);
//reflectiveColor.rgb = lerp(skyColor, reflectiveColor.rgb, reflectiveColor.a);
//REFRACTION
float2 perturbatedRefrTexCoords = screenPos.xy + bumpColor.rg;
float depth = PSIn.pos2D.z;
float refDepth = (texture_lineardepth.Sample(sampler_linear_mirror, screenPos));
float3 refractiveColor = xRefraction.SampleLevel(sampler_linear_mirror, perturbatedRefrTexCoords, 0).rgb;
float eyeDot = dot(normal, eyevector);
float mod = saturate(0.05*(refDepth-depth));
float3 dullColor = lerp(refractiveColor, g_xMat_diffuseColor.rgb, saturate(eyeDot));
refractiveColor = lerp(refractiveColor, dullColor, mod).rgb;
//FRESNEL TERM
float fresnelTerm = abs(eyeDot);
baseColor.rgb = lerp(reflectiveColor.rgb, refractiveColor, fresnelTerm);
//DULL COLOR
baseColor.rgb = lerp(baseColor.rgb, g_xMat_diffuseColor.rgb, 0.16);
baseColor.rgb=pow(abs(baseColor.rgb),GAMMA);
//DULL COLOR
baseColor.rgb = lerp(baseColor.rgb, g_xMat_diffuseColor.rgb, 0.16);
//SOFT EDGE
float fade = saturate(0.3* abs(refDepth-depth));
baseColor.a*=fade;
//SOFT EDGE
float fade = saturate(0.3* abs(refDepth- lineardepth));
baseColor.a*=fade;
OBJECT_PS_DEGAMMA
baseColor.rgb*= clamp( saturate( abs(dot(g_xWorld_SunDir.xyz,PSIn.nor)) *g_xWorld_SunColor.rgb ), g_xWorld_Ambient.rgb,1 );
//SPECULAR
if(g_xMat_hasSpe){
spec = xSpecularMap.Sample(sampler_aniso_wrap, PSIn.tex);
}
/*float3 reflectionVector = reflect(xSun, normal);
float specR = dot(normalize(reflectionVector), eyevector);
specR = pow(abs(specR), specular_power)*spec.w;
baseColor.rgb += saturate(xSunColor.rgb) * specR;*/
applySpecular(baseColor, g_xWorld_SunColor, normal, eyevector, g_xWorld_SunDir.xyz, 1, g_xMat_specular_power, spec.w, 0);
OBJECT_PS_DIRECTIONALLIGHT
OBJECT_PS_GAMMA
baseColor.rgb = pow(abs(baseColor.rgb*(1 + g_xMat_emissive)), INV_GAMMA);
OBJECT_PS_FOG
baseColor.rgb = applyFog(baseColor.rgb,getFog(getLinearDepth(depth/PSIn.pos2D.w)));
//Out.col = saturate(baseColor);
//Out.nor = float4((normal),1);
//Out.spe = saturate(spec);
//Out.vel = float4(PSIn.vel*float3(-1,1,1),1);
return baseColor;
OBJECT_PS_OUT_FORWARD
}
+11 -11
View File
@@ -770,7 +770,7 @@ void wiRenderer::LoadBasicShaders()
{ "COLOR_DITHER", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
};
UINT numElements = ARRAYSIZE(layout);
VertexShaderInfo* vsinfo = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "effectVS10.cso", wiResourceManager::VERTEXSHADER, layout, numElements));
VertexShaderInfo* vsinfo = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "objectVS10.cso", wiResourceManager::VERTEXSHADER, layout, numElements));
if (vsinfo != nullptr){
vertexShaders[VSTYPE_EFFECT10] = vsinfo->vertexShader;
vertexLayouts[VLTYPE_EFFECT] = vsinfo->vertexLayout;
@@ -811,8 +811,8 @@ void wiRenderer::LoadBasicShaders()
}
vertexShaders[VSTYPE_EFFECT] = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "effectVS.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
vertexShaders[VSTYPE_EFFECT_REFLECTION] = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "effectVS_reflection.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
vertexShaders[VSTYPE_EFFECT] = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "objectVS.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
vertexShaders[VSTYPE_EFFECT_REFLECTION] = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "objectVS_reflection.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
vertexShaders[VSTYPE_DIRLIGHT] = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "dirLightVS.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
vertexShaders[VSTYPE_POINTLIGHT] = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "pointLightVS.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
vertexShaders[VSTYPE_SPOTLIGHT] = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "spotLightVS.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
@@ -822,12 +822,12 @@ void wiRenderer::LoadBasicShaders()
vertexShaders[VSTYPE_ENVMAP] = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "envMapVS.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
vertexShaders[VSTYPE_ENVMAP_SKY] = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "envMap_skyVS.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
pixelShaders[PSTYPE_EFFECT] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "effectPS.cso", wiResourceManager::PIXELSHADER));
pixelShaders[PSTYPE_EFFECT_TRANSPARENT] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "effectPS_transparent.cso", wiResourceManager::PIXELSHADER));
pixelShaders[PSTYPE_SIMPLEST] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "effectPS_simplest.cso", wiResourceManager::PIXELSHADER));
pixelShaders[PSTYPE_EFFECT_FORWARDSIMPLE] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "effectPS_forwardSimple.cso", wiResourceManager::PIXELSHADER));
pixelShaders[PSTYPE_BLACKOUT] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "effectPS_blackout.cso", wiResourceManager::PIXELSHADER));
pixelShaders[PSTYPE_TEXTUREONLY] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "effectPS_textureonly.cso", wiResourceManager::PIXELSHADER));
pixelShaders[PSTYPE_EFFECT] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "objectPS.cso", wiResourceManager::PIXELSHADER));
pixelShaders[PSTYPE_EFFECT_TRANSPARENT] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "objectPS_transparent.cso", wiResourceManager::PIXELSHADER));
pixelShaders[PSTYPE_SIMPLEST] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "objectPS_simplest.cso", wiResourceManager::PIXELSHADER));
pixelShaders[PSTYPE_EFFECT_FORWARDSIMPLE] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "objectPS_forwardSimple.cso", wiResourceManager::PIXELSHADER));
pixelShaders[PSTYPE_BLACKOUT] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "objectPS_blackout.cso", wiResourceManager::PIXELSHADER));
pixelShaders[PSTYPE_TEXTUREONLY] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "objectPS_textureonly.cso", wiResourceManager::PIXELSHADER));
pixelShaders[PSTYPE_DIRLIGHT] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "dirLightPS.cso", wiResourceManager::PIXELSHADER));
pixelShaders[PSTYPE_DIRLIGHT_SOFT] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "dirLightSoftPS.cso", wiResourceManager::PIXELSHADER));
pixelShaders[PSTYPE_POINTLIGHT] = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "pointLightPS.cso", wiResourceManager::PIXELSHADER));
@@ -861,8 +861,8 @@ void wiRenderer::LoadLineShaders()
}
void wiRenderer::LoadTessShaders()
{
hullShaders[HSTYPE_EFFECT] = static_cast<HullShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "effectHS.cso", wiResourceManager::HULLSHADER));
domainShaders[DSTYPE_EFFECT] = static_cast<DomainShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "effectDS.cso", wiResourceManager::DOMAINSHADER));
hullShaders[HSTYPE_EFFECT] = static_cast<HullShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "objectHS.cso", wiResourceManager::HULLSHADER));
domainShaders[DSTYPE_EFFECT] = static_cast<DomainShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "objectDS.cso", wiResourceManager::DOMAINSHADER));
}
void wiRenderer::LoadSkyShaders()
+1 -1
View File
@@ -7,7 +7,7 @@ namespace wiVersion
// minor features, major bug fixes
const int minor = 6;
// minor bug fixes, alterations, refactors
const int revision = 7;
const int revision = 8;
long GetVersion()