Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicether committed Sep 19, 2017
1 parent 767f54f commit c27cf9b
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 250 deletions.
3 changes: 0 additions & 3 deletions Resources/SEGI.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ sampler2D _MainTex;
sampler2D PreviousGITexture;
sampler2D _CameraGBufferTexture0;
sampler2D _CameraMotionVectorsTexture;
// float4x4 _WorldToCamera;
float4x4 WorldToCamera;
// float4x4 _CameraToWorld;
float4x4 ProjectionMatrix;

int SEGISphericalSkylight;
Expand Down Expand Up @@ -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));
Expand Down
4 changes: 1 addition & 3 deletions Resources/SEGIBlocker.shader
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'

Shader "SEGI/GIBlocker"
Shader "SEGI/GIBlocker"
{
Properties
{
Expand Down
2 changes: 0 additions & 2 deletions Resources/SEGIClear.compute
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma kernel CSMain

RWTexture3D<uint> RG0;
//RWTexture3D<uint> BA0;

int Res;

Expand All @@ -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;
}
}
2 changes: 0 additions & 2 deletions Resources/SEGIClear_C.compute
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma kernel CSMain

RWTexture3D<uint> RG0;
//RWTexture3D<uint> BA0;

int Res;

Expand All @@ -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;
}
}
2 changes: 0 additions & 2 deletions Resources/SEGIMipFilter_C.compute
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
5 changes: 0 additions & 5 deletions Resources/SEGIRenderSunDepth.shader
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -26,7 +22,6 @@ SubShader
fixed4 _Color;
float _Cutoff;

// float4x4 _WorldToCamera;

struct v2f
{
Expand Down
5 changes: 0 additions & 5 deletions Resources/SEGIRenderSunDepth_C.shader
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -26,7 +22,6 @@ SubShader
fixed4 _Color;
float _Cutoff;

// float4x4 _WorldToCamera;

struct v2f
{
Expand Down
4 changes: 1 addition & 3 deletions Resources/SEGITraceScene.shader
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
48 changes: 3 additions & 45 deletions Resources/SEGITraceScene_C.shader
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -231,7 +226,6 @@ Shader "Hidden/SEGITraceScene_C" {
return TransformClipSpace(pos, SEGIClipTransform5);
}

//TODO: Optimize this part
float GISampleWeight(float3 pos)
{
float weight = 1.0;
Expand Down Expand Up @@ -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;


Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -324,44 +306,23 @@ 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;

float falloffFix = pow(fi, 2.0) * 4.0 + 0.0;

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);

Expand All @@ -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));
Expand Down Expand Up @@ -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);

Expand Down
7 changes: 1 addition & 6 deletions Resources/SEGIVoxelizeScene.shader
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit c27cf9b

Please sign in to comment.