Page 4 of 15

Re: Textured Polygons for All!

Posted: Thu Jan 24, 2013 1:35 am
by Ref
Still haven't got it locked down - not quite scaling properly - problem somewhere in my script - working on it.
Thought it would simply require dividing by image size - will have to think about this.
Surprised that scaling the texture using your effect was no faster that my primitive approach using separate image fragment for each quad.

Re: Textured Polygons for All!

Posted: Thu Jan 24, 2013 4:09 am
by xXxMoNkEyMaNxXx
It's because your image splitting is pre-processing, and the image scaling was already going on with no effect. :P
Scaling is obviously more memory efficient though. Could I ask for details on what you're having problems with? I'd like to help.

Re: Textured Polygons for All!

Posted: Thu Jan 24, 2013 3:40 pm
by Ref
xXxMoNkEyMaNxXx wrote:It's because your image splitting is pre-processing, and the image scaling was already going on with no effect. :P
Scaling is obviously more memory efficient though. Could I ask for details on what you're having problems with? I'd like to help.
You are most generous. I know hard it is to read other peoples code when not well written.
The demo I posted before (surface_texturing.love) provided the effect I was aiming for.
It was crude and I felt that your pixel effect already provided the same effect more efficiently via 'po' and 'res' settings.
What I did was to strip out from my demo the creation on new images for each quad and tried to add the appropriate scaling factor for 'po' and 'res'.
Removed:

Code: Select all

tmp = li.newImageData( tex.w, tex.h )
tmp:paste( master_image, 0, 0, tx[i], ty[j], tex.w, tex.h )  -- where tx & ty are location on image
img[j][i] = gr.newImage(tmp)	-- image to apply to corresponding quad
and replaced with:

Code: Select all

fragments[j][i] = { tx[i], ty[i], tex.w, tex.h }
where each of the parameters were divided by the image width or image height, as appropriate.
Net effect:
1. resulting pattern not textured the same as the original demo.
2. the display of the unmodified image (simple love.draw without any effects) disapears after the first frame and is replaced by a single line of characters(very small to the right of the main image)?????? - something completely unrelated and which work fine in original demo??? (Never seen before!)
If you are up to the challenge - great but really can't expect you to as I have bastardized you code.
Thanks anyway.

Re: Textured Polygons for All!

Posted: Thu Jan 24, 2013 4:53 pm
by xXxMoNkEyMaNxXx
Why don't you ever use local variables....................
All the equals signs are lined up, it took me ages to find 'cd'
The ends are tabbed in....................
Where did you pick up this terrible habit? ._.
/rage

Are you putting equal portions of the texture into each quad? because the quads themselves are already distorting the image.

Re: Textured Polygons for All!

Posted: Thu Jan 24, 2013 5:25 pm
by Ref
You were warned!
'rep' is receiving { tex.w, tex.h } for each quad so yes - all quads are receiving the same portion of the image.
Only 'op' is being changed.
Think problem is related to how image coordinates are being converted to fractions of the image.
Don't have a clew are to why effect changes love.draw outside pixel effect.
Thanks for looking.
Edit1:
Code is sub-alpha. Only looking for function.
Headed for: tex.draw(texture,quad,tex)
where texture = an image, quad contains 4 vertices & tex contains tex.x, tex,y, tex.width & tex.height
Got first two with only tex remaining.
Regarding coding style, it's called outlining where the most important info is displayed farest to left. Taught in grade school. Obviously, 'end' is not a topic so shouldn't be emphasized. For a final product I generally resort to the lemming style. GLSL syntax seems sub-human after coding in Lua.
Edit2:
OK! Confirmed that you effect functions as advertized. Great job! ~20% faster than my demo.
All a matter of properly converting image coordinates to fractions and insuring that everything stays in bounds - not as simple (until you figure it out) as it might seem. Now to see if there isn't a better (cleaner) way -"So annoying".
Still a mystery as to why the plain image drawn after using your code is corrupted (now a string of characters).
If I load a separate copy of the original image and draw it, everything is displayed appropriately????

Re: Textured Polygons for All!

Posted: Fri Jan 25, 2013 8:39 am
by Jasoco
Thanks to MonkeyMan I now have texture support...

Image

Had to do some recoding and fixing and there was a lot of touch and go for a while, but we pulled through.

Edit: Some problems I've found.

If you use love.graphics.translate() and love.graphics.scale() the image offsets to what it would be if translate and scale were not used.

And a new one, if you use setMode after the module is loaded, it will stop working. I have tried reloading it after resizing the window but it doesn't seem to want to reload itself. So I can't setMode after it's loaded or it will never work again... until it's restarted.

Re: Textured Polygons for All!

Posted: Sun Jan 27, 2013 12:14 am
by Ref
The pest is back.
Textured Polygons for All definitely WORKS with canvases!
Previous demo replaced with corrected (stupid error) one.

Re: Textured Polygons for All!

Posted: Sun Jan 27, 2013 8:20 am
by xXxMoNkEyMaNxXx
So you can't draw to a canvas? I don't really understand what's going on :|

Re: Textured Polygons for All!

Posted: Sun Jan 27, 2013 8:59 am
by IndieKid
And the Raycasting of floors and ceilings is waiting for texture support. :crazy:

Re: Textured Polygons for All!

Posted: Sun Jan 27, 2013 10:30 am
by xXxMoNkEyMaNxXx
@IndieKid If you can get the positions on screen, it will put an image on it, so it should already support that... This basically replaces the part where you call love.graphics.polygon with a funtion that will draw the polygon and put an image on it.