Commit Graph

200 Commits

Author SHA1 Message Date
bjorn 8462beef00 Fix/improve alpha cutoff;
The current flag did not work because float shader flags are not
supported.  It was also not very useful because it was per-shader
and did not use the alpha cutoff property of glTF materials.

Instead, let's turn the shader flag into an enable/disable boolean,
and add a scalar material property named "alphacutoff" that gets
read by the glTF importer.

When the alphaCutoff flag is enabled, the material property will be
compared against the pixel's alpha value to decide whether it should
get discarded.
2021-12-28 21:10:52 +02:00
Josip Miskovic 09cc73a988 Move text measuring to Rasterizer 2021-10-21 10:42:11 -07:00
bjorn 0a2f968850 Fix circle uvs;
After changing circle scale from diameter to radius, the uvs broke,
since they are calculated from the position.
2021-10-09 03:52:11 -07:00
bjorn 6b99862d3d Don't always force AMD mode to true!; 2021-10-03 15:31:29 -07:00
bjorn 48d98a701c Use WebGL buffer path on AMD GPUs;
AHHHHHHHHHHHHH
2021-10-03 15:31:17 -07:00
bjorn e2cad4ed81 Fix crash in Material:setTexture; 2021-07-10 09:42:49 -07:00
bjorn 4125796211 Fix shaders with nil stages;
The length was getting kept as zero, need to adjust length when
falling back to default shaders.
2021-06-21 10:22:15 -06:00
bjorn 82b7632cea Require material textures to be 2D; 2021-06-12 14:26:39 -06:00
bjorn 6413a6eda2 Fix Model:getTriangles; Add Lua API; 2021-03-25 12:29:11 -06:00
bjorn e1195a92a0 lovrModelGetTriangles; 2021-03-25 12:29:11 -06:00
bjorn 3a35f81918 Fix underscores not printing;
Signed arithmetic strikes again.  Before the padding was configurable,
padding was just a #define'd constant, so signedness didn't matter.
2021-03-25 12:18:48 -06:00
bjorn a3b791a7e7 Fix Canvas flushing; 2021-03-07 21:19:24 -07:00
bjorn 4f5adbc64c lovr.system; 2021-02-25 09:00:12 -07:00
bjorn 39a4d2c1d5 rm lovr.graphics.triangle; 2021-02-24 17:45:31 -07:00
bjorn 72a54bce2f Support STL models;
Only binary STL files are supported right now, ASCII is more challenging.
2021-02-23 12:07:16 -07:00
bjorn 1145085446 macOS fixes; 2021-02-22 17:07:28 -07:00
bjorn fb1447503b Fix gcc warnings; 2021-02-19 23:44:23 -07:00
bjorn 880d06a1d1 Only enable compute extensions on desktop GL; 2021-02-19 14:09:40 -07:00
bjorn 1757d30a59 Compute shader feature detection adjustment;
- Compute feature requires compute shaders, image load/store, and SSBOs.
- GLSL 330 is always used, instead of changing depending on compute shader extension.
- Explicitly enable compute shaders, image load/store, and SSBO extensions when needed.

