We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Pages: 1 2 
Shaderlib (Read 9518 times)
Shaderlib
Apr 18th, 2009, 8:15am
 
shaderlib

technical:
tested in windows xp 32bit
compiled for j1.5 ( so it should work for macs )


what is does:
loads glsl/cg shaders
loads cgfx effect files
connects to processing easily (as i use processing)
works with java/jogl just as good

get it at:
http://www.pixelnerve.com/processing/libraries/

more information:
documentation is online (not much comments sorry)
examples are in the zipfile
source code is in the zipfile (eclipse project)
Re: Shaderlib
Reply #1 - Apr 18th, 2009, 11:31am
 
hey, seems like "vitamin.math" is missing in the download.

F
Re: Shaderlib
Reply #2 - Apr 18th, 2009, 12:19pm
 
ah yes for the examples to run you will need to add vitamin to the processing libraries folder

http://www.pixelnerve.com/downloads/processing/vitamin_05.zip

still, shaderlib is independent of vitamin, it works on its own. you just need to work out your own vector/matrix math and change the code.
it should be easy to change to PVector and PMatrix. shaderlib takes floatbuffers/arrays.
Re: Shaderlib
Reply #3 - Apr 18th, 2009, 1:29pm
 
hm, i think the link is wrong .. and the link to the documentation too.
Re: Shaderlib
Reply #4 - Apr 18th, 2009, 1:48pm
 
im sorry. oh you're right. i've already fixed it
Re: Shaderlib
Reply #5 - May 20th, 2009, 1:53pm
 
V wrote on Apr 18th, 2009, 1:48pm:
im sorry. oh you're right. i've already fixed it


hmm i think the link for vitamin library is still not working, could you fix it please
Re: Shaderlib
Reply #6 - May 20th, 2009, 2:30pm
 
shaderlib does not need vitamin framework.

still you might need Vitamin for the examples, so here's vitamin latest pack:

www.pixelnerve.com/downloads/processing/vitamin_0_5.zip
Re: Shaderlib
Reply #7 - Jun 30th, 2009, 4:00pm
 
Im wondering whats wrong, i downloaded and wanted to test the examples, but it wont start because of :

UnsatisfiedLinkError: D:\07_Processing\processing-1.0.3\libraries\opengl\library\jogl_cg.dll: Can't find dependent libraries


any ideas ?
Re: Shaderlib
Reply #8 - Jun 30th, 2009, 4:37pm
 
actually jogl cant find dependencies which should be Cg Toolkit

download Cg Toolkit that you can get from nvidia website

it needs Cg.dll and CgGL.dll
Re: Shaderlib
Reply #9 - Jul 2nd, 2009, 1:19am
 
alright, its working but all i see is either a Magenta or red textured rotating square, and they all look the same. Is that it?
Re: Shaderlib
Reply #10 - Jul 2nd, 2009, 1:29am
 
magenta quads and red quads with texture. but they all pass thru glsl and/or cgfx shaders.

looking for anything specific? just ask so i can improve
Re: Shaderlib
Reply #11 - Jul 2nd, 2009, 1:34am
 
ok , then i guess i was expecting to much Smiley thanks!
Do you know some good resources?
Re: Shaderlib
Reply #12 - Jul 2nd, 2009, 1:52am
 
ofcourse. from nvidia you have loads of resources and help on how to use cg/cgfx

http://developer.nvidia.com/object/cg_tutorial_home.html

they also have GPU gems available online.


for GLSL a search on google brought this up:

http://www.google.pt/search?q=glsl+tutorials&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:pt-PT:official&client=firefox-a


i have more complicated examples, but i've chosen not to put them in the examples list as they are based on other libraries, i didnt think that would help beginners or even motivate them.

some simple magenta/red quads that even hold textuer should be enough to get anyone started.

pick that up, trying rendering anything else you would like, then
go through the  examples\cgfx_diffspec

it only shows a simple red textured quad as you said, but if you look closely you will see that it implements a blinn-phong lighting in cgfx =)
pass some more complicated geometry through it and you will get nice results..

hopefully thats what you would looking for.

later on, i have a obj and 3ds files import libraries online, you can check it out. in mri3ds there is an example that goes through the diffspec shader. It uses my own framework Vitamin, but it should be very easy to port to Shaderlib, since Shaderlib is the shader loading part of my framework =)

go on cedric, get to work and soon enough you will become a shader expert Smiley

may the force be with you
Re: Shaderlib
Reply #13 - Jul 2nd, 2009, 1:58am
 
