summaryrefslogtreecommitdiffstats
path: root/src/render/shaders/gl3
Commit message (Collapse)AuthorAgeFilesLines
* Do lighting calculation in world spaceLaszlo Agocs2015-12-1015-75/+55
| | | | | | | | | | | | | | | | 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-091-12/+24
| | | | | Change-Id: I61a4e072c1a2e00cdbcee917aa557e56fb8cb7c0 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Use light type in the shadersLaszlo Agocs2015-12-071-6/+12
| | | | | 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-041-15/+18
| | | | | | | | | | | | 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-043-108/+9
| | | | | | | | | | 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-044-80/+83
| | | | | | 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-021-22/+27
| | | | | | | 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-021-28/+6
| | | | | Change-Id: Ie082b7885e4465181c8c38e17bf0ce17543154b9 Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
* Migrate DiffuseSpecularMapMaterial to be light-awareLaszlo Agocs2015-12-021-32/+10
| | | | | Change-Id: I692e7ad9cdd63c2098e799c41937b2a4440f9c70 Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
* Migrate PerVertexMaterial to be light-awareLaszlo Agocs2015-12-022-17/+10
| | | | | | | | 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-011-2/+4
| | | | | Change-Id: I2cde7e7aca754efb8a0ca4bb81716e6b42169e62 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Migrate DiffuseMapMaterial to be light-awareLaszlo Agocs2015-12-011-33/+9
| | | | | Change-Id: I79cac9384a258bfd3e106beba1aebb44c5f15491 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Rename back to adsModel()Laszlo Agocs2015-12-012-2/+2
| | | | | | | | 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-014-72/+8
| | | | | | | 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-012-4/+2
| | | | | | | | | | | | 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-013-0/+88
| | | | | | | | Probably long overdue. Remove unused variants and rename diffuse to default. Change-Id: Ib94f1ba448f8bbfb7b10c7e4ca8bb90b1111a284 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Add a simple unlit textured materialSean Harmer2015-07-302-0/+32
| | | | | | | | | | | | | 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-272-0/+65
| | | | | | | cpp version to follow Change-Id: I7d6f48f6c9b54810fb127dfe6371ede026f129bf Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Add gooch material and exampleSean Harmer2015-07-042-0/+78
| | | | | | | Edge inking will come later. So many techniques to choose from. Change-Id: Ibbea66c09c158bebba5d8efaf08d18417fa9b161 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
* Add SkyboxEntity as a QML defaultPaul Lemire2015-05-102-0/+24
| | | | | | | Cpp classes to follow Change-Id: If2479917aa516cf5da37111ae6a5886a8e24e9e7 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
* Add new material QPerVertexColorMaterialLorenz2015-03-112-0/+51
| | | | | | | | 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-028-16/+16
| | | | | | | | | | | | 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>
* Default cpp materials + material-cpp examplePaul Lemire2014-12-3110-1/+420
| | | | | | | | | | | | | | | | | | | | | 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-222-0/+64
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>