summaryrefslogtreecommitdiffstats
path: root/src/render/shaders
Commit message (Collapse)AuthorAgeFilesLines
* GLSL 100 light include uses too many uniformsAndy Nichols2016-01-201-175/+1
| | | | | | | | With the additon of the uniforms for supporting spotlights, now it is only possible to have 2 active lights instead of 4. Change-Id: Ie9d84c85cda204f82f976fb55d8b5fe74ba58687 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
* Add missing precision qualifiersLaszlo Agocs2015-12-153-3/+3
| | | | | Change-Id: I362d40cc7861551b49d97120751b107d3d7f674e Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Bring the GLSL 1.00 fallback shader up-to-dateLaszlo Agocs2015-12-101-35/+170
| | | | | | | | | Add support for spotlights and increase the number of lights supported from 3 to 4. It is now on feature parity with the normal lighting shader code. Change-Id: I784ffb8bd0142253b5c8980e654fa25d683d93f0 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Do lighting calculation in world spaceLaszlo Agocs2015-12-1030-147/+110
| | | | | | | | | | | | | | | | As opposed to (mostly) camera space. Oops. While somewhat hidden with point lights, the problem became apparent with directional lights. Now that we have proper directional lights, change the default light, that is used when no light components are specified at all, from point to directional since this is cheaper and provides less surprises with arbitrary scenes. Also remove the duplicate phongalpha vertex shader in the process. Change-Id: I295660a1400b16b69e1516672e31794312ee48d1 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Add support for spotlightsLaszlo Agocs2015-12-092-24/+48
| | | | | Change-Id: I61a4e072c1a2e00cdbcee917aa557e56fb8cb7c0 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Separate GLSL 1.00 and newer shader snippets for lightsLaszlo Agocs2015-12-072-52/+321
| | | | | | | | | | | | | | | | | | | | Many but not all OpenGL ES 2.0 implementations support dynamic indexing. For these the normal for loop is fine. For simple GLSL 1.00 compilers without dynamic indexing support (e.g. RPi) a separate, limited version is provided that supports a lower number of lights and uses copy-paste instead of the loop. Right now there is no sane way to choose which snippet to use as that requires the OpenGL context at minimum (and even then we could only rely on vendor/renderer checks). Therefore a QT3D_GLSL100_WORKAROUND environment variable is used for now. This is temporary until we figure out something more sophisticated. The default GL2/ES2 lighting shader is now equivalent to the GL3 version, supporting up to 8 lights. Change-Id: I0244c920a1f2c2516b130991996afca68207a7db Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Use light type in the shadersLaszlo Agocs2015-12-072-9/+19
| | | | | Change-Id: If57f6818fb6c40a9b88b7a2e91088e3daddb435e Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Indicate light typeLaszlo Agocs2015-12-071-0/+1
| | | | | | | | | | | | Having a dedicated type field is required not just to make the shaders cleaner but also to avoid incorrect results when lights get moved around in the scene. Currently the shaders rely on the direction uniform to distinguish directional lights from the others, but this cannot work when the elements in the lights uniform array change, potentially leaving type-specific members like direction set when a point light takes the same index. Change-Id: I170e4b471c8cd9b4a23eca49690239c01944b3e6 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Fix directional lightsLaszlo Agocs2015-12-042-30/+33
| | | | | | | | | | | | The interpretation of lightDir was different for point and directional lights: it was surface-to-light for point lights, but light-to-surface for directional. Fix this by getting rid of lightDir and instead setting up s (surface-to-light) correctly. Change-Id: I0bc6947dc94622d7a95f55fd65b3baf43fd11528 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Migrate NormalDiffuseSpecularMapMaterial to be light-awareLaszlo Agocs2015-12-046-207/+20
| | | | | | | | | | Remove duplicated vertex shaders in the process. [normal]diffusespecularmap.vert is the same as [normal]diffusemap.vert hence there is no need for the former. Change-Id: If448005c593c765551ca239af6789df2f6e53af6 Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com> Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
* Migrate NormalDiffuseMap(Alpha)Material to be lights-awareLaszlo Agocs2015-12-048-154/+164
| | | | | | Change-Id: I91a6db87836c0e37af10d8de90e431240a7851e2 Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com> Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
* Migrate GoochMaterial to be light-awareLaszlo Agocs2015-12-022-29/+33
| | | | | | | On the ES2 path only the first light is taken into account for now. Change-Id: Ia8974bedddaa43539563149e718284076a519b5e Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
* Migrate PhongAlphaMaterial to be light-awareLaszlo Agocs2015-12-022-55/+12
| | | | | Change-Id: Ie082b7885e4465181c8c38e17bf0ce17543154b9 Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
* Migrate DiffuseSpecularMapMaterial to be light-awareLaszlo Agocs2015-12-022-63/+20
| | | | | Change-Id: I692e7ad9cdd63c2098e799c41937b2a4440f9c70 Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
* Migrate PerVertexMaterial to be light-awareLaszlo Agocs2015-12-024-32/+20
| | | | | | | | The original version has no specular component so leave that out in this version as well. To make this simple, introduce adModel(). Change-Id: I474485a19163ec55e6f6e025d94d8172297e847c Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
* Update specular normalization factor and fix parameter listsLaszlo Agocs2015-12-012-4/+8
| | | | | Change-Id: I2cde7e7aca754efb8a0ca4bb81716e6b42169e62 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Migrate DiffuseMapMaterial to be light-awareLaszlo Agocs2015-12-012-64/+18
| | | | | Change-Id: I79cac9384a258bfd3e106beba1aebb44c5f15491 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Rename back to adsModel()Laszlo Agocs2015-12-014-4/+4
| | | | | | | | The old name is more future proof since we may get an adModel() function too later on. Change-Id: I2dc14c26e14f5afc4217727589e18b1774727a2d Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Unify the default and phong shadersLaszlo Agocs2015-12-018-139/+16
| | | | | | | This also means that (Q)PhongMaterial is now lights capable. Change-Id: I8191fa6dfe96dadafdc9a2db47066650a8c96ee6 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Add light support to GL2/ES2 default shaderLaszlo Agocs2015-12-014-17/+56
| | | | | | | | | | | | However, take only the first light into account in order to keep pure ES2 devices working. We will need to figure something out later. NB this leads to a funny but totally correct effect in examples with multiple animated lights since the light that is taken into account is the one closest to the center of the lit entity. Change-Id: If2ad7c0bd5db177e48d763e1e1c86e65add45c8d Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Clean up the shader directoryLaszlo Agocs2015-12-0120-561/+0
| | | | | | | | Probably long overdue. Remove unused variants and rename diffuse to default. Change-Id: Ib94f1ba448f8bbfb7b10c7e4ca8bb90b1111a284 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Let There Be LightLaszlo Agocs2015-12-012-18/+27
| | | | | | | | | | | | | | | | Now with 100% more specular components. Enable proper lights in the default material. May break example since parameters like lightPosition, lightIntensity and diffuse do not exist anymore. The light calculation function is rearranged to have the diffuse and specular colors as output parameters. This way the diffusemap, diffusespecularmap, etc. materials can be migrated easily later on. Change-Id: Id0c69467aaaf6865d554aa2c4f302df7aab6563c Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Add shader fragment for basic lightingLaszlo Agocs2015-11-301-0/+33
| | | | | | | | | Simple diffuse lighting for point and direction lights for now. Not used from anywhere yet. Change-Id: I20f7ddad9ad5c78f120d47efe8599a2dbe015e65 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Purge spurious execute permissions.Edward Welbourne2015-09-292-0/+0
| | | | | | | | Graphics, XML and text descriptions of objects don't need it. Change-Id: Ie01908ef848e09fcc4e08bc1f508496dbd85de29 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* Add a simple unlit textured materialSean Harmer2015-07-304-0/+60
| | | | | | | | | | | | | This is useful for backgrounds or other simple texturing use cases where lighting is not desired. Also includes a texture coordinate offset property so the texture coordinates can easily be animated. C++ version to follow later. Change-Id: I8f6eba1ce28402bf59a18989884640018f473320 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Added PhongAlphaMaterial for qmlPaul Lemire2015-07-274-0/+125
| | | | | | | cpp version to follow Change-Id: I7d6f48f6c9b54810fb127dfe6371ede026f129bf Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Add gooch material and exampleSean Harmer2015-07-044-0/+152
| | | | | | | Edge inking will come later. So many techniques to choose from. Change-Id: Ibbea66c09c158bebba5d8efaf08d18417fa9b161 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Fix some small typosUnai IRIGOYEN2015-05-141-1/+1
| | | | | | | | | | | Fix a typo in QPhongMaterial class which caused setting ambient value to shininess parameter. Fix a typo in ES2 version of pervertexcolor fragment shader. Change-Id: I4623905a800ad310f19eb95d7391faaf70e9dd2b Task-number: QTBUG-44907 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
* Add SkyboxEntity as a QML defaultPaul Lemire2015-05-104-0/+44
| | | | | | | Cpp classes to follow Change-Id: If2479917aa516cf5da37111ae6a5886a8e24e9e7 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Add new material QPerVertexColorMaterialLorenz2015-03-116-0/+147
| | | | | | | | The new QPerVertexColorMaterial class provides color per vertex rendering. Change-Id: Idc87c21a07c2c8cd1ebfd5bed54c300c55e307ba Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Remove default uniform values for lightPosition and intensityLaszlo Agocs2015-02-0218-36/+36
| | | | | | | | | | | | The ES2 variants of the shaders have a default uniform value of 0. To be compatible with the other versions, start specifying the values for lightPosition and Intensity from C++, just like we already do from QML. This way the default values are coming from one single unified place regardless of the shader version in use, and examples like simple-cpp will work identically to simple-qml, even on ES2. Change-Id: If60185d0d3039e4354da8cc6e6b21a0db0bae963 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Supply ES2 versions of the default material shadersLaszlo Agocs2015-02-022-0/+39
| | | | | | | | | This also means that the building of the default material has to be delayed until the OpenGL context is known. Change-Id: I09c0db35a035cb1cfd16b564071445c2dcd4e53c Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Clean up GL2-ES2 shadersLaszlo Agocs2015-01-266-107/+101
| | | | | | | | | | | | | | | | | | | Unify light intensity in the phong material and shaders. The GL3 version had 1, 1, 1 whereas the other two used 1, 0, 1. The former is more sensible, so standardize on that. We also remove the default uniform values for GL2 and 3. The defaults are now coming from one central place in PhongMaterial.qml. All fragment shaders need to be revamped since these are common for OpenGL 2.0 and OpenGL ES 2.0. The only way to get something that compiles with both is to have the float/vecX precision qualifiers inline. This is in line with how ShaderEffect items work with Qt Quick. On non-ES Qt will dynamically add the necessary empty defines for highp etc. Remove also comments about uniform blocks (since it is not an option for ES2) and clean up the default values (which are coming from QML). Change-Id: If9862b4f2faf0b877da4032dcfcd123f259aa168 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Start fixing up the ES2 shadersLaszlo Agocs2015-01-2611-28/+18
| | | | | | | | | | | | | | | Version 120 is wrong. Everything must function with the default 100. Set the default precision in fragment shaders. Remove default uniform values. These will need some replacement on the C++ side. For the time being we just ignore it. This makes the shaders compiling at least. Change-Id: I0072c8a2027883f531413a48f680bb002c7f8222 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Andy Nichols <andy.nichols@theqtcompany.com>
* Default cpp materials + material-cpp examplePaul Lemire2014-12-3119-1/+816
| | | | | | | | | | | | | | | | | | | | | QDiffuseMapMaterial QDiffuseSpecularMapMaterial QNormalDiffuseMapMaterial QNormalDiffuseAlphaMapMaterial QNormalDiffuseSpecularMapMaterial material-cpp is mostly inspired from materials (QML) but nicer :). Note: there seems to be an issue with qrc and QUrl. The behavior is different between QML and C++. -In C++ we need to prefix with have qrc:/ and convert that to :/ (passing :/ directly returns "" when QUrl toString is called) -From QML no prefix is needed. -For QImage path, :/ should be used. Change-Id: Ib56fb9546c95c2872686a46ed048a290ab4a5b6f Task-number: QTBUG-41548 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Added QPhongMaterialPaul Lemire2014-12-224-0/+126
| | | | | | | | | QPhongMaterial is a default phong lightning implementation to be used in Qt3D scenes created from C++. Supports OpenGL 3.1, 2.0 and ES 2.0 Change-Id: I6f57ccf7ae2264cd0110de2081de841406a5efc4 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Add an example demonstrating more materialsSean Harmer2014-11-139-0/+419
| | | | | | Change-Id: I02c17262812fbfbd94287a0449027d985a2fe7ae Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Add rollerball example to show rendering and physics basicsSean Harmer2014-07-182-0/+64
| | | | | | | | At present it only exercises the renderer but it will be extended to also cover the physics aspect too. Change-Id: I83217f09eeb3471b8a508fa8a8948410ad1e1d58 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Automatic uniform bindingPaul Lemire2014-07-071-6/+6
| | | | | | | | | | | | | | | | | | If the shader contains a uniform with a standard uniform name, it will automatically be set. If a custom name is used within a shader for a standard uniform variable, the user can add a ParameterMapper with parameterName set to the Qt3D standardUniform name and shaderVariableName to the custom name. For user specified uniform parameters, if the parameter name is the same as the shader uniform name, the binding is done automatically. Otherwise, a ParameterMapper can be used. At the moment automatic binding for Attributes still has to be sorted out as default attribute names are dependent on a given MeshData. Change-Id: If244b26e5c2b01c8b319ba78c57fb1e131736dcb Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Relocate the render aspect outside of coreSean Harmer2014-03-294-0/+73
Change-Id: I636442d2d71342fd248b90674176cede895feab2 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>