home home

downloads files

forum forum

docs docs

wiki wiki

faq faq

Cube & Cube 2 FORUM


General Thread

by Aardappel on 01/05/2002 01:55, 15499 messages, last message: 12/08/2021 21:22, 8826326 views, last view: 12/09/2021 04:10

for questions, announcements etc.

Go to first 20 messagesGo to previous 20 messages    Board Index    Go to next 20 messagesGo to last 20 messages

#15184: Re: Steps for Greek lang.

by hypernova^ on 08/02/2014 14:31, refers to #15182

When adding code to the game, there aren't really any specified steps to follow. Instead, look at how the current fonts are implemented and study the code surrounding that. After a while, you should have a pretty good idea of what needs to be done. Hope this helped :)

reply to this message

#15185: Adding Depth of field.. help?!

by spikeymikey0196 on 08/03/2014 04:09

okay, so i've been modding away at the cube 2 engine to see how much i can do with it, so far i've got it to the same level tesseract has.. and i've been trying to implement Depth of field and its not working.. the code runs with glsl (tried it with blender) but it doesnt seem to be working for cube 2 :/
is my code wrong or something? o.o

"*/

uniform sampler2D bgl_RenderedTexture;
uniform sampler2D bgl_DepthTexture;
uniform float bgl_RenderedTextureWidth;
uniform float bgl_RenderedTextureHeight;

#define PI 3.14159265

float width = bgl_RenderedTextureWidth; //texture width
float height = bgl_RenderedTextureHeight; //texture height

vec2 texel = vec2(1.0/width,1.0/height);

//uniform variables from external script

uniform float focalDepth; //focal distance value in meters, but you may use autofocus option below
uniform float focalLength; //focal length in mm
uniform float fstop; //f-stop value
uniform bool showFocus; //show debug focus point and focal range (red = focal point, green = focal range)

/*
make sure that these two values are the same for your camera, otherwise distances will be wrong.
*/

float znear = 0.1; //camera clipping start
float zfar = 100.0; //camera clipping end

//------------------------------------------
//user variables

int samples = 3; //samples on the first ring
int rings = 3; //ring count

bool manualdof = false; //manual dof calculation
float ndofstart = 1.0; //near dof blur start
float ndofdist = 2.0; //near dof blur falloff distance
float fdofstart = 1.0; //far dof blur start
float fdofdist = 3.0; //far dof blur falloff distance

float CoC = 0.03;//circle of confusion size in mm (35mm film = 0.03mm)

bool vignetting = true; //use optical lens vignetting?
float vignout = 1.3; //vignetting outer border
float vignin = 0.0; //vignetting inner border
float vignfade = 22.0; //f-stops till vignete fades

bool autofocus = false; //use autofocus in shader? disable if you use external focalDepth value
vec2 focus = vec2(0.5,0.5); // autofocus point on screen (0.0,0.0 - left lower corner, 1.0,1.0 - upper right)
float maxblur = 1.0; //clamp value of max blur (0.0 = no blur,1.0 default)

float threshold = 0.5; //highlight threshold;
float gain = 2.0; //highlight gain;

float bias = 0.5; //bokeh edge bias
float fringe = 0.7; //bokeh chromatic aberration/fringing

bool noise = true; //use noise instead of pattern for sample dithering
float namount = 0.0001; //dither amount

bool depthblur = false; //blur the depth buffer?
float dbsize = 1.25; //depthblursize

/*
next part is experimental
not looking good with small sample and ring count
looks okay starting from samples = 4, rings = 4
*/

bool pentagon = false; //use pentagon as bokeh shape?
float feather = 0.4; //pentagon shape feather

//------------------------------------------


float penta(vec2 coords) //pentagonal shape
{
float scale = float(rings) - 1.3;
vec4 HS0 = vec4( 1.0, 0.0, 0.0, 1.0);
vec4 HS1 = vec4( 0.309016994, 0.951056516, 0.0, 1.0);
vec4 HS2 = vec4(-0.809016994, 0.587785252, 0.0, 1.0);
vec4 HS3 = vec4(-0.809016994,-0.587785252, 0.0, 1.0);
vec4 HS4 = vec4( 0.309016994,-0.951056516, 0.0, 1.0);
vec4 HS5 = vec4( 0.0 ,0.0 , 1.0, 1.0);

vec4 one = vec4( 1.0 );

vec4 P = vec4((coords),vec2(scale, scale));

vec4 dist = vec4(0.0);
float inorout = -4.0;

dist.x = dot( P, HS0 );
dist.y = dot( P, HS1 );
dist.z = dot( P, HS2 );
dist.w = dot( P, HS3 );

dist = smoothstep( -feather, feather, dist );

inorout += dot( dist, one );

dist.x = dot( P, HS4 );
dist.y = HS5.w - abs( P.z );

dist = smoothstep( -feather, feather, dist );
inorout += dist.x;

return clamp( inorout, 0.0, 1.0 );
}

