浏览代码

Added Fog

/vr_sandbox
Felipe Lira 8 年前
当前提交
21e43adc
共有 5 个文件被更改,包括 102 次插入20 次删除
  1. 12
      Assets/LowEndRenderLoop/LowEndRenderLoopScene.unity
  2. 16
      Assets/LowEndRenderLoop/LowEndRenderLoopShader.shader
  3. 10
      Assets/LowEndRenderLoop/LowEndRenderPipeline.cs
  4. 42
      Assets/LowEndRenderLoop/Textures/154.JPG.meta
  5. 42
      Assets/LowEndRenderLoop/Textures/168.JPG.meta

12
Assets/LowEndRenderLoop/LowEndRenderLoopScene.unity


RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 8
m_Fog: 0
m_FogColor: {r: 0.9191176, g: 0, b: 0, a: 1}
m_Fog: 1
m_FogColor: {r: 0.21280265, g: 0.19755623, b: 0.6397059, a: 1}
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 100
m_AmbientSkyColor: {r: 1, g: 0.551927, b: 0.30882353, a: 1}
m_FogDensity: 0.1
m_LinearFogStart: 10
m_LinearFogEnd: 43.88
m_AmbientSkyColor: {r: 0.09558821, g: 0.09558821, b: 0.09558821, a: 1}
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
m_AmbientIntensity: 0.4

16
Assets/LowEndRenderLoop/LowEndRenderLoopShader.shader


#pragma shader_feature _METALLICGLOSSMAP
#pragma shader_feature _NORMALMAP
#pragma shader_feature _EMISSION
#pragma multi_compile_fog
#include "UnityCG.cginc"
#include "UnityStandardBRDF.cginc"

half3 tangentWS : TEXCOORD4;
half3 binormalWS : TEXCOORD5;
half4 viewDir : TEXCOORD6; // xyz: viewDir, w: grazingTerm;
half3 vertexColor : TEXCOORD7;
UNITY_FOG_COORDS_PACKED(7, half4) // x: fogCoord, yzw: vertexColor
};
};
v2f vert(LowendVertexInput v)
{

o.tangentWS = half3(1, 0, 0);
o.binormalWS = half3(0, 1, 0);
#endif
o.vertexColor += EvaluateOneLight(lightInput, diffuseAndSpecularColor, diffuseAndSpecularColor, o.normalWS, o.posWS.xyz, o.viewDir.xyz);
o.fogCoord.yzw += EvaluateOneLight(lightInput, diffuseAndSpecularColor, diffuseAndSpecularColor, o.normalWS, o.posWS.xyz, o.viewDir.xyz);
UNITY_TRANSFER_FOG(o, o.hpos);
return o;
}

giIndirect.specular = half3(0, 0, 0);
half3 indirectColor = BRDF3_Indirect(diffuse, specular, giIndirect, i.posWS.w, i.normalWS.w);
half3 directColor = i.vertexColor * diffuseAlbedo.rgb;
half3 directColor = i.fogCoord.yzw * diffuseAlbedo.rgb;
// Compute direct contribution from main directional light.
// Only a single directional shadow caster is supported.

directColor += EvaluateOneLight(additionalLight, diffuse, specular, normal, posWorld, viewDir);
}
half3 finalColor = directColor + indirectColor + emission;
return half4(finalColor, diffuseAlbedo.a);
half3 color = directColor + indirectColor + emission;
UNITY_APPLY_FOG(i.fogCoord, color);
return half4(color, diffuseAlbedo.a);
}
ENDCG
}

10
Assets/LowEndRenderLoop/LowEndRenderPipeline.cs


using System;
using UnityEditor;
using UnityEngine;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Experimental.ScriptableRenderLoop;
using UnityEngine.Rendering;

context.ExecuteCommandBuffer(cmd);
cmd.Dispose();
VisibleLight[] lights = cull.visibleLights;
ShadowOutput shadowOutput;
m_ShadowPass.Render(context, cull, out shadowOutput);
SetupShadowShaderVariables(shadowOutput, context, camera.nearClipPlane, cullingParameters.shadowDistance);

settings.sorting.flags = SortFlags.CommonOpaque;
settings.inputFilter.SetQueuesOpaque();
if (Lightmapping.bakedGI)
#if UNITY_EDITOR
if (UnityEditor.Lightmapping.bakedGI)
#endif
context.DrawRenderers(ref settings);
context.DrawSkybox(camera);

cmd.SetGlobalVectorArray("globalLightAtten", lightAttenuations);
cmd.SetGlobalVectorArray("globalLightSpotDir", lightSpotDirections);
cmd.SetGlobalVector("globalLightCount", new Vector4(pixelLightCount, totalLightCount, 0.0f, 0.0f));
cmd.SetGlobalVectorArray("globalSH", shConstants);
context.ExecuteCommandBuffer(cmd);
cmd.Dispose();

42
Assets/LowEndRenderLoop/Textures/154.JPG.meta


fileFormatVersion: 2
guid: 618126695341ad844ac048b062fd2688
timeCreated: 1484052980
timeCreated: 1484139434
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}

textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: iPhone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: tvOS
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Windows Store Apps
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1

42
Assets/LowEndRenderLoop/Textures/168.JPG.meta


fileFormatVersion: 2
guid: 70218f73fcdf828428151dfdd3104a8f
timeCreated: 1484053139
timeCreated: 1484139437
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}

textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: iPhone
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: tvOS
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Android
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Windows Store Apps
maxTextureSize: 2048
textureFormat: -1
textureCompression: 1

正在加载...
取消
保存