Rename Diffuse to BaseColor
This commit is contained in:
@@ -4,7 +4,7 @@ module BasicMaterial;
|
||||
import InstanceData from Engine.InstanceData;
|
||||
import ViewerData from Engine.ViewerData;
|
||||
|
||||
option HasDiffuseTexture: bool = false;
|
||||
option HasBaseColorTexture: bool = false;
|
||||
option HasAlphaTexture: bool = false;
|
||||
option AlphaTest: bool = false;
|
||||
|
||||
@@ -27,13 +27,13 @@ const HasUV = (UvLocation >= 0);
|
||||
struct MaterialSettings
|
||||
{
|
||||
AlphaThreshold: f32,
|
||||
DiffuseColor: vec4[f32]
|
||||
BaseColor: vec4[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform[MaterialSettings],
|
||||
[binding(1)] MaterialDiffuseMap: sampler2D[f32],
|
||||
[binding(1)] MaterialBaseColorMap: sampler2D[f32],
|
||||
[binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
@@ -55,28 +55,28 @@ struct FragOut
|
||||
[entry(frag)]
|
||||
fn main(input: FragIn) -> FragOut
|
||||
{
|
||||
let diffuseColor = settings.DiffuseColor;
|
||||
let color = settings.BaseColor;
|
||||
|
||||
const if (HasUV)
|
||||
diffuseColor *= TextureOverlay.Sample(input.uv);
|
||||
color *= TextureOverlay.Sample(input.uv);
|
||||
|
||||
const if (HasColor)
|
||||
diffuseColor *= input.color;
|
||||
color *= input.color;
|
||||
|
||||
const if (HasDiffuseTexture)
|
||||
diffuseColor *= MaterialDiffuseMap.Sample(input.uv);
|
||||
const if (HasBaseColorTexture)
|
||||
color *= MaterialBaseColorMap.Sample(input.uv);
|
||||
|
||||
const if (HasAlphaTexture)
|
||||
diffuseColor.w *= MaterialAlphaMap.Sample(input.uv).x;
|
||||
color.w *= MaterialAlphaMap.Sample(input.uv).x;
|
||||
|
||||
const if (AlphaTest)
|
||||
{
|
||||
if (diffuseColor.w < settings.AlphaThreshold)
|
||||
if (color.w < settings.AlphaThreshold)
|
||||
discard;
|
||||
}
|
||||
|
||||
let output: FragOut;
|
||||
output.RenderTarget0 = diffuseColor;
|
||||
output.RenderTarget0 = color;
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,23 +4,23 @@ module DepthMaterial;
|
||||
import InstanceData from Engine.InstanceData;
|
||||
import ViewerData from Engine.ViewerData;
|
||||
|
||||
option HasDiffuseTexture: bool = false;
|
||||
option HasBaseColorTexture: bool = false;
|
||||
option HasAlphaTexture: bool = false;
|
||||
option AlphaTest: bool = false;
|
||||
|
||||
const HasUV = AlphaTest && (HasDiffuseTexture || HasAlphaTexture);
|
||||
const HasUV = AlphaTest && (HasBaseColorTexture || HasAlphaTexture);
|
||||
|
||||
[layout(std140)]
|
||||
struct BasicSettings
|
||||
{
|
||||
AlphaThreshold: f32,
|
||||
DiffuseColor: vec4[f32]
|
||||
BaseColor: vec4[f32]
|
||||
}
|
||||
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform[BasicSettings],
|
||||
[binding(1)] MaterialDiffuseMap: sampler2D[f32],
|
||||
[binding(1)] MaterialBaseColorMap: sampler2D[f32],
|
||||
[binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
@@ -36,13 +36,13 @@ struct FragIn
|
||||
[entry(frag), cond(AlphaTest)]
|
||||
fn main(input: FragIn)
|
||||
{
|
||||
let alpha = settings.DiffuseColor.a;
|
||||
let alpha = settings.BaseColor.a;
|
||||
|
||||
const if (HasUV)
|
||||
alpha *= TextureOverlay.Sample(input.uv).a;
|
||||
|
||||
const if (HasDiffuseTexture)
|
||||
alpha *= MaterialDiffuseMap.Sample(input.uv).a;
|
||||
const if (HasBaseColorTexture)
|
||||
alpha *= MaterialBaseColorMap.Sample(input.uv).a;
|
||||
|
||||
const if (HasAlphaTexture)
|
||||
alpha *= MaterialAlphaMap.Sample(input.uv).x;
|
||||
|
||||
@@ -6,7 +6,7 @@ import LightData from Engine.LightData;
|
||||
import ViewerData from Engine.ViewerData;
|
||||
|
||||
// Basic material options
|
||||
option HasDiffuseTexture: bool = false;
|
||||
option HasBaseColorTexture: bool = false;
|
||||
option HasAlphaTexture: bool = false;
|
||||
option AlphaTest: bool = false;
|
||||
|
||||
@@ -41,7 +41,7 @@ struct MaterialSettings
|
||||
{
|
||||
// BasicSettings
|
||||
AlphaThreshold: f32,
|
||||
DiffuseColor: vec4[f32],
|
||||
BaseColor: vec4[f32],
|
||||
|
||||
// PhongSettings
|
||||
AmbientColor: vec3[f32],
|
||||
@@ -57,7 +57,7 @@ const SpotLight = 2;
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform[MaterialSettings],
|
||||
[binding(1)] MaterialDiffuseMap: sampler2D[f32],
|
||||
[binding(1)] MaterialBaseColorMap: sampler2D[f32],
|
||||
[binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
@@ -88,23 +88,23 @@ struct FragOut
|
||||
[entry(frag)]
|
||||
fn main(input: VertToFrag) -> FragOut
|
||||
{
|
||||
let diffuseColor = settings.DiffuseColor;
|
||||
let color = settings.BaseColor;
|
||||
|
||||
const if (HasUV)
|
||||
diffuseColor *= TextureOverlay.Sample(input.uv);
|
||||
color *= TextureOverlay.Sample(input.uv);
|
||||
|
||||
const if (HasColor)
|
||||
diffuseColor *= input.color;
|
||||
color *= input.color;
|
||||
|
||||
const if (HasDiffuseTexture)
|
||||
diffuseColor *= MaterialDiffuseMap.Sample(input.uv);
|
||||
const if (HasBaseColorTexture)
|
||||
color *= MaterialBaseColorMap.Sample(input.uv);
|
||||
|
||||
const if (HasAlphaTexture)
|
||||
diffuseColor.w *= MaterialAlphaMap.Sample(input.uv).x;
|
||||
color.w *= MaterialAlphaMap.Sample(input.uv).x;
|
||||
|
||||
const if (AlphaTest)
|
||||
{
|
||||
if (diffuseColor.w < settings.AlphaThreshold)
|
||||
if (color.w < settings.AlphaThreshold)
|
||||
discard;
|
||||
}
|
||||
|
||||
@@ -216,13 +216,13 @@ fn main(input: VertToFrag) -> FragOut
|
||||
let lightColor = lightAmbient + lightDiffuse + lightSpecular;
|
||||
|
||||
let output: FragOut;
|
||||
output.RenderTarget0 = vec4[f32](lightColor, 1.0) * diffuseColor;
|
||||
output.RenderTarget0 = vec4[f32](lightColor, 1.0) * color;
|
||||
return output;
|
||||
}
|
||||
else
|
||||
{
|
||||
let output: FragOut;
|
||||
output.RenderTarget0 = diffuseColor;
|
||||
output.RenderTarget0 = color;
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import LightData from Engine.LightData;
|
||||
import ViewerData from Engine.ViewerData;
|
||||
|
||||
// Basic material options
|
||||
option HasDiffuseTexture: bool = false;
|
||||
option HasBaseColorTexture: bool = false;
|
||||
option HasAlphaTexture: bool = false;
|
||||
option AlphaTest: bool = false;
|
||||
|
||||
@@ -43,7 +43,7 @@ struct MaterialSettings
|
||||
{
|
||||
// BasicSettings
|
||||
AlphaThreshold: f32,
|
||||
DiffuseColor: vec4[f32],
|
||||
BaseColor: vec4[f32],
|
||||
|
||||
// PhongSettings
|
||||
AmbientColor: vec3[f32],
|
||||
@@ -59,7 +59,7 @@ const SpotLight = 2;
|
||||
external
|
||||
{
|
||||
[binding(0)] settings: uniform[MaterialSettings],
|
||||
[binding(1)] MaterialDiffuseMap: sampler2D[f32],
|
||||
[binding(1)] MaterialBaseColorMap: sampler2D[f32],
|
||||
[binding(2)] MaterialAlphaMap: sampler2D[f32],
|
||||
[binding(3)] TextureOverlay: sampler2D[f32],
|
||||
[binding(4)] instanceData: uniform[InstanceData],
|
||||
@@ -95,23 +95,23 @@ struct FragOut
|
||||
[entry(frag)]
|
||||
fn main(input: VertToFrag) -> FragOut
|
||||
{
|
||||
let diffuseColor = settings.DiffuseColor;
|
||||
let color = settings.BaseColor;
|
||||
|
||||
const if (HasUV)
|
||||
diffuseColor *= TextureOverlay.Sample(input.uv);
|
||||
color *= TextureOverlay.Sample(input.uv);
|
||||
|
||||
const if (HasColor)
|
||||
diffuseColor *= input.color;
|
||||
color *= input.color;
|
||||
|
||||
const if (HasDiffuseTexture)
|
||||
diffuseColor *= MaterialDiffuseMap.Sample(input.uv);
|
||||
const if (HasBaseColorTexture)
|
||||
color *= MaterialBaseColorMap.Sample(input.uv);
|
||||
|
||||
const if (HasAlphaTexture)
|
||||
diffuseColor.w *= MaterialAlphaMap.Sample(input.uv).x;
|
||||
color.w *= MaterialAlphaMap.Sample(input.uv).x;
|
||||
|
||||
const if (AlphaTest)
|
||||
{
|
||||
if (diffuseColor.w < settings.AlphaThreshold)
|
||||
if (color.w < settings.AlphaThreshold)
|
||||
discard;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ fn main(input: VertToFrag) -> FragOut
|
||||
else
|
||||
normal = normalize(input.normal);
|
||||
|
||||
let albedo = diffuseColor.xyz;
|
||||
let albedo = color.xyz;
|
||||
let metallic: f32;
|
||||
let roughness: f32;
|
||||
|
||||
@@ -211,7 +211,7 @@ fn main(input: VertToFrag) -> FragOut
|
||||
|
||||
let ambient = (0.03).rrr * albedo;
|
||||
|
||||
let color = ambient + lightRadiance * diffuseColor.rgb;
|
||||
let color = ambient + lightRadiance * color.rgb;
|
||||
color = color / (color + vec3[f32](1.0, 1.0, 1.0));
|
||||
color = pow(color, (1.0 / 2.2).xxx);
|
||||
|
||||
@@ -222,7 +222,7 @@ fn main(input: VertToFrag) -> FragOut
|
||||
else
|
||||
{
|
||||
let output: FragOut;
|
||||
output.RenderTarget0 = diffuseColor;
|
||||
output.RenderTarget0 = color;
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user