Example #1
0
        public static WaterTextureRenderer Create(int waterPlaneLength)
        {
            var model       = new PlaneModel(waterPlaneLength / 2);
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\water\WaterTexture.vert.glsl"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\water\WaterTexture.frag.glsl"), ShaderType.FragmentShader);
            var map = new AttributeMap();

            map.Add("a_vertex", PlaneModel.strPosition);
            map.Add("a_texCoord", PlaneModel.strTexCoord);
            var renderer = new WaterTextureRenderer(model, shaderCodes, map, new FrontFaceSwitch(FrontFaceMode.CCW), new ClearColorSwitch(Color.Black, 0), new ViewportSwitch(0, 0, TEXTURE_SIZE, TEXTURE_SIZE));

            renderer.Lengths          = new vec3(waterPlaneLength, 0, waterPlaneLength);
            renderer.waterPlaneLength = waterPlaneLength;

            return(renderer);
        }
Example #2
0
        public static WaterRenderer Create(int waterPlaneLength)
        {
            var model       = new WaterPlaneModel(waterPlaneLength);
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\water\Water.vert.glsl"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\water\Water.frag.glsl"), ShaderType.FragmentShader);
            var map = new AttributeMap();

            map.Add("a_vertex", WaterPlaneModel.strPosition);
            var renderer = new WaterRenderer(model, shaderCodes, map, new FrontFaceSwitch(FrontFaceMode.CCW));

            renderer.waterTextureRenderer = WaterTextureRenderer.Create(waterPlaneLength);
            renderer.backgroundRenderer   = WaterBackgroundRenderer.Create(waterPlaneLength);
            renderer.Lengths          = new vec3(waterPlaneLength + 1, waterPlaneLength + 1, waterPlaneLength + 1);
            renderer.waterPlaneLength = waterPlaneLength;

            return(renderer);
        }