diff --git a/WickedEngine/objectDS.hlsl b/WickedEngine/objectDS.hlsl index 50335b8a9..07afbd8b6 100644 --- a/WickedEngine/objectDS.hlsl +++ b/WickedEngine/objectDS.hlsl @@ -143,10 +143,6 @@ PixelInputType main(ConstantOutputType input, float3 uvwCoord : SV_DomainLocatio Out.atl = vertexAtlas; Out.color = vertexColor; Out.nor = normalize(vertexNormal.xyz); - Out.nor2D = mul((float3x3)g_xCamera_View, Out.nor.xyz).xy; - - Out.ReflectionMapSamplingPos = mul(g_xFrame_MainCamera_ReflVP, vertexPosition); - return Out; } \ No newline at end of file diff --git a/WickedEngine/objectHF.hlsli b/WickedEngine/objectHF.hlsli index eb2120c63..d635cd2c5 100644 --- a/WickedEngine/objectHF.hlsli +++ b/WickedEngine/objectHF.hlsli @@ -57,11 +57,9 @@ struct PixelInputType float4 uvsets : UVSETS; float2 atl : ATLAS; float3 nor : NORMAL; - float4 pos2D : SCREENPOSITION; float3 pos3D : WORLDPOSITION; + float4 pos2D : SCREENPOSITION; float4 pos2DPrev : SCREENPOSITIONPREV; - float4 ReflectionMapSamplingPos : PLANARREFLECTIONPOSITION; - float2 nor2D : NORMAL2D; }; struct GBUFFEROutputType @@ -141,9 +139,12 @@ inline void SpecularAA(in float3 N, inout float roughness) } } -inline float3 PlanarReflection(in float2 reflectionUV, in float2 bumpColor) +inline float3 PlanarReflection(in Surface surface, in float2 bumpColor) { - return texture_reflection.SampleLevel(sampler_linear_clamp, reflectionUV + bumpColor*g_xMaterial.normalMapStrength, 0).rgb; + float4 reflectionUV = mul(g_xFrame_MainCamera_ReflVP, float4(surface.P, 1)); + reflectionUV.xy /= reflectionUV.w; + reflectionUV.xy = reflectionUV.xy * float2(0.5f, -0.5f) + 0.5f; + return texture_reflection.SampleLevel(sampler_linear_clamp, reflectionUV.xy + bumpColor*g_xMaterial.normalMapStrength, 0).rgb; } #define NUM_PARALLAX_OCCLUSION_STEPS 32 @@ -176,7 +177,7 @@ inline void Parallatexture_occlusionmapping(inout float4 uvsets, in float3 V, in uvsets += difference.xyxy; } -inline void Refraction(in float2 ScreenCoord, in float2 normal2D, in float3 bumpColor, inout Surface surface, inout float4 color, inout Lighting lighting) +inline void Refraction(in float2 ScreenCoord, inout Surface surface, inout float4 color, inout Lighting lighting) { if (g_xMaterial.refractionIndex > 0) { @@ -184,7 +185,8 @@ inline void Refraction(in float2 ScreenCoord, in float2 normal2D, in float3 bump float mipLevels; texture_refraction.GetDimensions(0, size.x, size.y, mipLevels); const float sampled_mip = (g_xFrame_AdvancedRefractions ? surface.roughness * mipLevels : 0); - float2 perturbatedRefrTexCoords = ScreenCoord.xy + (normal2D + bumpColor.rg) * g_xMaterial.refractionIndex; + const float2 normal2D = mul((float3x3)g_xCamera_View, surface.N.xyz).xy; + float2 perturbatedRefrTexCoords = ScreenCoord.xy + normal2D * g_xMaterial.refractionIndex; float4 refractiveColor = texture_refraction.SampleLevel(sampler_linear_clamp, perturbatedRefrTexCoords, sampled_mip); surface.albedo.rgb = lerp(refractiveColor.rgb, surface.albedo.rgb, color.a); lighting.direct.diffuse = lerp(1, lighting.direct.diffuse, color.a); @@ -770,9 +772,7 @@ GBUFFEROutputType_Thin main(PIXELINPUT input) const float lineardepth = input.pos2D.w; input.pos2D.xy /= input.pos2D.w; input.pos2DPrev.xy /= input.pos2DPrev.w; - input.ReflectionMapSamplingPos.xy /= input.ReflectionMapSamplingPos.w; - const float2 refUV = input.ReflectionMapSamplingPos.xy * float2(0.5f, -0.5f) + 0.5f; const float2 ScreenCoord = input.pos2D.xy * float2(0.5f, -0.5f) + 0.5f; const float2 velocity = ((input.pos2DPrev.xy - g_xFrame_TemporalAAJitterPrev) - (input.pos2D.xy - g_xFrame_TemporalAAJitter)) * float2(0.5f, -0.5f); const float2 ReprojectedScreenCoord = ScreenCoord + velocity; @@ -877,7 +877,10 @@ GBUFFEROutputType_Thin main(PIXELINPUT input) bumpColor *= g_xMaterial.normalMapStrength; //REFLECTION - float4 reflectiveColor = texture_reflection.SampleLevel(sampler_linear_mirror, refUV + bumpColor.rg, 0); + float4 reflectionUV = mul(g_xFrame_MainCamera_ReflVP, float4(surface.P, 1)); + reflectionUV.xy /= reflectionUV.w; + reflectionUV.xy = reflectionUV.xy * float2(0.5f, -0.5f) + 0.5f; + float4 reflectiveColor = texture_reflection.SampleLevel(sampler_linear_mirror, reflectionUV + bumpColor.rg, 0); //REFRACTION @@ -900,7 +903,7 @@ GBUFFEROutputType_Thin main(PIXELINPUT input) ApplyEmissive(surface, lighting); #ifdef PLANARREFLECTION - lighting.indirect.specular += PlanarReflection(refUV, bumpColor.rg); + lighting.indirect.specular += PlanarReflection(surface, bumpColor.rg); #endif @@ -920,7 +923,7 @@ GBUFFEROutputType_Thin main(PIXELINPUT input) #ifndef WATER #ifndef ENVMAPRENDERING #ifdef TRANSPARENT - Refraction(ScreenCoord, input.nor2D, bumpColor, surface, color, lighting); + Refraction(ScreenCoord, surface, color, lighting); #else float4 ssr = texture_ssr.SampleLevel(sampler_linear_clamp, ReprojectedScreenCoord, surface.roughness * 5); lighting.indirect.specular = lerp(lighting.indirect.specular, ssr.rgb, ssr.a); diff --git a/WickedEngine/objectVS_common.hlsl b/WickedEngine/objectVS_common.hlsl index eb1213c22..ba7f9b123 100644 --- a/WickedEngine/objectVS_common.hlsl +++ b/WickedEngine/objectVS_common.hlsl @@ -23,9 +23,6 @@ PixelInputType main(Input_Object_ALL input) Out.uvsets = surface.uvsets; Out.atl = surface.atlas; Out.nor = surface.normal; - Out.nor2D = mul((float3x3)g_xCamera_View, Out.nor.xyz).xy; - - Out.ReflectionMapSamplingPos = mul(g_xFrame_MainCamera_ReflVP, surface.position); return Out; } \ No newline at end of file diff --git a/WickedEngine/waterVS.hlsl b/WickedEngine/waterVS.hlsl index d87de49f1..747e270c9 100644 --- a/WickedEngine/waterVS.hlsl +++ b/WickedEngine/waterVS.hlsl @@ -19,9 +19,6 @@ PixelInputType main(Input_Object_POS_TEX input) Out.uvsets = surface.uvsets; Out.atl = 0; Out.nor = surface.normal; - Out.nor2D = mul((float3x3)g_xCamera_View, Out.nor.xyz).xy; - - Out.ReflectionMapSamplingPos = mul(g_xFrame_MainCamera_ReflVP, surface.position); return Out; } \ No newline at end of file diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 2ec22063a..f878c8b1c 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates const int minor = 35; // minor bug fixes, alterations, refactors, updates - const int revision = 1; + const int revision = 2; long GetVersion()