[windows] project SoC GLSL

Given that even the Intel 910 can handle Pixel Shader 2.0, and that the other chips go as far as 3.0, it’s entirely the driver that doesn’t support GLSL if this is, in fact, true. GLSL might be a driver update away. (and might already have support in Linux, who knows.)

Of course, give that the chips have been out for well over a year, I’m guessing that driver update isn’t coming…

Update : http://graphicall.org/builds/builds/showbuild.php?action=show&id=450

log:
Material structures creation refactor for better error detection
+Defmaterial now works
+Created colorband changes events
+Created colorband parallel structure and function prototypes

Will this support tangent space normal mapping at some point?

Also how do i get uv mapping to work?

When I startup blender, it gives me a “GLSL Supported” message but when I enable preview it disables with a compile error.


GLSL GHash init
Compiled with Python version 2.5.
Warning: could not determine argv[0] path
Checking for installed Python... got it!

GLSL Supported
ARB_fragment_program is supported.
   ALU instructions:    1024
   texture instructions: 512
   texture indirections: 511
   local parameters:      64
   env parameters:        64
   temp registers:         128
   attributes:             10
ARB_vertex_program is supported.
   ALU instructions:    0
   texture instructions: 0
   texture indirections: 0
   local parameters:      256
   env parameters:        256
   temp registers:         65535
   attributes:             32

GLSL GHash init

GLSL GHash init

GLSL deactivated.

GLSL Light created.

 GLSL Material created.

 GLSL MaterialTree created.

GLSL Program created.

GLSL Shader code writing...

GLSL Shader Compiled.

* nh * pow(nh, hard) * vec3(l.color + vert_color) * spec_color);
}
vec3 cooktorrarea(light l, vec3 vnormal, vec3 spec_color, float spec, float hard, float unused){
    vec3 view = normalize(eye - pos);
    vec3 h = normalize((eye - pos) + (l.loc - pos));
    float nh = max(dot(vnormal, h), 0.0);
    float nv = max(dot(vnormal, view), 0.0);
    return((spec * pow(nh, hard) * spec_color / (0.1 + nv)) * vec3(l.color + vert_color));
}


GLSL Shader Compile Error

 Code:
