OpenGL works again, Vulkan can be switched to, fixed most of the vulkan validation errors, better shadows, soft shadows, emissive lighting, and multiple different opacity rendering methods
This commit is contained in:
parent
0d41f3e15b
commit
5b231d6920
54 changed files with 1102 additions and 268 deletions
|
|
@ -10,17 +10,25 @@ layout(location = 4) in vec2 inTextCoords;
|
|||
|
||||
layout(location = 0) out vec4 outAlbedo;
|
||||
|
||||
|
||||
struct Material {
|
||||
vec4 diffuseColor;
|
||||
uint hasTexture;
|
||||
uint textureIdx;
|
||||
uint hasNormalMap;
|
||||
uint normalMapIdx;
|
||||
uint hasRoughMap;
|
||||
uint roughMapIdx;
|
||||
float roughnessFactor;
|
||||
float metallicFactor;
|
||||
vec4 diffuseColor; //16
|
||||
uint hasTexture; //20
|
||||
uint textureIdx; //24
|
||||
uint hasNormalMap; //28
|
||||
uint normalMapIdx; //32
|
||||
uint hasRoughMap; //36
|
||||
uint roughMapIdx; //40
|
||||
float roughnessFactor; //44
|
||||
float metallicFactor; //48
|
||||
vec4 emissiveColour; //64
|
||||
uint hasEmissiveMap; //68
|
||||
uint emissiveMapIdx; //72
|
||||
uint hasTranslucencyMap; //76
|
||||
uint translucencyMapIdx; //80
|
||||
float translucencyFactor; //84
|
||||
uint hasOpacityMap; //88
|
||||
uint OpacityMapIdx; //92
|
||||
float OpacityFactor; //96
|
||||
};
|
||||
|
||||
layout(set = 2, binding = 0) readonly buffer MaterialUniform{
|
||||
|
|
@ -36,13 +44,23 @@ layout(push_constant) uniform pc{
|
|||
void main()
|
||||
{
|
||||
|
||||
|
||||
Material material = matUniform.materials[push_constants.materialIdx];
|
||||
if(material.hasTexture == 1){
|
||||
vec4 texColor = texture(textSampler[material.textureIdx],inTextCoords);
|
||||
if(texColor.a < 0.4){discard;}
|
||||
outAlbedo = texColor;
|
||||
} else{
|
||||
outAlbedo = material.diffuseColor;
|
||||
}
|
||||
vec4 Opacity = vec4(outAlbedo.a,outAlbedo.a,outAlbedo.a,1);
|
||||
if(material.OpacityFactor != 1) Opacity = vec4(material.OpacityFactor, material.OpacityFactor, material.OpacityFactor, 1);
|
||||
if(material.hasOpacityMap > 0 && material.OpacityMapIdx < MAX_TEXTURES){
|
||||
Opacity = texture(textSampler[material.OpacityMapIdx], inTextCoords);
|
||||
}
|
||||
|
||||
float opacityf = Opacity.x + Opacity.y + Opacity.z;
|
||||
opacityf = opacityf/3;
|
||||
if(opacityf < 0.4){discard;}
|
||||
|
||||
outAlbedo = vec4(outAlbedo.rgb, opacityf);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue