The task is to implement light reflection on a vinyl record surface using fragment shader only. For bonus points you can implement reading a radial record structure from a 1D texture.
C#: Template for the task is prepared in the grcis repository. You can use the 086shader project, there is reasonable GLSL shader setup prepared for you extension and you can find sample texturing code as well. In case you will be using input 1D texture, please load a raster image from disk file.
C++: You can use template sample09 from the ogl repository. GLSL shaders are initialized in the initGLSL() function, for texture loaded from file, see sample08, function prepareTextures().
Drawn shape: use single rectangle (square), simulate one or two sides of a vinyl record. The area outside of a disk should be transparent (set alpha channel to zero in the shader). You need to setup transparency in OpenGL rendering by adding two commands:
// C# GL.Enable( EnableCap.Blend ); GL.BlendFunc( BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha ); // C++ glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
See This page fo reference.
Texture coordinates: create a new variable (varying value) for passing 2D coordinates to the fragment shader. Optional 1D texture coordinate should be easily computed as the distance from the current point to the vinyl center.
C#: In the InitShaderRepository() you can define custom sets of shaders assembled into shader programs. Don't forget to define all handles to uniform variables and assemble all the shader pipelines corectly. Look into the log.txt file for eventual error messages. Current uniform values are set in the RenderScene() just before rendering code (if ( useShaders ) ..).
C++: Definition of the shader set is in the initGLSL() function. You must define all handles to uniform variables and assemble all the shader pipelines corectly. Look into the log.txt file for eventual error messages. Current uniform values are set in the drawGLScene() just before rendering code (if ( shaders ) ..).
Send all your modifications in complete Visual Studio project, including shader files and perhaps larger data files (textures). Write a brief document about your method.
Hand in before: 21. 5. 2017
Basis: 20 points for functional fragment-shader implementation simulating a vinyl record
bonuses: up to 5 additional points for using input 1D texture for radial record structure,
up to 7 points for using noise, two-sided record implementation, textured record center, ..
Recommended starting point: Visual Studio project 086shader from the grcis repository (C#) or sample09 from the ogl repository (C++).
Copyright (C) 2008-2017 J. Pelikán, last change: 2019-05-09 17:52:59 +0200 (Thu, 09 May 2019)