#version 410 #pragma include "Includes/Configuration.include" #pragma include "Includes/Structures/VertexOutput.struct" #extension GL_EXT_shader_image_load_store : enable // Input from the vertex shader layout(location=0) in VertexOutput vOutput; // Texture Samplers uniform sampler2D p3d_Texture0; uniform sampler2D p3d_Texture1; uniform sampler2D p3d_Texture2; uniform sampler2D p3d_Texture3; layout(location=7) in vec4 position_in_object_coordinates; // This is required for the materials #pragma include "Includes/MaterialPacking.include" #pragma include "Includes/CommonFunctions.include" // This include enables us to compute the tangent in the fragment shader #pragma include "Includes/TangentFromDDX.include" // Transparency bufers layout (r32ui) coherent uniform uimage2D pixelCountBuffer; layout (r32ui) coherent uniform uimage2D listHeadBuffer; layout (r32i) coherent uniform iimage2D spinLockBuffer; layout (rgba32ui) coherent uniform uimageBuffer materialDataBuffer; #pragma include "Includes/Transparency.include" uniform vec3 cameraPosition; void main() { float inside = 1.6; float outside = 2.6; if(length(position_in_object_coordinates) > outside || length(position_in_object_coordinates) < inside) { discard; } // Create a material to store the properties on //Material m = getDefaultMaterial(); TransparentMaterial tm = getDefaultTransparentMaterial(); vec2 newTexCoords = vOutput.texcoord; newTexCoords.x = (length(position_in_object_coordinates) - inside) / (outside - inside); // ^ adjust so inner ring edge is 0, outer edge is 1 // Sample the diffuse color //vec4 sampledDiffuse = texture(p3d_Texture0, vOutput.texcoord); vec4 sampledDiffuse = texture(p3d_Texture0, newTexCoords); // Alpha test // if (sampledDiffuse.a < 0.5) discard; // Sample the other maps vec4 sampledNormal = texture(p3d_Texture1, vOutput.texcoord); vec4 sampledSpecular = texture(p3d_Texture2, vOutput.texcoord); vec4 sampledRoughness = texture(p3d_Texture3, vOutput.texcoord); // Extract the material properties float bumpFactor = vOutput.materialDiffuse.w * 0.0; float specularFactor = vOutput.materialSpecular.x; float metallic = vOutput.materialSpecular.y; float roughnessFactor = vOutput.materialSpecular.z; // Merge the detail normal with the vertex normal vec3 detailNormal = sampledNormal.xyz * 2.0 - 1.0; vec3 tangent; vec3 binormal; reconstructTanBin(tangent, binormal); vec3 mixedNormal = mergeNormal(detailNormal, bumpFactor, vOutput.normalWorld, tangent, binormal); // Store the properties //m.baseColor = sampledDiffuse.rgb * vOutput.materialDiffuse.rgb; //m.roughness = sampledRoughness.r * roughnessFactor; //m.specular = sampledSpecular.r * specularFactor; //m.metallic = metallic; //m.normal = mixedNormal; //m.position = vOutput.positionWorld; //m.roughness = 0.4; //m.specular = 0.01; //m.metallic = 0.0; //m.translucency = (vOutput.materialDiffuse.r + vOutput.materialDiffuse.g + vOutput.materialDiffuse.b) / 3; //tm.color = sampledDiffuse.rgb * vOutput.materialDiffuse.rgb; tm.color = sampledDiffuse.rgb; tm.alpha = (sampledDiffuse.r + sampledDiffuse.g + sampledDiffuse.b) * 3.0/ 3.0; //tm.alpha = (tm.color.r + tm.color.g + tm.color.b) / 3.0; //tm.alpha = 0.1; tm.normal = mixedNormal; tm.depth = distance(cameraPosition, vOutput.positionWorld) / CAMERA_FAR; tm.materialType = 0; // Write the material to the G-Buffer //renderMaterial(m); renderTransparentMaterial(tm); }