float bdepth(vec2 coords) //blurring depth
{
float d = 0.0;
float kernel[9];
vec2 offset[9];

vec2 wh = vec2(texel.x, texel.y) * dbsize;

offset[0] = vec2(-wh.x,-wh.y);
offset[1] = vec2( 0.0, -wh.y);
offset[2] = vec2( wh.x -wh.y);

offset[3] = vec2(-wh.x, 0.0);
offset[4] = vec2( 0.0, 0.0);
offset[5] = vec2( wh.x, 0.0);

offset[6] = vec2(-wh.x, wh.y);
offset[7] = vec2( 0.0, wh.y);
offset[8] = vec2( wh.x, wh.y);

kernel[0] = 1.0/16.0; kernel[1] = 2.0/16.0; kernel[2] = 1.0/16.0;
kernel[3] = 2.0/16.0; kernel[4] = 4.0/16.0; kernel[5] = 2.0/16.0;
kernel[6] = 1.0/16.0; kernel[7] = 2.0/16.0; kernel[8] = 1.0/16.0;


for( int i=0; i<9; i++ )
{
float tmp = texture2D(bgl_DepthTexture, coords + offset[i]).r;
d += tmp * kernel[i];
}

return d;
}


vec3 color(vec2 coords,float blur) //processing the sample
{
vec3 col = vec3(0.0);

col.r = texture2D(bgl_RenderedTexture,coords + vec2(0.0,1.0)*texel*fringe*blur).r;
col.g = texture2D(bgl_RenderedTexture,coords + vec2(-0.866,-0.5)*texel*fringe*blur).g;
col.b = texture2D(bgl_RenderedTexture,coords + vec2(0.866,-0.5)*texel*fringe*blur).b;

vec3 lumcoeff = vec3(0.299,0.587,0.114);
float lum = dot(col.rgb, lumcoeff);
float thresh = max((lum-threshold)*gain, 0.0);
return col+mix(vec3(0.0),col,thresh*blur);
}

vec2 rand(vec2 coord) //generating noise/pattern texture for dithering
{
float noiseX = ((fract(1.0-coord.s*(width/2.0))*0.25)+(fract(coord.t*(height/2.0))*0.75))*2.0-1.0;
float noiseY = ((fract(1.0-coord.s*(width/2.0))*0.75)+(fract(coord.t*(height/2.0))*0.25))*2.0-1.0;

if (noise)
{
noiseX = clamp(fract(sin(dot(coord ,vec2(12.9898,78.233))) * 43758.5453),0.0,1.0)*2.0-1.0;
noiseY = clamp(fract(sin(dot(coord ,vec2(12.9898,78.233)*2.0)) * 43758.5453),0.0,1.0)*2.0-1.0;
}
return vec2(noiseX,noiseY);
}

vec3 debugFocus(vec3 col, float blur, float depth)
{
float edge = 0.002*depth; //distance based edge smoothing
float m = clamp(smoothstep(0.0,edge,blur),0.0,1.0);
float e = clamp(smoothstep(1.0-edge,1.0,blur),0.0,1.0);

col = mix(col,vec3(1.0,0.5,0.0),(1.0-m)*0.6);
col = mix(col,vec3(0.0,0.5,1.0),((1.0-e)-(1.0-m))*0.2);

return col;
}

float linearize(float depth)
{
return -zfar * znear / (depth * (zfar - znear) - zfar);
}

float vignette()
{
float dist = distance(gl_TexCoord[3].xy, vec2(0.5,0.5));
dist = smoothstep(vignout+(fstop/vignfade), vignin+(fstop/vignfade), dist);
return clamp(dist,0.0,1.0);
}