This allows implementations that don't support GLSL 430 to run compute shaders,
and keeps the min supported GL version more consistently at GL3.3.
2021-02-19 14:07:27 -07:00
bjorn a2b7e1619d Fix wasm compilation issues; 2021-02-19 09:05:57 -07:00
bjorn 023067ec27 util.h no longer uses atomics; 2021-02-11 16:37:55 -07:00
bjorn 5ae5acfb18 Make Font texture rgba16f;
Sampling from rg11b10f does not appear to work on mobile.
2021-02-10 15:22:30 -07:00
bjorn 0919da4091 Improve MSDF font shader; Add spread/padding settings to Font; 2021-02-10 07:08:29 -07:00
bjorn 9377406854 Fix font wrap issue with spaces;
If a space starts before the wrap limit, but ends after it, the next
word won't wrap properly even though it should.
2021-02-09 08:06:37 -07:00
bjorn 84f65c26e4 Move utf8 back into util; 2021-02-08 20:55:51 -07:00
bjorn 8164e0b6e8 TextureData is now named Image!;
The existing Image construct was renamed StorageImage.
2021-02-08 20:17:47 -07:00
bjorn 8c714c45b0 Clean up some includes; 2021-02-08 11:16:00 -07:00
bjorn 0e318aa46e Make Rasterizer opaque; 2021-02-08 10:58:39 -07:00
bjorn 6d92d54079 Try having arr_t in util; 2021-02-08 18:25:05 -07:00
bjorn bc4cde1653 Adjust lovrRelease signature; 2021-02-08 17:52:26 -07:00
bjorn 3ded60948f rm core/ref; rm lovrAlloc; util does refcounting; 2021-02-08 17:26:44 -07:00
bjorn ed09bc3cfa rm unnecessary newlines in assert messages; 2021-02-07 16:58:50 -07:00
bjornbytes 80a33c0544 mat4_multiply -> mat4_mul;
quat_mul vs. mat4_multiply is inconsistent.  Going with mul over
multiply is consistent with vec3_sub and Lua's __mul metamethod.
2020-11-21 14:32:59 -07:00
bjorn e8db2f8187 Basic cylinder uvs; 2020-11-12 18:08:05 -07:00
bjorn 1e7749a58a Fix MSVC warnings;
It's that time of year.
2020-11-12 18:08:05 -07:00
bjornbytes 5c381ead34 Force set vsync in lovrGraphicsCreateWindow;
Headset drivers are allowed to override the vsync setting if vsync
messes up their frame timing.  The vsync property is effectively a
global piece of state in core/os and doesn't change across restarts
because the window is persistent.  This can mean that if you switch
from a headset driver that wants vsync off (anything except desktop)
to a headset driver that doesn't care what the vsync is (desktop),
you could end up with a vsync setting that doesn't match t.window.vsync.
I think this is a symptom of poor design somewhere and the best solution
to this probem is "to just not have it".  Similar issues exist for, e.g.
the window size (but that one is less weird because at least you were
the one who changed it).  For now we are just going to ensure that
lovr.graphics.createWindow always modifies the vsync property.
Untested, may need to adjust this fix later.
2020-11-02 11:57:02 -07:00
bjorn e12a6b7dc4 Fix WebGL; 2020-11-01 23:11:35 -07:00
bjorn 38875cb399 Fix buffer flushing;
lovrGraphicsMapBuffer had the potential to cause a flush.  Flushing
unmaps buffers.  This meant that during any of the calls to map while
creating a Batch, it was possible to cause a flush and unmap other
buffers that expected to be mapped.  This caused writes to unmapped
pointers and subsequent skipping of calls to glFlushMappedBufferRange.

The fix is to figure out if we need to flush upfront and get it out
of the way before mapping any buffers.
2020-10-29 12:12:34 -06:00
bjorn 6a4779e899 Pico: Reset index buffer binding using vao; 2020-10-19 19:24:18 -06:00
bjorn 0388213be4 Reset camera after lovr.headset.renderTo; 2020-10-02 19:50:00 -06:00
bjorn 96fee538b9 Revert "More strict compute shader test;"
This reverts commit 61abb6f02b.
2020-09-29 17:30:50 -06:00
bjorn dd6e05cf32 Fix timers feature being true on GLES; 2020-09-24 19:04:50 -07:00
bjorn f1447fd69a lovr.graphics.get/setViewPose; lovr.graphics.get/setProjection; 2020-09-24 19:03:37 -07:00
bjorn 61abb6f02b More strict compute shader test;
Some hardware supports ARB_compute_shader but not 4.3, causing
shader compilation failures because currently we switch to GLSL 430
if compute shaders are detected.

Instead, just detect GL 4.3 instead of looking for the compute shader
extension.  This means that compute shaders will sometimes be
unavailable even when they're supported.

It would be possible to improve this by modifying the way shaders
are compiled.  Maybe the highest supported GLSL version should be used,
but this makes shader authoring somewhat more difficult.
2020-09-24 05:29:35 -07:00
bjorn 9b0812c4f9 Disable timer queries on GLES;
They aren't compatible with multiview.
2020-09-19 17:25:54 -07:00
bjorn 2e65d71a74 Prevent mapped buffers from being discarded;
We never try to do this anyway, and the unmapping code in discard
doesn't flush contents so it's better for people to unmap the
buffer themselves before calling discard.
2020-09-19 17:21:37 -07:00
bjorn 61e9c746a8 Buffer sync fix;
It appears that GL_MAP_UNSYNCHRONIZED_BIT interferes with
GL_MAP_INVALIDATE_BUFFER_BIT's ability to discard buffer
contents.  Removing the unsynchronized bit fixes visual
glitches on Intel HD GPUs.
2020-09-19 17:19:34 -07:00
bjorn c7ca7eaa38 Add compute dispatch limit; 2020-09-18 15:19:34 -07:00
bjorn 4f730a89a7 android: fix t.graphics.debug; 2020-09-16 20:40:39 -07:00
bjorn 37522bd8a3 OpenXR: MSAA; 2020-08-26 13:42:42 -06:00