marinos.giannoukakis Posted June 17, 2015 Share Posted June 17, 2015 Ok these are removed features from openGL, does Unigine has these predefined....? if is different for Unigine2 and Unigine1, please for both versions..... Link to comment
marinos.giannoukakis Posted June 17, 2015 Author Share Posted June 17, 2015 is this how we would calculate the removed gl_Normal....? float3 normal = getTangentBasis(float3(dot(row_0.xyz,s_attribute_2.xyz),dot(row_1.xyz,s_attribute_2.xyz),dot(row_2.xyz,s_attribute_2.xyz))); and, float4 gl_normal = (normal, 1.0f); ???? Link to comment
unclebob Posted June 18, 2015 Share Posted June 18, 2015 Hi there, Marinos! In 1.0 we store normal/binormal/tangent as vertex attributes. In 2.0 we store whole tbn basis in quat form also as vertex attribute. Link to comment
marinos.giannoukakis Posted June 18, 2015 Author Share Posted June 18, 2015 Hi Unclebob :).... so would you mind providing a little example of this....? for both Unigine versions if possible... and possibly point me to the files in source...? Thanks..... Link to comment
silent Posted June 19, 2015 Share Posted June 19, 2015 Hi Marinos, Could you please be more specific and provide us more details about what you are trying to achieve? If you want to port some old shader, please post the full shader code here. Thanks! How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
marinos.giannoukakis Posted June 19, 2015 Author Share Posted June 19, 2015 Awesome thanks Silent I sure can....:) there you go, //Vertex: //============================================== varying vec3 N; varying vec3 I; varying vec4 Cs; void main() { vec4 P = gl_ModelViewMatrix * gl_Vertex; I = P.xyz - vec3 (0); N = gl_NormalMatrix * gl_Normal; Cs = gl_Color; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } //**************************************************************************// and fragment, //=====================================================// varying vec3 N; varying vec3 I; varying vec4 Cs; // globals uniform float edgefalloff; uniform float intensity; uniform float ambient; // entry point void main() { float opac = dot(normalize(-N), normalize(-I)); opac = abs(opac); opac = ambient + intensity*(1.0-pow(opac, edgefalloff)); //opac = 1.0 - opac; gl_FragColor = opac * Cs; gl_FragColor.a = opac; } //***************************************************************************// all the best.... Link to comment
marinos.giannoukakis Posted June 23, 2015 Author Share Posted June 23, 2015 Hi silent.... any suggestions on the above....? Link to comment
unclebob Posted June 25, 2015 Share Posted June 25, 2015 Hi Marinos! varying is a deprecated glsl construct, you should use in and out keywords instead. Here's useful explanation about them: http://gamedev.stackexchange.com/questions/29672/in-out-keywords-in-glsl Also, our shader system is designed in a way that you already get many input parameters with fancy names like s_attribute_0, s_attribute_1 which automatically filled by the engine depending on what exactly it's going to render. You can get started with our shaders from <SDK root>/data/core/shaders/default/common/common_base.h, fragment_base.h and vertex_base.h files. For example, instead of gl_Projection, you can use our s_projection uniform. Link to comment
marinos.giannoukakis Posted June 25, 2015 Author Share Posted June 25, 2015 yup already aware of the deprecated glsl and have already replaced all that (varyings with in/outs), also i am also aware of SOME of Unigine replacements and try to use that too.... it was this i had a problem with (N = gl_NormalMatrix * gl_Normal;) and also i am not aware what the s_imodelview (or something) found in the unigine shaders stands for. And also if there is a unigine define for gl_ModelViewMatrix (is it the s_imodelview)....? i just posted the shader as i had it initially since it was asked from Silent and was hoping for a specific answer on the shader so i don t ask fragmented questions..... Link to comment
unclebob Posted June 26, 2015 Share Posted June 26, 2015 gl_NormalMatrix is just transposed inverse modelview matrix, so you can multiply by s_imodelview on the left side (which is equal to multiplying by transposed s_imodelview on the right side) in order to get correct results. Something like that: // these lines could be found in core/shaders/default/mesh/vertex_base.shader float3 tangent,binormal,normal; getTangentBasis(s_attribute_2,tangent,binormal,normal); // these lines could be found in core/shaders/default/common/vertex_base_ambient.h s_texcoord_1.xyz = mul3(s_imodelview,tangent); s_texcoord_2.xyz = mul3(s_imodelview,binormal); s_texcoord_3.xyz = mul3(s_imodelview,normal); Here's cool article, explaining the math behind that, read at the bottom (I mean why normal matrix is transposed inverse modelview matrix): https://www.cs.uaf.edu/2007/spring/cs481/lecture/01_23_matrices.html Link to comment
marinos.giannoukakis Posted June 26, 2015 Author Share Posted June 26, 2015 Awsome thanks Unclebob, just wasn t sure whether s_imodelview is the inverse modelview already because of the "i" in front of the modelview.....:D Link to comment
Recommended Posts