Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - ProN3rd

that would be awesome nabz

lol i crashed my graphics card with too much shading -_-
so that topic is out of the question at least for now

but i found some very nice open gl examples in the snippets section, INLINE here i come :)

by the way, i tried many things to make a texture of irregular size (like 237*183)  fit on a billbord rectangle surface but I seems like only texture sizes with a multiple of n^2 work correctly. Can anyone confirm this?
sure it is, i think there is a misunderstanding, i mean not clipping, but edgeclamping.

If i was to use skybox-graphics for the cube, i would have either have to draw 8 objects (all of them being surfaces with different textures), or draw 1 cube-objects that uses a huge textures where each face has differnt texture coordinates.

for the first approach, all edges of the cube dont go smoothly into each other. The 2nd approach has only some edges run smoothly into each other.

The texture is simply not "clamped" to the edge of the surface. As far as i read in the internet this seems to be a commond problem that occurs especially on skyboxes. OpenGL therefore provides to command "Clamp_to_edge". However i do not know how to include it in GLBasic.

This is exactly what i mean: It describes the problem along with the solution and a screenshot.

i had some problems with clipping of the skybox and i read somewhere that i need the following Open GL Command to include right after i set the texture of the skycube:

Code (glbasic) Select


if i could just find a way to make it work.  :giveup:  I have some example from the 2d scaling system which makes GL_LineWidth work, but i cant derive from that how I would figure out how to make the above commands work. Any help is very appreciated  :nw:
hey i was wondering about the practical implications of such an entity component system based approach for smaller projects. I sure see the advantages for enormous projects that involve many people and years of development. But what about a small indie game that only consists of a few thousand lines? There is so much exception handling going on, i couldnt even image how to realize this effecintly with an entity approach.
thanks erico, this helps a lot, glad to hear you also making progress

i was so busy the last days gonna check this all out in detail later.

yes cameraup, is quite shifted, i prefer to move the camera instead of objects, i heared this doenst make a difference and camera movement is more logical to me, but i guess the usual way is to move objects. Not sure about that
nice example erico, this is exactly what i mean. Stepping with the cam in the shadow makes the shadow disspear

do you think its a bug, or what could it possibly mean?

for fov, i think you cant choose values that are so low like 15. The scene will be totally distorted. I guess usual values range from 60-100?
ah yes i see, but just brings it back to the usual problem :)
i tried fov 15, but the shadow still dissapears when the camera is fully in the shadow, it only took a bit longer since you moved the camera -200. at this point the player sphere is already out of the obstacle shadow.

oh dear I just removed the skybox and now i get very weired results: i dont get any shadow at all... ... until i step infront of the obstacle.

lol, its like the opposite effect, the shadow is illuminated and appears when i step with the camera "inside it". completly the opposite and weired. Maybe its not a bug after all, but still its not working and i would need a skybox in any case :D

but probably it has something to do with the skybox, why should i not see a shadow in the first place when it is removed?

Code (glbasic) Select

                //Draw skybox   
            //            X_CULLMODE -1
             //           X_DRAWOBJ skybox,0
             //           X_CLEAR_Z
               //         X_CULLMODE 1
I have recreated an example that shows exactly my problem in a few lines. Use ArrowUp and ArrowDown to control the player into the shadow. As soon as the player is fully in the shadow of the wall (tunnel), the shadow dissapears, meanwhile I will further check on your responses. thanks again for all your help

Code (glbasic) Select

//Utility Class

//Create Coordinates
GLOBAL pl AS Txyz ; pl.x = -0; pl.y = 0; pl.z = 10 //Player
GLOBAL cam AS Txyz ; cam.x = -50; cam.y = 0; cam.z = 10 //Cam
GLOBAL li AS Txyz ; li.x = -100; li.y = -400; li.z = 500 //Light
GLOBAL pr AS Txyz ; pr.x = 0; pr.y = 0; pr.z = -250 //Road
GLOBAL po AS Txyz ; po.x = 100; po.y = -75; po.z = 0 //Obstacle (Wall)

//Create Objects
GLOBAL player = GENX_OBJ() ; CreateSphere(player,5,10,RGB(255,0,0))
GLOBAL skybox = GENX_OBJ() ; CreateCube(skybox,3000,RGB(40,40,100))
GLOBAL road = GENX_OBJ() ; CreateCube(road,500,RGB(100,100,100))
GLOBAL obstacle = GENX_OBJ(); CreateCube(obstacle,100,RGB(130,10,130))

