FabricMC / yarn

Libre Minecraft mappings, free to use for everyone. No exceptions.
Creative Commons Zero v1.0 Universal
868 stars 370 forks source link

"draw" vs. "render" #984

Open Runemoro opened 4 years ago

Runemoro commented 4 years ago

When should we use each?

liach commented 4 years ago

so in game stuff is almost all render. gui is like a mix of render and draw for now

natanfudge commented 4 years ago

Rendering or image synthesis is the automatic process of generating a photorealistic or non-photorealistic image from a 2D or 3D model (or models in what collectively could be called a scene file) by means of computer programs.

Draw for simple things (rectangles, circles, buttons; text is a bit on the edge since it's not trivial). Render for complex things/models (items, blocks, entities).

Runemoro commented 4 years ago

But then the question is what do we consider "simple"? Is the sky rendered or drawn? Does the PathfindingDebugRenderer draw or render paths? Is a box drawn or rendered (we currently have drawBox, which calls renderQuad!)? Is text rendered or drawn?

natanfudge commented 4 years ago

I would say for everything you've mentioned it should be render (apart from the PathfindingDebugRenderer since I don't know what that is).

Sollace commented 4 years ago

I use render and draw interchangeably as synonyms. Usually render is for more involved processes whilst draw is a blunt edge.

In places I have used render for public-facing methods and draw for the internal/supporting/general-use util methods as well though.

DreenDex commented 4 years ago

Maybe render for world & 3D stuff and draw for screen & 2D stuff will be fine?

liach commented 4 years ago

Agree, draw for 2d and render for 3d. e.g. drawTexturedRect (mojang called it blit, a 2d operation, before) is 2d, and renderEntity is 3d.

Prospector commented 4 years ago

IMO draw is the basic stuff and rendering is when you put a bunch of draws together. For example, you draw a line, or draw a texture, or draw text. But you render a model.

liach commented 4 years ago

How about a piece of text? should it be draw or render string?

Imo the distinguishing feature for 2d and 3d is the matrix transformation. If there is no transformation involved in one step, I'd call that step and its components "draw"; if there is transformation, I'd call it "render".

For instance, if we draw a string that is the name of an entity, we call it drawing a name. But if we goes to upper level and see how the name is affected by the transforms of the entity or be occluded, we call it rendering a name plate.

Prospector commented 4 years ago

I agree