struct light{
    vec3 loc;
    vec3 vec;
    vec3 color;
    float dist;
    float energy;
    float att1;
    float att2;
    float att3;
    float att4;
    float gamma;
    float area_x;
    float area_y;
    float sphere;
    float square;
    float area_type;
    float layer;
    mat4 mat;
    float areasize;
    float k;
    float spotsize;
    float spotblend;
};
varying vec3 vert_color;
varying vec3 normal, pos;
varying vec4 realcolor;
uniform vec3 eye;
uniform vec3 amb_color;
uniform float amb_exp, amb_range;uniform vec3 u_mat_0_diff_color;
uniform vec3 u_mat_0_spec_color;
uniform vec3 u_mat_0_normal;
uniform float u_mat_0_alpha;
uniform float u_mat_0_diff1;
uniform float u_mat_0_diff2;
uniform float u_mat_0_diff3;
uniform float u_mat_0_spec1;
uniform float u_mat_0_spec2;
uniform float u_mat_0_spec3;
uniform float u_mat_0_amb_fac;
uniform float u_mat_0_emit;
uniform int u_mat_0_hard;
uniform light lights[2];
vec3 lambertdef(light l, vec3 vnormal, vec3 diff_color, float ref, float unused1, float unused2){
    vec3 lightVec = normalize(l.loc - pos);
        return(max(dot(lightVec, vnormal), 0.0) * ref * vec3(l.color + vert_color) * diff_color);
}
vec3 lambertsun(light l, vec3 vnormal, vec3 diff_color, float ref, float unused1, float unused2){
    vec3 lightVec = normalize(l.vec);
     return(max(dot(lightVec, vnormal) * ref * vec3(l.color + vert_color) * diff_color, 0.0));
}vec3 lamberthemi(light l, vec3 vnormal, vec3 diff_color, float ref){
    vec3 lightVec = normalize(l.vec);
    return((0.5 * dot(lightVec, vnormal) + 0.5) * ref * vec3(l.color + vert_color) * diff_color);
}vec3 lambertarea(light l, vec3 vnormal, vec3 diff_color, float ref, float unused1, float unused2){
    vec3 lightVec = normalize(l.loc - pos);
    vec3 vect1, vect2, vect3, vect4;
    vec3 cross1, cross2, cross3, cross4;
    float rad[4];

    float fac;

    vect1 = normalize(pos - vec3(l.mat[0][0], l.mat[0][1], l.mat[0][2]));
    vect2 = normalize(pos - vec3(l.mat[1][0], l.mat[1][1], l.mat[1][2]));
    vect3 = normalize(pos - vec3(l.mat[2][0], l.mat[2][1], l.mat[2][2]));
    vect4 = normalize(pos - vec3(l.mat[3][0], l.mat[3][1], l.mat[3][2]));

    cross1 = normalize(cross(vect1, vect2));
    cross2 = normalize(cross(vect2, vect3));
    cross3 = normalize(cross(vect3, vect4));
    cross4 = normalize(cross(vect4, vect1));
    
    rad[0] = dot(vect1, vect2);
    rad[1] = dot(vect2, vect3);
    rad[2] = dot(vect3, vect4);
    rad[3] = dot(vect4, vect1);

    rad[0] = acos(clamp(rad[0], -1.0, 1.0)) * (1 - floor(clamp(rad[0], 0.1, 1.0) + 0.00001));
    rad[1] = acos(clamp(rad[1], -1.0, 1.0)) * (1 - floor(clamp(rad[1], 0.1, 1.0) + 0.00001));
    rad[2] = acos(clamp(rad[2], -1.0, 1.0)) * (1 - floor(clamp(rad[2], 0.1, 1.0) + 0.00001));
    rad[3] = acos(clamp(rad[3], -1.0, 1.0)) * (1 - floor(clamp(rad[3], 0.1, 1.0) + 0.00001));
    
    fac  = rad[0] * dot(vnormal, cross1);
    fac += rad[1] * dot(vnormal, cross2);
    fac += rad[2] * dot(vnormal, cross3);
    fac += rad[3] * dot(vnormal, cross4);

    fac = max(pow(-fac * l.areasize, l.k), 0.0);
        return(fac * ref * vec3(l.color + vert_color) * diff_color);
}
vec3 cooktorrdef(light l, vec3 vnormal, vec3 spec_color, float spec, float hard, float unused){
    vec3 view = normalize(eye - pos);
    vec3 h = normalize((eye - pos) + (l.loc - pos));
    float nh = max(dot(vnormal, h), 0.0);
    float nv = max(dot(vnormal, view), 0.0);
    return((spec * pow(nh, hard) * spec_color / (0.1 + nv)) * vec3(l.color + vert_color));
}
vec3 cooktorrsun(light l, vec3 vnormal, vec3 spec_color, float spec, float hard, float unused){
    vec3 view = normalize(eye - pos);
    vec3 h = normalize((eye - pos) + l.vec);
    float nh = max(dot(vnormal, h), 0.0);
    float nv = max(dot(vnormal, view), 0.0);
    return(spec * pow(nh, hard) * vec3(l.color + vert_color) * spec_color / (0.1 + nv));
}
vec3 cooktorrhemi(light l, vec3 vnormal, vec3 spec_color, float spec, float hard){
    vec3 view = normalize(eye - pos);
    vec3 h = normalize((eye - pos) + l.vec);
    float nh = 0.5 * (max(dot(vnormal, h), 0.0)) + 0.5;
    return(spec * nh * pow(nh, hard) * vec3(l.color + vert_color) * spec_color);
}
vec3 cooktorrarea(light l, vec3 vnormal, vec3 spec_color, float spec, float hard, float unused){
    vec3 view = normalize(eye - pos);
    vec3 h = normalize((eye - pos) + (l.loc - pos));
    float nh = max(dot(vnormal, h), 0.0);
    float nv = max(dot(vnormal, view), 0.0);
    return((spec * pow(nh, hard) * spec_color / (0.1 + nv)) * vec3(l.color + vert_color));
}
float visibility_lamp(light l){
    float visifac = 1.0;
    vec3 lv = (pos - l.loc);
    float dist = sqrt(dot(lv, lv));
    visifac = l.dist / (l.dist + (l.att1 * dist));
    visifac *= (l.dist * l.dist) / ( l.dist * l.dist + (l.att2 * dist * dist));
    visifac = max(visifac * l.att3, l.dist / (l.dist + dist) * l.att4);
    float m = max(l.dist - dist, 0.0);
    return(visifac * max(m / l.dist, l.sphere));
}

