Josh Posted January 13, 2014 Share Posted January 13, 2014 Here are the values Leadwerks will automatically send to shaders when they are bound: if (uniform_currenttime) uniform_currenttime->SetFloat(Time::GetCurrent()); if (uniform_buffersize) uniform_buffersize->SetVec2(Vec2(buffer->GetWidth(),buffer->GetHeight())); if (uniform_drawmatrix) uniform_drawmatrix->SetMat4(graphicsdriver->drawmatrix); if (uniform_drawcolor) uniform_drawcolor->SetVec4(Leadwerks::GraphicsDriver::GetCurrent()->drawcolor); if (uniform_projectionmatrix) uniform_projectionmatrix->SetMat4(graphicsdriver->projectionmatrix); if (uniform_isbackbuffer) uniform_isbackbuffer->SetInt(buffer->isbackbuffer); if (world != NULL) { if (uniform_ambientlight) uniform_ambientlight->SetVec4(world->ambientlight); if (uniform_tessstrength) uniform_tessstrength->SetFloat(world->tessellationstrength); } if (ActiveCamera!=NULL) { if (uniform_projectioncameramatrix) uniform_projectioncameramatrix->SetMat4(ActiveCamera->projectioncameramatrix); if (uniform_cameraposition) uniform_cameraposition->SetVec3(ActiveCamera->GetPosition(true)); if (uniform_cameradrawmode) uniform_cameradrawmode->SetInt(ActiveCamera->drawmode); if (uniform_cameraprojectionmode) uniform_cameraprojectionmode->SetInt(ActiveCamera->projectionmode); if (uniform_lighting_ambient) uniform_lighting_ambient->SetVec4(ActiveCamera->world->ambientlight); if (uniform_camerarange) uniform_camerarange->SetVec2(ActiveCamera->range); if (uniform_camerazoom) uniform_camerazoom->SetFloat(ActiveCamera->zoom); if (uniform_cameramatrix) uniform_cameramatrix->SetMat4(ActiveCamera->mat); if (uniform_prevprojectioncameramatrix) uniform_prevprojectioncameramatrix->SetMat4(ActiveCamera->prevprojectioncameramatrix); if (uniform_camerainversematrix) uniform_camerainversematrix->SetMat4(ActiveCamera->mat.Inverse()); if (uniform_cameranormalmatrix) uniform_cameranormalmatrix->SetMat3(Mat3(ActiveCamera->mat)); if (uniform_camerainversenormalmatrix) uniform_camerainversenormalmatrix->SetMat3(Mat3(ActiveCamera->mat.Inverse())); } else { if (uniform_projectioncameramatrix) uniform_projectioncameramatrix->SetMat4(graphicsdriver->projectioncameramatrix); } Additionally, texture0-15 are automatically initialized to 0,1,2, etc. 7 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
shadmar Posted January 13, 2014 Share Posted January 13, 2014 Thx. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Rastar Posted January 13, 2014 Share Posted January 13, 2014 Great, thanks! And while you're at it : Could you specify the channel layout of the fragment shader output (frag0, frag1, ...)? I mean, frag0 is the diffuse and frag1 is the normal, but if I read your shaders correctly you are e.g. assigning the alpha from the diffuse to the alpha of the normal vector? Quote Link to comment Share on other sites More sharing options...
Admin Posted January 13, 2014 Share Posted January 13, 2014 Sure: Channel 0 r = diffuse.r g = diffuse.g b = diffuse.b a = diffuse.a Channel 1 r = normal.x g = normal.y b = normal.z a = specularity Channel 2 r = emissive.r g = emissive.g b = emissive.b a = material flags 1: Lighting enabled 2: Decals enabled (reserved) 1 Quote Link to comment Share on other sites More sharing options...
SarperSoher Posted January 13, 2014 Share Posted January 13, 2014 How about the input attributes? vertex_position, vertex_color etc? Quote Link to comment Share on other sites More sharing options...
Admin Posted January 13, 2014 Share Posted January 13, 2014 If you look at the animated model shader, that has everything. And there are also two uniform buffers in use, one for bone matrices for vertex skinning, and the other for instance matrices. The right-hand column of the instance matrices stores the entity color, to make it more compact. Quote Link to comment Share on other sites More sharing options...
SarperSoher Posted January 13, 2014 Share Posted January 13, 2014 Also I'm seeing some other uniforms in "diffuse normal specular" shader. Like "materialcolorspecular, lighting_ambient, buffersize etc. Quote Link to comment Share on other sites More sharing options...
Admin Posted January 13, 2014 Share Posted January 13, 2014 materialcolorspecular and materialcolordiffuse are self-explanatory. The others you listed are all in the code above. Quote Link to comment Share on other sites More sharing options...
SarperSoher Posted January 14, 2014 Share Posted January 14, 2014 materialcolorspecular and materialcolordiffuse are self-explanatory. The others you listed are all in the code above. Why can't you just add a list of ALL of them with their descriptions to a shader reference self-explanatory or not? You want some great looking shots filling the gallery to promote the engine right? Help the shader developers! I mean most of the API is self-explanatory but they are there in the documents with unnecessary amounts of code examples for both C++ and Lua and a butt load of description. This is lazy, do the Right-Thing-To-Do as Carmack's fond of saying Quote Link to comment Share on other sites More sharing options...
Admin Posted January 14, 2014 Share Posted January 14, 2014 True. In reality, if I simply added a mechanism for plug and play post-processing effects it would fill up overnight. Quote Link to comment Share on other sites More sharing options...
beo6 Posted January 15, 2014 Share Posted January 15, 2014 yay. got the first thing displaying shader wise. Not quite there yet but at least i see something. was just using the wrong variable names Still at the beginning to learn though 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted October 18, 2014 Author Share Posted October 18, 2014 Built-in uniform values (SEO) Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
codeape Posted October 20, 2014 Share Posted October 20, 2014 Maybe this topic should be a sticky one. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.