diff --git a/WickedEngine/envMapGS.hlsl b/WickedEngine/envMapGS.hlsl index 4ba1361c1..78b911f68 100644 --- a/WickedEngine/envMapGS.hlsl +++ b/WickedEngine/envMapGS.hlsl @@ -6,12 +6,12 @@ CBUFFER(CubemapRenderCB, CBSLOT_RENDERER_CUBEMAPRENDER) } [maxvertexcount(18)] -void main(triangle VSOut input[3], inout TriangleStream CubeMapStream) +void main(triangle VSOut_EnvmapRendering input[3], inout TriangleStream CubeMapStream) { [unroll] for (int f = 0; f < 6; ++f) { - PSIn output; + PSIn_EnvmapRendering output; output.RTIndex = f; [unroll] for (uint v = 0; v < 3; v++) diff --git a/WickedEngine/envMapHF.hlsli b/WickedEngine/envMapHF.hlsli index 223b18204..ac4cf05a2 100644 --- a/WickedEngine/envMapHF.hlsli +++ b/WickedEngine/envMapHF.hlsli @@ -3,7 +3,7 @@ #include "globals.hlsli" -struct VSOut +struct VSOut_EnvmapRendering { float4 pos : SV_Position; float3 nor : NORMAL; @@ -12,7 +12,7 @@ struct VSOut float ao : AMBIENT_OCCLUSION; }; -struct PSIn +struct PSIn_EnvmapRendering { float4 pos : SV_Position; float3 pos3D : WORLDPOSITION; @@ -24,13 +24,13 @@ struct PSIn }; -struct VSOut_Sky +struct VSOut_Sky_EnvmapRendering { float4 pos : SV_POSITION; float3 nor : NORMAL; }; -struct PSIn_Sky +struct PSIn_Sky_EnvmapRendering { float4 pos : SV_POSITION; float3 nor : NORMAL; diff --git a/WickedEngine/envMapVS.hlsl b/WickedEngine/envMapVS.hlsl index aeab3b814..faab4e865 100644 --- a/WickedEngine/envMapVS.hlsl +++ b/WickedEngine/envMapVS.hlsl @@ -2,9 +2,9 @@ #include "envMapHF.hlsli" -VSOut main(Input_Object_POS_TEX input) +VSOut_EnvmapRendering main(Input_Object_POS_TEX input) { - VSOut Out = (VSOut)0; + VSOut_EnvmapRendering Out; float4x4 WORLD = MakeWorldMatrixFromInstance(input.instance); VertexSurface surface = MakeVertexSurfaceFromInput(input); diff --git a/WickedEngine/envMap_skyGS.hlsl b/WickedEngine/envMap_skyGS.hlsl index 690177e5b..7a40fabdd 100644 --- a/WickedEngine/envMap_skyGS.hlsl +++ b/WickedEngine/envMap_skyGS.hlsl @@ -6,11 +6,11 @@ CBUFFER(CubemapRenderCB, CBSLOT_RENDERER_CUBEMAPRENDER) } [maxvertexcount(18)] -void main(triangle VSOut_Sky input[3], inout TriangleStream< PSIn_Sky > CubeMapStream) +void main(triangle VSOut_Sky_EnvmapRendering input[3], inout TriangleStream< PSIn_Sky_EnvmapRendering > CubeMapStream) { for (int f = 0; f < 6; ++f) { - PSIn_Sky output; + PSIn_Sky_EnvmapRendering output; output.RTIndex = f; for (uint v = 0; v < 3; v++) { diff --git a/WickedEngine/envMap_skyPS_dynamic.hlsl b/WickedEngine/envMap_skyPS_dynamic.hlsl index 1f93a3f9a..a658cf45a 100644 --- a/WickedEngine/envMap_skyPS_dynamic.hlsl +++ b/WickedEngine/envMap_skyPS_dynamic.hlsl @@ -2,7 +2,7 @@ #include "lightingHF.hlsli" #include "skyHF.hlsli" -float4 main(PSIn_Sky input) : SV_TARGET +float4 main(PSIn_Sky_EnvmapRendering input) : SV_TARGET { float3 normal = normalize(input.nor); float4 color = float4(GetDynamicSkyColor(normal), 1); diff --git a/WickedEngine/envMap_skyPS_static.hlsl b/WickedEngine/envMap_skyPS_static.hlsl index 766ea072b..417e9833a 100644 --- a/WickedEngine/envMap_skyPS_static.hlsl +++ b/WickedEngine/envMap_skyPS_static.hlsl @@ -3,7 +3,7 @@ TEXTURECUBE(texture_sky, float4, TEXSLOT_ONDEMAND0) -float4 main(PSIn_Sky input) : SV_TARGET +float4 main(PSIn_Sky_EnvmapRendering input) : SV_TARGET { float3 normal = normalize(input.nor); return float4(DEGAMMA(texture_sky.SampleLevel(sampler_linear_clamp, normal, 0).rgb), 1); diff --git a/WickedEngine/envMap_skyVS.hlsl b/WickedEngine/envMap_skyVS.hlsl index e7f92aa2a..da973fe4d 100644 --- a/WickedEngine/envMap_skyVS.hlsl +++ b/WickedEngine/envMap_skyVS.hlsl @@ -1,9 +1,9 @@ #include "envMapHF.hlsli" #include "icosphere.hlsli" -VSOut_Sky main(uint vid : SV_VERTEXID) +VSOut_Sky_EnvmapRendering main(uint vid : SV_VERTEXID) { - VSOut_Sky Out; + VSOut_Sky_EnvmapRendering Out; Out.pos = float4(ICOSPHERE[vid].xyz,0); Out.nor = ICOSPHERE[vid].xyz; return Out; diff --git a/WickedEngine/objectHF.hlsli b/WickedEngine/objectHF.hlsli index 7c547d824..39865a4d8 100644 --- a/WickedEngine/objectHF.hlsli +++ b/WickedEngine/objectHF.hlsli @@ -1,7 +1,7 @@ #ifndef _OBJECTSHADER_HF_ #define _OBJECTSHADER_HF_ -#if !(defined(TILEDFORWARD) && !defined(TRANSPARENT)) +#if defined(TILEDFORWARD) && !defined(TRANSPARENT) #define DISABLE_ALPHATEST #endif @@ -164,7 +164,7 @@ inline void ParallaxOcclusionMapping(inout float2 UV, in float3 V, in float3x3 T UV = finalTexCoords; } -inline void Refraction(in float2 ScreenCoord, in float2 normal2D, in float3 bumpColor, in Surface surface, inout float4 color) +inline void Refraction(in float2 ScreenCoord, in float2 normal2D, in float3 bumpColor, inout Surface surface, inout float4 color) { float2 size; float mipLevels; @@ -329,13 +329,16 @@ inline void TiledLighting(in float2 pixel, in Surface surface, inout float3 diff envmapAccumulation.rgb = (1 - envmapAccumulation.a) * (envmapColor.a * envmapColor.rgb) + envmapAccumulation.rgb; envmapAccumulation.a = envmapColor.a + (1 - envmapColor.a) * envmapAccumulation.a; // if the accumulation reached 1, we skip the rest of the probes: - iterator = envmapAccumulation.a < 1 ? iterator : envmapCount - 1; + iterator = envmapAccumulation.a < 1 ? iterator : envmapArrayEnd - 1; } } #endif // DISABLE_LOCALENVPMAPS // Apply global envmap where there is no local envmap information: - envmapAccumulation.rgb = lerp(EnvironmentReflection_Global(surface.P, surface.R, envMapMIP), envmapAccumulation.rgb, envmapAccumulation.a); + if (envmapAccumulation.a < 0.99f) + { + envmapAccumulation.rgb = lerp(EnvironmentReflection_Global(surface.P, surface.R, envMapMIP), envmapAccumulation.rgb, envmapAccumulation.a); + } specular += max(0, envmapAccumulation.rgb * surface.F); @@ -443,7 +446,7 @@ float4 main(PIXELINPUT input) : SV_TARGET #elif defined(TRANSPARENT) float4 main(PIXELINPUT input) : SV_TARGET #elif defined(ENVMAPRENDERING) -float4 main(PSIn input) : SV_TARGET +float4 main(PSIn_EnvmapRendering input) : SV_TARGET #elif defined(DEFERRED) GBUFFEROutputType main(PIXELINPUT input) #elif defined(FORWARD) @@ -594,7 +597,7 @@ GBUFFEROutputType_Thin main(PIXELINPUT input) #endif - // return point: + // end point: #if defined(TRANSPARENT) || defined(TEXTUREONLY) || defined(ENVMAPRENDERING) return color; #else @@ -612,95 +615,4 @@ GBUFFEROutputType_Thin main(PIXELINPUT input) -//// MACROS -////////////// -// -//#define OBJECT_PS_MAKE_SIMPLE \ -// float2 UV = input.tex * g_xMat_texMulAdd.xy + g_xMat_texMulAdd.zw; \ -// float4 color = g_xMat_baseColor * float4(input.instanceColor, 1) * xBaseColorMap.Sample(sampler_objectshader, UV); \ -// color.rgb = DEGAMMA(color.rgb); \ -// ALPHATEST(color.a); \ -// float opacity = color.a; \ -// float emissive = g_xMat_emissive; \ -// float2 pixel = input.pos.xy; -// -// -//#define OBJECT_PS_MAKE_COMMON \ -// OBJECT_PS_MAKE_SIMPLE \ -// float3 diffuse = 0; \ -// float3 specular = 0; \ -// float3 V = g_xCamera_CamPos - input.pos3D; \ -// float dist = length(V); \ -// V /= dist; \ -// Surface surface = CreateSurface(input.pos3D, normalize(input.nor), V, color, \ -// g_xMat_reflectance * xReflectanceMap.Sample(sampler_objectshader, UV).r, \ -// g_xMat_metalness * xMetalnessMap.Sample(sampler_objectshader, UV).r, \ -// g_xMat_roughness * xRoughnessMap.Sample(sampler_objectshader, UV).r, \ -// emissive, g_xMat_subsurfaceScattering); \ -// float3 bumpColor = 0; \ -// float depth = input.pos.z; \ -// float ao = 1; -// -//#define OBJECT_PS_MAKE \ -// OBJECT_PS_MAKE_COMMON \ -// float lineardepth = input.pos2D.w; \ -// float2 refUV = float2(1, -1)*input.ReflectionMapSamplingPos.xy / input.ReflectionMapSamplingPos.w * 0.5f + 0.5f;\ -// float2 ScreenCoord = float2(1, -1) * input.pos2D.xy / input.pos2D.w * 0.5f + 0.5f; \ -// float2 velocity = ((input.pos2DPrev.xy/input.pos2DPrev.w - g_xFrame_TemporalAAJitterPrev) - (input.pos2D.xy/input.pos2D.w - g_xFrame_TemporalAAJitter)) * float2(0.5f, -0.5f); -// -//#define OBJECT_PS_COMPUTETANGENTSPACE \ -// float3 T, B; \ -// float3x3 TBN = compute_tangent_frame(surface.N, surface.P, UV, T, B); -// -//#define OBJECT_PS_NORMALMAPPING \ -// NormalMapping(UV, surface.P, surface.N, TBN, bumpColor); \ -// surface.Update(); -// -//#define OBJECT_PS_PARALLAXOCCLUSIONMAPPING \ -// ParallaxOcclusionMapping(UV, surface.V, TBN); -// -//#define OBJECT_PS_SPECULARANTIALIASING \ -// SpecularAA(surface.N, surface.roughness); -// -//#define OBJECT_PS_REFRACTION \ -// Refraction(ScreenCoord, input.nor2D, bumpColor, surface, color); -// -//#define OBJECT_PS_LIGHT_FORWARD \ -// ForwardLighting(surface, diffuse, specular); -// -//#define OBJECT_PS_LIGHT_TILED \ -// TiledLighting(pixel, surface, diffuse, specular); -// -//#define OBJECT_PS_VOXELRADIANCE \ -// VoxelRadiance(surface, diffuse, specular, ao); -// -//#define OBJECT_PS_LIGHT_END \ -// color.rgb = lerp(1, GetAmbientColor() * ao + diffuse, opacity) * surface.albedo + specular; -// -//#define OBJECT_PS_DITHER \ -// clip(dither(input.pos.xy) - input.dither); -// -//#define OBJECT_PS_PLANARREFLECTIONS \ -// specular = max(specular, PlanarReflection(UV, refUV, surface)); -// -//#define OBJECT_PS_FOG \ -// color.rgb = applyFog(color.rgb, getFog(dist)); -// -//#define OBJECT_PS_OUT_GBUFFER \ -// GBUFFEROutputType Out; \ -// Out.g0 = float4(color.rgb, 1); /*FORMAT_R8G8B8A8_UNORM*/ \ -// Out.g1 = float4(encode(surface.N), velocity); /*FORMAT_R16G16B16_FLOAT*/ \ -// Out.g2 = float4(0, 0, surface.sss, surface.emissive); /*FORMAT_R8G8B8A8_UNORM*/ \ -// Out.g3 = float4(surface.roughness, surface.reflectance, surface.metalness, ao); /*FORMAT_R8G8B8A8_UNORM*/ \ -// return Out; -// -//#define OBJECT_PS_OUT_FORWARD \ -// GBUFFEROutputType_Thin Out; \ -// Out.g0 = color; /*FORMAT_R16G16B16_FLOAT*/ \ -// Out.g1 = float4(encode(surface.N), velocity); /*FORMAT_R16G16B16_FLOAT*/ \ -// return Out; -// -//#define OBJECT_PS_OUT_FORWARD_SIMPLE \ -// return color; - #endif // _OBJECTSHADER_HF_ \ No newline at end of file diff --git a/models/Sample/scene.wimf b/models/Sample/scene.wimf index 88ec763a9..89aeed991 100644 Binary files a/models/Sample/scene.wimf and b/models/Sample/scene.wimf differ