Permalink
Browse files

* fixed tiny memory leak in msbObject

* fixed aliveTexture shader
* minor lighting/shading experiments
  • Loading branch information...
fiezi committed Jan 21, 2013
1 parent edd8f4f commit 99b418af302898de478b291dd636c5a45ec952e9
View
Binary file not shown.
View
@@ -215,73 +215,103 @@ void MsbObject::memberFromString(memberID *mID,string value){
//for this, in order to not mix up vector components and full vectors, let's check first
if (testForVector3Component(cValue)){
- if (setVector3PropertyTo (mID, readVector3fComponent(cValue)))
- return;
+ if (setVector3PropertyTo (mID, readVector3fComponent(cValue))){
+ free(cValue);
+ return;
+ }
}
if (testForVector4Component(cValue)){
- if (setVector4PropertyTo (mID, readVector4fComponent(cValue)))
- return;
+ if (setVector4PropertyTo (mID, readVector4fComponent(cValue))){
+ free(cValue);
+ return;
+ }
}
//give special priority to locations and other vectors!
- if (setPropertyTo (mID, readVector3f(cValue)))
- return;
- if (setPropertyTo (mID, readVector4f(cValue)))
- return;
- if (setPropertyTo (mID, readMatrix4f(cValue)))
- return;
- if (setPropertyTo (mID, readBool(cValue)))
- return;
- if (setPropertyTo (mID, readGLuint(cValue)))
- return;
- if (setPropertyTo (mID, readInt(cValue)))
- return;
- if (setPropertyTo (mID, readFloat(cValue)))
+ if (setPropertyTo (mID, readVector3f(cValue))){
+ free(cValue);
return;
-
-
- if (setStringPropertyTo(mID, readString(cValue)))
- return;
+ }
+ if (setPropertyTo (mID, readVector4f(cValue))){
+ free(cValue);
+ return;
+ }
+ if (setPropertyTo (mID, readMatrix4f(cValue))){
+ free(cValue);
+ return;
+ }
+ if (setPropertyTo (mID, readBool(cValue))){
+ free(cValue);
+ return;
+ }
+ if (setPropertyTo (mID, readGLuint(cValue))){
+ free(cValue);
+ return;
+ }
+ if (setPropertyTo (mID, readInt(cValue))){
+ free(cValue);
+ return;
+ }
+ if (setPropertyTo (mID, readFloat(cValue))){
+ free(cValue);
+ return;
+ }
- if (setNodePropertyTo(mID, readNode(cValue)))
+ if (setStringPropertyTo(mID, readString(cValue))){
+ free(cValue);
return;
+ }
- if (setActorPropertyTo(mID, readActor(cValue)))
+ if (setNodePropertyTo(mID, readNode(cValue))){
+ free(cValue);
return;
+ }
+ if (setActorPropertyTo(mID, readActor(cValue))){
+ free(cValue);
+ return;
+ }
///vectors
- if (setVecPropertyTo (mID,readVecString(cValue)))
+ if (setVecPropertyTo (mID,readVecString(cValue))){
+ free(cValue);
return;
-
+ }
+
cValue = new char [value.size()+1];
strcpy (cValue, value.c_str());
- if (setVecPropertyTo (mID,readVecActor(cValue)))
+ if (setVecPropertyTo (mID,readVecActor(cValue))){
+ free(cValue);
return;
-
+ }
+
cValue = new char [value.size()+1];
strcpy (cValue, value.c_str());
- if (setVecPropertyTo (mID,readVecNode(cValue)))
+ if (setVecPropertyTo (mID,readVecNode(cValue))){
+ free(cValue);
return;
-
+ }
+
cValue = new char [value.size()+1];
strcpy (cValue, value.c_str());
- if (setVecPropertyTo (mID,readVecVector3f(cValue)))
+ if (setVecPropertyTo (mID,readVecVector3f(cValue))){
+ free(cValue);
return;
-
+ }
cValue = new char [value.size()+1];
strcpy (cValue, value.c_str());
- if (setVecPropertyTo (mID,readVecVector4f(cValue)))
+ if (setVecPropertyTo (mID,readVecVector4f(cValue))){
+ free(cValue);
return;
-
- delete(cValue);
+ }
+ free(cValue);
}
//TODO: I am sure this can be done much nicer...
View
@@ -261,6 +261,7 @@ void Renderer::registerProperties(){
createMemberID("BUSEBLENDING",&bUseBlending, this,true,"10BoolButton");
createMemberID("BMULTISAMPLE",&bMultisample,this,false);
createMemberID("BSSAO",&bSSAO,this,true,"10BoolButton");
+
createMemberID("BDRAWCOLOR",&bDrawColor,this,true,"10BoolButton");
createMemberID("BSHADOWPASS",&bShadowPass,this,true,"10BoolButton");
createMemberID("BDOF",&bDOF,this,true,"10BoolButton");
@@ -2614,7 +2615,8 @@ bool Renderer::LoadTextureTGA( string filename, bool wrap, bool bAlpha, string t
// build our texture and mipmaps
if (bAlpha)
- glTexImage2D( GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, FreeImage_GetWidth(myBitmap), FreeImage_GetHeight(myBitmap), 0, GL_BGRA, GL_UNSIGNED_BYTE, FreeImage_GetBits(myBitmap) );
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, FreeImage_GetWidth(myBitmap), FreeImage_GetHeight(myBitmap), 0, GL_BGRA, GL_UNSIGNED_BYTE, FreeImage_GetBits(myBitmap) );
+ //glTexImage2D( GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, FreeImage_GetWidth(myBitmap), FreeImage_GetHeight(myBitmap), 0, GL_BGRA, GL_UNSIGNED_BYTE, FreeImage_GetBits(myBitmap) );
else
glTexImage2D( GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB, FreeImage_GetWidth(myBitmap), FreeImage_GetHeight(myBitmap), 0, GL_BGR, GL_UNSIGNED_BYTE, FreeImage_GetBits(myBitmap) );
View
@@ -299,6 +299,7 @@ void UdpInput::createNewInputConnect(Vector4f btnColor, std::string btnName, uns
inputConnectButtons.push_back(myBtn);
myBtn->setup();
+ cout << "generating new InputConnectButton..." << endl;
//create a field for the actor target reference - use NULL
if (numInputs>=targetActors.size())
View
@@ -1,6 +1,6 @@
<?xml version="1.0" ?>
<Moviesandbox>
- <Settings WindowSizeX="1280" WindowSizeY="720" ScreenSizeX="1280" ScreenSizeY="720" bWarpMouse="0" bFullScreen="0" BackgroundTex="NULL" bDrawLighting="0" bMultisample="1" numSamples="2" ShadowSize="1.0" LightingSize="1.0" SceneSize="1.0" MouseSensitivity="0.08" MoveSpeed="4.0" FOV="45" SceneTemplateName="blank.scene" StartProject="C:/Moviesandbox/projects/balda/" />
+ <Settings WindowSizeX="1920" WindowSizeY="1080" ScreenSizeX="1920" ScreenSizeY="1080" bWarpMouse="0" bFullScreen="0" BackgroundTex="grey_bkg" bDrawLighting="0" bMultisample="1" numSamples="2" ShadowSize="1.0" LightingSize="1.0" SceneSize="1.0" MouseSensitivity="0.08" MoveSpeed="10.0" FOV="45" SceneTemplateName="blank.scene" StartProject="C:/Moviesandbox/projects/balda/" />
<ExternalInput taskName="moviesandbox" filenameWin32="./Moviesandbox.exe" filenameOSX="./Moviesandbox.app/Contents/MacOS/Moviesandbox" filenameLinux="./Moviesandbox" />
<ExternalInput taskName="kinectInput" filenameWin32="tools/msbKinect/msbKinect.exe" filenameOSX="tools/msbKinect/msbKinect.app/Contents/MacOS/msbKinect" filenameLinux="tools/msbKinect/msbKinect" />
<ExternalInput taskName="audioInput" filenameWin32="tools/AudioTool.exe" filenameOSX="NULL" filenameLinux="NULL" />
Binary file not shown.
View
@@ -1,40 +1,79 @@
-uniform sampler2D tex;
-uniform vec4 postColor;
-uniform bool bComputeLight;
-uniform float objectID;
+uniform sampler2D tex;
+uniform vec4 postColor;
+uniform bool bComputeLight;
+uniform float farClip;
+
+varying float zPos;
+varying float oID;
+
+float unpackToFloat(vec4 value){
-varying vec3 N;
-varying float backSide;
+ const vec4 bitSh = vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0);
+
+ return dot(value, bitSh);
+}
+
+vec4 packToVec4(float value){
+
+ const vec4 bitSh = vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0);
+ const vec4 bitMsk = vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
+ vec4 res = fract(value * bitSh);
+ res -= res.xxyz * bitMsk;
+
+ return res;
+}
+
+vec3 packToVec3(float value){
+
+ const vec3 bitSh = vec3(255.0 * 255.0, 255.0, 1.0);
+ const vec3 bitMsk = vec3(0.0, 1.0 / 255.0, 1.0 / 255.0);
+ vec3 res = fract(value * bitSh);
+ res -= res.xxy * bitMsk;
+
+ return res;
+}
+
+vec2 packToVec2(float value){
+
+ const vec2 bitSh = vec2(255.0, 1.0);
+ const vec2 bitMsk = vec2(0.0, 1.0 / 255.0);
+ vec2 res = fract(value * bitSh);
+ res -= res.xx * bitMsk;
+
+ return res;
+}
+
-varying float zPos;
-varying vec4 picking;
void main(){
vec4 color = texture2D(tex,gl_TexCoord[0].st);
+ vec4 objColor=color * gl_Color;
//black if not facing light
- gl_FragData[0]=color * gl_Color;//* postColor;
-
- if (gl_FragData[0].a<0.5)
- gl_FragData[0].r=1.0;
+ objColor.r=floor(objColor.r*100.0)/100.0 ;
+ objColor.r=max(0.0,objColor.r);
-
- //transparency...
- if (gl_FragData[0].a < 0.1){
- discard;
- }
- else{
+ //transparency...
+ if (objColor.a < 0.9){
+ discard;
+ }else{
gl_FragDepth=gl_FragCoord.z;
- gl_FragData[1]=vec4(N.x ,N.y ,N.z, zPos );
- }
-
- if (!bComputeLight)
- gl_FragData[1]=vec4(-100.0 ,0.0 ,0.0, zPos );
+ }
- gl_FragData[2]=picking;
+ if (!bComputeLight){
+ if (objColor.r>0.1){
+ objColor.r-=0.004;
+ }else{
+ objColor.r+=0.004;
+ }
- gl_FragData[3]=vec4(0.0,0.0,0.0,1.0);
+ //do not do blending between compute and non-compute light!
+ objColor.a=1.0;
+ }
+ gl_FragData[0]=objColor;
+ gl_FragData[1].xy=packToVec2(zPos);
+ gl_FragData[1].zw=packToVec2(oID);
}
View
@@ -5,12 +5,11 @@ uniform mat4 cameraInverse;
uniform float particleMultiplier;
uniform float particleAngleScale;
uniform float objectID;
+uniform float farClip;
varying float zPos;
-varying vec4 picking;
+varying float oID;
-varying vec3 N;
-varying float backSide;
/*
* Point Size
@@ -35,6 +34,7 @@ float pointSize(){
* Main
*/
+
void main(){
//texturing
@@ -43,18 +43,17 @@ void main(){
//reset gl_Vertex coordinate or we create weird distortions!
vec4 myVertex=gl_Vertex;
- myVertex.x+=0.01 * sin(time * 0.0001 + myVertex.y+objectID);
- myVertex.y+=0.01 * sin(time * 0.001 + myVertex.z);
- myVertex.w=1.0;
-
- N = gl_NormalMatrix * gl_Normal;
gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * myVertex;
+ myVertex.x+=0.01 * sin(time * 0.001 + myVertex.y+objectID);
+ myVertex.y+=0.2 * sin(time * 0.002 + gl_Position.x);
+ myVertex.w=1.0;
+
+ gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * myVertex;
gl_PointSize= pointSize();
- picking = cameraInverse * gl_ModelViewMatrix * myVertex ;
- picking.w = objectID;
- zPos=gl_Position.z;
+ zPos=gl_Position.z/farClip;
+ oID= (objectID+100.0) /1024.0;
}
@@ -249,11 +249,12 @@ vec4 computeLight(){
float att=max( 0.0 , (gl_LightSource[0].linearAttenuation - dist)/gl_LightSource[0].linearAttenuation );
colorLight.xyz=att * NdotL *1.0 * lightColor;
+ //colorLight.xyz= NdotL *1.0 * lightColor;
if (NdotL>0.0 && specularExp >0){
vec3 NH = normalize(lightDirectionNormalized - camZ );
- colorLight.xyz+=1.0 * lightColor * pow(max(0.0, dot(pixelNormal,NH)),specularExp );
+ colorLight.xyz*=1.0 * lightColor * pow(max(0.0, dot(pixelNormal,NH)),specularExp );
}
@@ -290,20 +291,19 @@ vec4 shadowMapping(){
ssShadow=(ssShadow* 0.5) + 0.5;
- vec4 shadowColor=texture2D(shadowTex, ssShadow.xy,1.0 );
- // vec4 shadowColor=blur3(shadowTex, ssShadow.xy,0.0 );
+ // vec4 shadowColor=texture2D(shadowTex, ssShadow.xy,0.0 );
+ vec4 shadowColor=blur3(shadowTex, ssShadow.xy,1.0 );
shadowColor.x = unpackToFloat(shadowColor.rg) * farClip;
if (ssShadow.x<1.0 && ssShadow.x > 0.0 && ssShadow.y<1.0 && ssShadow.y >0.0){
float falloff = shadowCoord.z - shadowColor.x;
if (falloff<1.0 ){
- myLight+= abs( min (1.0,max( 0.0,(0.1 *shadowColor.x-falloff)/(0.1*shadowColor.x) ) ) ) * computeLight( );
+ myLight+= abs( min (1.0,max( 0.0,(1.0 *shadowColor.x-falloff)/(1.0*shadowColor.x) ) ) ) * computeLight( );
myLight *=1.0-abs( (ssShadow.x-0.5) * 2.0);
//myLight *=1.0-abs( (ssShadow.y-0.5) * 2.0);
}
}else
myLight+= 0.0;
-
return myLight;
}
@@ -315,7 +315,11 @@ void main(){
getPixelLoc();
//add old lighting data
- gl_FragColor= texture2D(tex, texCoord)+ shadowMapping();
+ gl_FragColor= texture2D(tex, texCoord) + shadowMapping();
+ //gl_FragColor.r=min(1.15,gl_FragColor.r);
+ //gl_FragColor.g=min(1.15,gl_FragColor.g);
+ //gl_FragColor.b=min(1.15,gl_FragColor.b);
+ //gl_FragColor= shadowMapping();
//gl_FragColor= texture2D(tex, texCoord) + computeLight();
//gl_FragColor= computeLight();
//gl_FragColor= vec4(1,0,0,1);
View
@@ -158,7 +158,7 @@ vec4 computeDOF() {
float depthValue= unpackToFloat(texture2D(depthTex, texCoord).rg)*farClip;
- vec4 blurPart=blur(tex, texCoord,3.0);
+ vec4 blurPart=blur(tex, texCoord,1.0);
vec4 sharpPart= texture2D(tex,texCoord,0.0);
sharpPart.a=1.0;
@@ -177,7 +177,7 @@ vec4 computeDOF() {
*/
//linear focus
- float focusDepth=focus/5.0 +1.0;
+ float focusDepth=focus/2.0 +1.0;
//get depth distance to focus:
float combine=abs(depthValue-focus);
//clamp focus:
Oops, something went wrong.

0 comments on commit 99b418a

Please sign in to comment.