Login Action Required

The NinevehGL Forum uses a new concept of "socialized forum" or as we like to say "Tweet Forum".


Here is the deal:
  1. No new registration is required. Just sign in with your Twitter account and authorize the NinevehGL Forum.
  2. Once you’re in, you'll be able to "Follow a Thread", that means every time that thread receive a new post or update you'll receive a mention on your twitter.
  3. Besides, you can enable "Auto Share", then every new post and/or thread you make will be tweeted on your timeline. (By default, auto-share is enabled only for your threads)

Forum Rules:

1. We understand human comunication can become "hot" sometimes. So some insults and bad words ARE allowed. Just don't push too much being an asshole all the time.

2. SPAMMERS are not allowed. There are penalties for this kind of user and they can be banned forever.

3. You can report other users, if you judge necessary. An user reported many times by many people can also be banned forever. However you can also receive penalties for report deliberately for no apparent reason.

If there is a similar thread title, make sure the other one doesn't already have the answer you're looking for.

This forum uses the BBCode (Bulletin Board Code), here are some instructions:

Bold: [b]text[/b]
Italic: [i]text[/i]
Underline: [u]text[/u]

Code: [code]text[/code]
Quote:
[quote=@username]text[/quote]
[quote]text[/quote]

List:
[ul] [*]item [/ul]
[ol] [*]item [/ol]

