Exemple #1
0
        /// <summary>
        /// renders the mesh using the supplied shader and matrix
        /// </summary>
        /// <param name="furShader"></param>
        /// <param name="meshToWorld"></param>
        /// <param name="worldToScreen"></param>
        /// <param name="furTexture"></param>
        /// <param name="offset"></param>
        public void FurRender(FurShader furShader, Matrix4 meshToWorld, Matrix4 worldToScreen, Texture furTexture, float offset)
        {
            GL.UseProgram(furShader.programID);

            // enable texture
            furShader.SetTexture(furTexture);

            // pass transform to vertex shader
            furShader.SetUniforms(meshToWorld, worldToScreen);
            GL.Uniform1(furShader.uniform_furoffset, offset);

            drawMesh(furShader);
        }
Exemple #2
0
 public FurModel(Mesh mesh, Texture texture, Texture furTexture, Shader shader, FurShader furShader, Matrix4 modelTransformation)
     : base(mesh, texture, shader, modelTransformation)
 {
     this.furTexture = furTexture;
     this.furShader  = furShader;
 }
Exemple #3
0
        // initialize
        public void Init()
        {
            // initialize camera
            camera = new Camera(new Vector3(0, 10, 15), Quaternion.FromAxisAngle(Vector3.UnitX, -0.5f));

            // initialize stopwatch
            timer = new Stopwatch();
            timer.Start();

            // create model shaders
            shaderDefault    = Shader.Load("vs", "fs");
            shaderNormal     = Shader.Load("vs_normal", "fs_normal");
            shaderConstant   = Shader.Load("vs", "fs_const");
            shaderFur        = new FurShader("../../shaders/vs_fur.glsl", "../../shaders/fs_fur.glsl");
            shaderSkyBox     = Shader.Load("vs_skybox", "fs_skybox");
            shaderReflective = Shader.Load("vs", "fs_reflective");
            // create post processing shaders
            shaderPostProc       = Shader.Load("vs_post", "fs_post");
            shaderKernel         = new PostKernelShader("../../shaders/vs_post.glsl", "../../shaders/fs_kernel.glsl");
            shaderVigAndChrom    = new PostVigAndChromShader("../../shaders/vs_post.glsl", "../../shaders/fs_vigchrom.glsl");
            shaderPostBloomBlend = Shader.Load("vs_post", "fs_bloomblend");

            // load meshes
            meshTeapot    = new Mesh("../../assets/teapot.obj");
            meshFloor     = new Mesh("../../assets/floor.obj");
            meshCube      = new Mesh("../../assets/cube.obj");
            meshHeightMap = new HeightMap("../../assets/heightmap.png");

            // load textures
            textureFur       = Texture.Load("fur.png");
            textureWood      = Texture.Load("wood.jpg");
            textureTrump     = Texture.Load("thetrump.png");
            textureBrickWall = Texture.Load("brickwall.jpg");
            textureSkyBox    = new CubeTexture(
                "../../assets/sea_rt.JPG", "../../assets/sea_lf.JPG",
                "../../assets/sea_up.JPG", "../../assets/sea_dn.JPG",
                "../../assets/sea_bk.JPG", "../../assets/sea_ft.JPG"
                );
            // load normal maps
            normalNormal    = Texture.Load("normal_normal.png");
            normalBrickWall = Texture.Load("brickwall_normal.jpg");
            normalHeightMap = Texture.Load("heightmap_normal.png");

            ResizeWindow();
            quad = new ScreenQuad();

            // create models
            modelTeapot    = new Model(meshTeapot, textureWood, shaderNormal, Matrix4.CreateTranslation(new Vector3(0, 0.1f, 0)));
            modelFloor     = new Model(meshFloor, textureBrickWall, shaderNormal, Matrix4.Identity);
            modelLightPos  = new Model(meshCube, null, shaderConstant, Matrix4.Identity);
            modelHeightMap = new Model(meshHeightMap, textureTrump, shaderDefault, Matrix4.CreateScale(10f) * Matrix4.CreateTranslation(20f, 0f, 0f));
            Model teapot2 = new Model(meshTeapot, textureWood, shaderDefault, Matrix4.CreateScale(0.5f, 1f, 0.5f) * Matrix4.CreateRotationY(1.5f) * Matrix4.CreateTranslation(new Vector3(0, 24f, 0)));

            // set normal maps of specific models
            modelFloor.normalMap     = normalBrickWall;
            modelTeapot.normalMap    = normalBrickWall;
            modelLightPos.color      = new Vector3(1f, 1f, .5f);
            modelHeightMap.normalMap = normalHeightMap;

            // create special models
            ReflectiveModel refl   = new ReflectiveModel(meshTeapot, shaderReflective, Matrix4.CreateTranslation(0, 12f, 0), textureSkyBox);
            FurModel        furmod = new FurModel(meshTeapot, textureBrickWall, textureFur, shaderDefault, shaderFur, Matrix4.CreateRotationX((float)Math.PI / 2f) * Matrix4.CreateTranslation(new Vector3(0, 36f, 0)));

            // set up scenegraph
            SceneNode mainNode = new SceneNode();

            subScene = new SceneNode();
            subScene.AddChildModel(refl);
            subScene.AddChildModel(furmod);
            subScene.AddChildModel(teapot2);

            mainNode.AddChildNode(subScene);

            mainNode.AddChildModel(modelFloor);
            mainNode.AddChildModel(modelTeapot);
            mainNode.AddChildModel(modelLightPos);
            mainNode.AddChildModel(modelHeightMap);
            scene = new SceneGraph(mainNode);

            // set kernel used for final post processing step
            kernel = Kernel.SmallGaussianBlur;
        }