SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Editing

Reply
 
Thread Tools Search this Thread
Old 1 Week Ago   #1
Ors
Custom User Title
 
Ors's Avatar
Default Ors' Random Whims

I think I need a thread for my projects in case I'll do them as much as I've planned to do. (Extremely unlikely) I was a little bored and wanted to do some stuff with Lua.

I recently tried some graphical things with OpenGL, and I thought why not drawing triangles and stuff in Lua as well. I haven't also seen easy RGB colors in SRB2's Lua before. Here are two things I'd like to show in action: A function that draws triangles, and a function that converts RGB-values to SRB2's Palette.

This is what the drawing function looks like:
Spoiler: code
Code:
//The main Drawing function
local function DrawScene(v, p)
	// Setting up points for a triangle
	local p1 = vec2(100 + cos(20000000*leveltime)*100/FRACUNIT, 0)
	local p2 = vec2(160, 50+sin(15000000*leveltime)*50/FRACUNIT)
	local p3 = vec2(50+sin(10000000*leveltime)*50/FRACUNIT, 160)
	// RGB color for the triangle
	local r = sin(20000000*leveltime)
	local g = sin(-20000000*leveltime)
	local b = sin(20000000*leveltime)
	// Draw the triangle (point1, point2, point3, color, drawer)
	DrawTriangle2D(p1, p2, p3, ColorToPalette(vec3(r, g, b)), v)
	// Draw the gradient color thing pixel by pixel
	// Demonstrating the function that converts RGB values to palette colors
	for i = 0, 31
		for j = 0, 31
			r = i*FRACUNIT/32
			g = j*FRACUNIT/32
			b = FixedMul(r,g)
			v.drawFill(100+i, 50+j, 1, 1, ColorToPalette(vec3(r, g, b)))
		end
	end
end


And here's the result:
__________________
Custom signature!

Last edited by Ors; 1 Week Ago at 09:04 PM.
Ors is offline   Reply With Quote
Old 1 Week Ago   #2
Xkower8181
btw do not touch the sonic
 
Xkower8181's Avatar
Default

Quote:
Originally Posted by Ors View Post
Spoiler: Triangles


Soo...

Sonic R-obo Blast 2 when?
__________________
Spoiler:
hi you just wasted some second of your live on this
enjoy
Xkower8181 is offline   Reply With Quote
Old 1 Week Ago   #3
Ors
Custom User Title
 
Ors's Avatar
Default

Quote:
Originally Posted by Xkower8181 View Post
Soo...

Sonic R-obo Blast 2 when?
When someone makes as optimized and fast Lua than the original SRB2's code =P

Anyway, a little progress has been made. Rotation matrices rotate the cubes, the world when camera rotates, and the player and its movements. Projection is done by dividing xy-coordinates by z (or yz by x, conversion is done in the calculations). After that we check if we can draw a triangle. If its points aren't behind the player and its points' projection's determinant is greater than 0, we can.


(Btw, the models are drawn in the right order. There's no depth comparison at the moment)

EDIT:
Let's actually show the cubes from another direction for lulz =P
__________________
Custom signature!

Last edited by Ors; 1 Week Ago at 11:29 AM. Reason: Lulz
Ors is offline   Reply With Quote
Old 1 Week Ago   #4
Larztard
Yeah...
 
Larztard's Avatar
Default

This is pretty interesting so far. I wonder what you're doing will all this...?
__________________
YouTube
Larztard is offline   Reply With Quote
Old 1 Week Ago   #5
Ors
Custom User Title
 
Ors's Avatar
Default

Quote:
Originally Posted by Larztard View Post
This is pretty interesting so far. I wonder what you're doing will all this...?
Nice question. So far, this has been made just for the fun of doing it. Maybe there'll be some application for this later.
__________________
Custom signature!
Ors is offline   Reply With Quote
Old 1 Week Ago   #6
Smith The Icefox
CHI DONT BREAK THIS FREAKIN
 
Smith The Icefox's Avatar
Default

Sonic LSD Blast 2?
Great idea...
__________________
My Discord: Code#2962|Netgames Name: Kye or Code
Always looking for a trustable pal
Smith The Icefox is offline   Reply With Quote
Old 1 Week Ago   #7
Lach
Latch? Lock?? Lack???
 
Lach's Avatar
Default

That's amazing. I wish I understood how to program 3D space using only 2D coordinates.
Lach is offline   Reply With Quote
Old 1 Week Ago   #8
GreenKnight9000
 
GreenKnight9000's Avatar
Default

Quote:
Originally Posted by Ors View Post
When someone makes as optimized and fast Lua than the original SRB2's code =P

Anyway, a little progress has been made. Rotation matrices rotate the cubes, the world when camera rotates, and the player and its movements. Projection is done by dividing xy-coordinates by z (or yz by x, conversion is done in the calculations). After that we check if we can draw a triangle. If its points aren't behind the player and its points' projection's determinant is greater than 0, we can.


(Btw, the models are drawn in the right order. There's no depth comparison at the moment)

EDIT:
Let's actually show the cubes from another direction for lulz =P
Holy assbiscuits!
That REALLY gives me a PS1 vibe!
__________________
Certified Emerald Hunter for online matches
-Known as ThomasTheHedgehog888 in matches-
GreenKnight9000 is offline   Reply With Quote
Old 5 Days Ago   #9
Ors
Custom User Title
 
Ors's Avatar
Default

A function for quadrilaterals instead of triangles makes it slightly easier to draw things and generate models. (and draw the models with less functions called by name, and less phases anyway)

https://gfycat.com/gifs/detail/Gentl...ctingBlackbird
Someone remember Amiga?
__________________
Custom signature!

Last edited by Ors; 5 Days Ago at 04:07 PM. Reason: The restricted-size-GIF was too restricted
Ors is offline   Reply With Quote
Old 5 Days Ago   #10
Katwover
typicality nonsensical
 
Katwover's Avatar
Default

Quote:
Originally Posted by Ors View Post
I was just about to say - this thread brings to mind the Amiga demoscene. Id heavily support the creation of a map with Amiga demo-style graphics if it was possible.
__________________
I like remastering MIDIs? Oh I guess there's no harm in a few minutes of your time.
Katwover is offline   Reply With Quote
Old 4 Days Ago   #11
Jay
I'm lazy, let's face it
 
Jay's Avatar
Default

My gosh, this is incredible. I tried to do something like this once but the wireframe alone was horribly inefficient. What kind of framerates are you getting? Do you plan to add any sort of primitive lighting or texture mapping?
__________________
Quote:
Originally Posted by Jay
breaking news
acativision shoves out another yearly release for Cape CoD
Jay is offline   Reply With Quote
Old 4 Days Ago   #12
Ors
Custom User Title
 
Ors's Avatar
Default

Quote:
Originally Posted by Jay View Post
My gosh, this is incredible. I tried to do something like this once but the wireframe alone was horribly inefficient. What kind of framerates are you getting? Do you plan to add any sort of primitive lighting or texture mapping?
The FPS depends on how many faces you have to draw and how big part of the screen the shapes take. Right now the limit for me is ~150 faces before you can see the frames dropping clearly. I have thought about lighting, and very basic lighting could be reasonably fast. Texture mapping is out of question though. Now the triangles and quadrilaterals are drawn line by line in single color except of pixel by pixel. With textures that would be more complicated. Maybe someone else can try if they have ideas for execution and power in their computers.

Edit: You mentioned wireframes. Don't give up on that.
__________________
Custom signature!

Last edited by Ors; 4 Days Ago at 07:54 PM. Reason: Wireframe
Ors is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:48 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.