shadmar Posted February 19, 2014 Share Posted February 19, 2014 Would be great. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
klepto2 Posted February 19, 2014 Share Posted February 19, 2014 +1 It will make life a lot easier. Specially in situation where a lot of different shaders needs same functions and constants. Currently it is damn hard to maintain constant changes between shaders. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
gamecreator Posted February 19, 2014 Share Posted February 19, 2014 Josh, give these people what they want. 1 Quote Link to comment Share on other sites More sharing options...
Admin Posted February 19, 2014 Share Posted February 19, 2014 The reason we don't is because the shader editor would no longer be able to show the line an error occurs on, and it would make dynamic shader reloading impossible. Quote Link to comment Share on other sites More sharing options...
klepto2 Posted February 19, 2014 Share Posted February 19, 2014 Well, i understand why you may focus on other things currently, but both of your points are not truely valid. 1. not getting the correct error-line: Might be a bit harder to implement, but keeping the original and processed code (maybe even with some metadata) a simple diff should already work. You should be able to register if an errorline is in the included part or not and be able to jump into the correct file. 2. impossible to reload? Definetly not impossible, but might be a bit tricky. Short solution: ignore includes for the reload, just track saves for the main shader. I could live with that. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted February 20, 2014 Share Posted February 20, 2014 After the flags parameter, there is a hidden feature I use for lighting shaders: Shader* Shader::Load(const std::string& path, const int flags, const std::string& precode) I use it to pass preprocessor defines to the shaders so I don't have to keep a lot of extra versions of them. 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...
klepto2 Posted February 20, 2014 Share Posted February 20, 2014 Just as reminder: You can do something like this in glsl: code with #pragma include: #version 400 uniform sampler2D texture1; uniform sampler2D texture2; uniform bool isbackbuffer; uniform vec2 buffersize; uniform float currenttime; uniform float intensity = 2.0; out vec4 fragData0; #pragma include "functions.glsl" void main(void) { vec2 icoord = vec2(gl_FragCoord.xy/buffersize); if (isbackbuffer) icoord.y = 1.0 - icoord.y; vec4 scene = texture2D(texture1, icoord); // rendered scene vec4 blur = texture2D(texture2, icoord); // glowmap fragData0 = clamp(scene + (blur*intensity), 0.0, 1.0); } and the merged code: #version 400 uniform sampler2D texture1; uniform sampler2D texture2; uniform bool isbackbuffer; uniform vec2 buffersize; uniform float currenttime; uniform float intensity = 2.0; out vec4 fragData0; #line 1 'functions.glsl' //code of functions.glsl #line 12 0 void main(void) { vec2 icoord = vec2(gl_FragCoord.xy/buffersize); if (isbackbuffer) icoord.y = 1.0 - icoord.y; vec4 scene = texture2D(texture1, icoord); // rendered scene vec4 blur = texture2D(texture2, icoord); // glowmap fragData0 = clamp(scene + (blur*intensity), 0.0, 1.0); } An idea for the auto reloading: maybe you can only scan open shader files if they use the #include statement and reload only these. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted February 20, 2014 Share Posted February 20, 2014 Does that pragma line actually work? 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...
klepto2 Posted February 20, 2014 Share Posted February 20, 2014 no, you need to parse it and replace it with the '#line ...' part. Unfortunalty the Khronos group ignores the include requests for ages. HLSL can do this out of the box. Sorry if this wasn't clear. I only choosed #pragma because glsl will ignore everything after #pragma if it is not known to the glsl compiler. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI 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.