Thanks alot! i will do my best Smiley
Re: Shaderlib
Reply #14 - Jul 14th, 2009, 11:01am
 
V wrote on Apr 18th, 2009, 8:15am:
shaderlib

technical:
tested in windows xp 32bit
compiled for j1.5 ( so it should work for macs )


Seems to be working on Mac too (at least on mine  ;-) ) , OSX 10.5.6, Processing 1.0.3) although i'm experiencing issues with one of the examples (that crashes upon launch) and strange behaviours (aka black screen) when doing slight modifications of the examples that work (but it might be my fault).

More specifically, out of the 5 examples, all work OK but for the "glsl_simple" sketch which crashes with:
Code:

loading texture: dark3.jpg with id= 1
(ShaderGLSL)  Info Log of Shader Object ID: 1
(ShaderGLSL)  --------------------------
(ShaderGLSL)  Shader was compiled sucessfully!
(ShaderGLSL)  --------------------------

(ShaderGLSL)  Error occured with object parameter: 0

Invalid memory access of location 00000000 eip=60db31a3


Otherwise, as mentioned above, i've tried some modification to the sketch "cgfx_texture" to try and combine it with a video feed to test performance in anticipation of trying to mix and match GLSL and Cg shaders in a chain. The simple test i made is as follows:
Quote:
import processing.opengl.*;
import javax.media.opengl.*;  
import javax.media.opengl.glu.*;  
import com.sun.opengl.cg.*;
import com.sun.opengl.util.*;  

import vitamin.math.*;
import vitamin.shaderlib.*;

import processing.video.*;

GL _gl;
GLU _glu;

Capture video;

VTexture tex;

int shaderID;
ShaderManager shaderMan;

void setup()
{
  // Added to circumvent issue between OpenGL and video libs on mac
  try {
    quicktime.QTSession.open();
  } catch (quicktime.QTException qte) {
    qte.printStackTrace();
  } 
  size( 800, 600, OPENGL );

  video = new Capture(this, width, height,  25);

  _gl = ((PGraphicsOpenGL)g).gl;
  _glu = ((PGraphicsOpenGL)g).glu;

//tex = new VTexture("dark3.jpg");

  shaderMan = new ShaderManager( _gl );
  shaderID = shaderMan.addEffect( "simple", dataPath("simple_texture.cgfx") );
}


void draw() {
    if (video.available()) {
      tex = new VTexture(video);

    _gl = ((PGraphicsOpenGL)g).beginGL();  
    _gl.glClearColor( 0, 0, 0, 1 );
    _gl.glClear( GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT );  

    vperspective( 45, 1.3333, 1, 5000 );
    vcamera( 0, 0, 100, 0, 0, 0, 0, 1, 0 );

    _gl.glRotatef( frameCount, 0, 1, 0 );

    _gl.glDisable( GL.GL_TEXTURE_2D );
    Matrix matWorld = new Matrix();
    matWorld.identity();
    matWorld.rotateY( frameCount );
    matWorld.transpose();

    shaderMan.enable( shaderID );
    shaderMan.setTextureParameter( "ColorSampler", tex.getId() );
    shaderMan.setMatrixParameterSemantic( "WORLDVIEWPROJECTION", ShaderSemantics.WORLDVIEWPROJECTION_MATRIX, ShaderSemantics.IDENTITY_MATRIX );
    shaderMan.setMatrixParameterSemantic( "MODELVIEWMATRIX", ShaderSemantics.VIEW_MATRIX, ShaderSemantics.IDENTITY_MATRIX );
    shaderMan.setMatrixParameterSemantic( "WORLDMATRIX", matWorld.getArray() );
    ((ShaderCGFX)shaderMan.getActiveShader()).setTechnique( "Technique_SimpleDiffuseTexture" );
    ((ShaderCGFX)shaderMan.getActiveShader()).setPass();
  
    vrect( 0, 0, 0, 20, 20 );
    
    ((ShaderCGFX)shaderMan.getActiveShader()).resetPass();
    shaderMan.disable();

    ((PGraphicsOpenGL)g).endGL();
    }
}

void stop()
{
  super.stop();
}



Note that i've also added a new Constructor "VTexture( PImage pimg )":
Quote:
  VTexture( PImage pimg )
  {
    _tex = null;
    _buffer = null;
    _img = null;
    
    isLoaded = false;
    
    loadPImageFromMemory( pimg );
  }

so that the VTexture is updated with the video frame whenever a new frame is available.

What seems odd (to me) is that the resulting screen is pitch black with no error reported. Any idea as to what might be going wrong?

Pages: 1 2