From c27cf9bf77e064161ea157caf41d96d1f89c56c3 Mon Sep 17 00:00:00 2001 From: Cody Darr Date: Tue, 19 Sep 2017 14:35:45 -0700 Subject: [PATCH] More cleanup --- Resources/SEGI.cginc | 3 - Resources/SEGIBlocker.shader | 4 +- Resources/SEGIClear.compute | 2 - Resources/SEGIClear_C.compute | 2 - Resources/SEGIMipFilter_C.compute | 2 - Resources/SEGIRenderSunDepth.shader | 5 -- Resources/SEGIRenderSunDepth_C.shader | 5 -- Resources/SEGITraceScene.shader | 4 +- Resources/SEGITraceScene_C.shader | 48 +------------- Resources/SEGIVoxelizeScene.shader | 7 +- Resources/SEGIVoxelizeScene_C.shader | 84 +----------------------- Resources/SEGI_C.cginc | 94 +-------------------------- 12 files changed, 10 insertions(+), 250 deletions(-) diff --git a/Resources/SEGI.cginc b/Resources/SEGI.cginc index d4769d9..4a8156c 100644 --- a/Resources/SEGI.cginc +++ b/Resources/SEGI.cginc @@ -55,9 +55,7 @@ sampler2D _MainTex; sampler2D PreviousGITexture; sampler2D _CameraGBufferTexture0; sampler2D _CameraMotionVectorsTexture; -// float4x4 _WorldToCamera; float4x4 WorldToCamera; -// float4x4 _CameraToWorld; float4x4 ProjectionMatrix; int SEGISphericalSkylight; @@ -165,7 +163,6 @@ float4 ConeTrace(float3 voxelOrigin, float3 kernel, float3 worldNormal, float2 u float3 skyColor = float3(0.0, 0.0, 0.0); - //sky tinting float upGradient = saturate(dot(kernel, float3(0.0, 1.0, 0.0))); float sunGradient = saturate(dot(kernel, -SEGISunlightVector.xyz)); skyColor += lerp(SEGISkyColor.rgb * 1.0, SEGISkyColor.rgb * 0.5, pow(upGradient, (0.5).xxx)); diff --git a/Resources/SEGIBlocker.shader b/Resources/SEGIBlocker.shader index e31520b..aada81a 100644 --- a/Resources/SEGIBlocker.shader +++ b/Resources/SEGIBlocker.shader @@ -1,6 +1,4 @@ -// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' - -Shader "SEGI/GIBlocker" +Shader "SEGI/GIBlocker" { Properties { diff --git a/Resources/SEGIClear.compute b/Resources/SEGIClear.compute index ab421a9..25dac83 100644 --- a/Resources/SEGIClear.compute +++ b/Resources/SEGIClear.compute @@ -1,7 +1,6 @@ #pragma kernel CSMain RWTexture3D RG0; -//RWTexture3D BA0; int Res; @@ -11,6 +10,5 @@ void CSMain (uint3 id : SV_DispatchThreadID) for (int i = 0; i < Res; i++) { RG0[uint3(id.xy, i)] = 0; - //BA0[uint3(id.xy, i)] = 0; } } diff --git a/Resources/SEGIClear_C.compute b/Resources/SEGIClear_C.compute index ab421a9..25dac83 100644 --- a/Resources/SEGIClear_C.compute +++ b/Resources/SEGIClear_C.compute @@ -1,7 +1,6 @@ #pragma kernel CSMain RWTexture3D RG0; -//RWTexture3D BA0; int Res; @@ -11,6 +10,5 @@ void CSMain (uint3 id : SV_DispatchThreadID) for (int i = 0; i < Res; i++) { RG0[uint3(id.xy, i)] = 0; - //BA0[uint3(id.xy, i)] = 0; } } diff --git a/Resources/SEGIMipFilter_C.compute b/Resources/SEGIMipFilter_C.compute index 5ae3210..d9e74bd 100644 --- a/Resources/SEGIMipFilter_C.compute +++ b/Resources/SEGIMipFilter_C.compute @@ -26,14 +26,12 @@ void CSMain (uint3 id : SV_DispatchThreadID) tex.rgba *= 2.0; float3 writeCoord = fcoord; - //writeCoord = writeCoord * 0.5 + 0.5 + ClipmapOverlap.xyz * 0.0; writeCoord = writeCoord * 0.5 + 0.25; writeCoord += ClipmapOverlap.xyz * 1.0; writeCoord *= destinationRes; uint3 writeCoordi = uint3(writeCoord.x, writeCoord.y, writeCoord.z); Destination[writeCoordi] = tex; - //Destination[writeCoordi] = float4(0.01, 0.005, 0.0, 0.0); } } diff --git a/Resources/SEGIRenderSunDepth.shader b/Resources/SEGIRenderSunDepth.shader index 9de537d..75a2fa9 100644 --- a/Resources/SEGIRenderSunDepth.shader +++ b/Resources/SEGIRenderSunDepth.shader @@ -1,7 +1,3 @@ -// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' - -// Upgrade NOTE: commented out 'float4x4 _WorldToCamera', a built-in variable - Shader "Hidden/SEGIRenderSunDepth" { Properties { _Color ("Main Color", Color) = (1,1,1,1) @@ -26,7 +22,6 @@ SubShader fixed4 _Color; float _Cutoff; - // float4x4 _WorldToCamera; struct v2f { diff --git a/Resources/SEGIRenderSunDepth_C.shader b/Resources/SEGIRenderSunDepth_C.shader index 3d56cf9..0b087f7 100644 --- a/Resources/SEGIRenderSunDepth_C.shader +++ b/Resources/SEGIRenderSunDepth_C.shader @@ -1,7 +1,3 @@ -// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' - -// Upgrade NOTE: commented out 'float4x4 _WorldToCamera', a built-in variable - Shader "Hidden/SEGIRenderSunDepth_C" { Properties { _Color ("Main Color", Color) = (1,1,1,1) @@ -26,7 +22,6 @@ SubShader fixed4 _Color; float _Cutoff; - // float4x4 _WorldToCamera; struct v2f { diff --git a/Resources/SEGITraceScene.shader b/Resources/SEGITraceScene.shader index 084826a..d002748 100644 --- a/Resources/SEGITraceScene.shader +++ b/Resources/SEGITraceScene.shader @@ -1,6 +1,4 @@ -// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' - -Shader "Hidden/SEGITraceScene" { +Shader "Hidden/SEGITraceScene" { Properties { _Color ("Main Color", Color) = (1,1,1,1) diff --git a/Resources/SEGITraceScene_C.shader b/Resources/SEGITraceScene_C.shader index 25d5449..6a3120e 100644 --- a/Resources/SEGITraceScene_C.shader +++ b/Resources/SEGITraceScene_C.shader @@ -1,8 +1,4 @@ -// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' - -// Upgrade NOTE: replaced '_Object2World' with '_Object2World' - -Shader "Hidden/SEGITraceScene_C" { +Shader "Hidden/SEGITraceScene_C" { Properties { _Color ("Main Color", Color) = (1,1,1,1) @@ -140,7 +136,6 @@ Shader "Hidden/SEGITraceScene_C" { p[i].pos = mul(UNITY_MATRIX_P, p[i].pos); - //p[i].pos.z *= -1.0; #if defined(UNITY_REVERSED_Z) p[i].pos.z = 1.0 - p[i].pos.z; @@ -231,7 +226,6 @@ Shader "Hidden/SEGITraceScene_C" { return TransformClipSpace(pos, SEGIClipTransform5); } - //TODO: Optimize this part float GISampleWeight(float3 pos) { float weight = 1.0; @@ -263,11 +257,9 @@ Shader "Hidden/SEGITraceScene_C" { float dist = length(voxelOrigin * 2.0 - 1.0); - //int startMipLevel = log2(dist + 1); int startMipLevel = 0; voxelOrigin = TransformClipSpaceInverse(voxelOrigin, SEGICurrentClipTransform); - //voxelOrigin.xyz = TransformClipSpace(voxelOrigin.xyz, SEGIInverseCurrentClipTransform * float4(1.0, 1.0, 1.0, 1.0)); voxelOrigin.xyz += worldNormal.xyz * 0.016; @@ -283,7 +275,6 @@ Shader "Hidden/SEGITraceScene_C" { float coneDistance = (exp2(fi * 4.0) - 0.99) / 8.0; - //float coneSize = fi * 6.0 * lerp(SEGIVoxelScaleFactor, 1.0, 0.5); float coneSize = coneDistance * width * 10.3; float3 voxelCheckCoord = voxelOrigin.xyz + adjustedKernel.xyz * (coneDistance * 1.12 * 1.0); @@ -293,18 +284,9 @@ Shader "Hidden/SEGITraceScene_C" { mipLevel = max(startMipLevel, log2(pow(fi, 1.3) * 24.0 * width + 1.0)); - - - //voxelCheckCoord = TransformClipSpace1(voxelCheckCoord); - //sample = tex3Dlod(SEGIVolumeLevel1, float4(voxelCheckCoord.xyz, coneSize)) * GISampleWeight(voxelCheckCoord); - ///* - if (mipLevel == 0) - { - sample = tex3Dlod(SEGIVolumeLevel0, float4(voxelCheckCoord.xyz, coneSize)) * GISampleWeight(voxelCheckCoord); - } - else if (mipLevel == 1) + if (mipLevel == 0 || mipLevel == 1) { voxelCheckCoord = TransformClipSpace1(voxelCheckCoord); sample = tex3Dlod(SEGIVolumeLevel1, float4(voxelCheckCoord.xyz, coneSize)) * GISampleWeight(voxelCheckCoord); @@ -324,12 +306,11 @@ Shader "Hidden/SEGITraceScene_C" { voxelCheckCoord = TransformClipSpace4(voxelCheckCoord); sample = tex3Dlod(SEGIVolumeLevel4, float4(voxelCheckCoord.xyz, coneSize)) * GISampleWeight(voxelCheckCoord); } - else //if (mipLevel == 5) + else { voxelCheckCoord = TransformClipSpace5(voxelCheckCoord); sample = tex3Dlod(SEGIVolumeLevel5, float4(voxelCheckCoord.xyz, coneSize)) * GISampleWeight(voxelCheckCoord); } - //*/ float occlusion = skyVisibility; @@ -337,31 +318,11 @@ Shader "Hidden/SEGITraceScene_C" { gi.rgb += sample.rgb * (coneSize * 1.0 + 1.0) * occlusion * falloffFix; - //skyVisibility *= pow(saturate(1.0 - (sample.a) * (coneSize * 0.2 + 1.0 + coneSize * coneSize * 0.08)), lerp(0.014, 1.0, min(1.0, coneSize / 5.0))); skyVisibility *= pow(saturate(1.0 - sample.a * SEGISecondaryOcclusionStrength * (1.0 + coneDistance * farOcclusionStrength)), 1.0 * occlusionPower); } - - /* - skyVisibility *= saturate(dot(worldNormal, kernel)); - skyVisibility *= lerp(saturate(dot(kernel, float3(0.0, 1.0, 0.0)) * 10.0), 1.0, SEGISphericalSkylight); - gi *= saturate(dot(worldNormal, kernel)); - - float3 skyColor = float3(0.0, 0.0, 0.0); - - float upGradient = saturate(dot(kernel, float3(0.0, 1.0, 0.0))); - float sunGradient = saturate(dot(kernel, -SEGISunlightVector.xyz)); - skyColor += lerp(SEGISkyColor.rgb * 2.0, SEGISkyColor.rgb, pow(upGradient, (0.5).xxx)); - skyColor += GISunColor.rgb * pow(sunGradient, (4.0).xxx) * SEGISoftSunlight; - - gi *= 0.5; - - gi += skyColor * skyVisibility; - - return float4(gi.rgb * 0.8, 0.0f); - */ float NdotL = pow(saturate(dot(worldNormal, kernel) * 1.0 - 0.0), 1.0); @@ -372,7 +333,6 @@ Shader "Hidden/SEGITraceScene_C" { float3 skyColor = float3(0.0, 0.0, 0.0); - //sky tinting float upGradient = saturate(dot(kernel, float3(0.0, 1.0, 0.0))); float sunGradient = saturate(dot(kernel, -SEGISunlightVector.xyz)); skyColor += lerp(SEGISkyColor.rgb * 1.0, SEGISkyColor.rgb * 0.5, pow(upGradient, (0.5).xxx)); @@ -549,8 +509,6 @@ Shader "Hidden/SEGITraceScene_C" { gi.rgb += traceResult.a * 1.0 * SEGISkyColor; - //gi.rgb = (0.3).xxx; - float4 result = float4(gi.rgb, 2.0); diff --git a/Resources/SEGIVoxelizeScene.shader b/Resources/SEGIVoxelizeScene.shader index d7fe082..39ccd83 100644 --- a/Resources/SEGIVoxelizeScene.shader +++ b/Resources/SEGIVoxelizeScene.shader @@ -1,6 +1,4 @@ -// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' - -Shader "Hidden/SEGIVoxelizeScene" { +Shader "Hidden/SEGIVoxelizeScene" { Properties { _Color ("Main Color", Color) = (1,1,1,1) @@ -312,9 +310,6 @@ Shader "Hidden/SEGIVoxelizeScene" { float3 col = sunVisibility.xxx * sunNdotL * color.rgb * tex.rgb * GISunColor.rgb * GISunColor.a + _EmissionColor.rgb * 0.9 * emissionTex.rgb; - //float3 col = color.rgb * tex.rgb * GISunColor.rgb * GISunColor.a + _EmissionColor.rgb * 0.9 * emissionTex.rgb; - //float3 col = saturate(float3(shadowPos.xy, 0.0)); - float4 prevBounce = tex3D(SEGIVolumeTexture1, fcoord + SEGIVoxelSpaceOriginDelta.xyz); col.rgb += prevBounce.rgb * 1.6 * SEGISecondaryBounceGain * tex.rgb * color.rgb; diff --git a/Resources/SEGIVoxelizeScene_C.shader b/Resources/SEGIVoxelizeScene_C.shader index ef0f4fb..4c16dab 100644 --- a/Resources/SEGIVoxelizeScene_C.shader +++ b/Resources/SEGIVoxelizeScene_C.shader @@ -1,10 +1,4 @@ -// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' - -// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' - -// Upgrade NOTE: replaced '_Object2World' with '_Object2World' - -Shader "Hidden/SEGIVoxelizeScene_C" { +Shader "Hidden/SEGIVoxelizeScene_C" { Properties { _Color ("Main Color", Color) = (1,1,1,1) @@ -98,7 +92,6 @@ Shader "Hidden/SEGIVoxelizeScene_C" { for (int i = 0; i < 3; i++) { p[i] = input[i]; - //p[i].pos = mul(unity_ObjectToWorld, p[i].pos); p[i].pos = UnityObjectToClipPos(p[i].pos); } @@ -142,58 +135,19 @@ Shader "Hidden/SEGIVoxelizeScene_C" { if (angle == 0) { - //p[i].pos = mul(SEGIVoxelViewFront, p[i].pos); - //p[i].pos = mul(SEGIVoxelVPFront, p[i].pos); p[i].pos.xyz = op.xyz; - //p[i].pos.z *= 0.5; - - //p[i].pos.x = - p[i].pos.x; } else if (angle == 1) { - //p[i].pos = mul(SEGIVoxelViewLeft, p[i].pos); - //p[i].pos = mul(SEGIVoxelVPLeft, p[i].pos); - - /* - #if defined(UNITY_REVERSED_Z) - p[i].pos.x = (op.z); - #else - p[i].pos.x = (1.0 - op.z); - #endif - - p[i].pos.y = op.y; - p[i].pos.z = (op.x); - */ - p[i].pos.xyz = op.zyx * float3(1.0, 1.0, -1.0); } else { - //p[i].pos = mul(SEGIVoxelViewTop, p[i].pos); - //p[i].pos = mul(SEGIVoxelVPTop, p[i].pos); - - /* - p[i].pos.x = op.x; - #if defined(UNITY_REVERSED_Z) - p[i].pos.y = (1.0 - op.z); - p[i].pos.z = op.y; - #else - p[i].pos.y = (op.z) - p[i].pos.z = 1.0 - (op.y); - #endif - */ p[i].pos.xyz = op.xzy * float3(1.0, 1.0, -1.0); } p[i].pos.z = p[i].pos.z * 0.5 + 0.5; - //p[i].pos = mul(UNITY_MATRIX_P, p[i].pos); - //p[i].pos = mul(SEGIVoxelProjectionGPU, p[i].pos); - - //p[i].pos.z *= -1.0; - - //p[i].pos.z /= VoxelResolution; - #if defined(UNITY_REVERSED_Z) p[i].pos.z = 1.0 - p[i].pos.z; #else @@ -229,7 +183,6 @@ Shader "Hidden/SEGIVoxelizeScene_C" { float4 DecodeRGBAuint(uint value) { - //return float4(1,1,1,1); uint ai = value & 0x0000007F; uint vi = (value / 0x00000080) & 0x000007FF; uint si = (value / 0x00040000) & 0x0000007F; @@ -249,7 +202,6 @@ Shader "Hidden/SEGIVoxelizeScene_C" { uint EncodeRGBAuint(float4 color) { - //return 0; //7[HHHHHHH] 7[SSSSSSS] 11[VVVVVVVVVVV] 7[AAAAAAAA] float3 hsv = rgb2hsv(color.rgb); hsv.z = pow(hsv.z, 1.0 / 3.0); @@ -271,22 +223,6 @@ Shader "Hidden/SEGIVoxelizeScene_C" { void interlockedAddFloat4(RWTexture3D destination, int3 coord, float4 value) { - /* - uint writeValue = EncodeRGBAuint(value); - uint compareValue = 0; - uint originalValue; - - [allow_uav_condition] for (int i = 0; i < 12; i++) - { - InterlockedCompareExchange(destination[coord], compareValue, writeValue, originalValue); - if (compareValue == originalValue) - break; - compareValue = originalValue; - float4 originalValueFloats = DecodeRGBAuint(originalValue); - writeValue = EncodeRGBAuint(originalValueFloats + value); - } - */ - uint comp; uint orig = destination[coord]; @@ -301,22 +237,6 @@ Shader "Hidden/SEGIVoxelizeScene_C" { void interlockedAddFloat4b(RWTexture3D destination, int3 coord, float4 value) { - /* - uint writeValue = EncodeRGBAuint(value); - uint compareValue = 0; - uint originalValue; - - [allow_uav_condition] for (int i = 0; i < 1; i++) - { - InterlockedCompareExchange(destination[coord], compareValue, writeValue, originalValue); - if (compareValue == originalValue) - break; - compareValue = originalValue; - float4 originalValueFloats = DecodeRGBAuint(originalValue); - writeValue = EncodeRGBAuint(originalValueFloats + value); - } - */ - uint comp; uint orig = destination[coord]; @@ -411,12 +331,10 @@ Shader "Hidden/SEGIVoxelizeScene_C" { float3 col = sunVisibility.xxx * sunNdotL * color.rgb * tex.rgb * GISunColor.rgb * GISunColor.a + _EmissionColor.rgb * 0.9 * emissionTex.rgb; - //float3 col = color.rgb * tex.rgb * GISunColor.rgb * GISunColor.a + _EmissionColor.rgb * 0.9 * emissionTex.rgb; float4 prevBounce = tex3D(SEGICurrentIrradianceVolume, fcoord + SEGIVoxelSpaceOriginDelta.xyz); col.rgb += prevBounce.rgb * 0.2 * SEGISecondaryBounceGain * tex.rgb * color.rgb; - //col.rgb *= _Color.a; float4 result = float4(col.rgb, 2.0); diff --git a/Resources/SEGI_C.cginc b/Resources/SEGI_C.cginc index b53fee2..12d02d5 100644 --- a/Resources/SEGI_C.cginc +++ b/Resources/SEGI_C.cginc @@ -73,9 +73,7 @@ sampler2D _MainTex; sampler2D PreviousGITexture; sampler2D _CameraGBufferTexture0; sampler2D _CameraMotionVectorsTexture; -// float4x4 _WorldToCamera; float4x4 WorldToCamera; -// float4x4 _CameraToWorld; float4x4 ProjectionMatrix; int SEGISphericalSkylight; @@ -146,7 +144,6 @@ float2 rand(float2 coord) return float2(noiseX, noiseY); } -//TODO: Optimize this part float GISampleWeight(float3 pos) { float weight = 1.0; @@ -174,63 +171,10 @@ float4 ConeTrace(float3 voxelOrigin, float3 kernel, float3 worldNormal, float2 u float dist = length(voxelOrigin * 2.0 - 1.0); - /* - //Screen space tracing - float4 kernelScreen = mul(WorldToCamera, float4(kernel.xyz, 0.0)); - kernelScreen.xyz = normalize(kernelScreen.xyz); - - float4 screenOrigin = GetViewSpacePosition(uv.xy); - float3 screenSamplePos = screenOrigin; - - screenSamplePos += kernelScreen * 0.0025; - - float ss = 0.015; - - ss *= -screenOrigin.z * 0.3; - - for (int i = 0; i < 5; i++) - { - screenSamplePos += kernelScreen * ss * 2.0; - - float3 screenSamplePosProj = ProjectBack(float4(screenSamplePos.xyz, screenOrigin.w)); - - float3 readScreenPos = GetViewSpacePosition(screenSamplePosProj.xy).xyz; - - if (readScreenPos.z > screenSamplePos.z) - { - float distanceWeight = saturate(1.0 - abs(readScreenPos.z - screenSamplePos.z) / 2.95); - //float3 colorSample = tex2Dlod(PreviousGITexture, float4(screenSamplePosProj.xy, 0.0, 0.0)).rgb * tex2Dlod(_CameraGBufferTexture0, float4(screenSamplePosProj.xy, 0.0, 0.0)).rgb; - //colorSample += clamp(tex2Dlod(_MainTex, float4(screenSamplePosProj.xy, 0.0, 0.0)).rgb, (0.0).xxx, (10000.0).xxx); - //gi.rgb += colorSample * 3.0 * distanceWeight * skyVisibility; - - skyVisibility *= lerp(1.0, 0.0, distanceWeight * saturate(OcclusionStrength * 100.0)); - break; - } - - ss *= 1.3; - } - */ - - int startMipLevel = log2(length(voxelOrigin.xyz * 2.0 - 1.0) + 1); - startMipLevel = 0; + int startMipLevel = 0; voxelOrigin.xyz += worldNormal.xyz * 0.016 * (exp2(startMipLevel) - 1); - //voxelOrigin.xyz += worldNormal.xyz * 0.03; - //voxelOrigin.xyz -= adjustedKernel * 0.03; - - /* - float stepSize = 0.019; - float3 rayPos = voxelOrigin; - for (int i = 0; i < numSteps * 2; i++) - { - rayPos += kernel * stepSize; - - - } - */ - ///* - for (int i = 0; i < numSteps; i++) { float fi = ((float)i + dither) / numSteps; @@ -238,22 +182,15 @@ float4 ConeTrace(float3 voxelOrigin, float3 kernel, float3 worldNormal, float2 u float coneDistance = (exp2(fi * 4.0) - 0.99) / 8.0; - //coneDistance = pow(coneDistance, 1.2); - //coneDistance -= 0.00; float coneSize = coneDistance * width * 10.3; - //float3 voxelCheckCoord = voxelOrigin.xyz + adjustedKernel.xyz * (coneDistance * 1.12 * TraceLength * lengthMult + 0.019 * (exp2(startMipLevel) - 1)); float3 voxelCheckCoord = voxelOrigin.xyz + adjustedKernel.xyz * (coneDistance * 1.12 * TraceLength * lengthMult + 0.000); - //voxelCheckCoord -= adjustedKernel.xyz * (1.12 * TraceLength * lengthMult) * 0.2 * (1.0 - skyVisibility); float4 giSample = float4(0.0, 0.0, 0.0, 0.0); - int mipLevel = floor(coneSize) + 0; - //mipLevel = width; - mipLevel = max(startMipLevel, log2(pow(fi, 1.3) * 24.0 * width + 1.0)); - //mipLevel = 5; + int mipLevel = max(startMipLevel, log2(pow(fi, 1.3) * 24.0 * width + 1.0)); //if (mipLevel == 0) //{ // sample = tex3Dlod(SEGIVolumeLevel0, float4(voxelCheckCoord.xyz, coneSize)) * GISampleWeight(voxelCheckCoord); @@ -278,15 +215,11 @@ float4 ConeTrace(float3 voxelOrigin, float3 kernel, float3 worldNormal, float2 u voxelCheckCoord = TransformClipSpace4(voxelCheckCoord); giSample = tex3Dlod(SEGIVolumeLevel4, float4(voxelCheckCoord.xyz, coneSize)) * GISampleWeight(voxelCheckCoord); } - else// if (mipLevel == 5) + else { voxelCheckCoord = TransformClipSpace5(voxelCheckCoord); giSample = tex3Dlod(SEGIVolumeLevel5, float4(voxelCheckCoord.xyz, coneSize)) * GISampleWeight(voxelCheckCoord); } - //else - //{ - // sample = float4(1.0, 0.0, 0.0, 0.0); - //} float occlusion = skyVisibility; @@ -294,13 +227,10 @@ float4 ConeTrace(float3 voxelOrigin, float3 kernel, float3 worldNormal, float2 u giSample.a *= lerp(saturate(coneSize / 1.0), 1.0, NearOcclusionStrength); giSample.a *= (0.8 / (fi * fi * 2.0 + 0.15)); - //gi.rgb += sample.rgb * (coneSize * 1.0 + 1.0) * occlusion * falloffFix; gi.rgb += giSample.rgb * occlusion * (coneDistance + NearLightGain) * 80.0 * (1.0 - fi * fi); - //skyVisibility *= pow(saturate(1.0 - (sample.a) * (1.0 / coneDistance + 0.1) * (coneSize * 0.2 * FarOcclusionStrength + 1.0 + coneSize * coneSize * 0.05 * FarthestOcclusionStrength) * OcclusionStrength), lerp(0.014, 1.5 * OcclusionPower, min(1.0, coneSize / 5.0))); skyVisibility *= pow(saturate(1.0 - giSample.a * OcclusionStrength * (1.0 + coneDistance * FarOcclusionStrength)), 1.0 * OcclusionPower); } - //*/ float NdotL = pow(saturate(dot(worldNormal, kernel) * 1.0 - 0.0), 0.5); gi *= NdotL; @@ -316,7 +246,6 @@ float4 ConeTrace(float3 voxelOrigin, float3 kernel, float3 worldNormal, float2 u float3 skyColor = float3(0.0, 0.0, 0.0); - //sky tinting float upGradient = saturate(dot(kernel, float3(0.0, 1.0, 0.0))); float sunGradient = saturate(dot(kernel, -SEGISunlightVector.xyz)); skyColor += lerp(SEGISkyColor.rgb * 1.0, SEGISkyColor.rgb * 0.5, pow(upGradient, (0.5).xxx)); @@ -326,8 +255,6 @@ float4 ConeTrace(float3 voxelOrigin, float3 kernel, float3 worldNormal, float2 u gi += skyColor * skyVisibility * skyMult * 10.0; - //gi += startMipLevel * 0.01 * float3(1.0, 0.0, 0.0); //Visualize cascade LODs - return float4(gi.rgb * 0.8, 0.0f); } @@ -366,32 +293,26 @@ float4 SpecularConeTrace(float3 voxelOrigin, float3 kernel, float3 worldNormal, if (mipLevel == 0) { giSample = tex3Dlod(SEGIVolumeLevel0, float4(voxelCheckCoord.xyz, coneSize)); - //giSample = lerp(giSample, tex3Dlod(SEGIVolumeLevel1, float4(voxelCheckCoord.xyz, coneSize + 1.0)), frac(coneSize)); } else if (mipLevel == 1) { voxelCheckCoord = TransformClipSpace1(voxelCheckCoord); giSample = tex3Dlod(SEGIVolumeLevel1, float4(voxelCheckCoord.xyz, coneSize)); - //voxelCheckCoord = TransformClipSpace2(voxelCheckCoord); - //giSample = lerp(giSample, tex3Dlod(SEGIVolumeLevel2, float4(voxelCheckCoord.xyz, coneSize + 1.0)), frac(coneSize)); } else if (mipLevel == 2) { voxelCheckCoord = TransformClipSpace2(voxelCheckCoord); giSample = tex3Dlod(SEGIVolumeLevel2, float4(voxelCheckCoord.xyz, coneSize)); - //giSample = lerp(giSample, tex3Dlod(SEGIVolumeLevel3, float4(voxelCheckCoord.xyz, coneSize + 1.0)), frac(coneSize)); } else if (mipLevel == 3) { voxelCheckCoord = TransformClipSpace3(voxelCheckCoord); giSample = tex3Dlod(SEGIVolumeLevel3, float4(voxelCheckCoord.xyz, coneSize)); - //giSample = lerp(giSample, tex3Dlod(SEGIVolumeLevel4, float4(voxelCheckCoord.xyz, coneSize + 1.0)), frac(coneSize)); } else if (mipLevel == 4) { voxelCheckCoord = TransformClipSpace4(voxelCheckCoord); giSample = tex3Dlod(SEGIVolumeLevel4, float4(voxelCheckCoord.xyz, coneSize)); - //giSample = lerp(giSample, tex3Dlod(SEGIVolumeLevel5, float4(voxelCheckCoord.xyz, coneSize + 1.0)), frac(coneSize)); } else { @@ -436,15 +357,6 @@ float4 VisualConeTrace(float3 voxelOrigin, float3 kernel, float skyVisibility, i float4 giSample = float4(0.0, 0.0, 0.0, 0.0); - //sample = tex3Dlod(SEGIVolumeLevel0, float4(voxelCheckCoord.xyz, coneSize)); - - - //voxelCheckCoord -= SEGIClipTransform1.xyz * 0.1; - //voxelCheckCoord *= SEGIClipTransform1.w; - - //voxelCheckCoord = floor(voxelCheckCoord * 64.0) / 64.0; - - if (volumeLevel == 0) giSample = tex3Dlod(SEGIVolumeLevel0, float4(voxelCheckCoord.xyz, 0.0));