URL:
[url]http://url.com[/url]
[url=http://url.com]text[/url]

Image:
[img]http://imageurl.com[/img]

Embed (videos, code, 3D):
[embed]http://url.com[/embed]

Welcome to the NinevehGL's world!
NinevehGL is a 3D engine forged with pure Obj-C.
Welcome to the
Forum!
Hello, Guest.

Your current vote:

You can change your vote many times. But it's still one single vote.

about reflection Map
Vote this thread:


@luiso_ps

Posts: 6

NGLNewbie

Wed, Apr 3 2013


First of all let me congratulate you for your amazing job so far. You have here an excelent product, intuitive yet complete and efficient.

Now to my question, I saw in a previous post in this forum that the reflectiveMap, refraction, etc, were on hold until further notice. It is still this way?? You have any idea when it may come out??

In case it takes long, I would like to do it myself. How do you suggest me to attack this problem (using a custom shader?). Can you point me to any documentation on this matter?

Man, sorry for the amount of questions but I would like to do this, and I have no clue how to implement a shader (no knowledge of GLSL). So any help is welcome.

Thanks in advance,

Luiso
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Wed, Apr 3 2013


In response to: @luiso_ps

Hello buddy,

First of, thanks for your compliments. We're very glad to hear that.
Yes, it still under development.

Another yes! You definitely can do it with custom shaders.
It involves a GLSL knowledge and some knowledge about how NinevehGL create shaders.

Your custom shaders doesn't need to be in pairs and you don't need to specify everything, you can use what NinevehGL already have for you. For example, using just a custom FSH you can do something like:

NSString*reflectionShader=@"
uniform sampler2D myRflLevel;
uniform lowp float myRflMap;

void main(void)
{
lowp vec3 eyeVector=(u_nglMVIMatrix* vec4(0.0,0.0,0.0,1.0)- v_nglPosition).xyz;
highp vec3 reflectionMap= mat3(u_nglMVIMatrix)* reflect(normalize(eyeVector), _nglNormal);
_nglAmbient= mix(_nglAmbient, texture2D(myRflLevel, reflectionMap.xy* 0.5 0.5), myRflMap);
}";

NGLShader*rflShader=[NGLShader shadersWithSourcesVertex:nil andFragment:reflectionShader];
[rflShader bindUniform:@"myRflLevel" count:1 dataType:NGL_FLOAT data:&rotX];
[rflShader bindTexture:@"myRflMap" texture:myNGLTexture];
mesh.shader= rflShader;


This is just a start. The above shader technique uses the ambient color to make a reflection, which is not the best approach, but it works. The"vec4(0.0,0.0,0.0,1.0)" is relative to a deformation you could do above the flat reflection.

Hope this helps to start.
0% like this - 0/0

@luiso_ps

Posts: 6

NGLNewbie

Wed, Apr 3 2013


In response to: @dineybomfim

Thank you very much for your quick response, it was indeed very useful. I managed to correct some small typos in order to make the shader work, and it came out like this:


NSString *vShader = @""
"uniform sampler2D myRflLevel;"
"uniform lowp float myRflMap;"
""
"void main(void)"
"{"
" lowp vec3 eyeVector=(u_nglMVPMatrix* vec4(0.0,0.0,0.0,1.0) - a_nglPosition).xyz;"
" highp vec3 reflectionMap= mat3(u_nglMVPMatrix)* reflect(normalize(eyeVector), _nglNormal);"
" _nglAmbient= mix(_nglAmbient, texture2D(myRflLevel, reflectionMap.xy* 0.5, 0.5), myRflMap);"
"}";
NGLShaders *rflShader=[NGLShaders shadersWithSourcesVertex:vShader andFragment:nil];
_rotX = 0.3;
[rflShader bindUniform:@"myRflLevel" count:1 dataType:NGL_FLOAT data:&_rotX];
texture = [[NGLTexture texture2DWithFile:@"Panorama Living.jpg"] retain];
[rflShader bindTexture:@"myRflMap" texture:texture];
_mesh.shaders = rflShader;


The previous fragment of code is inside the method meshLoadingDidFinish and a compileCoreMesh is called right afterwards.

However, the following error keeps appearing and the mesh don't get rendered.


***** NGLError *****
Error while processing NGLES2Program.
Shader compile error.
ERROR: 0:33: Use of undeclared identifier '_nglNormal'
ERROR: 0:33: Use of undeclared identifier '_nglAmbient'
ERROR: 0:33: Use of undeclared identifier '_nglAmbient'
ERROR: 0:33: Use of undeclared identifier 'reflectionMap'

********************
2013-04-03 22:16:02.347 basics[24195:1430b]
***** NGLError *****
Error while processing NGLES2Program.
Program link error.
ERROR: OpenGL ES 2.0 requires exactly one vertex and one fragment shader to validly link.

********************


It is like the _nglNormal is not defined for some reason and it causes the other errors in cascade.

Do you have any idea why this may happen??

If you need any more details please tell me.

Thank again for your help,

Saludos

Luiso
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Wed, Apr 3 2013


In response to: @luiso_ps

Oh yeah,

We've already added this kind of intelligence to our shaders. It'll come in the next version. However with the current version the _nglNormal and _nglAmbient will just be present if your mesh already have that.

You can just set a simple ambientColor in one material and use any feature that include normals (like lights on) and NinevehGL will compile those variables for you.
0% like this - 0/0

@luiso_ps

Posts: 6

NGLNewbie

Thu, Apr 4 2013


In response to: @dineybomfim

Ok, indeed the ambient texture of the mesh was not set, but the lights were on (shouldn't this at least include the normals?).

Anyway, I will set an ambient Map to the mesh and see what happens. I tell you the out come, and maybe when it is done, I will publish an almost complete fragment of the code (is not that much ), so the people looking at the forums have a more complete answer as well.

Saludos

Luis
0% like this - 0/0

@luiso_ps

Posts: 6

NGLNewbie

Thu, Apr 4 2013


In response to: @dineybomfim

Ok I tried to assign an ambient Map, an ambient Color, turned on the lights and _nglNormal keept throwing error. Then I changed _nglNormal to v_nglNormal and the error stopped (don't know the meaning of what I did).

But then _nglAmbient keept giving error and with that one I don't have any idea what to do.

Saludos

Luis
0% like this - 0/0

@dineybomfim

Posts: 571

NGLAdmin

Fri, Apr 5 2013


In response to: @luiso_ps

Very strange,
We'll investigate it.
0% like this - 0/0
Technology

NinevehGL is a 3D engine built right on top of OpenGL ES and it uses all the programmable pipeline power, making it easy for you to create great application with shaders.

Share on


Follow NinevehGL
Fastest way to contact us:

Copyright © 2011 db-in. All rights reserved.