浏览代码

Update hlsl generator for nested class and regenerate file for HD

/RenderPassXR_Sandbox
sebastienlagarde 8 年前
当前提交
36f2d0de
共有 6 个文件被更改,包括 40 次插入40 次删除
  1. 7
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightDefinition.cs.hlsl
  2. 8
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Builtin/BuiltinData.cs.hlsl
  3. 16
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs.hlsl
  4. 8
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.cs.hlsl
  5. 20
      Assets/ScriptableRenderPipeline/ShaderGenerator/Editor/CSharpToHLSL.cs
  6. 21
      Assets/ScriptableRenderPipeline/ShaderGenerator/Editor/ShaderTypeGeneration.cs

7
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightDefinition.cs.hlsl


//
#define ENVCONSTANTS_SPEC_CUBE_LOD_STEP (6)
//
// UnityEngine.Experimental.Rendering.HDPipeline.StencilLightingUsage: static fields
//
#define STENCILLIGHTINGUSAGE_NO_LIGHTING (0)
#define STENCILLIGHTINGUSAGE_SPLIT_LIGHTING (1)
#define STENCILLIGHTINGUSAGE_REGULAR_LIGHTING (2)
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.LightData
// PackingRules = Exact
struct LightData

8
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Builtin/BuiltinData.cs.hlsl


#ifndef BUILTINDATA_CS_HLSL
#define BUILTINDATA_CS_HLSL
//
// UnityEngine.Experimental.Rendering.HDPipeline.Builtin.BuiltinData: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Builtin+BuiltinData: static fields
//
#define DEBUGVIEW_BUILTIN_BUILTINDATA_OPACITY (100)
#define DEBUGVIEW_BUILTIN_BUILTINDATA_BAKE_DIFFUSE_LIGHTING (101)

#define DEBUGVIEW_BUILTIN_BUILTINDATA_DEPTH_OFFSET (107)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Builtin.LightTransportData: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Builtin+LightTransportData: static fields
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Builtin.BuiltinData
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Builtin+BuiltinData
// PackingRules = Exact
struct BuiltinData
{

float depthOffset;
};
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Builtin.LightTransportData
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Builtin+LightTransportData
// PackingRules = Exact
struct LightTransportData
{

16
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.cs.hlsl


#ifndef LIT_CS_HLSL
#define LIT_CS_HLSL
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit.MaterialId: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+MaterialId: static fields
//
#define MATERIALID_LIT_SSS (0)
#define MATERIALID_LIT_STANDARD (1)

//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit.MaterialFeatureFlags: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+MaterialFeatureFlags: static fields
//
#define FEATURE_FLAG_MATERIAL_LIT_SSS (4096)
#define FEATURE_FLAG_MATERIAL_LIT_STANDARD (8192)

//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit.SurfaceData: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+SurfaceData: static fields
//
#define DEBUGVIEW_LIT_SURFACEDATA_BASE_COLOR (1000)
#define DEBUGVIEW_LIT_SURFACEDATA_SPECULAR_OCCLUSION (1001)

#define DEBUGVIEW_LIT_SURFACEDATA_SPECULAR_COLOR (1013)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit.TransmissionType: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+TransmissionType: static fields
//
#define TRANSMISSIONTYPE_NONE (0)
#define TRANSMISSIONTYPE_REGULAR (1)

// UnityEngine.Experimental.Rendering.HDPipeline.Lit.BSDFData: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+BSDFData: static fields
//
#define DEBUGVIEW_LIT_BSDFDATA_DIFFUSE_COLOR (1030)
#define DEBUGVIEW_LIT_BSDFDATA_FRESNEL0 (1031)

#define DEBUGVIEW_LIT_BSDFDATA_TRANSMITTANCE (1047)
//
// UnityEngine.Experimental.Rendering.HDPipeline.Lit.GBufferMaterial: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Lit+GBufferMaterial: static fields
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Lit.SurfaceData
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Lit+SurfaceData
// PackingRules = Exact
struct SurfaceData
{

float3 specularColor;
};
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Lit.BSDFData
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Lit+BSDFData
// PackingRules = Exact
struct BSDFData
{

8
Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.cs.hlsl


#ifndef UNLIT_CS_HLSL
#define UNLIT_CS_HLSL
//
// UnityEngine.Experimental.Rendering.HDPipeline.Unlit.SurfaceData: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Unlit+SurfaceData: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Unlit.BSDFData: static fields
// UnityEngine.Experimental.Rendering.HDPipeline.Unlit+BSDFData: static fields
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Unlit.SurfaceData
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Unlit+SurfaceData
// PackingRules = Exact
struct SurfaceData
{

// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Unlit.BSDFData
// Generated from UnityEngine.Experimental.Rendering.HDPipeline.Unlit+BSDFData
// PackingRules = Exact
struct BSDFData
{

20
Assets/ScriptableRenderPipeline/ShaderGenerator/Editor/CSharpToHLSL.cs


{
if (attr is GenerateHLSL)
{
var parent = type.DeclaringType;
if (parent != null)
ShaderTypeGenerator gen;
if (s_TypeName.TryGetValue(type.FullName, out gen))
Debug.LogError("The GenerateHLSL attribute not supported on nested classes (" + type.FullName + "), skipping.");
}
else
{
ShaderTypeGenerator gen;
if (s_TypeName.TryGetValue(type.FullName, out gen))
{
Debug.LogError("Duplicate typename with the GenerateHLSL attribute detected: " + type.FullName +
" declared in both " + gen.type.Assembly.FullName + " and " + type.Assembly.FullName + ". Skipping the second instance.");
}
s_TypeName[type.FullName] = new ShaderTypeGenerator(type, attr as GenerateHLSL);
Debug.LogError( "Duplicate typename with the GenerateHLSL attribute detected: " + type.FullName +
" declared in both " + gen.type.Assembly.FullName + " and " + type.Assembly.FullName + ". Skipping the second instance.");
s_TypeName[type.FullName] = new ShaderTypeGenerator(type, attr as GenerateHLSL);
}
}
}

{
writer.Write(gen.EmitFunctions() + "\n");
}
}
}
writer.Write("\n#endif\n");

21
Assets/ScriptableRenderPipeline/ShaderGenerator/Editor/ShaderTypeGeneration.cs


public string fieldName;
public Type fieldType;
public bool isDirection;
public bool isSRGB;
public bool isSRGB;
}
void Error(string error)

