Improving Material shader code generation
This commit is contained in:
@@ -10,15 +10,9 @@ struct BlinnPhong : IBRDF
|
||||
float3 baseColor;
|
||||
float metallic = 0;
|
||||
float3 normal = float3(0, 1, 0);
|
||||
float subsurface = 0;
|
||||
float specular = 0.5;
|
||||
float roughness = 0.5;
|
||||
float specularTint = 0;
|
||||
float anisotropic = 0;
|
||||
float sheen = 0;
|
||||
float sheenTint = 0.5f;
|
||||
float clearCoat = 0;
|
||||
float clearCoatGloss = 1;
|
||||
float sheen = 1.f;
|
||||
|
||||
float3 evaluate(float3 view, float3 light, float3 surfaceNormal, float3 tangent, float3 biTangent, float3 lightColor)
|
||||
{
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import StaticMeshShaderAttributes;
|
||||
import MaterialParameter;
|
||||
import BRDF;
|
||||
import Common;
|
||||
|
||||
interface ILightEnv
|
||||
{
|
||||
float3 illuminate<B:IBRDF>(VertexShaderInput input, B brdf, float3 wo);
|
||||
float3 illuminate<B:IBRDF>(MaterialFragmentParameter input, B brdf, float3 wo);
|
||||
};
|
||||
|
||||
struct DirectionalLight : ILightEnv
|
||||
@@ -70,5 +69,5 @@ struct Lights
|
||||
uint numPointLights;
|
||||
};
|
||||
|
||||
layout(set = 0, binding = 1, std430)
|
||||
layout(set = 0, binding = 1)
|
||||
ConstantBuffer<Lights> gLightEnv;
|
||||
|
||||
@@ -6,4 +6,13 @@ interface IMaterial
|
||||
{
|
||||
associatedtype BRDF : IBRDF;
|
||||
BRDF prepare(MaterialFragmentParameter input);
|
||||
|
||||
float3 getWorldOffset();
|
||||
|
||||
float3 getBaseColor(MaterialFragmentParameter input);
|
||||
float getMetallic(MaterialFragmentParameter input);
|
||||
float3 getNormal(MaterialFragmentParameter input);
|
||||
float getSpecular(MaterialFragmentParameter input);
|
||||
float getRoughness(MaterialFragmentParameter input);
|
||||
float getSheen(MaterialFragmentParameter input);
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ struct MaterialVertexParameter
|
||||
#if NUM_MATERIAL_TEXCOORDS
|
||||
float2 texCoords[NUM_MATERIAL_TEXCOORDS];
|
||||
#endif
|
||||
#if USE_INSTANCING
|
||||
#ifdef USE_INSTANCING
|
||||
float4x4 instanceLocalToWorld;
|
||||
float3 instanceLocalPosition;
|
||||
float4 perInstanceParams;
|
||||
@@ -26,7 +26,7 @@ struct MaterialFragmentParameter
|
||||
float4 clipPosition;
|
||||
float4 vertexColor;
|
||||
float3x3 tangentToWorld;
|
||||
#if USE_INSTANCING
|
||||
#ifdef USE_INSTANCING
|
||||
float3 perInstanceParams;
|
||||
#endif
|
||||
#if NUM_MATERIAL_TEXCOORDS
|
||||
@@ -37,4 +37,11 @@ struct MaterialFragmentParameter
|
||||
float3 result = mul(tangentToWorld, tangentSpaceNormal);
|
||||
return result;
|
||||
}
|
||||
float3 transformNormalTexture(float3 rawNormal)
|
||||
{
|
||||
rawNormal = 2.0 * rawNormal - float3(1.0, 1.0, 1.0);
|
||||
return transformNormalToWorld(rawNormal);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
+7
-1
@@ -114,7 +114,7 @@ struct VertexShaderInput
|
||||
return result;
|
||||
}
|
||||
|
||||
float3 getWorldPosition(VertexValueCache cache)
|
||||
float3 getWorldPosition()
|
||||
{
|
||||
float4x4 localToWorld = gSceneData.localToWorld;
|
||||
float3 rotatedPosition = localToWorld[0].xyz * position.xxx + localToWorld[1].xyz * position.yyy + localToWorld[2].xyz * position.zzz;
|
||||
@@ -191,4 +191,10 @@ struct PositionOnlyVertexShaderInput
|
||||
float3 instanceTransform2;
|
||||
float3 instanceTransform3;
|
||||
#endif // USE_INSTANCING
|
||||
float3 getWorldPosition()
|
||||
{
|
||||
float4x4 localToWorld = gSceneData.localToWorld;
|
||||
float3 rotatedPosition = localToWorld[0].xyz * position.xxx + localToWorld[1].xyz * position.yyy + localToWorld[2].xyz * position.zzz;
|
||||
return rotatedPosition + localToWorld[3].xyz;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user