void main()
{
//scene depth calculation

float depth = linearize(texture2D(bgl_DepthTexture,gl_TexCoord[0].xy).x);

if (depthblur)
{
depth = linearize(bdepth(gl_TexCoord[0].xy));
}

//focal plane calculation

float fDepth = focalDepth;

if (autofocus)
{
fDepth = linearize(texture2D(bgl_DepthTexture,focus).x);
}

//dof blur factor calculation

float blur = 0.0;

if (manualdof)
{
float a = depth-fDepth; //focal plane
float b = (a-fdofstart)/fdofdist; //far DoF
float c = (-a-ndofstart)/ndofdist; //near Dof
blur = (a>0.0)?b:c;
}

else
{
float f = focalLength; //focal length in mm
float d = fDepth*1000.0; //focal plane in mm
float o = depth*1000.0; //depth in mm

float a = (o*f)/(o-f);
float b = (d*f)/(d-f);
float c = (d-f)/(d*fstop*CoC);

blur = abs(a-b)*c;
}

blur = clamp(blur,0.0,1.0);

// calculation of pattern for ditering

vec2 noise = rand(gl_TexCoord[0].xy)*namount*blur;

// getting blur x and y step factor

float w = (1.0/width)*blur*maxblur+noise.x;
float h = (1.0/height)*blur*maxblur+noise.y;

// calculation of final color

vec3 col = vec3(0.0);

if(blur < 0.05) //some optimization thingy
{
col = texture2D(bgl_RenderedTexture, gl_TexCoord[0].xy).rgb;
}

else
{
col = texture2D(bgl_RenderedTexture, gl_TexCoord[0].xy).rgb;
float s = 1.0;
int ringsamples;

for (int i = 1; i <= rings; i += 1)
{
ringsamples = i * samples;

for (int j = 0 ; j < ringsamples ; j += 1)
{
float step = PI*2.0 / float(ringsamples);
float pw = (cos(float(j)*step)*float(i));
float ph = (sin(float(j)*step)*float(i));
float p = 1.0;
if (pentagon)
{
p = penta(vec2(pw,ph));
}
col += color(gl_TexCoord[0].xy + vec2(pw*w,ph*h),blur)*mix(1.0,(float(i))/(float(rings)),bias)*p;
s += 1.0*mix(1.0,(float(i))/(float(rings)),bias)*p;
}
}
col /= s; //divide by sample count
}

if (showFocus)
{
col = debugFocus(col, blur, depth);
}

if (vignetting)
{
col *= vignette();
}

gl_FragColor.rgb = col;
gl_FragColor.a = 1.0;
}"

reply to this message

#15186: Create an one Server

by 4-Tune on 08/04/2014 15:59

Iknow how to create such an one Server, but i can't do it. Could anyone create such a server for me? ....it should be an public server...

reply to this message

#15187: Re: Create an one Server

by hypernova^ on 08/05/2014 00:18, refers to #15186

Would you please explain what you mean by a "one server"? Perhaps I can help.

reply to this message

#15188: Confused and baffled.

by Buggy on 08/05/2014 09:18

I don't suppose anyone knows what I'm doing wrong here?