#define MATERIAL_ID 0

#define MATERIAL_FUNC material_0
vec3 MATERIAL_FUNC(inout vec3 diff_color, inout vec3 spec_color, inout vec3 normal, inout float alpha, float diff1, float diff2, float diff3, float spec1, float spec2, float spec3, float amb_fac, float emit, int hard){
  vec3 diff_rslt = vec3(0.0, 0.0, 0.0);
  vec3 spec_rslt = vec3(0.0, 0.0, 0.0);
  vec3 amb_rslt = amb_color * amb_fac;
  float vis = 0.0;

#define LIGHT_CALCULATIONS 1

#define LIGHT_ID 0

#define VISIBILITY visibility_lamp

#define CALC_DIFFUSE 1

#define DIFF_SHADER_ID lambertdef

#define CALC_SPECULAR 1

#define SPEC_SHADER_ID cooktorrdef
#ifdef LIGHT_ID
vis = VISIBILITY(lights[LIGHT_ID]);
#endif    

#ifdef CALC_DIFFUSE 
#ifdef LIGHT_ID
#ifdef HEMI
diff_rslt+= amb_exp * (1.0 - exp(DIFF_SHADER_ID(lights[LIGHT_ID], normal, diff_color, diff1) * lights[LIGHT_ID].layer * lights[LIGHT_ID].energy * vis * amb_range));
#else
diff_rslt+= DIFF_SHADER_ID(lights[LIGHT_ID], normal, diff_color, diff1, diff2, diff3) * lights[LIGHT_ID].layer * lights[LIGHT_ID].energy * vis;    
#endif
#endif
#endif
    
#ifdef CALC_SPECULAR
#ifdef LIGHT_ID
#ifdef HEMI
spec_rslt+= SPEC_SHADER_ID(lights[LIGHT_ID], normal, spec_color, spec1, hard) * lights[LIGHT_ID].layer * lights[LIGHT_ID].energy * vis;
#else
spec_rslt+= SPEC_SHADER_ID(lights[LIGHT_ID], normal, spec_color, spec1, spec2, spec3) * lights[LIGHT_ID].layer * lights[LIGHT_ID].energy * vis;
#endif
#endif
#endif

#undef VISIBILITY
#undef LIGHT_ID
#undef CALC_DIFFUSE
#undef CALC_SPECULAR
#undef DIFF_SHADER_ID
#undef SPEC_SHADER_ID
#undef HEMI
#ifdef LIGHT_CALCULATIONS
  return(amb_exp * (1.0 - exp(diff_rslt * amb_range)) + spec_rslt + amb_rslt); 
#else
  return(vec3(0.0, 0.0, 0.0));
#endif
}

#undef MATERIAL_ID
#undef MATERIAL_FUNC
void main(void){  vec3 norm = normalize(normal); vec3 diff_color = realcolor.xyz; vec3 spec_color = u_mat_0_spec_color; float alpha = realcolor.a; float diff1 = u_mat_0_diff1; float diff2 = u_mat_0_diff2; float diff3 = u_mat_0_diff3; float spec1 = u_mat_0_spec1; float spec2 = u_mat_0_spec2; float spec3 = u_mat_0_spec3; float amb_fac = u_mat_0_amb_fac; float emit = u_mat_0_emit; int hard = u_mat_0_hard; vec3 result = material_0(diff_color, spec_color, norm, alpha, diff1, diff2, diff3, spec1, spec2, spec3, amb_fac, emit, hard); gl_FragColor = vec4(result, alpha);}


GLSL Program removed.

 GLSL MaterialTree removed.

 GLSL Material removed.

GLSL GHash init

GLSL Light removed.

GLSL deactivated.

GLSL GHash init

GLSL activated.
Saved session recovery to C:	mp\quit.blend

GLSL GHash init

Blender quit

The graphics card is an ATI Mobility FireGL V5200.

log:
Colorband texture creation and uniform sending
GLSL code correction for colorbands
Duplicate lights fix

Doanload at : http://graphicall.org/builds/builds/showbuild.php?action=show&id=450

