Esempio n. 1
0
        public static void DrawNudMaterialSphere(Shader shader, Nud.Material material, Mesh3D screenTriangle, Dictionary <NudEnums.DummyTexture, Texture> dummyTextures)
        {
            if (!shader.LinkStatusIsOk)
            {
                return;
            }

            shader.UseProgram();

            // Use the same uniforms as the NUD shader.
            var uniformBlock = new UniformBlock(shader, "MaterialProperties")
            {
                BlockBinding = 1
            };

            NudUniforms.SetMaterialPropertyUniforms(uniformBlock, shader, material);

            Nud.SetStageLightingUniforms(shader, 0);
            ModelContainer.SetRenderSettingsUniforms(shader);

            ModelContainer.SetLightingUniforms(shader, nudSphereCamera);
            ModelContainer.SetCameraMatrixUniforms(nudSphereCamera, shader);

            // Use default textures rather than textures from the NUT.
            NudUniforms.SetTextureUniformsNudMatSphere(shader, material, dummyTextures);

            // These values aren't needed in the shader currently.
            shader.SetVector3("cameraPosition", 0, 0, 0);
            shader.SetFloat("zBufferOffset", 0);
            shader.SetFloat("bloomThreshold", Runtime.bloomThreshold);

            bool isTransparent = (material.SrcFactor > 0) || (material.DstFactor > 0) || (material.AlphaFunction > 0) || (material.AlphaTest > 0);

            shader.SetBoolToInt("isTransparent", isTransparent);

            // Set texture uniforms for the mesh attributes.
            shader.SetTexture("normalTex", sphereNrmTex, 15);
            shader.SetTexture("uvTex", sphereUvTex, 16);
            shader.SetTexture("tanTex", sphereTanTex, 17);
            shader.SetTexture("bitanTex", sphereBitanTex, 18);

            // Draw full screen "quad" (big triangle)
            ScreenDrawing.DrawScreenTriangle(shader, screenTriangle);
        }
Esempio n. 2
0
        public static void DrawNudMaterialSphere(Shader shader, NUD.Material material, Mesh3D screenTriangle, Dictionary <NUD.DummyTextures, Texture> dummyTextures)
        {
            if (!shader.ProgramCreatedSuccessfully)
            {
                return;
            }

            shader.UseProgram();

            // Use the same uniforms as the NUD shader.
            GenericMaterial genericMaterial = new GenericMaterial();

            NudUniforms.SetMaterialPropertyUniforms(genericMaterial, material);
            genericMaterial.SetShaderUniforms(shader);

            NUD.SetStageLightingUniforms(shader, 0);
            ModelContainer.SetRenderSettingsUniforms(shader);

            nudSphereCamera.UpdateMatrices();
            ModelContainer.SetLightingUniforms(shader, nudSphereCamera);
            ModelContainer.SetCameraMatrixUniforms(nudSphereCamera, shader);

            // Use default textures rather than textures from the NUT.
            NudUniforms.SetTextureUniformsNudMatSphere(shader, material, dummyTextures);

            // These values aren't needed in the shader currently.
            shader.SetVector3("cameraPosition", 0, 0, 0);
            shader.SetFloat("zBufferOffset", 0);
            shader.SetFloat("bloomThreshold", Runtime.bloomThreshold);

            bool isTransparent = (material.srcFactor > 0) || (material.dstFactor > 0) || (material.alphaFunction > 0) || (material.alphaTest > 0);

            shader.SetBoolToInt("isTransparent", isTransparent);

            // Set texture uniforms for the mesh attributes.
            shader.SetTexture("normalTex", sphereNrmTex.Id, TextureTarget.Texture2D, 15);
            shader.SetTexture("uvTex", sphereUvTex.Id, TextureTarget.Texture2D, 16);
            shader.SetTexture("tanTex", sphereTanTex.Id, TextureTarget.Texture2D, 17);
            shader.SetTexture("bitanTex", sphereBitanTex.Id, TextureTarget.Texture2D, 18);

            // Draw full screen "quad" (big triangle)
            ScreenDrawing.DrawScreenTriangle(shader, screenTriangle);
        }