make[1]: Leaving directory `/home/pi/cube/Saurbraten/trunk/src/enet'
g++ -O3 -fomit-frame-pointer -Wall -fsigned-char -Ishared -Iengine -Ifpsgame -Ienet/include -I/usr/X11R6/include `sdl-config --cflags` -c -o engine/glare.o engine/glare.cpp
In file included from engine/glare.cpp:2:0:
engine/rendertarget.h: In member function ‘void rendertarget::cleanup(bool)’:
engine/rendertarget.h:58:58: error: ‘glDeleteFramebuffersOES’ was not declared in this scope
engine/rendertarget.h:59:59: error: ‘glDeleteRenderbuffersOES’ was not declared in this scope
engine/rendertarget.h: In member function ‘void rendertarget::cleanupblur()’:
engine/rendertarget.h:69:54: error: ‘glDeleteFramebuffersOES’ was not declared in this scope
engine/rendertarget.h:71:55: error: ‘glDeleteRenderbuffersOES’ was not declared in this scope
engine/rendertarget.h: In member function ‘void rendertarget::setupblur()’:
engine/rendertarget.h:83:50: error: ‘glGenFramebuffersOES’ was not declared in this scope
engine/rendertarget.h:84:54: error: ‘glBindFramebufferOES’ was not declared in this scope
engine/rendertarget.h:85:97: error: ‘glFramebufferTexture2DOES’ was not declared in this scope
engine/rendertarget.h:88:55: error: ‘glGenRenderbuffersOES’ was not declared in this scope
engine/rendertarget.h:89:43: error: ‘glGenRenderbuffersOES’ was not declared in this scope
engine/rendertarget.h:90:60: error: ‘glBindRenderbufferOES’ was not declared in this scope
engine/rendertarget.h:91:77: error: ‘glRenderbufferStorageOES’ was not declared in this scope
engine/rendertarget.h:92:112: error: ‘glFramebufferRenderbufferOES’ was not declared in this scope
engine/rendertarget.h: In member function ‘void rendertarget::setup(int, int)’:
engine/rendertarget.h:103:58: error: ‘glGenFramebuffersOES’ was not declared in this scope
engine/rendertarget.h:104:60: error: ‘glBindFramebufferOES’ was not declared in this scope
engine/rendertarget.h:127:89: error: ‘glFramebufferTexture2DOES’ was not declared in this scope
engine/rendertarget.h:128:64: error: ‘glCheckFramebufferStatusOES’ was not declared in this scope
engine/rendertarget.h:153:61: error: ‘glGenRenderbuffersOES’ was not declared in this scope
engine/rendertarget.h:154:76: error: ‘glBindRenderbufferOES’ was not declared in this scope
engine/rendertarget.h:159:96: error: ‘glRenderbufferStorageOES’ was not declared in this scope
engine/rendertarget.h:160:118: error: ‘glFramebufferRenderbufferOES’ was not declared in this scope
engine/rendertarget.h:161:64: error: ‘glCheckFramebufferStatusOES’ was not declared in this scope
engine/rendertarget.h:167:60: error: ‘glBindFramebufferOES’ was not declared in this scope
engine/rendertarget.h: In member function ‘void rendertarget::blur(int, float, int, int, int, int, bool)’:
engine/rendertarget.h:301:150: error: ‘glFramebufferTexture2DOES’ was not declared in this scope
engine/rendertarget.h:302:82: error: ‘glBindFramebufferOES’ was not declared in this scope
engine/rendertarget.h: In member function ‘void rendertarget::render(int, int, int, float)’:
engine/rendertarget.h:433:60: error: ‘glBindFramebufferOES’ was not declared in this scope
engine/rendertarget.h:435:95: error: ‘glFramebufferTexture2DOES’ was not declared in this scope
engine/rendertarget.h:489:60: error: ‘glBindFramebufferOES’ was not declared in this scope
make: *** [engine/glare.o] Error 1

The various somethingsomethingsomethingOES are defined in glext.h, which was included in cube.h where those were defined. But even if I directly include glext.h in that file, it just spits out a bunch of errors about unexpected * before ) and then ends with those exact same issues.

reply to this message

#15189: ..

by Buggy on 08/09/2014 10:59

Nevermind I figured it out a while ago.

reply to this message

#15190: research with cubeengine

by juergenhah on 08/26/2014 09:41

I'm a researcher in the field of spatial cognition that likes to play ego shooters.

We want to use ego shooters to answer following research question: "When do we learn the environment?"

The goal of the research idea is to record all movements from the players and store them. In post processing we want to analyze their behavior.

The question I have for you guys: Is it possible to record the player movements on the server?

Thank you very much!

reply to this message

#15191: Re: research with cubeengine

by Papriko on 08/26/2014 18:04, refers to #15190

Yes, there is both, movie recording and demo recording.
I am not 100% sure on the details, but I think the movie function is just a normal audio/screencap in AVI format, while demos are recorded in their own format and actually contain every player movement, chat messages and what not, even when not on screen.

As I said, I barely use this feature, so I am not entirely sure on the details. Here is a link with the demo-related commands, so you can mess around a little: http://sauerbraten.org/docs/game.html#demo_recording

reply to this message

#15192: offcentered cube

by Quad on 08/27/2014 09:39

If i start sauerbraten the window isnt centered and i cant place it in the right way. Always playing with a frame and not in full screen modus. Can someone help? (By the way i have the right resolution settings)

reply to this message

#15193: Re: offcentered cube

by Papriko on 08/27/2014 18:06, refers to #15192

I usually go for a slightly lower resolution than my screen for windowed mode. For a 1024*768 screen, I use 1024*640 as resolution. It is the easiest way to make sure that the hotbar and the window's bar and all still got room without overlapping and cutting off pieces of the game.

Also, when you alt-tab into another window, Sauer loses the mouse focus. That way you can grab the window and push it around properly.

reply to this message

#15194: Caustics without water

by Jesse_Pinkman2 on 09/08/2014 12:05

Yo,

guess you all know these shiny caustics that appear on all visible walls when you underwater, right?

Well i'm working on a map with a stargate and want to have these caustics-animations on the walls... but i don't want to fill that room with water. Is it possible?

reply to this message

#15195: Re: Caustics without water

by hypernova^ on 09/08/2014 18:13

Hello,

You can add a thin layer of alpha on the surfaces you want the caustics to be on, then you can add the caustics textures to your map's .cfg file, make them slightly transparent and scroll them. I'm not a good mapper at all and there's probably a better way, but this should give you something like what you want. For dealing with texture v-commands I highly recommend this script:

http://quadropolis.us/node/3548

Have fun!

reply to this message

#15196: Re: Caustics without water

by suicizer03 on 09/08/2014 22:55, refers to #15194

Try the next line into your map's config-file;

setshader stdworld
texture 0 "textures/nieb/autumn/leaves.jpg"
texlayer 353 "<rotate:3>brushes/gradient_64.png" 4 5
texscale 0.5

An addition to that would be;
texscroll 0 -0.5

There you go, a texture which isn't using any material to achieve so.
However, it can't make the exact movements like caustics and it can only occupy 2 textures.

If you're too lazy to actually implement that, download the map on the next node on Quadropolis and dive into the well.

http://quadropolis.us/node/3858

But for you're concern; if you really want to do it right, I still would advice you to write a shader in glsl (and OpenGL Assembly). Although probably not the easiest thing to do.

I hope that helped.

P.S.
There one has been made a shader in OpenGL (use "/forceglsl 0" to see so) which actually looks a lot like caustics but isn't supporting glsl shadersettings (as there were no back then). So it's not really useful nowadays.

http://quadropolis.us/node/3090

reply to this message

#15197: thanks

by Jesse_Pinkman2 on 09/10/2014 10:01

thanks guys, i'll look into that.
But actually i just hoped there was an easy and quick solution just to have the same underwater caustics without water. Oh well ;)

Really appreciate your help though.

reply to this message

#15198: Re: thanks

by suicizer03 on 09/10/2014 14:56, refers to #15197

Too bad there never is, else it would have been done already =P.

reply to this message

#15199: Re: offcentered cube

by raz on 09/11/2014 23:40, refers to #15192

@Quad: /fullscreen 1
@4-Tune: There are literally tons of empty servers, and you want to make more? Simply to be an admin? Just deal with being a normal master, and if you want to edit in private and can't do that then go offline instead.

reply to this message

#15200: Re: Create an one Server

by Papriko on 09/12/2014 00:46, refers to #15186

Also, crawling into the buttocks of existing server admins in order to gain admin rights yourself usually is not that hard. Just pick a server where you have a good ping and start being a little slimey-boy (or girl. Whatever).

reply to this message

#15201: HELP

by zephyr on 09/15/2014 02:43

I was fiddling with the settings and accidentally turned the mouse sensitivity up to 1000. Now I can't move my mouse precisely enough to click on anything. Is there any way to turn the mouse sensitivity back down without having to click on options? Obviously, I'm a new user and have some very basic computer and coding knowledge. I'm running Cube 2 on a 2014 Macbook Pro (mavericks os x version 10.9.4) Please respond sometime soon because I am unable to play the gamewith this.

reply to this message

#15202: Re: HELP

by suicizer03 on 09/15/2014 06:27, refers to #15201

press "T" and then "/sensitivity 3" or "/" and then "sensitivity 3".

reply to this message

#15203: ..

by Papriko on 09/23/2014 16:52

Source question: What is the difference between a VARR and a VARFR? I figured out that the additional R apparently defines it as a map variable instead of a local one, but what does the F do? An F prefix turns it into a float, but what is an F suffix?

Or even better: where is the whole stuff defined, so I can look up what all those pre- and suffixes do? I already figured out a lot of 'em, but not all.

reply to this message

Go to first 20 messagesGo to previous 20 messages    Board Index    Go to next 20 messagesGo to last 20 messages


Post a Message

Username

Email

Subject

Body

8 added to 3 =


content by Aardappel & eihrul © 2001-2021
website by SleepwalkR © 2001-2021
42367083 visitors requested 58073176 pages
page created in 0.152 seconds using 9 queries
hosted by Boost Digital