very impressive, i like when we get to see all the updates and how the development is progressing. FAST!
keep it up, we’re all excited.
(and the people that aren’t excited, probably don’t understand)

I tried this with an Intel 82945G Express video card on XP SP2 with the latest drivers and as soon as I try to enable GLSL preview it crashes. The console shows the following:

GLSL GHash init
Compiled with Python version 2.5.
‘import site’ failed; use -v for traceback
Checking for installed Python… No installed Python found.
Only built-in modules are available. Some scripts may not run.
Continuing happily.

GLSL Supported
ARB_fragment_program is supported.
ALU instructions: 64
texture instructions: 32
texture indirections: 4
local parameters: 24
env parameters: 32
temp registers: 16
attributes: 10
ARB_vertex_program is supported.
ALU instructions: 0
texture instructions: 1590805410
texture indirections: 23723968
local parameters: 96
env parameters: 96
temp registers: 12
attributes: 16

GLSL GHash init

GLSL deactivated.

The above portion is in the console before I click the GLSL preview button, and then after the following is displayed:

GLSL Light created.

GLSL Material created.

GLSL MaterialTree created.

GLSL Program created.

So what can I interpret from this? How do I determine whether the video card is supported for GLSL and vice versa?

The brief description of the card from Intel says this:

The Intel® 82945G Express Chipset Family supports hardware acceleration of OpenGL* applications in 16-bit and 32-bit color depths. OpenGL* 1.4 plus ARB_vertex_buffer and EXT_shadow_funcs extensions and TexEnv shader caching is the latest version currently supported by the Intel® Graphics Media Accelerator Drivers. Drivers that come with Windows* or that are downloaded from Windows* Update typically do not support OpenGL*. For optimal performance of OpenGL applications, install the latest graphics drivers from Intel. Also, exit any running background applications, such as virus scanners, NetMeeting* or any programs that run in the task bar.

how secure is it that the GLSL will run on most computers since there seems to be such an issue between NVIDA, ATI, and INTEL cards/chips.

I am just curious.

Hello,
a quick reply to say that SoC project rock’s !
It is terrible, thanks to maike.

I test the build (july 17th) with this file :
http://perso.orange.fr/marolles/testGLSL.blend
and there is a little problem, but i dont know why ?
(If that can help maike).

Hi folks. Iám new in here, but often visited this nice forum. So i decided to
enter your community.

Iám starting to compile blender for the OSXintel-platform and just made some builds
available at GRAFICALL. Now iám looking at GLSL. After correcting some includes
( missing glew.h in 3 locations ), i got it compiled. But when trying to activate it, it
deactivates every time i add a lamp, console shows compile error. Looks like almost
the same as wizard´s protocol. I don´t know what iám missing. Does it need some x-ta
stuff or are there just small bugs or is it incomplete for OSX. Worrying.
If you like me to show off the whole protocol, let me know.

Main thing i recognize:

GLSL Shader Compiled.
Memoryblock free: pointer not in memlist
Memoryblock free: pointer not in memlist

ghts[1

GLSL Shader Compile Error

Anyway, GLSL is a great step ahead and i like to support development.

Greetz…jens

Hi
With the newest svn-version of GLSL-build , i have a strange thing happening.
System-info of blender tells me, it could´t find the blender-home-dir.
That´s strange ´cause it allocates deeper dir´s like script´s etc. o.k…
As a sideeffect, it prduces the Bpymenus-file in my root dir.
What could that be? i checked permissions, seems alright so far.
Dunno to saay more this time, maybe someone has an idea ?
This never occured before the last changes, but GLSL was non-functional
anyway.

EDIT: Reversed to older version of EXPP_interface.c, where i identified erratic changes .
Blender dir found again as normal, GLSL nonfunctional as before - fragment-shader-error.

Greetz…Jens

Can you share the extra steps you used to get it to compile in Intel ??

I will do a hole description in time, now just the short version.
Special GLSL-changes at the bottom of the text.

  1. Install Appel-Dev-Tools from DVD or download.

  2. Get SVN: http://downloads.open.collab.net/binaries.html
    it is a binary, so no prob.Installs at: /usr/local/bin/svn

2a. Get scons, has to be compiled on Mac too.
http://www.scons.org/download.php
Compile and install with: setup.py install

  1. Get the blender source libs, put it into a Blender-dev folder you created.

  2. In terminal, go to this newly crated folder with lib-folder in and type:

/usr/local/bin/svn checkout https://svn.blender.org/svnroot/bf-blender/branches/xxx/

where xxx is the wanted branch like “soc-2007-maike” for example.

  1. In finder, go to folder xxx/config and open darwin-config.py
    with an editor ( textedit will do). Change th first line so that it points to
    the needed lib : LCGDIR = ‘#…/lib/darwin-8.9.1-i386’ (example)
    Find the lines with: openAL, ffmpg, player an set variables to “false”.
    Change iconv line from false to true.

5a… Change Python lines to what you have ( 2.3 is preinstalled )
BF_PYTHON_VERSION = ‘2.3’
if BF_PYTHON_VERSION==‘2.3’:

Important note :
When having python 2.5 intalled parallel to old 2.3, i found out
it´s the best way to us this in script to avoid mismatch errors later:

python.org libs install in /library

BF_PYTHON_VERSION = ‘2.5’
if BF_PYTHON_VERSION==‘2.5’:
BF_PYTHON = ‘/Library/Frameworks/Python.framework/Versions/’
else:
BF_PYTHON = ‘/Library/Frameworks/Python.framework/Versions/’

So only library ( not system/library ) directory is searched !!!

  1. in terminal go into particles directory and type: /Library/Frameworks/Python.framework/Versions/2.3/bin/scons.

Maybe you have to get openEXR too: openexr-1.4.0a.tar.gz
just extract then ./configure and then sudo make install.
compile blender again.

For GLSL-branch:
Compiler will tell you missing GLEW.komponents 3 times: You can find the includes and change the path
or more easy copy Folder GL( with glew.h, glxew.h , wglew.h inside ) from extern/glew/include/ to

  1. extern/bFtgl/incude/
    2.intern/bmfont/intern/
  2. source/blender/include/

This should work, try and report back.

Greetz…Jens

just posting to keep notified on jens progress with osx86!

Hello, I finally found time to poste a compilation, the nexw things is a good support of colorband : http://graphicall.org/builds/builds/showbuild.php?action=show&id=450

fragment shader compile error

Windows XP SP2
ATI x1950xt
2 gigs of RAM
Pentium d 805

i got pages and pages of feedback. I skipped ahead to the end, because i don’t know how to copy paste from the console

----------------->
GLSL Shader Compile Error

GLSL Program removed

GLSL MaterialTree removed.

GLSL Material removed.

GLSL GHash init

GLSL Light removed.

GLSL Deactivated

GLSL GHash init

GLSL activated.

------------------------------------>

i’m probably wrong, but it looks like most of the stuff printing out isn’t feedback but code… maybe a quote is missing after a PRINT?

thanks!

In spite it is compiling on OSX, there is still a glitch that
prevents the shaders form working, result: fragment-shader-error.
I tried to check where the things go wrong with no result yet.
Anyone an idea, where to catch the bug ?

Greetz…Jens

Hi everybody,

Please, please for the moment do not give error feedback if you’re using an ATi card.
At the moment I’m only testing this using NVidia cards. It seems that the ATi driver is much more strict than the NVidia’s.
I expect to soon buy an ATi card for testing and only then will need feedback.
Also if you test with heavy scenes, especially with a lot of lights, expect it not to work as the graphics cards gpu’s have limited number of instructions and right now the calculation is being done in only one pass. This also aplies to older cards that although supporting glsl only support a very small number of instructions and so won’t be supported.

I apologise for not having this working on ATi but I’m going to be an optimist and consider it an optimization.

Specularity is out of place because still don’t know the eye position to calculate the right position. Also when using normal as input for colorbands it is also wrong as it also needs the eye position.

Also errors are not always in the output, but if you want to report just need the ones that say: “error:” followed by some kind of code.

http://www.alunos.dcc.fc.up.pt/%7Ec9907027/cb.jpg
http://http://www.alunos.dcc.fc.up.pt/%7Ec9907027/cb.jpg
Cheers,
Miguel Torres Lima

A question:

Is it remotely possible that said glsl integration could gradually grow into an integrated hybrid hardware-assisted rendering engine for super-fast rendering?

Afaik daz-studio has something similar (speaking of free and low-cost software).

I’d like to ask the same. it looks great btw.