X_MAKE3D 1,2000,90
X_CAMERA cam.x,cam.y,cam.z,pl.x,pl.y,pl.z
//Draw skybox
X_DRAWOBJ skybox,0
//Draw scene
X_MOVEMENT pr.x,pr.y,pr.z ; X_DRAWOBJ road,0
X_MOVEMENT po.x,po.y,po.z ; X_DRAWOBJ obstacle,0
X_MOVEMENT pl.x,pl.y,pl.z ; X_DRAWOBJ player,0
//Shadow light
X_SPOT_LT -3,0,li.x,li.y,li.z,0,0,0,360
//Draw scene again
X_MOVEMENT pr.x,pr.y,pr.z ; X_DRAWOBJ road,0
X_MOVEMENT po.x,po.y,po.z ; X_DRAWOBJ obstacle,0
X_MOVEMENT pl.x,pl.y,pl.z ; X_DRAWOBJ player,0

//Movement Player
IF KEY(200); INC pl.x; INC cam.x; ENDIF
IF KEY(208); DEC pl.x; DEC cam.x; ENDIF

//Utility Functions

FUNCTION CreateSphere: num, r, n, col
LOCAL i,j, theta1, theta2, theta3, pi
pi = ACOS(0)*2
IF r < 0 THEN r = -r
IF n < 4 THEN n = 4

X_AUTONORMALS 2 // smooth edges
FOR j=0 TO INTEGER(n/2) -1
theta1 = j * 2*pi / n - pi/2;
theta2 = (j + 1) * 2*pi / n - pi/2;
FOR i=0 TO n
theta3 = i * 2*pi / n;
X_OBJADDVERTEX r*COS(theta2) * COS(theta3), r*SIN(theta2), _
r*COS(theta2) * SIN(theta3), i/n, 2*(j+1)/n, col
X_OBJADDVERTEX r*COS(theta1) * COS(theta3), r*SIN(theta1), _
r*COS(theta1) * SIN(theta3), i/n, 2*j/n, col

FUNCTION CreateCube: num, sz, col
// Diese Variablen sind als LOCAL definiert:
// num, sz,
X_AUTONORMALS 1 // For a cube, hard edges
// Front Face
X_OBJADDVERTEX  sz, -sz,  sz, 1, 0, col
X_OBJADDVERTEX -sz, -sz,  sz, 0, 0, col
X_OBJADDVERTEX  sz,  sz,  sz, 1, 1, col
X_OBJADDVERTEX -sz,  sz,  sz, 0, 1, col
// Back Face
X_OBJADDVERTEX -sz,  sz, -sz, 1, 1, col
X_OBJADDVERTEX -sz, -sz, -sz, 1, 0, col
X_OBJADDVERTEX  sz,  sz, -sz, 0, 1, col
X_OBJADDVERTEX  sz, -sz, -sz, 0, 0, col
// Top Face
X_OBJADDVERTEX -sz,  sz,  sz, 0, 0, col
X_OBJADDVERTEX -sz,  sz, -sz, 0, 1, col
X_OBJADDVERTEX  sz,  sz,  sz, 1, 0, col
X_OBJADDVERTEX  sz,  sz, -sz, 1, 1, col
// Bottom Face
X_OBJADDVERTEX  sz, -sz, -sz, 0, 1, col
X_OBJADDVERTEX -sz, -sz, -sz, 1, 1, col
X_OBJADDVERTEX  sz, -sz,  sz, 0, 0, col
X_OBJADDVERTEX -sz, -sz,  sz, 1, 0, col
// Right face
X_OBJADDVERTEX  sz,  sz, -sz, 1, 1, col
X_OBJADDVERTEX  sz, -sz, -sz, 1, 0, col
X_OBJADDVERTEX  sz,  sz,  sz, 0, 1, col
X_OBJADDVERTEX  sz, -sz,  sz, 0, 0, col
// Left Face
X_OBJADDVERTEX -sz, -sz,  sz, 1, 0, col
X_OBJADDVERTEX -sz, -sz, -sz, 0, 0, col
X_OBJADDVERTEX -sz,  sz,  sz, 1, 1, col
X_OBJADDVERTEX -sz,  sz, -sz, 0, 1, col


i am still having troubles with shading. Its a bit difficult to explain: the scene is rendered nicely with shadows even... but if I step inside the shadow, the shadow dissapears.

i am really struggeling with this. To explain i have enclosed three screenshots, where you see me flying in a tunnel which casts a shadow on the road (example1 and example2), the light source is behind right in the scene. However as soon as I am completly in the tunnel the shadow of the tunnel dissapears (Example3) and doesnt get rendered any more. The tunnel itsself is still rendered but it doesnt block the light any more. the ball is still casting a shadow on the road, which should be impossible as the ball is now fully in the tunnel.

