Is that a pixel shader? And are those jittery colors artifacts in the image or the shader?
No automerge
Oysi's 3D Rendering & Physics Engine
- Someguynamedpie
- Citizen
- Posts: 71
- Joined: Wed Mar 31, 2010 10:59 pm
Re: Oysi's 3D Rendering & Physics Engine
Got a nice new video with many features! =D
Follow the potato. Achieve enlightenment.
- Sheepolution
- Party member
- Posts: 264
- Joined: Mon Mar 04, 2013 9:31 am
- Location: The Netherlands
- Contact:
Re: Oysi's 3D Rendering & Physics Engine
That's better light than I've seen in real 3D game engines. Looking at you, Blender.
Re: Oysi's 3D Rendering & Physics Engine
Haha. You're probably gonna love my shadows, then. But first I have a video which shows the pendulum-y thingy I made earlier on. It's quite robust, so I should be able to do stuff like attach 2 parts together like that, and also add verlet integration for ropes. Maybe even have the ropes themselves collide with things so you could toss a rope over a long part, or something. =O
ANYWAY...
ANYWAY...
Follow the potato. Achieve enlightenment.
Re: Oysi's 3D Rendering & Physics Engine
Is this going to be released as a library or anything of the sort?
Re: Oysi's 3D Rendering & Physics Engine
I'm not very keen on open source, due to personal reasons. My plan was to make a basic sort of library for people to use, but people would probably just be confused by that. I know I was confused when I was looking at the source code for 3D stuff back when I didn't know anything about it. So instead I started making tutorials. I think that's the best way for me to release my code, really. Because to be quite honest, if I release the current stuff I use, very few people will actually understand it. And while it's fun to play around with the demo (as demonstrated by my brothers, who got captivated it xD), as a programmer it's a whole lot more fun to be able to play around with the code itself. Understand each part of it, so you don't have to do extensive trial & error just to draw a few polygons.adnzzzzZ wrote:Is this going to be released as a library or anything of the sort?
So, if you already haven't, check out my 3D tutorials on youtube (youtube.com/oysi93). For the tutorials, the source code is in the description.
If you want me to stop making more fancy stuff, and instead just do more tutorials, then please do inform me. =)
Follow the potato. Achieve enlightenment.
-
- Prole
- Posts: 49
- Joined: Thu May 29, 2014 10:56 am
Re: Oysi's 3D Rendering & Physics Engine
Hi Oysi.
I don’t mean to pry, but what is your issue with open source? You don’t seem to have a problem using open sourced code, as you are working with love2d... Why not share back?
I don’t mean to pry, but what is your issue with open source? You don’t seem to have a problem using open sourced code, as you are working with love2d... Why not share back?
--
My OOP implementation:
https://github.com/stefanstr/class-by-gestaltist.git
My dungeon / tiled map generator:
https://github.com/stefanstr/lua_maps_by_gestaltist
My Love2D experiments:
https://github.com/stefanstr/Small-Love2D-Projects
My OOP implementation:
https://github.com/stefanstr/class-by-gestaltist.git
My dungeon / tiled map generator:
https://github.com/stefanstr/lua_maps_by_gestaltist
My Love2D experiments:
https://github.com/stefanstr/Small-Love2D-Projects
- ArchAngel075
- Party member
- Posts: 319
- Joined: Mon Jun 24, 2013 5:16 am
Re: Oysi's 3D Rendering & Physics Engine
To be fair, if Oysi does tutorials on what he has put together somewhat over time, then essentially he does share the code...
Say if he shows how to do simple collision checks of the 3D bodies in a tutorial then he is sharing the code aswell, but true to the idea of helping others (where you give them the knowledge and oppurtunity to achieve a result desired rather than writing the code for the person and leaving them with a small understanding of how the code works).
Im perfectly happy watching these showcases, cause it shows me what I can lookup for when i want to fiddle with such things, sure I need to find and write out the code myself, but its more fun and teaches me exactly what the damn is going on aswell as giving me the result.... (and it teaches me respect for simple 3D games)
Ofcourse i can also ask why isnt any code snippets shared, but if I could actually sit down, listen/watch his tutorials he has so far Ill be ecstatic just being able to turn my silly Blender mishaps into a model in some game!
Ill just wait for that one tutorial on collision handles before avoiding this topic almost entirely, or grow impatient and frantically search the web for snippets to teach me myself...(and isnt self learning better, again)
then again...I like BTW and suffering through used holidays working on a game that is scrapped because I dont like the end gameplay... i must really be into torture eh?
---
Anyhow, Oysi just keep teasing appetites with splendid 3D stuffies done in Love2D...atleast it shows its possible yeah?
Say if he shows how to do simple collision checks of the 3D bodies in a tutorial then he is sharing the code aswell, but true to the idea of helping others (where you give them the knowledge and oppurtunity to achieve a result desired rather than writing the code for the person and leaving them with a small understanding of how the code works).
Im perfectly happy watching these showcases, cause it shows me what I can lookup for when i want to fiddle with such things, sure I need to find and write out the code myself, but its more fun and teaches me exactly what the damn is going on aswell as giving me the result.... (and it teaches me respect for simple 3D games)
Ofcourse i can also ask why isnt any code snippets shared, but if I could actually sit down, listen/watch his tutorials he has so far Ill be ecstatic just being able to turn my silly Blender mishaps into a model in some game!
Ill just wait for that one tutorial on collision handles before avoiding this topic almost entirely, or grow impatient and frantically search the web for snippets to teach me myself...(and isnt self learning better, again)
then again...I like BTW and suffering through used holidays working on a game that is scrapped because I dont like the end gameplay... i must really be into torture eh?
---
Anyhow, Oysi just keep teasing appetites with splendid 3D stuffies done in Love2D...atleast it shows its possible yeah?
Re: Oysi's 3D Rendering & Physics Engine
Implemented my shadows into the thing. =)
I also optimized my physics.
I also added fullscreen. =O
If anyone is interested in how, when I first experimented with shadows, I found this tutorial and this video very helpful.
Essentially what is going on, is that before I render the scene from the camera all normal and nice, I first render it from the sun, and I render only the depth. This is the shadow map itself. Then when I render the scene from the camera, I take the 3d position of the pixel, project it with the sun's projection data, and find the pixel on the shadow map that corresponds to that. I match the depth stored in the map against the depth to the pixel's 3d pos (from the camera). If the depth stored is farther away, that means the pixel is lit. If it's closer, that means something is occluding the pixel, thus not lit.
I have some point light shading going on as well (although not in this demo), but no shadows for them yet.
I also optimized my physics.
I also added fullscreen. =O
If anyone is interested in how, when I first experimented with shadows, I found this tutorial and this video very helpful.
Essentially what is going on, is that before I render the scene from the camera all normal and nice, I first render it from the sun, and I render only the depth. This is the shadow map itself. Then when I render the scene from the camera, I take the 3d position of the pixel, project it with the sun's projection data, and find the pixel on the shadow map that corresponds to that. I match the depth stored in the map against the depth to the pixel's 3d pos (from the camera). If the depth stored is farther away, that means the pixel is lit. If it's closer, that means something is occluding the pixel, thus not lit.
I have some point light shading going on as well (although not in this demo), but no shadows for them yet.
Follow the potato. Achieve enlightenment.
Re: Oysi's 3D Rendering & Physics Engine
Here are those point lights:
And it is actually quite interesting how it works. Because I didn't find a way to send structs to the shader, so I just sent a bunch of vec3 arrays. The below code shows the creation of the data and the sun. Interestingly, the sun is just a point light that is very far away and has constant attenuation. Which really just gives the same effect as a directional light, but I was too lazy to make different systems. Next up I will add that, and also do spot lights with shadows. So anyway, each index represents a light's data. lightPos is, well, position. lightAtt is the attenuation, where the x=constant, y=linear, z=quadratic. And lightCol is the color. (Cutting off the names so they align =D)
And then it's sent to the shader like this:
And to be nice, here's the code that actually does the shading, which also covers some of the shadow mapping. (I added comments to explain things)
If you have any questions, feel free to ask.
(gotta take this open source thing one step at a time)
And it is actually quite interesting how it works. Because I didn't find a way to send structs to the shader, so I just sent a bunch of vec3 arrays. The below code shows the creation of the data and the sun. Interestingly, the sun is just a point light that is very far away and has constant attenuation. Which really just gives the same effect as a directional light, but I was too lazy to make different systems. Next up I will add that, and also do spot lights with shadows. So anyway, each index represents a light's data. lightPos is, well, position. lightAtt is the attenuation, where the x=constant, y=linear, z=quadratic. And lightCol is the color. (Cutting off the names so they align =D)
Code: Select all
local lightPos = {}
local lightAtt = {}
local lightCol = {}
lightPos[1] = vec3.new(10, 15, -20):unit() * 1e10
lightAtt[1] = vec3.new(1, 0, 0)
lightCol[1] = vec3.new(1, 1, 1)
Code: Select all
shaders.mainShader.shader:sendInt("numLights", #lightPos)
shaders.mainShader.shader:send("lightPos", unpack(lightPos))
shaders.mainShader.shader:send("lightAtt", unpack(lightAtt))
shaders.mainShader.shader:send("lightCol", unpack(lightCol))
Code: Select all
// Lights
for (int i = 0; i < numLights; i++) {
vec3 pos = lightPos[i];
vec3 att = lightAtt[i];
vec3 col = lightCol[i];
vec3 dif = pos - p; // vector from the 3D pixel position to the light position
if (dot(dif, n) > 0.0) { // make sure the normal is facing the light
vec3 lightDir = normalize(dif);
float dist = length(dif);
float atten = 1.0 / (att.x + att.y*dist + att.z*dist*dist); // calculate attenuation
bool shade = true; // ugly hax to make shadows only work for light 0
// Shadows for directional light
if (i == 0) {
// project the 3D position of the pixel into the sun's view
vec3 proj = (sunInv * vec4(p, 1.0)).xyz;
float z = -proj.z;
float x = 0.5 + 0.5*proj.x/z * sunfMul;
float y = 0.5 - 0.5*proj.y/z * sunfMul;
// get the pixel stored in the shadow map (a depth buffer) at that pixel
vec4 dc = texture2D(sunMap, vec2(x, y));
float d = dc.r*255.0*255.0 + dc.g*255.0 + dc.b; // convert my depth format to a float
if (dc.a == 1.0 && z > d + 0.01) // if the pixel is occluded by another object, don't shade it
shade = false;
}
// Do shading
if (shade) {
// Diffuse
float diff = dot(n, lightDir);
if (diff > 0.0)
color += texColor.rgb * diff * col * atten; // add to main color
// Specular
vec3 R = dir - 2.0*n*dot(n, dir); // reflect 'dir' on 'n'
float spec = dot(R, lightDir);
if (spec > 0.0)
color += col * pow(spec, 50.0) * 0.5 * atten; // add to main color
}
}
}
(gotta take this open source thing one step at a time)
Follow the potato. Achieve enlightenment.
Who is online
Users browsing this forum: Ahrefs [Bot] and 9 guests