Author Topic: Wavefront object viewer  (Read 79032 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #15 on: January 31, 2015, 10:59:25 PM »
Hi Frank,

From your screen shot, I notice that the cursor seems to cover the first character of the filename. What hardware are you using?

Are you able to load any of the other models?

I am using Patrice's Obj viewer opengl pixel format, with multisamples set to 4

from winutil.inc
Code: OxygenBasic
  1.   {
  2.     0x2001,01,     'WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
  3.    0x2010,01,     'WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
  4.    0x2011,01,     'WGL_DOUBLE_BUFFER_ARB, GL_TRUE,
  5.   '0x2013,0x202B, 'WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
  6.    0x2014,24,     'WGL_COLOR_BITS_ARB, 24,
  7.    0x201B,08,     'WGL_ALPHA_BITS_ARB, 08,
  8.    0x2022,24,     'WGL_DEPTH_BITS_ARB, 24,
  9.    0x2023,08,     'WGL_STENCIL_BITS_ARB, 08,
  10.    0x2041,01,     'WGL_SAMPLE_BUFFERS_ARB, 01, //Number of buffers (must be 1 at time of writing)
  11.    0x2042,ns,     'WGL_SAMPLES_ARB, 04,        //Number of samples
  12.    0x0000,00      'terminate list
  13.  }
  14.  



.
« Last Edit: January 31, 2015, 11:37:53 PM by Charles Pegge »

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #16 on: February 01, 2015, 02:25:19 PM »
Hi Mike,

My viewer currently has no respect for filepaths in retrieving mtl and texture files. I think this accounts for your results with Arc170 and R2D2. But good news that the graphics work on all those different systems. Thank you!




With regard to OxyScheme, I have been trying to resolve some semantic inconsistencies in O2 obtaining addresses. The @ operator should always be used when the address of a function/variable/label is required, but not otherwise.

Thus:

Line 96
  FILE* _iob = __p__iob()
equiv at syntax
  FILE _iob at __p__iob()

Line 178 & 179
  quad    num_ivalue(sys p) at @num_ivalue_asm
  double  num_rvalue(sys p) at @num_rvalue_asm

Line 471
  ! function atoll        (char* a) as quad at @atoll_asm


« Last Edit: February 01, 2015, 04:31:53 PM by Charles Pegge »

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #17 on: February 01, 2015, 04:17:12 PM »
Hi Patrice,

I have very skeletal examples using Vertex buffer objects and shaders. To compile in 64 bit code, I had to ensure that all my integer array buffers were 32 bit (especially for glGenBuffers(..) ).

After that, I was able to compile, link and run your vertex shader in a 64 bit binary.  - I used text files for the vertex and fragment shaders, rather than inline strings.

So OpenGL must be the innocent party and the problem lies somewhere with C++

vertex shader in plain text
Code: [Select]
#version 110
varying vec3 normal;
void main()
{
  normal = normalize(gl_NormalMatrix * gl_Normal);
  gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  gl_TexCoord[0] = gl_MultiTexCoord0;
}
« Last Edit: February 01, 2015, 04:29:55 PM by Charles Pegge »

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #18 on: February 14, 2015, 05:15:06 AM »
Very smooth!

I have not yet managed to render ironman. Even if materials and lighting are suppressed, my Object viewer will not show the main surface.

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #19 on: February 14, 2015, 09:51:45 AM »

Quote
Would you like to look at my (VISUAL STUDIO) C++ 64-bit version source code, may be that could help you ?

Yes please, Patrice :)

I will also try out some smaller models. It is hard to do diagnostics on such huge data.

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #20 on: February 15, 2015, 02:49:35 PM »
Thanks Patrice, I will study tomorrow - (Monday).

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #21 on: February 24, 2015, 04:19:19 AM »
Hi Patrice,

Chrome is quite tricky to render. Since none of my neighbours own a Cadillac, I went off to study my bathroom taps :). Perhaps the best way is have high specular light and s streaky texture to serve as a pseudo-reflective surface.

To get a simple profile of Opengl's specular effects, I made a chart of spheres . The top row uses 100% specular material, with shininess values going 1 2 4 8 16 ..256.

The following rows reduce specular material in favour of diffuse material.

ProjectsA/OpenglCns/Shininess1.o2bas
Code: OxygenBasic
  1.   % Title "Sphere Mapping Demo"
  2.   % Animated
  3.   % ScaleUp
  4.  '% PlaceCentral
  5. '% AnchorCentral
  6.  include "$\inc\ConsoleG.inc"
  7.  
  8.  
  9.   sub main()
  10.   ==========
  11.   static sys   imgn,res,wi,ht
  12.   static sys   defmat,m
  13.   static float angx,angy
  14.   static float ma[13] 'for material
  15.  static float amb,namb
  16.   float f1,f2,f3
  17.   if not defmat
  18.     defmat=1
  19.     amb=.0
  20.     namb=1.0-amb
  21.     ma[1]={amb,amb,amb,1.} 'ambient
  22.  end if
  23.   cls 0,.0,0
  24.   pushstate
  25.   move -2,3,-4.0
  26.   shading
  27.   for j=1 to 8
  28.     pushstate
  29.     move 0,-4*j
  30.     m=1
  31.     for i=1 to 8
  32.       pushstate
  33.       move 4.1*i
  34.       scale 2
  35.       rotateY angY
  36.       f1=namb*j/8
  37.       f2=namb-f1
  38.       f3=m
  39.       m+=m 'log scale 1 2 4 8 16 .. 256
  40.      ma[5]={f1,f1,f1,1} 'diffuse
  41.      ma[9]={f2,f2,f2,1} 'specular
  42.      ma[13]=f3 'shininess
  43.      material ma
  44.       go sphere
  45.       popstate
  46.     next
  47.     popstate
  48.   next
  49.   popstate
  50.   angx+=.100 : if angx>=360 then angx-=360
  51.   angy+=.125 : if angy>=360 then angy-=360
  52.   end sub 'main
  53.  
  54.   EndScript
  55.  



