Playmat - A Mode 7 Library
- yetneverdone
- Party member
- Posts: 449
- Joined: Sat Sep 24, 2016 11:20 am
- Contact:
Re: Playmat - A Mode 7 Library
I've tried the demo, and sort of change the code to see the effects. Pretty cool and simple! it's like raycasting(is it?) more in-depth explanation to each function perhaps will help alot?
My GameDev Website
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Going Home:A Pixelated Horror Game
My Repositories!
Follow me lovingly!
Nga pala, pinoy ako.
Re: Playmat - A Mode 7 Library
I know for a fact it's a GLSL compiler optimization thing, i.e. GPU drivers. I use nVidia proprietary drivers 340.96. It's easy to reproduce on any version of LÖVE. It's just something that any shader author should be aware of, if they want their shaders to work in all drivers.Jasoco wrote:What version of Löve do you have? What GPU and drivers? It worked for me on 0.10.2.
Code: Select all
shader = love.graphics.newShader[[
extern float unused;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords)
{
vec4 texturecolor = Texel(texture, texture_coords);
return texturecolor * color;
}
]]
shader:send("unused", 1)
Code: Select all
Error: main.lua:9: Shader uniform 'unused' does not exist.
A common error is to define but not use the variable.
stack traceback:
[C]: in function 'send'
main.lua:9: in main chunk
[C]: in function 'require'
[string "boot.lua"]:429: in function <[string "boot.lua"]:275>
[C]: in function 'xpcall'
Here's a request to keep the values with a special pragma, for debugging: https://www.opengl.org/discussion_board ... -debugging
Even this code, which uses the extern variable but multiplies it by 0.0, errors out, because the compiler is smart enough to know that multiplying a value by 0.0 makes the value irrelevant, and optimizes it out:
Code: Select all
shader = love.graphics.newShader[[
extern int unused;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords)
{
vec4 texturecolor = Texel(texture, texture_coords);
return texturecolor * color * (unused * 0.0 + 1.0);
}
]]
shader:send("unused", 3);
Re: Playmat - A Mode 7 Library
Ahum..yetneverdone wrote:wow, very awesome. Possible to make doom-esque fps?
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
personal page and a raycaster
Re: Playmat - A Mode 7 Library
It's actually more like 3d projection, but instead of an actual z value, the screen's y-position is used.yetneverdone wrote:it's like raycasting(is it?) more in-depth explanation to each function perhaps will help alot?
The further up the screen, the further the points on the texture.
z = screen_y
x/z
y/z
That is basically the core to how it all works, but i don't think i can explain it better than that!
- alberto_lara
- Party member
- Posts: 372
- Joined: Wed Oct 30, 2013 8:59 pm
Re: Playmat - A Mode 7 Library
Thanks! I was looking for something like this
EDIT: I've changed the map for a bigger one and it seems weird now, am I doing something wrong? EDIT 2: The map image has to be a square, right?
EDIT: I've changed the map for a bigger one and it seems weird now, am I doing something wrong? EDIT 2: The map image has to be a square, right?
Re: Playmat - A Mode 7 Library
For now, yes.EDIT 2: The map image has to be a square, right?
I'm already working on it right now, so hopefully it'll be fixed quite soon!
EDIT: It is now fixed! You can check out the newest version at github!
- alberto_lara
- Party member
- Posts: 372
- Joined: Wed Oct 30, 2013 8:59 pm
Re: Playmat - A Mode 7 Library
Thanks!EDIT: It is now fixed! You can check out the newest version at github!
Re: Playmat - A Mode 7 Library
It's impossible to tell whether the variable was nuked by compiler or never existed there in the first place, not without potentially extremely complex and computationally intensive static analysis. If it failed to set shader variable silently, you'd stuck for much longer with typos in variable names. The way it works now is the best possible compromise.pgimeno wrote: The error message comes from LÖVE, almost surely because the LÖVE authors are well aware of that problem. Perhaps a better treatment by LÖVE would be that Shader:send doesn't raise an error when the uniform doesn't exist, but returns a status instead, like the GLSL wiki suggests.
Re: Playmat - A Mode 7 Library
I changed the beginning of the shader to
extern Image map;
extern float x;
extern float y;
extern number zoomx;
extern number zoomy;
extern number fov;
extern number offset;
extern int wrap;
and I was able to make it work on Linux and Android 6. I took a screenshot from Android 6 on landscape image mode.
It looks like that uniforms shouldn't be initialized on the shader.
extern Image map;
extern float x;
extern float y;
extern number zoomx;
extern number zoomy;
extern number fov;
extern number offset;
extern int wrap;
and I was able to make it work on Linux and Android 6. I took a screenshot from Android 6 on landscape image mode.
It looks like that uniforms shouldn't be initialized on the shader.
- alberto_lara
- Party member
- Posts: 372
- Joined: Wed Oct 30, 2013 8:59 pm
Re: Playmat - A Mode 7 Library
I'm using NES zelda map, twice (8192 × 1408 pixels), rendering 1024 sprites and it is still 60 FPS, nice!
Who is online
Users browsing this forum: No registered users and 3 guests