if (!attr.needParamDebug)
return shaderText;
// Specific to HDRenderPipeline
// Specific to HDRenderPipeline
string lowerStructName = type.Name.ToLower();
shaderText += "//\n";

{
shaderText += " result = " + lowerStructName + "." + debugField.fieldName + ".xxx * 0.5 + 0.5;\n";
}
else
else
{
shaderText += " result = " + lowerStructName + "." + debugField.fieldName + ".xxx;\n";
}

{
shaderText += " result = " + lowerStructName + "." + debugField.fieldName + " * 0.5 + 0.5;\n";
}
else
else
}
}
}
else if (debugField.fieldType == typeof(Vector4))
{

}
else // This case left is suppose to be a complex structure. Either we don't support it or it is an enum. Consider it is an enum with GetIndexColor, user can override it if he want.
{
shaderText += " result = GetIndexColor(" + lowerStructName + "." + debugField.fieldName + ");\n";
shaderText += " result = GetIndexColor(" + lowerStructName + "." + debugField.fieldName + ");\n";
if (debugField.isSRGB)
{
shaderText += " needLinearToSRGB = true;\n";

}
shaderText += " }\n";
shaderText += "}\n";
shaderText += "}\n";
return shaderText;
}

if (attr.needParamDebug)
{
string subNamespace = type.Namespace.Substring(type.Namespace.LastIndexOf((".")) + 1);
string className = type.FullName.Substring(type.FullName.LastIndexOf((".")) + 1); // ClassName include nested class
className = className.Replace('+', '_'); // FullName is Class+NestedClass replace by Class_NestedClass
string defineName = ("DEBUGVIEW_" + subNamespace + "_" + type.Name + "_" + name).ToUpper();
string defineName = ("DEBUGVIEW_" + className + "_" + name).ToUpper();
m_Statics[defineName] = Convert.ToString(attr.paramDefinesStart + debugCounter++);
bool isDirection = false;

正在加载...
取消
保存