cinetec_tech Posted April 14, 2015 Share Posted April 14, 2015 I am trying to use the uniform variable Time and viewport Resolution in fragment shader, something like the _Time & _ScreenParams in UNITY shader, iResolution & iGlobalTime in Shadertoy.com, What are the built-in variable for UNIGINE if they exit. If they don't exit, how to implement such variable? Anyone knows? I appreciated for reading this post. THX Link to comment
cinetec_tech Posted April 14, 2015 Author Share Posted April 14, 2015 I actually figured out the Resolution is "s_viewport", still don't know what is Time. Link to comment
ulf.schroeter Posted April 15, 2015 Share Posted April 15, 2015 Actually I think Time is NOT available as some Unigine default shader variable. Therefore just must extend some Unigine material and provide time as an additional parameter to your shader code. Link to comment
unclebob Posted April 16, 2015 Share Posted April 16, 2015 Hi Cinetec! We don't have built-in uniform for time so you have to declare and modify it by yourself or you can define an expression parameter and use built-in "time" variable in that expression so it'll be filled automatically: <parameter name="custom_time_uniform" type="expression">time</parameter> 1 Link to comment
cinetec_tech Posted April 16, 2015 Author Share Posted April 16, 2015 Thank you so much Unclebob, you are awesome! The problem has been solved by using your method, but to make it work, I must pass the built-in "time" variable inside a vec4. Something like: <parameter name="custom_time_uniform" type="expression">vec4(time,0,0,0)</parameter> Link to comment
unclebob Posted April 22, 2015 Share Posted April 22, 2015 No, you're awesome! Keep doing great shaders! Link to comment
marinos.giannoukakis Posted April 26, 2015 Share Posted April 26, 2015 yup exactly unclebob's suggestion is the solution, you basically get the time parameter of the system functions and straight pass it on a float, works for me... the vec4 or vec3 solution i use for the mouse input (used in some of these shaders), since there is not vec2 in unigine script... i would use also app width and height for resolution (????).... i have actually imported most of the fragment shaders and raymarchers from the glsl sandbox and shadertoy into Unigine.... since we are on the topic though i have noticed a significant drop on FPS between the same shaders from shadertoy and 'glsl hacker', when i import them into Unigine... the same shader could run in 60-70 fps and then drop down to 20-25 when importing them into Unigine... whould an explanation on that be possible...? (i do have in mind that all of these shaders are case studies and fun experiments and usually not at all optimised for performance, but still.....)..... Link to comment
unclebob Posted April 27, 2015 Share Posted April 27, 2015 Hey Marinos, As Cinetec mentioned earlier, you can use s_viewport in order to get resolution information. I need more information about how exactly you ported your shader from shadertoy into Unigine, because there are many reasons why your shader is not working as fast as it's working on shadertoy. For example, it could be rendered couple of times per frame if you set this shader for multiple passes in one material or there might be other post-process materials or the app resolution is different than on shadertoy. 1 Link to comment
marinos.giannoukakis Posted April 27, 2015 Share Posted April 27, 2015 ok i will post more info really soon then... thanks unclebob..... :) "the app resolution is different than on shadertoy", obviously this one is one i do have in mind.... i ll post info since there might be one of the other reasons you are mentioning.... Link to comment
Recommended Posts