basic PBR is working!

PBR
cosmonaut 2020-08-03 16:27:59 -07:00
parent 4dab4dfb48
commit 5465b13b9d
3 changed files with 22 additions and 20 deletions

View File

@ -55,11 +55,11 @@ PixelShaderInput main_vs(VertexShaderInput input)
{
PixelShaderInput output;
output.PositionWS = mul(input.Position, World).xyz;
output.TexCoord = input.TexCoord;
output.NormalWS = normalize(mul(input.Normal, WorldInverseTranspose));
output.PositionWS = mul(input.Position, World).xyz;
output.NormalWS = mul(input.Normal, WorldInverseTranspose);
output.Position = mul(input.Position, WorldViewProjection);
return output;
}
@ -104,7 +104,7 @@ float GeometrySmith(float3 N, float3 V, float3 L, float roughness)
}
// The case where we have no texture maps for any PBR data
float4 None(PixelShaderInput input) : SV_TARGET
float4 None(PixelShaderInput input) : SV_TARGET0
{
float3 albedo = AlbedoValue;
float metallic = MetallicValue;
@ -208,7 +208,7 @@ float4 AlbedoMapPS(PixelShaderInput input) : SV_TARGET
float4 AlbedoMetallicRoughnessMapPS(PixelShaderInput input) : SV_TARGET
{
float3 albedo = SAMPLE_TEXTURE(AlbedoTexture, input.TexCoord).rgb;
float3 albedo = pow(SAMPLE_TEXTURE(AlbedoTexture, input.TexCoord), 2.2).rgb;
float2 metallicRoughness = SAMPLE_TEXTURE(MetallicRoughnessTexture, input.TexCoord).rg;
float metallic = metallicRoughness.r;
float roughness = metallicRoughness.g;
@ -263,6 +263,6 @@ Technique PBR
Pass Pass1
{
VertexShader = compile vs_3_0 main_vs();
PixelShader = compile ps_3_0 None();
PixelShader = compile ps_3_0 AlbedoMetallicRoughnessMapPS();
}
}

Binary file not shown.

View File

@ -218,6 +218,7 @@ namespace Smuggler
graphicsDevice,
metallicRoughnessChannel.Value.Texture.PrimaryImage.Content.Open()
);
System.Console.WriteLine(effect.MetallicRoughnessTexture.Width);
}
var parameter = metallicRoughnessChannel.Value.Parameter;
@ -231,24 +232,24 @@ namespace Smuggler
effect.AO = 1f;
effect.Lights[0] = new PBRLight(
new Vector3(-10f, 10f, -10f),
new Vector3(-10f, 10f, -5f),
new Vector3(300f, 300f, 300f)
);
// effect.Lights[1] = new PBRLight(
// new Vector3(10f, 10f, 10f),
// new Vector3(300f, 300f, 300f)
// );
effect.Lights[1] = new PBRLight(
new Vector3(10f, 10f, 5f),
new Vector3(300f, 300f, 300f)
);
// effect.Lights[2] = new PBRLight(
// new Vector3(-10f, -10f, 10f),
// new Vector3(300f, 300f, 300f)
// );
effect.Lights[2] = new PBRLight(
new Vector3(-10f, -10f, 5f),
new Vector3(300f, 300f, 300f)
);
// effect.Lights[3] = new PBRLight(
// new Vector3(10f, -10f, 10f),
// new Vector3(300f, 300f, 300f)
// );
effect.Lights[3] = new PBRLight(
new Vector3(10f, -10f, 5f),
new Vector3(300f, 300f, 300f)
);
/* FIXME: how to load cube maps from GLTF? */
/*
@ -311,7 +312,7 @@ namespace Smuggler
for (int i = 0; i < normals.Length; i++)
{
var normal = normalAccessor[i];
normals[i] = -new Vector3(normal.X, normal.Z, normal.Y);
normals[i] = new Vector3(-normal.X, -normal.Z, normal.Y);
}
return normals;
@ -415,6 +416,7 @@ namespace Smuggler
uint[] indices,
Vector3[] positions
) {
System.Console.WriteLine("normals");
var normals = Normals(primitive);
var texcoords = TexCoords(primitive);