.
« Last Edit: February 24, 2015, 04:28:15 AM by Charles Pegge »

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #22 on: February 24, 2015, 02:11:58 PM »
Patrice,

I can smell the chrome polish and the car wax :)

Must discover the secrets of mapping reflections over a curved surface..
« Last Edit: February 24, 2015, 03:05:46 PM by Charles Pegge »

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #23 on: February 26, 2015, 04:07:16 AM »

With regard to creating environments for these models with reflective surfaces:

Cube Map OpenGL Tutorial



http://www.nvidia.com/object/cube_map_ogl_tutorial.html

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #24 on: March 01, 2015, 02:57:42 PM »
Hi Mike,

Do you have any material on cubic reflection mapping? Then the face of the Cadillac owner may be reflected in the windscreen and chrome fittings :)

I am currently hacking my way into OpenGl shaders.

« Last Edit: March 01, 2015, 03:23:22 PM by Charles Pegge »

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #25 on: March 02, 2015, 02:21:27 AM »

Many thanks for the references, Mike.

It take an awesome amount of code to put up a few pixels :)

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #26 on: March 05, 2015, 05:02:52 AM »
Getting to grips with shaders:

This one looks very useful, for me at least, since it combines texture, and ambient,diffuse and specular lighting.

Code: OxygenBasic
  1.   '
  2.  'MULTIPLE LIGHT SHADER
  3.  '=====================
  4.  '
  5.  vs[4]=
  6.   "
  7.   varying vec3 vN;
  8.   varying vec3 v;
  9.   varying vec2 texCoord;
  10.   void main(void)  
  11.   {    
  12.     texCoord = gl_MultiTexCoord0;
  13.     v  = vec3(gl_ModelViewMatrix * gl_Vertex);      
  14.     vN = normalize(gl_NormalMatrix * gl_Normal);
  15.     gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;  
  16.   }
  17.   "
  18.   fs[4]=
  19.   "
  20.   uniform sampler2D textureUnit;
  21.   varying vec3 vN;
  22.   varying vec3 v;
  23.   varying vec2 texCoord;
  24.   #define MAX_LIGHTS 3
  25.   void main (void)
  26.   {
  27.     vec3 N = normalize(vN);
  28.     vec4 finalColor = vec4(0.1, 0.4, 0.0, 0.0);
  29.    
  30.     for (int i=0;i<MAX_LIGHTS;i++)
  31.     {
  32.       vec3 L = normalize(gl_LightSource[i].position.xyz - v);
  33.       vec3 E = normalize(-v); // we are in Eye Coordinates, so EyePos is (0,0,0)
  34.       vec3 R = normalize(-reflect(L,N));
  35.    
  36.       //calculate Ambient Term:
  37.       vec4 Iamb = gl_FrontLightProduct[i].ambient;
  38.       //calculate Diffuse Term:
  39.       vec4 Idiff = gl_FrontLightProduct[i].diffuse * max(dot(N,L), 0.0);
  40.       Idiff = clamp(Idiff, 0.0, 1.0);
  41.    
  42.       // calculate Specular Term:
  43.       vec4 Ispec = gl_FrontLightProduct[i].specular
  44.              * pow(max(dot(R,E),0.0),0.3*gl_FrontMaterial.shininess);
  45.       Ispec = clamp(Ispec, 0.0, 1.0);
  46.    
  47.       finalColor +=
  48.         Iamb
  49.       + Idiff
  50.       + Ispec;
  51.     }
  52.     // write Total Color:
  53.     gl_FragColor = gl_FrontLightModelProduct.sceneColor + finalColor
  54.     * texture2D(textureUnit, texCoord).rgba;
  55.   }
  56.   "
  57.   '
  58.  


  SkyBox shaders can be used for a 360 degree background in all directions.

 
Code: OxygenBasic
  1.   '
  2.  'SKYBOX SHADER
  3.  '=============
  4.  '
  5.  vs[8]=
  6.   "
  7.   #version 120
  8.   void main()
  9.   {
  10.     gl_TexCoord[0].stp = gl_Vertex.xyz;
  11.     gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
  12.   }
  13.   "
  14.   fs[8]=
  15.   "
  16.   #version 120
  17.   uniform samplerCube CubeMap;
  18.   void main()
  19.   {
  20.     gl_FragColor = textureCube(CubeMap, gl_TexCoord[0].stp);
  21.   }
  22.   "
  23.   '
  24.  '
  25.  


.

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #27 on: March 08, 2015, 02:16:27 PM »

Chrome and Glass could be enhanced by reflection, as well as specular effects. I am currently venturing into cubic reflection mapping to see what the possibilties are:




.

Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #28 on: March 11, 2015, 01:44:57 PM »
Thanks Patrice.

I think that in real transparent surfaces, most of what we see is reflections and refractions. transparency is usually the minor component.


Charles Pegge

  • Guest
Re: Wavefront object viewer
« Reply #29 on: March 20, 2015, 01:39:23 PM »

I'm intrigued by the Lara hair texture. The algorithm for generating hair would be applicable to a multitude of other challenging textures.