Jump to content

GIMPY73

Members
  • Posts

    300
  • Joined

  • Last visited

Posts posted by GIMPY73

  1. Ahhh wait got it working :blink:

     

    Ok i ran the wizard , it created a directory on my desktop called MyGame.

     

    I then copied MyGame.bmx into the root of c:\LWE-2.32 , double clicked MyGame.bmx , BMax opened up.

     

    I clicked build and it ran fine.

     

    So maybe its a problem with path's ???(abstract path ??)

     

    Thanks

    Gimpy73 :rolleyes:

  2. Yeah , i installed it into its own directory c:\LWE-2.32

     

    Its not a biggy at the mo MG ( i suck at programming lol) , it just seems that every new update brings more problems :blink: , and that makes it harder to get into programming.

     

    Thanks

    Gimpy73 :rolleyes:

  3. Here is the full error with source code :

     

    Error: Failed to link shader program.

    Vertex info

    -----------

    (0) : error C6007: Constant register limit exceeded; more than 1024 constant registers needed to compiled program

    (0) : error C6007: Constant register limit exceeded; more than 1024 constant registers needed to compiled program

     

     

    Vert source:
    #version 120
    #define LW_MAX_PASS_SIZE 1024
    #define LW_INSTANCED
    #define LW_SM4 
    #define LW_DIFFUSE texture0
    #define LW_BUMPMAP texture1
    
    uniform vec3 terrainscale;
    uniform sampler2D texture15;
    uniform float terrainsize;
    
    float GetTerrainHeight( in vec2 position ) {
    float terrainresolution = terrainsize/terrainscale.x;
    vec2 texcoord;
    float pixelsize = 1.0 / terrainresolution;
    texcoord = position.xy / terrainsize + 0.5;
    texcoord += 0.5 * pixelsize;
    return texture2D( texture15, texcoord ).x * terrainscale.y;
    }
    
    
    //uniform mat4 meshmatrix;
    uniform vec2 meshlayeroffset;
    uniform float meshlayerscale;
    uniform float meshlayersize;
    uniform float meshlayersectorsize;
    
    uniform float instancepasssize;
    
    uniform sampler2D texture10;
    
    #ifdef LW_INSTANCED
    #ifndef LW_SKIN
    	#extension GL_EXT_gpu_shader4 : enable
    	//#extension GL_EXT_bindable_uniform : enable
    	//bindable uniform mat4 instancematrix[ LW_MAX_PASS_SIZE ];
    	uniform mat4 instancematrix[ LW_MAX_PASS_SIZE ];
    #else
    	uniform mat4 animmatrix[69];
    	uniform mat4 instancematrix[1];
    #endif
    #else
    uniform mat4 instancematrix[1];
    #endif
    
    #ifdef LW_SKIN
    
    attribute vec4 boneindices;
    uniform float bonecount;
    
    mat4 GetAnimMatrix( in int i ) {
    return animmatrix[i];
    /*
    mat4 mat;
    
    float f=i;
    f+=0.5;
    
    mat[0]=texture2D(texture10,vec2( 0.5/64.0, f/bonecount ));
    mat[1]=texture2D(texture10,vec2( 1.5/64.0, f/bonecount ));
    mat[2]=texture2D(texture10,vec2( 2.5/64.0, f/bonecount ));
    mat[3]=texture2D(texture10,vec2( 3.5/64.0, f/bonecount ));		
    
    return mat;*/
    }
    
    #endif
    
    
    uniform float apptime;
    uniform vec2 buffersize;
    uniform float meshlayerrange;
    uniform float meshlayerheight;
    uniform vec3 cameraposition;
    uniform float camerazoom;
    uniform float vegetationviewdistance;
    uniform float vegetationheight;
    
    varying vec3 T,B,N;
    varying vec2 texcoord0;
    varying vec2 texcoord1;
    varying vec3 cubecoord;
    varying vec3 vertexposition;
    varying vec4 modelvertex;
    varying vec4 projectionspace;
    varying vec4 refractionspace;
    varying vec4 fragcolor;
    
    #ifdef LW_PARALLAXMAP
    varying vec3 eyevec;
    #endif
    
    #ifdef LW_MESHLAYER
    varying float vegetationfade;
    #endif
    
    void main(void) {
    
    vec4 vertexcameraposition;
    
    mat4 mat;
    vec4 color;
    
    #ifdef LW_SKIN
    //mat=meshmatrix;
    mat=instancematrix[0];
    #else
    #ifdef LW_INSTANCED
    	mat=instancematrix[ gl_InstanceID ];
    
    	/*
    	float f=gl_InstanceID;
    	f+=0.5;
    	mat[0]=texture2D(texture10,vec2(0.5/64.0,f/instancepasssize));
    	mat[1]=texture2D(texture10,vec2(1.5/64.0,f/instancepasssize));
    	mat[2]=texture2D(texture10,vec2(2.5/64.0,f/instancepasssize));
    	mat[3]=texture2D(texture10,vec2(3.5/64.0,f/instancepasssize));
    	*/
    #else
    	mat=instancematrix[0];//meshmatrix;
    #endif
    
    #endif
    
    color.x=mat[0][3];
    color.y=mat[1][3];
    color.z=mat[2][3];
    color.w=mat[3][3];
    
    mat[0][3]=0.0;
    mat[1][3]=0.0;
    mat[2][3]=0.0;
    mat[3][3]=1.0;
    
    
    
    fragcolor = gl_Color*color;
    
    modelvertex = gl_Vertex;
    
    #ifdef LW_SKIN
    	fragcolor=color;
    	mat  = GetAnimMatrix( int(boneindices[0]) ) * gl_Color[0];
    	mat += GetAnimMatrix( int(boneindices[1]) ) * gl_Color[1];
    	mat += GetAnimMatrix( int(boneindices[2]) ) * gl_Color[2];
    	mat += GetAnimMatrix( int(boneindices[3]) ) * gl_Color[3];
    	/*
    	mat = animmatrix[ int(boneindices[0]) ] * gl_Color[0];
    	mat += animmatrix[ int(boneindices[1]) ] * gl_Color[1]; 
    	mat += animmatrix[ int(boneindices[2]) ] * gl_Color[2];
    	mat += animmatrix[ int(boneindices[3]) ] * gl_Color[3];
    	*/
    #endif
    
    mat3 nmat = mat3(mat[0].xyz,mat[1].xyz,mat[2].xyz);
    
    #ifdef LW_MESHLAYER
    	mat[3].y=0.0;
    #endif
    
    modelvertex = mat * modelvertex;
    
    #ifdef LW_MESHLAYER
    	//Align to terrain height
    	modelvertex.y += GetTerrainHeight(modelvertex.xz);
    	//Sink into ground with distance
    	float mld = length(modelvertex.xyz - cameraposition )/vegetationviewdistance;
    	//mld += abs(mat[3].x-int(mat[3].x)) * 0.25;
    	vegetationfade=mld;
    	mld = clamp( (mld-0.75)*4.0, 0.0, 1.0 );
    	modelvertex.y -= mld * vegetationheight;
    #endif
    
    #ifdef LW_SWAY
    	float seed = mod(apptime / 100.0 * 0.25,360.0);
    	seed += mat[3].x*33.0 + mat[3].y*67.8 + mat[3].z*123.5;
    	seed += gl_Vertex.x + gl_Vertex.y + gl_Vertex.z;
    	vec4 movement = vec4( vec3( gl_Color.x * gl_Normal * LW_SWAY * (sin(seed)+0.25*cos(seed*5.2+3.2)) ),0.0);		
    	modelvertex += movement;
    	fragcolor = color;
    #endif
    
    vertexposition = modelvertex.xyz;
    vertexcameraposition = gl_ModelViewProjectionMatrix * modelvertex;		
    
    texcoord0=gl_MultiTexCoord0.xy;
    texcoord1=gl_MultiTexCoord1.xy;
    
    #ifdef LW_CUBEMAP
    	cubecoord = modelvertex.xyz - CameraPosition;
    	cubecoord = reflect( cubeCoord , normalize(nmat * gl_Normal) );
    #endif
    
    nmat = gl_NormalMatrix * nmat;
    
    N = normalize( nmat * gl_Normal );
    #ifdef LW_BUMPMAP
    	T = normalize( nmat * gl_MultiTexCoord2.xyz );		
    	B = normalize( nmat * gl_MultiTexCoord3.xyz );
    #endif
    
    gl_Position = vertexcameraposition;
    
    #ifdef __GLSL_CG_DATA_TYPES
    	gl_ClipVertex = gl_ModelViewMatrix * modelvertex;
    #endif
    
    #ifdef LW_PARALLAXMAP
    	modelvertex = gl_ModelViewMatrix * modelvertex;
    	mat3 TBN_Matrix;
        	TBN_Matrix[0] = T;
    	TBN_Matrix[1] = B;
    	TBN_Matrix[2] = N;
    	eyevec = vec3(-modelvertex) * TBN_Matrix;
    //		modelvertex = gl_ModelViewMatrix * modelvertex;
    //		EyeVec = vec3(dot(T,-modelvertex), dot(B,-modelvertex), dot(N,-modelvertex));
    #endif
    
    }
    
    
    
    Frag source:
    #version 120
    #define LW_MAX_PASS_SIZE 1024
    #define LW_INSTANCED
    #define LW_SM4 
    #define LW_DIFFUSE texture0
    #define LW_BUMPMAP texture1
    #define LW_SPECULAR
    
    #extension GL_ARB_draw_buffers : enable
    
    uniform vec3 cameraposition;
    uniform vec2 buffersize;
    uniform vec2 camerarange;
    
    float greyscale( in vec3 color ) {
    return color.x * 0.3 + color.y * 0.59 + color.z * 0.11;
    }
    
    float DepthToZPosition(in float depth) {
    return camerarange.x / (camerarange.y - depth * (camerarange.y - camerarange.x)) * camerarange.y;
    }
    
    float ZPositionToDepth(in float z) {
    return (camerarange.x / (z / camerarange.y) - camerarange.y) / -(camerarange.y - camerarange.x);
    }
    
    
    #ifdef LW_DETAIL
    uniform sampler2D LW_DETAIL;
    #endif
    
    #ifdef LW_DIFFUSE
    uniform sampler2D LW_DIFFUSE;
    #endif
    
    #ifdef LW_DIFFUSE2
    uniform sampler2D LW_DIFFUSE2;
    #endif
    
    #ifdef LW_SPECULARMAP
    uniform sampler2D LW_SPECULARMAP;
    #endif
    
    #ifdef LW_BUMPMAP
    uniform sampler2D LW_BUMPMAP;
    #endif
    
    #ifdef LW_BUMPMAP2
    uniform sampler2D LW_BUMPMAP2;
    #endif
    
    #ifdef LW_BLOOM
    uniform sampler2D LW_BLOOM;
    #endif
    
    #ifdef LW_CUBEMAP
    uniform samplerCube LW_CUBEMAP;
    #endif
    
    #ifdef LW_GIMAP
    uniform sampler2D LW_GIMAP;
    #endif
    
    #ifdef LW_PARALLAXMAP
    uniform sampler2D LW_PARALLAXMAP;
    varying vec3 eyevec;
    #endif
    
    #ifdef LE_REFRACTION
    uniform sampler2D LE_REFRACTION;
    uniform sampler2D LE_DEPTHBUFFER;
    uniform float refractionstrength = 0.01;
    #endif
    
    #ifdef LW_POMMAP
    vec3 vLightTS=vec3(0.577,0.577,0.577);
    varying vec3 eyevec;
    float depthP = 0.01;
    float nMinSamples = 20;
    float nMaxSamples = 50;	
    #endif
    
    #ifdef LW_MESHLAYER
    varying float vegetationfade;
    #endif
    
    #ifdef LW_ALPHABLEND
    uniform sampler2D LW_ALPHABLEND_INCOMINGCOLOR;
    uniform sampler2D LW_ALPHABLEND_INCOMINGNORMAL;
    #endif
    
    varying vec3 vertexposition;
    varying vec3 T,B,N;
    varying vec2 texcoord0;
    varying vec2 texcoord1;
    varying vec3 cubecoord;
    varying vec4 modelvertex;
    varying vec4 fragcolor;
    
    float fOcclusionShadow = 1.0;
    
    uniform sampler2D texture14;
    uniform float terrainsize;
    uniform vec3 terrainscale;
    uniform float bumpscale;
    uniform float specular;
    uniform float gloss;
    
    //Terrain color map
    uniform sampler2D texture12;
    
    void main(void) {
    
    vec4 diffuse = fragcolor;
    vec3 normal;
    float shininess = 0.0;
    vec2 texcoord=texcoord0;// only use this because of parallax mapping
    float selfillumination = 0.0;	
    
    vec2 terraincoord;
    float terrainresolution;
    
    #ifdef LW_VERTEXGI
    	diffuse = vec4(1);
    #endif
    
    #ifdef LW_PARALLAXMAP
    	texcoord += (diffuse.w * 0.04 - 0.036) * normalize(eyevec).xy;
    	//texcoord += (texture2D(LW_DIFFUSE,texcoord).w * 0.04 - 0.036) * normalize(eyevec).xy;
    #endif
    
    #ifdef LW_POMMAP
    	// for POM, the heightmap is in the alpha of the diffuse so save ur diffuse with DXT5 I chose this because the alpha of DXT5 is higher precision
    // from Microsoft's and Ati's implementation thank them for the source 
    // Compute the ray direction for intersecting the height field profile with 
    // current view ray. See the above paper for derivation of this computation. (Ati's comment)
    
    // Compute initial parallax displacement direction: (Ati's comment)
    vec2 vparallaxdirection = normalize(eyevec).xy;
    
    // The length of this vector determines the furthest amount of displacement: (Ati's comment)
    float flength         = length( eyevec );
    float fparallaxlength = sqrt( flength * flength - eyevec.z * eyevec.z ) / eyevec.z; 
    
    // Compute the actual reverse parallax displacement vector: (Ati's comment)
    vec2 vParallaxOffsetTS = vparallaxdirection * fparallaxlength;
    
    // Need to scale the amount of displacement to account for different height ranges
    // in height maps. This is controlled by an artist-editable parameter: (Ati's comment)
    vParallaxOffsetTS *= depthP; 
    
    int nNumSamples;
    nNumSamples = int((mix( nMinSamples, nMaxSamples, 1-dot( vparallaxdirection, N.xy ) )));	//In reference shader: int nNumSamples = (int)(lerp( nMinSamples, nMaxSamples, dot( eyeDirWS, N ) ));
    float fStepSize = 1.0 / float(nNumSamples);	
    float fCurrHeight = 0.0;
    float fPrevHeight = 1.0;
    float fNextHeight = 0.0;
    int    nStepIndex = 0;
    vec2 vTexOffsetPerStep = fStepSize * vParallaxOffsetTS;
    vec2 vTexCurrentOffset = texcoord.xy;
    float  fCurrentBound     = 1.0;
    float  fParallaxAmount   = 0.0;
    
    vec2 pt1 = vec2(0,0);
    vec2 pt2 = vec2(0,0);	    
    
    while ( nStepIndex < nNumSamples ) 
    {
    vTexCurrentOffset -= vTexOffsetPerStep;
    
    // Sample height map which in this case is stored in the alpha channel of the normal map: (Ati's comment)
    fCurrHeight = texture2D( LW_DIFFUSE, vTexCurrentOffset).a; 
    
    fCurrentBound -= fStepSize;
    
    if ( fCurrHeight > fCurrentBound ) 
    {   
       pt1 = vec2( fCurrentBound, fCurrHeight );
       pt2 = vec2( fCurrentBound + fStepSize, fPrevHeight );
    
       nStepIndex = nNumSamples + 1;	//Exit loop
       fPrevHeight = fCurrHeight;
    }
    else
    {
       nStepIndex++;
       fPrevHeight = fCurrHeight;
    }
    } 
    float fDelta2 = pt2.x - pt2.y;
    float fDelta1 = pt1.x - pt1.y;
    
    float fDenominator = fDelta2 - fDelta1;
    
    // SM 3.0 requires a check for divide by zero, since that operation will generate
    // an 'Inf' number instead of 0, as previous models (conveniently) did: (Ati's comment)
    if ( fDenominator == 0.0 )
    {
    fParallaxAmount = 0.0;
    }
    else
    {
    fParallaxAmount = (pt1.x * fDelta2 - pt2.x * fDelta1 ) / fDenominator;
    }
    vec2 vParallaxOffset = vParallaxOffsetTS * (1 - fParallaxAmount );
    texcoord = texcoord - vParallaxOffset;        
    
    vLightTS = T * vLightTS.x + B * vLightTS.y + N * vLightTS.z;
    vec2 vLightRayTS = vLightTS.xy * depthP;
    // Compute the soft blurry shadows taking into account self-occlusion for
    // features of the height field:
    float sh0 = texture2D( LW_DIFFUSE, texcoord).a;
    //float sh7 = (texture2D( LW_DIFFUSE, texcoord + vLightRayTS * 0.55).a - sh0 - 0.55 ) * 6;
    //float sh6 = (texture2D( LW_DIFFUSE, texcoord + vLightRayTS * 0.44).a - sh0 - 0.44 ) * 8;
    //float sh5 = (texture2D( LW_DIFFUSE, texcoord + vLightRayTS * 0.33).a - sh0 - 0.33 ) * 10;
    //float sh4 = (texture2D( LW_DIFFUSE, texcoord + vLightRayTS * 0.22).a - sh0 - 0.22 ) * 12;
    // Compute the actual shadow strength:
    //fOcclusionShadow = 1 - max( max( max(  sh7, sh6 ), sh5 ), sh4 );
    // The previous computation overbrightens the image, let's adjust for that:
    //fOcclusionShadow = fOcclusionShadow* .1+.45;
    
    //diffuse *= fOcclusionShadow;
    
    
    #endif
    
    #ifdef LW_DIFFUSE2
    	vec4 diffuse2 = texture2D(LW_DIFFUSE2,texcoord);
    	diffuse = vec4(1);
    #endif	
    
    #ifdef LW_DIFFUSE
    	diffuse *= texture2D(LW_DIFFUSE,texcoord);//*fOcclusionShadow;
    #endif
    
    #ifdef LW_ALPHATEST
    	if (diffuse.w<0.5) {
    		discard;
    	}
    #endif
    
    
    normal = N;
    
    #ifdef LW_BUMPMAP
    
    	#ifdef LW_TERRAINNORMALS
    		//Use terrain normals
    		terraincoord=vec2(vertexposition.x,-vertexposition.z) / terrainsize + 0.5;
    		terrainresolution = terrainsize / terrainscale.x;
    		terraincoord += 0.5 / terrainresolution;
    		vec3 worldNormal = ((texture2D(texture14,terraincoord).xyz - 0.5) * 2.0).xyz;
    		normal = normalize(gl_NormalMatrix*worldNormal);
    	#else
    		vec4 bumpcolor = texture2D(LW_BUMPMAP,texcoord);
    		normal = bumpcolor.xyz * 2.0 - 1.0;
    	#endif
    
    	#ifdef LW_DETAIL
    		normal += texture2D(LW_DETAIL,texcoord * 4.0).xyz * 2.0 - 1.0;
    	#endif
    	normal.z /= bumpscale;
    	normal = T * normal.x + B * normal.y + N * normal.z;
    	normal = normalize(normal);
    	#ifdef LW_SPECULAR
    		shininess = bumpcolor.a*specular;//*fOcclusionShadow
    	#endif
    	#ifdef LW_SPECULARMAP
    		shininess = texture2D(LW_SPECULARMAP,texcoord).x*specular;//*fOcclusionShadow
    	#endif
    
    #else
    	normal=normalize(normal);
    #endif
    
    #ifdef LW_BUMPMAP2
    	vec3 normal2;
    	float shininess2;
    
    	vec4 bumpcolor2 = texture2D(LW_BUMPMAP2,texcoord);
    	normal2 = bumpcolor2.xyz * 2.0 - 1.0;
    
    	normal2.z /= bumpscale;
    	normal2 = T * normal2.x + B * normal2.y + N * normal2.z;
    	normal2 = normalize(normal2);
    	#ifdef LW_SPECULAR
    		shininess2 = bumpcolor2.a*specular;
    	#endif
    
    #endif	
    
    #ifdef LW_TERRAINNORMALS
    	#ifndef LW_BUMPMAP
    		//Use terrain normals
    		terraincoord=vec2(vertexposition.x,-vertexposition.z) / terrainsize + 0.5;
    		terrainresolution = terrainsize / terrainscale.x;
    		terraincoord.x -= 0.5 / terrainresolution;
    		//vec4 normsample=((texture2D(texture14,terraincoord).xyz - 0.5) * 2.0).xyz;
    		vec3 worldNormal = ((texture2D(texture14,terraincoord).xyz - 0.5) * 2.0).xyz;
    		normal = normalize(gl_NormalMatrix*worldNormal);
    		//shininess = normsample.w;
    	#endif
    #endif
    
    #ifdef LW_TERRAINCOLOR
    	//Use terrain color
    	terraincoord=vec2(vertexposition.x,-vertexposition.z) / terrainsize + 0.5;
    	terrainresolution = terrainsize / terrainscale.x;
    	terraincoord.x -= 0.5 / terrainresolution;
    	//terraincoord.y += 0.5 / terrainresolution;
    	vec4 terraincolor = texture2D(texture12,terraincoord);
    	diffuse = vec4( greyscale(diffuse.xyz) * 2.0 * terraincolor.xyz,diffuse.w);
    
    	#ifdef LW_MESHLAYER
    		float temp_w=diffuse.w;
    		diffuse = diffuse * (1.0-vegetationfade) + terraincolor * vegetationfade;
    		diffuse.w=temp_w;
    	#endif
    
    	shininess = terraincolor.w;
    #endif
    
    #ifdef LE_REFRACTION
    	diffuse.a=0.25;
    	vec4 refractionvector = vec4( gl_FragCoord.x/buffersize.x, gl_FragCoord.y/buffersize.y, gl_FragCoord.z, 1.0 );
    	vec4 refractionvector2 = refractionvector + refractionstrength * vec4(normal,0.0);		
    	if (gl_FragCoord.z<DepthToZPosition(texture2DProj(LE_DEPTHBUFFER,refractionvector2).x)) {
    		refractionvector=refractionvector2;
    	}
    	vec4 transparency = texture2DProj(LE_REFRACTION,refractionvector);
    	diffuse = transparency * diffuse;
    #endif
    
    vec3 adjustednormal = normal*0.5+0.5;
    float adjustedgloss = gloss;
    
    shininess=clamp(shininess,0,1)*0.5;
    
    #ifdef LW_BUMPMAP2
    	shininess = fragcolor.r * shininess + (1.0-fragcolor.r) * shininess2;
    	normal = fragcolor.r * normal + (1.0-fragcolor.r) * normal2;
    #endif
    
    #ifdef LW_DIFFUSE2
    	diffuse = fragcolor.r * diffuse + (1.0-fragcolor.r) * diffuse2;
    #endif	
    
    //Diffuse
    gl_FragData[0] = diffuse;	
    
    //Normal
    #ifdef LW_FULLBRIGHT
    	gl_FragData[1] = vec4(1.0,1.0,1.0,diffuse.w);
    #else
    	gl_FragData[1] = vec4(adjustednormal,diffuse.w);
    #endif
    
    //Bloom
    #ifdef LW_BLOOM
    	vec4 bloomcolor = texture2D(LW_BLOOM,texcoord) * fragcolor;
    	gl_FragData[3] = bloomcolor;
    	gl_FragData[3].w = 1.0;
    #else
    	#ifdef LW_GIMAP
    		vec4 gicolor = texture2D(LW_GIMAP,vec2(texcoord1.x,1.0-texcoord1.y));
    
    		//We're going to clamp the results to prevent overbrightening when the lightmap environment doesn't match the dynamic lighting
    		//float gilum = gicolor.r * 0.3 + gicolor.g * 0.59 + gicolor.b * 0.11;
    		//float giscale = clamp(gilum,0,0.1) / gilum;
    		//gicolor.x *= giscale;
    		//gicolor.y *= giscale;
    		//gicolor.z *= giscale;
    		gicolor *= diffuse;
    		gicolor.w = 0.0;
    		gl_FragData[3] = gicolor;
    	#else
    		#ifdef LW_VERTEXGI
    			gl_FragData[3] = fragcolor * diffuse;
    			gl_FragData[3].w = 0.0;
    		#else
    			gError: Failed to link shader program.
    Vertex info
    -----------
    (0) : error C6007: Constant register limit exceeded; more than 1024 constant registers needed to compiled program
    (0) : error C6007: Constant register limit exceeded; more than 1024 constant registers needed to compiled program
    Vert source:
    #version 120
    #define LW_MAX_PASS_SIZE 1024
    #define LW_INSTANCED
    #define LW_SM4 
    #define LW_DIFFUSE texture0
    #define LW_BUMPMAP texture1
    uniform vec3 terrainscale;
    uniform sampler2D texture15;
    uniform float terrainsize;
    float GetTerrainHeight( in vec2 position ) {
    float terrainresolution = terrainsize/terrainscale.x;
    vec2 texcoord;
    float pixelsize = 1.0 / terrainresolution;
    texcoord = position.xy / terrainsize + 0.5;
    texcoord += 0.5 * pixelsize;
    return texture2D( texture15, texcoord ).x * terrainscale.y;
    }
    //uniform mat4 meshmatrix;
    uniform vec2 meshlayeroffset;
    uniform float meshlayerscale;
    uniform float meshlayersize;
    uniform float meshlayersectorsize;
    uniform float instancepasssize;
    uniform sampler2D texture10;
    #ifdef LW_INSTANCED
    #ifndef LW_SKIN
    	#extension GL_EXT_gpu_shader4 : enable
    	//#extension GL_EXT_bindable_uniform : enable
    	//bindable uniform mat4 instancematrix[ LW_MAX_PASS_SIZE ];
    	uniform mat4 instancematrix[ LW_MAX_PASS_SIZE ];
    #else
    	uniform mat4 animmatrix[69];
    	uniform mat4 instancematrix[1];
    #endif
    #else
    uniform mat4 instancematrix[1];
    #endif
    #ifdef LW_SKIN
    attribute vec4 boneindices;
    uniform float bonecount;
    mat4 GetAnimMatrix( in int i ) {
    return animmatrix[i];
    /*
    mat4 mat;
    float f=i;
    f+=0.5;
    
    mat[0]=texture2D(texture10,vec2( 0.5/64.0, f/bonecount ));
    mat[1]=texture2D(texture10,vec2( 1.5/64.0, f/bonecount ));
    mat[2]=texture2D(texture10,vec2( 2.5/64.0, f/bonecount ));
    mat[3]=texture2D(texture10,vec2( 3.5/64.0, f/bonecount ));		
    return mat;*/
    }
    #endif
    uniform float apptime;
    uniform vec2 buffersize;
    uniform float meshlayerrange;
    uniform float meshlayerheight;
    uniform vec3 cameraposition;
    uniform float camerazoom;
    uniform float vegetationviewdistance;
    uniform float vegetationheight;
    varying vec3 T,B,N;
    varying vec2 texcoord0;
    varying vec2 texcoord1;
    varying vec3 cubecoord;
    varying vec3 vertexposition;
    varying vec4 modelvertex;
    varying vec4 projectionspace;
    varying vec4 refractionspace;
    varying vec4 fragcolor;
    #ifdef LW_PARALLAXMAP
    varying vec3 eyevec;
    #endif
    #ifdef LW_MESHLAYER
    varying float vegetationfade;
    #endif
    void main(void) {
    
    vec4 vertexcameraposition;
    
    mat4 mat;
    vec4 color;
    #ifdef LW_SKIN
    //mat=meshmatrix;
    mat=instancematrix[0];
    #else
    #ifdef LW_INSTANCED
    	mat=instancematrix[ gl_InstanceID ];
    
    	/*
    	float f=gl_InstanceID;
    	f+=0.5;
    	mat[0]=texture2D(texture10,vec2(0.5/64.0,f/instancepasssize));
    	mat[1]=texture2D(texture10,vec2(1.5/64.0,f/instancepasssize));
    	mat[2]=texture2D(texture10,vec2(2.5/64.0,f/instancepasssize));
    	mat[3]=texture2D(texture10,vec2(3.5/64.0,f/instancepasssize));
    	*/
    #else
    	mat=instancematrix[0];//meshmatrix;
    #endif
    
    #endif
    color.x=mat[0][3];
    color.y=mat[1][3];
    color.z=mat[2][3];
    color.w=mat[3][3];
    mat[0][3]=0.0;
    mat[1][3]=0.0;
    mat[2][3]=0.0;
    mat[3][3]=1.0;
    
    fragcolor = gl_Color*color;
    
    modelvertex = gl_Vertex;
    
    #ifdef LW_SKIN
    	fragcolor=color;
    	mat  = GetAnimMatrix( int(boneindices[0]) ) * gl_Color[0];
    	mat += GetAnimMatrix( int(boneindices[1]) ) * gl_Color[1];
    	mat += GetAnimMatrix( int(boneindices[2]) ) * gl_Color[2];
    	mat += GetAnimMatrix( int(boneindices[3]) ) * gl_Color[3];
    	/*
    	mat = animmatrix[ int(boneindices[0]) ] * gl_Color[0];
    	mat += animmatrix[ int(boneindices[1]) ] * gl_Color[1]; 
    	mat += animmatrix[ int(boneindices[2]) ] * gl_Color[2];
    	mat += animmatrix[ int(boneindices[3]) ] * gl_Color[3];
    	*/
    #endif
    
    mat3 nmat = mat3(mat[0].xyz,mat[1].xyz,mat[2].xyz);
    
    #ifdef LW_MESHLAYER
    	mat[3].y=0.0;
    #endif
    
    modelvertex = mat * modelvertex;
    
    #ifdef LW_MESHLAYER
    	//Align to terrain height
    	modelvertex.y += GetTerrainHeight(modelvertex.xz);
    	//Sink into ground with distance
    	float mld = length(modelvertex.xyz - cameraposition )/vegetationviewdistance;
    	//mld += abs(mat[3].x-int(mat[3].x)) * 0.25;
    	vegetationfade=mld;
    	mld = clamp( (mld-0.75)*4.0, 0.0, 1.0 );
    	modelvertex.y -= mld * vegetationheight;
    #endif
    #ifdef LW_SWAY
    	float seed = mod(apptime / 100.0 * 0.25,360.0);
    	seed += mat[3].x*33.0 + mat[3].y*67.8 + mat[3].z*123.5;
    	seed += gl_Vertex.x + gl_Vertex.y + gl_Vertex.z;
    	vec4 movement = vec4( vec3( gl_Color.x * gl_Normal * LW_SWAY * (sin(seed)+0.25*cos(seed*5.2+3.2)) ),0.0);		
    	modelvertex += movement;
    	fragcolor = color;
    #endif
    vertexposition = modelvertex.xyz;
    vertexcameraposition = gl_ModelViewProjectionMatrix * modelvertex;		
    texcoord0=gl_MultiTexCoord0.xy;
    texcoord1=gl_MultiTexCoord1.xy;
    
    #ifdef LW_CUBEMAP
    	cubecoord = modelvertex.xyz - CameraPosition;
    	cubecoord = reflect( cubeCoord , normalize(nmat * gl_Normal) );
    #endif
    l_FragData[3] = vec4(0,0,0,1);
    		#endif
    	#endif
    #endif
    
    
    
    //Modify depth output for shadows
    #ifdef LW_POMMAP
    	float z = DepthToZPosition(gl_FragCoord.z);
    	z = z -diffuse.a * fparallaxlength * depthP;
    	gl_FragDepth = ZPositionToDepth( z );
    #endif
    
    gl_FragData[2]=vec4(shininess,gloss,0.0,diffuse.w);
    
    /*
    float c;
    float temp;
    temp=adjustednormal.x*100.0;
    c=int(temp);
    temp=adjustednormal.y*100.0;
    c+=int(temp)/100.0;
    temp=adjustednormal.z*100.0;
    c+=int(temp)/100.0/100.0;
    gl_FragData[1].x = c;
    */
    }
    
    
    nmat = gl_NormalMatrix * nmat;
    
    N = normalize( nmat * gl_Normal );
    #ifdef LW_BUMPMAP
    	T = normalize( nmat * gl_MultiTexCoord2.xyz );		
    	B = normalize( nmat * gl_MultiTexCoord3.xyz );
    #endif
    
    gl_Position = vertexcameraposition;
    
    #ifdef __GLSL_CG_DATA_TYPES
    	gl_ClipVertex = gl_ModelViewMatrix * modelvertex;
    #endif
    #ifdef LW_PARALLAXMAP
    	modelvertex = gl_ModelViewMatrix * modelvertex;
    	mat3 TBN_Matrix;
        	TBN_Matrix[0] = T;
    	TBN_Matrix[1] = B;
    	TBN_Matrix[2] = N;
    	eyevec = vec3(-modelvertex) * TBN_Matrix;
    //		modelvertex = gl_ModelViewMatrix * modelvertex;
    //		EyeVec = vec3(dot(T,-modelvertex), dot(B,-modelvertex), dot(N,-modelvertex));
    #endif
    
    }
    Frag source:
    #version 120
    #define LW_MAX_PASS_SIZE 1024
    #define LW_INSTANCED
    #define LW_SM4 
    #define LW_DIFFUSE texture0
    #define LW_BUMPMAP texture1
    #define LW_SPECULAR
    #extension GL_ARB_draw_buffers : enable
    uniform vec3 cameraposition;
    uniform vec2 buffersize;
    uniform vec2 camerarange;
    float greyscale( in vec3 color ) {
    return color.x * 0.3 + color.y * 0.59 + color.z * 0.11;
    }
    float DepthToZPosition(in float depth) {
    return camerarange.x / (camerarange.y - depth * (camerarange.y - camerarange.x)) * camerarange.y;
    }
    float ZPositionToDepth(in float z) {
    return (camerarange.x / (z / camerarange.y) - camerarange.y) / -(camerarange.y - camerarange.x);
    }
    #ifdef LW_DETAIL
    uniform sampler2D LW_DETAIL;
    #endif
    #ifdef LW_DIFFUSE
    uniform sampler2D LW_DIFFUSE;
    #endif
    #ifdef LW_DIFFUSE2
    uniform sampler2D LW_DIFFUSE2;
    #endif
    #ifdef LW_SPECULARMAP
    uniform sampler2D LW_SPECULARMAP;
    #endif
    #ifdef LW_BUMPMAP
    uniform sampler2D LW_BUMPMAP;
    #endif
    #ifdef LW_BUMPMAP2
    uniform sampler2D LW_BUMPMAP2;
    #endif
    #ifdef LW_BLOOM
    uniform sampler2D LW_BLOOM;
    #endif
    #ifdef LW_CUBEMAP
    uniform samplerCube LW_CUBEMAP;
    #endif
    #ifdef LW_GIMAP
    uniform sampler2D LW_GIMAP;
    #endif
    #ifdef LW_PARALLAXMAP
    uniform sampler2D LW_PARALLAXMAP;
    varying vec3 eyevec;
    #endif
    #ifdef LE_REFRACTION
    uniform sampler2D LE_REFRACTION;
    uniform sampler2D LE_DEPTHBUFFER;
    uniform float refractionstrength = 0.01;
    #endif
    #ifdef LW_POMMAP
    vec3 vLightTS=vec3(0.577,0.577,0.577);
    varying vec3 eyevec;
    float depthP = 0.01;
    float nMinSamples = 20;
    float nMaxSamples = 50;	
    #endif
    #ifdef LW_MESHLAYER
    varying float vegetationfade;
    #endif
    #ifdef LW_ALPHABLEND
    uniform sampler2D LW_ALPHABLEND_INCOMINGCOLOR;
    uniform sampler2D LW_ALPHABLEND_INCOMINGNORMAL;
    #endif
    varying vec3 vertexposition;
    varying vec3 T,B,N;
    varying vec2 texcoord0;
    varying vec2 texcoord1;
    varying vec3 cubecoord;
    varying vec4 modelvertex;
    varying vec4 fragcolor;
    float fOcclusionShadow = 1.0;
    uniform sampler2D texture14;
    uniform float terrainsize;
    uniform vec3 terrainscale;
    uniform float bumpscale;
    uniform float specular;
    uniform float gloss;
    //Terrain color map
    uniform sampler2D texture12;
    void main(void) {
    
    vec4 diffuse = fragcolor;
    vec3 normal;
    float shininess = 0.0;
    vec2 texcoord=texcoord0;// only use this because of parallax mapping
    float selfillumination = 0.0;	
    vec2 terraincoord;
    float terrainresolution;
    
    #ifdef LW_VERTEXGI
    	diffuse = vec4(1);
    #endif
    
    #ifdef LW_PARALLAXMAP
    	texcoord += (diffuse.w * 0.04 - 0.036) * normalize(eyevec).xy;
    	//texcoord += (texture2D(LW_DIFFUSE,texcoord).w * 0.04 - 0.036) * normalize(eyevec).xy;
    #endif
    
    #ifdef LW_POMMAP
    	// for POM, the heightmap is in the alpha of the diffuse so save ur diffuse with DXT5 I chose this because the alpha of DXT5 is higher precision
    // from Microsoft's and Ati's implementation thank them for the source 
    // Compute the ray direction for intersecting the height field profile with 
    // current view ray. See the above paper for derivation of this computation. (Ati's comment)
    
    // Compute initial parallax displacement direction: (Ati's comment)
    vec2 vparallaxdirection = normalize(eyevec).xy;
    
    // The length of this vector determines the furthest amount of displacement: (Ati's comment)
    float flength         = length( eyevec );
    float fparallaxlength = sqrt( flength * flength - eyevec.z * eyevec.z ) / eyevec.z; 
    
    // Compute the actual reverse parallax displacement vector: (Ati's comment)
    vec2 vParallaxOffsetTS = vparallaxdirection * fparallaxlength;
    
    // Need to scale the amount of displacement to account for different height ranges
    // in height maps. This is controlled by an artist-editable parameter: (Ati's comment)
    vParallaxOffsetTS *= depthP; 
    
    int nNumSamples;
    nNumSamples = int((mix( nMinSamples, nMaxSamples, 1-dot( vparallaxdirection, N.xy ) )));	//In reference shader: int nNumSamples = (int)(lerp( nMinSamples, nMaxSamples, dot( eyeDirWS, N ) ));
    float fStepSize = 1.0 / float(nNumSamples);	
    float fCurrHeight = 0.0;
    float fPrevHeight = 1.0;
    float fNextHeight = 0.0;
    int    nStepIndex = 0;
    vec2 vTexOffsetPerStep = fStepSize * vParallaxOffsetTS;
    vec2 vTexCurrentOffset = texcoord.xy;
    float  fCurrentBound     = 1.0;
    float  fParallaxAmount   = 0.0;
    vec2 pt1 = vec2(0,0);
    vec2 pt2 = vec2(0,0);	    
    
    while ( nStepIndex < nNumSamples ) 
    {
    vTexCurrentOffset -= vTexOffsetPerStep;
    // Sample height map which in this case is stored in the alpha channel of the normal map: (Ati's comment)
    fCurrHeight = texture2D( LW_DIFFUSE, vTexCurrentOffset).a; 
    fCurrentBound -= fStepSize;
    if ( fCurrHeight > fCurrentBound ) 
    {   
       pt1 = vec2( fCurrentBound, fCurrHeight );
       pt2 = vec2( fCurrentBound + fStepSize, fPrevHeight );
       nStepIndex = nNumSamples + 1;	//Exit loop
       fPrevHeight = fCurrHeight;
    }
    else
    {
       nStepIndex++;
       fPrevHeight = fCurrHeight;
    }
    } 
    float fDelta2 = pt2.x - pt2.y;
    float fDelta1 = pt1.x - pt1.y;
    
    float fDenominator = fDelta2 - fDelta1;
    
    // SM 3.0 requires a check for divide by zero, since that operation will generate
    // an 'Inf' number instead of 0, as previous models (conveniently) did: (Ati's comment)
    if ( fDenominator == 0.0 )
    {
    fParallaxAmount = 0.0;
    }
    else
    {
    fParallaxAmount = (pt1.x * fDelta2 - pt2.x * fDelta1 ) / fDenominator;
    }
    vec2 vParallaxOffset = vParallaxOffsetTS * (1 - fParallaxAmount );
    texcoord = texcoord - vParallaxOffset;        
    vLightTS = T * vLightTS.x + B * vLightTS.y + N * vLightTS.z;
    vec2 vLightRayTS = vLightTS.xy * depthP;
    // Compute the soft blurry shadows taking into account self-occlusion for
    // features of the height field:
    float sh0 = texture2D( LW_DIFFUSE, texcoord).a;
    //float sh7 = (texture2D( LW_DIFFUSE, texcoord + vLightRayTS * 0.55).a - sh0 - 0.55 ) * 6;
    //float sh6 = (texture2D( LW_DIFFUSE, texcoord + vLightRayTS * 0.44).a - sh0 - 0.44 ) * 8;
    //float sh5 = (texture2D( LW_DIFFUSE, texcoord + vLightRayTS * 0.33).a - sh0 - 0.33 ) * 10;
    //float sh4 = (texture2D( LW_DIFFUSE, texcoord + vLightRayTS * 0.22).a - sh0 - 0.22 ) * 12;
    // Compute the actual shadow strength:
    //fOcclusionShadow = 1 - max( max( max(  sh7, sh6 ), sh5 ), sh4 );
    // The previous computation overbrightens the image, let's adjust for that:
    //fOcclusionShadow = fOcclusionShadow* .1+.45;
    //diffuse *= fOcclusionShadow;
    #endif
    #ifdef LW_DIFFUSE2
    	vec4 diffuse2 = texture2D(LW_DIFFUSE2,texcoord);
    	diffuse = vec4(1);
    #endif	
    
    #ifdef LW_DIFFUSE
    	diffuse *= texture2D(LW_DIFFUSE,texcoord);//*fOcclusionShadow;
    #endif
    #ifdef LW_ALPHATEST
    	if (diffuse.w<0.5) {
    		discard;
    	}
    #endif
    normal = N;
    
    #ifdef LW_BUMPMAP
    	#ifdef LW_TERRAINNORMALS
    		//Use terrain normals
    		terraincoord=vec2(vertexposition.x,-vertexposition.z) / terrainsize + 0.5;
    		terrainresolution = terrainsize / terrainscale.x;
    		terraincoord += 0.5 / terrainresolution;
    		vec3 worldNormal = ((texture2D(texture14,terraincoord).xyz - 0.5) * 2.0).xyz;
    		normal = normalize(gl_NormalMatrix*worldNormal);
    	#else
    		vec4 bumpcolor = texture2D(LW_BUMPMAP,texcoord);
    		normal = bumpcolor.xyz * 2.0 - 1.0;
    	#endif
    
    	#ifdef LW_DETAIL
    		normal += texture2D(LW_DETAIL,texcoord * 4.0).xyz * 2.0 - 1.0;
    	#endif
    	normal.z /= bumpscale;
    	normal = T * normal.x + B * normal.y + N * normal.z;
    	normal = normalize(normal);
    	#ifdef LW_SPECULAR
    		shininess = bumpcolor.a*specular;//*fOcclusionShadow
    	#endif
    	#ifdef LW_SPECULARMAP
    		shininess = texture2D(LW_SPECULARMAP,texcoord).x*specular;//*fOcclusionShadow
    	#endif
    
    #else
    	normal=normalize(normal);
    #endif
    #ifdef LW_BUMPMAP2
    	vec3 normal2;
    	float shininess2;
    
    	vec4 bumpcolor2 = texture2D(LW_BUMPMAP2,texcoord);
    	normal2 = bumpcolor2.xyz * 2.0 - 1.0;
    
    	normal2.z /= bumpscale;
    	normal2 = T * normal2.x + B * normal2.y + N * normal2.z;
    	normal2 = normalize(normal2);
    	#ifdef LW_SPECULAR
    		shininess2 = bumpcolor2.a*specular;
    	#endif
    
    #endif	
    
    #ifdef LW_TERRAINNORMALS
    	#ifndef LW_BUMPMAP
    		//Use terrain normals
    		terraincoord=vec2(vertexposition.x,-vertexposition.z) / terrainsize + 0.5;
    		terrainresolution = terrainsize / terrainscale.x;
    		terraincoord.x -= 0.5 / terrainresolution;
    		//vec4 normsample=((texture2D(texture14,terraincoord).xyz - 0.5) * 2.0).xyz;
    		vec3 worldNormal = ((texture2D(texture14,terraincoord).xyz - 0.5) * 2.0).xyz;
    		normal = normalize(gl_NormalMatrix*worldNormal);
    		//shininess = normsample.w;
    	#endif
    #endif
    #ifdef LW_TERRAINCOLOR
    	//Use terrain color
    	terraincoord=vec2(vertexposition.x,-vertexposition.z) / terrainsize + 0.5;
    	terrainresolution = terrainsize / terrainscale.x;
    	terraincoord.x -= 0.5 / terrainresolution;
    	//terraincoord.y += 0.5 / terrainresolution;
    	vec4 terraincolor = texture2D(texture12,terraincoord);
    	diffuse = vec4( greyscale(diffuse.xyz) * 2.0 * terraincolor.xyz,diffuse.w);
    	#ifdef LW_MESHLAYER
    		float temp_w=diffuse.w;
    		diffuse = diffuse * (1.0-vegetationfade) + terraincolor * vegetationfade;
    		diffuse.w=temp_w;
    	#endif
    	shininess = terraincolor.w;
    #endif
    
    #ifdef LE_REFRACTION
    	diffuse.a=0.25;
    	vec4 refractionvector = vec4( gl_FragCoord.x/buffersize.x, gl_FragCoord.y/buffersize.y, gl_FragCoord.z, 1.0 );
    	vec4 refractionvector2 = refractionvector + refractionstrength * vec4(normal,0.0);		
    	if (gl_FragCoord.z<DepthToZPosition(texture2DProj(LE_DEPTHBUFFER,refractionvector2).x)) {
    		refractionvector=refractionvector2;
    	}
    	vec4 transparency = texture2DProj(LE_REFRACTION,refractionvector);
    	diffuse = transparency * diffuse;
    #endif
    
    vec3 adjustednormal = normal*0.5+0.5;
    float adjustedgloss = gloss;
    
    shininess=clamp(shininess,0,1)*0.5;
    
    #ifdef LW_BUMPMAP2
    	shininess = fragcolor.r * shininess + (1.0-fragcolor.r) * shininess2;
    	normal = fragcolor.r * normal + (1.0-fragcolor.r) * normal2;
    #endif
    #ifdef LW_DIFFUSE2
    	diffuse = fragcolor.r * diffuse + (1.0-fragcolor.r) * diffuse2;
    #endif	
    
    //Diffuse
    gl_FragData[0] = diffuse;	
    //Normal
    #ifdef LW_FULLBRIGHT
    	gl_FragData[1] = vec4(1.0,1.0,1.0,diffuse.w);
    #else
    	gl_FragData[1] = vec4(adjustednormal,diffuse.w);
    #endif
    
    //Bloom
    #ifdef LW_BLOOM
    	vec4 bloomcolor = texture2D(LW_BLOOM,texcoord) * fragcolor;
    	gl_FragData[3] = bloomcolor;
    	gl_FragData[3].w = 1.0;
    #else
    	#ifdef LW_GIMAP
    		vec4 gicolor = texture2D(LW_GIMAP,vec2(texcoord1.x,1.0-texcoord1.y));
    
    		//We're going to clamp the results to prevent overbrightening when the lightmap environment doesn't match the dynamic lighting
    		//float gilum = gicolor.r * 0.3 + gicolor.g * 0.59 + gicolor.b * 0.11;
    		//float giscale = clamp(gilum,0,0.1) / gilum;
    		//gicolor.x *= giscale;
    		//gicolor.y *= giscale;
    		//gicolor.z *= giscale;
    		gicolor *= diffuse;
    		gicolor.w = 0.0;
    		gl_FragData[3] = gicolor;
    	#else
    		#ifdef LW_VERTEXGI
    			gl_FragData[3] = fragcolor * diffuse;
    			gl_FragData[3].w = 0.0;
    		#else
    			gl_FragData[3] = vec4(0,0,0,1);
    		#endif
    	#endif
    #endif
    
    //Modify depth output for shadows
    #ifdef LW_POMMAP
    	float z = DepthToZPosition(gl_FragCoord.z);
    	z = z -diffuse.a * fparallaxlength * depthP;
    	gl_FragDepth = ZPositionToDepth( z );
    #endif
    
    gl_FragData[2]=vec4(shininess,gloss,0.0,diffuse.w);
    
    /*
    float c;
    float temp;
    temp=adjustednormal.x*100.0;
    c=int(temp);
    temp=adjustednormal.y*100.0;
    c+=int(temp)/100.0;
    temp=adjustednormal.z*100.0;
    c+=int(temp)/100.0/100.0;
    gl_FragData[1].x = c;
    */
    }
    
    Process complete

  4. Ok updated BMax , copied that LuaJit file across , rebuilt the docs.

     

    Ran the project wizard , same error as above.

     

    Ran the project wizard but made BMax run in debugmode , same error as above but the BMax code stops on this line :

     

    material=LoadMaterial("abstract::cobblestones.mat")

     

    Thanks

    Gimpy73 :rolleyes:

  5. No probs MG

     

    Here is the error that i got from the project wizard + blitzmax

     

    Error: Failed to link shader program.

    Vertex info

    -----------

    (0) : error C6007: Constant register limit exceeded; more than 1024 constant registers needed to compiled program

    (0) : error C6007: Constant register limit exceeded; more than 1024 constant registers needed to compiled program

     

     

    Hope this helps :lol:

     

    Thanks

     

    Gimpy73 :blink:

  6. Also the project wizard don't seem to work.

     

    I ran it just to create the simple cobblestone cube , and blitzmax came up with an error about linking to shader , then spat out a load of C/C++ code ???

     

    Thanks

    Gimpy73 :blink:

  7. Never mind , i fixed it by adding another pivot for the camera :)

     

    It seems to snap when you press the right mouse button , but atleast it works :lol:

     

     

    'Use the Leadwerks Engine module as our base
    
    Framework leadwerks.engine
    
    'Create an OpenGL graphics window 
    Graphics 800, 600
    
    'Allows the engine to find files and load files from zip packages 
    RegisterAbstractPath AppDir
    
    'Create a world 
    If Not CreateWorld() RuntimeError "Failed to create world."
    
    campiv=CreatePivot()
    'Create a camera 
    cam:TCamera = CreateCamera(campiv)
    PositionEntity cam,vec3(0,60,-30)
    
    'create a ligt
    light:TLight = CreateDirectionalLight()
    RotateEntity(light, Vec3(65, 45, 0))
    
    'Create a render Buffer
    buffer:TBuffer = CreateBuffer(800, 600, BUFFER_COLOR | BUFFER_DEPTH | BUFFER_NORMAL)
    
    piv=CreatePivot()
    
    'create a mesh
    cube:TMesh = CreateCube()
    PositionEntity cube,vec3(0,.5,0)
    
    Local plane:tentity = CreatePlane()
    ScaleEntity  plane,  Vec3(100,0.1,100)
    
    PaintEntity (plane,LoadMaterial("abstract::cobblestones.mat"))
    
    Local pick:TPick
    
    'Main loop 
    While Not KeyHit(KEY_ESCAPE) 
    
    mx# = GraphicsWidth()/2 - MouseX()
    
    PositionEntity (campiv,vec3(cube.position.x,cube.position.y,cube.position.z))
    'PositionEntity (cam,vec3(cube.position.x,cube.position.y+60,cube.position.z-30))
    PointEntity cam,campiv
    
    'pick objects with the mouse
    If MouseDown(1) = True
    
    	pick = CameraPick(cam, Vec3(MouseX(), MouseY(), 1000))
    
    	If pick Then
    
    		PositionEntity (piv,vec3(pick.x,.5,pick.z))
    		PointEntity cube,piv
    		Local speed#=.3
    
    	End If
    
    End If
    
    'Zoom in / out	
    Select MouseZSpeed()
    
    Case 1
    	MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
    
    	zoom#=zoom#+1
    
    Case -1
    	MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
    	zoom#=zoom#-1
    
    End Select
    
    If zoom#<1 Then zoom#=1 
    If zoom#>5 Then zoom#=5
    CameraZoom cam,zoom#
    
    If MouseDown(2) = True
    	speed#=0
    	MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
    	TurnEntity campiv,vec3(0,mx#,0)
    End If
    
    If (EntityDistance(cube,piv) < 1.2)
    	speed#=0
    End If
    
    MoveEntity cube,vec3(0,0,speed#)
    
    'Update timing, physics, and other miscellaneous updates 
    UpdateWorld
    
    'Draw the world 
    SetBuffer(buffer)
    RenderWorld
    
    'render lighting
    SetBuffer(BackBuffer())
    RenderLights(buffer)
    
    
    'Swap the graphics buffers so we can see what we drew 
    Flip
    Wend

     

    Thanks

    Gimpy73 :blink:

  8. Ok ive been playing abit more with this and ran into a problem.

     

     

    'Use the Leadwerks Engine module as our base
    
    Framework leadwerks.engine
    
    'Create an OpenGL graphics window 
    Graphics 800, 600
    
    'Allows the engine to find files and load files from zip packages 
    RegisterAbstractPath AppDir
    
    'Create a world 
    If Not CreateWorld() RuntimeError "Failed to create world."
    
    'Create a camera 
    cam:TCamera = CreateCamera()
    
    'create a ligt
    light:TLight = CreateDirectionalLight()
    RotateEntity(light, Vec3(65, 45, 0))
    
    'Create a render Buffer
    buffer:TBuffer = CreateBuffer(800, 600, BUFFER_COLOR | BUFFER_DEPTH | BUFFER_NORMAL)
    
    piv=CreatePivot()
    
    'create a mesh
    cube:TMesh = CreateCube()
    PositionEntity cube,vec3(0,.5,0)
    
    Local plane:tentity = CreatePlane()
    ScaleEntity  plane,  Vec3(100,0.1,100)
    
    PaintEntity (plane,LoadMaterial("abstract::cobblestones.mat"))
    
    Local pick:TPick
    
    'Main loop 
    While Not KeyHit(KEY_ESCAPE) 
    
    PositionEntity (cam,vec3(cube.position.x,cube.position.y+60,cube.position.z-30))
    PointEntity cam,cube
    
    'pick objects with the mouse
    If MouseDown(1) = True
    
    	pick = CameraPick(cam, Vec3(MouseX(), MouseY(), 1000))
    
    	If pick Then
    
    		PositionEntity (piv,vec3(pick.x,.5,pick.z))
    		PointEntity cube,piv
    		Local speed#=.3
    
    	End If
    
    End If
    
    'Zoom in / out	
    Select MouseZSpeed()
    
    Case 1
    	MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
    
    	zoom#=zoom#+1
    
    Case -1
    	MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
    	zoom#=zoom#-1
    
    End Select
    
    If zoom#<1 Then zoom#=1 
    If zoom#>5 Then zoom#=5
    CameraZoom cam,zoom#
    
    
    If MouseDown(2) = True
    	speed#=0
    	mx# = MouseXSpeed()*.3
    	TurnEntity cam,vec3(0,mx#,0)
    End If
    
    If (EntityDistance(cube,piv) < 1.2)
    	speed#=0
    End If
    
    MoveEntity cube,vec3(0,0,speed#)
    
    'Update timing, physics, and other miscellaneous updates 
    UpdateWorld
    
    'Draw the world 
    SetBuffer(buffer)
    RenderWorld
    
    'render lighting
    SetBuffer(BackBuffer())
    RenderLights(buffer)
    
    
    'Swap the graphics buffers so we can see what we drew 
    Flip
    Wend

     

    Im trying to get the camera to point and rotate around the cube when the right mouse button is held down.

    I used some old code from a Blitz3D project and that worked fine for Blitz3D.

     

    I can get the camera to point and rotate around the cube as a seperate program , but i don't want to work with the above code.

     

    Any pointers on this???

     

    Thanks

    Gimpy73 :)

×
×
  • Create New...