The tunnel constist basically of thin plates using the top and bottom surfaces of the create cube function. The plates are wrapped around the road. I used Cullmode 1.

for the rendering pipeline, its nothing fance with the very basic setup. I didnt include any spotlight (1 to7) or ambient light, neither a 2nd spotlight-3 call at the end (shadows get rendered with the Xmake2d call it sais in the help file).

Make 3d
Set Cam
draw skybox
X Spot Lt -1 at cam pos
draw objects
X spot lt -3 at light source
draw objects again
make 2d
i think such an algorythm can be easly modfied so the buildtrack function gets just random values and creates a new track every time
the actual data for each segment that flows into the createtrack function is saved and loaded using a txt file. Because i dont like to code hard values in the program or type them into the textfile manually, i build a small editor, so you can actually build a track from any kind of segments in real time and save everything, back to the txt file if it needs to be adjusted later. however the editor is buggy at the moment and by no means any better than dealing with plain numbers, but shall be a part of the final programm so one can make custom tracks  =D

here is a screenshot that highlights some features. the obj setting is the "world" editor, where i can include primitives and objects. The track editor is a different thing. As mentioned the track is made of three objects.
Quote from: matchy on 2015-Oct-23
Oh I see now and I will have to check out those showroom samples. The similar race track I had was segmented but only a flat road and any road segment can be added that would go on forever rather than in track loop, like a forever runner phone game. So I am guessing the segments, along with the textures, are imported files or constructed in real time? How is the mapping of the road done? Is it manual or auto seed generated map?  :-[

get ready for cartoon racers  =D

The track is one object (ok basically there are three, but not that important now) and gets build from lots of vertexes at the start of the program. Let me write some pseude code so you get the idea what happens before the mainloop:

Code (glbasic) Select

Function BuildTrack:

LOCAL starttrack = 0

startobj track
addSegment(starttrack, straight,lenght = 200, newheight = 100, number of subsegments etc...)
addSegment(starttrack,curve,lenght = 200, newheight = 0,  number of subsegments etc...)
addSegment(starttrack,looping,lenght = 200, newheight = 0, etc... getting the idea)
addmoreSegments ....

Function AddSegment: byref starttrack, all the other  parameters...,
calculate all x, y,z and whatever needed for subsegments according to the input parameters
calculate the end of this segment to byref it for the next segment later
for i = 0 to number of subsegments
    addvertexes x,y,z  //just usal tex coordinates like when drawing a rectangular surface from 4x vertexes
    addmorevertexes etc....

return startrack (= end of this segment)

OK, now the three objects are: Road, Borders and Decorating things make the bottom and the outer sides. Since Road and Borders only are used for collision testing later and they have different collision formulas, i had to split up the track into more than one objects, so I could "talk" the the borders and the road independently.
Thanks guys for the nice words, but i couldnt have done it without the amazing support of you and all the examples here in the GL Basic community.

The track is generated procedurally. I learned a lot from the "Pseudo 3D" example from the Showroom and the S Zero example. The track is basically build of various segments (which can be straight, curve or looping). Each segment uses of course more inputs than just that, for example the lenght, the roadwidth, the height, and the exact amount of curveture as well as some looping paramenters can be adjusted for each segment. A segment consists of various subsegments, which are the actual triangles that get drawn. So if i need a track that goes forward, curve, forward, looping etc.. i can easly build it within seconds :)

For the orientation each vehicle has three perpendicular unity normal vectors that get rotated according to the normal of the collision surface via a rotation matrix. Smooth camera movement is a bit tricky, i still couldnt find the optimal solution.

At the weekend I will have more time to continue with the project, gonna try out X_Shader command.

Thank you, suddenly things works, cant describe how happy i am  :enc:

Of course I just begin to understand the process: did I get you right that for each light that shall cast a shadow I have to use the complete pipeline?
Such as...
Code (glbasic) Select

For each light
   Set Normal spotlight //(for example light Number 1 with player coordinates)
  // hmm, I included a light with -1 value here as well for bumpmapping, how can this be handled?
   Draw objects
   Turn on shadow spot light //(Number -3 with player coordinates?)
   Draw objects
   Cast shadow spot light color  // (player coordinates, how can i set color?)

anyway i make so much progress and I am greatful for your help. I couldnt get any results with toon shading yet. I wonder how it works. Check this video I just uploaded to youtube, where i am testing todays results: