Tag Info

10

Yes, it isn't what we want to do. Matrix multiplication is not communative, which is to say that switching the order produces different things. Think of it this way, if you do these operations: Turn left 90 degrees Go forward 10 meters You end up at a different position then if you did: Go forward 10 meters Turn left 90 degrees This doesn't mean it's ...

9

It's not particularly useful for you but you should definitely leave it at 1. It's used when applying transformations to the model. Matrix multiplication can only multiply numbers, it can't add. That makes moving objects impossible unless the 4th component exists. Let's look at an example: If we want to move the vector \vec v = \begin{bmatrix}a \\ b\\c\...

8

This is Unity's automatic batching systems at work. In order to save you draw calls, when Unity sees multiple (small) models using the same material, it combines them into a single mesh so it can render them all together. To retain each model's individual transformation (translation/rotation/scale) in space, the transforms are baked into the vertex ...

5

The calculation falls apart like so: If every one of those 3 million polygons rasterizes to at least one pixel on average, then doing the operation in the fragment shader still results in it being evaluated (up to) 3 million times, even if your screen or output buffer has only 2 million pixels. If each one rasterizes to two pixels on average, then you might ...

5

gl_Position is a Homogeneous coordinates. Homogeneous coordinates are needed for perspective projection. Note, if a vector vec4(x, y, z, 1.0) is multiplied by a perspective projection matrix, this results in a Homogeneous coordinates. The projection matrix describes the mapping from 3D points of a scene, to 2D points of the viewport. The projection matrix ...

4

why don't you use a transformation matrix and pass it into the shader? Flipping can be done with a negative scale value. But maybe misunderstood you, Iam not sure.

3

It's valid, but you have a limited number of interpolators between the two shader stages, and depending how much data you're sending you may bump into that limit. You'll almost certainly need to split your cbuffer in two - lights per-vertex and lights per-pixel - with the per-vertex buffer containing the bare minimum of data. However, you should also bear in ...

3

TL;DR: Edit your shader compilation to use Shader Model 5.1 or later. With the DirectX 12 API, there is no supported device to date that supports anything less than Direct3D Feature Level 11.0. Therefore, there is no point in using any of the down-level profiles lower than 5.1. See Microsoft Docs The default in most UWP templates if you don't set an ...

3

normalMapping should use TBN, Parallax Mapping should use transpose(TBN), and viewDirection should mul transpose(TBN).

2

The actual root cause of this problem was identified by Felsir in this question. It turns out that an exception was thrown because no shader was applied when drawing primitives using GraphicsDevice. In other words, there was effectively nothing wrong with the shader itself (either using BasicEffect or a custom one). The exception message was misleading. I'm ...

2

This section is not correct: sb.Begin(SpriteSortMode.Deferred, null, null, null, null, basicEffect, camera.Transform); graphicsDevice.DrawUserIndexedPrimitives(PrimitiveType.LineStrip, vertices, 0, vertices.Length, indexData, 0, primitiveCount); sb.End(); You're using a spriteBatch and then bypass it by calling the DrawUserIndexedPrimitives directly. I'm ...

2

First, you are misunderstanding the point of the article; these are not two different kinds of fragment shading. This is just an illustration two different coordinate systems. Which one you use will depend upon which one is more convenient for whatever operations you're doing. Let's take some simple examples: Texture Mapping If you're just doing regular ...

2

You should think of a single pass of a shader as a complete render of the object: first, the vertex shader decides where the vertices should go within the camera's projection then, the rasterizer/interpolator selects which pixels are covered by the mesh and what blended values of the vertex shader output each one should use lastly, the pixel shader decides ...

2

You're using floor in your vertex shader, which runs only once for each vertex. So if you're rendering a standard quad or a blit pass, it only sees 4 UV values: (0, 0), (0, 1), (1, 0), (1, 1). And for numbers like these (if _Pixels is an integer), your formula is a no-op: floor( (0, 1) * _Pixels ) / _Pixels = floor( (0, _Pixels) ) / _Pixels = (0, ...

2

What you're finding here is that drawing the line based on your height above/below the boundary gives inconsistent results: in places where the height changes quickly (steep slopes), the outline ends up being very narrow, or even disappearing at some zooms/camera angles. But in places where the height changes gradually, the outline gets thicker, because the ...

1

If there was just one "proper strategy" or "best way", the API would give you only that one option to ensure everyone got the best outcome. But that's not how gamedev works. Different games have different needs. In one game, every mesh needs texture coordinates and normals and tangents, so they can set up every buffer following that ...

1

I used world space shader to draw Infinite grid sorry I haven't enough time to convert this to glsl but I hope it will help you first you should draw a square in shader: then you can use fraction to repeat the square pattern to make a grid it seems good but it isn't infinite! to make it infinite you can use world space shader nice! you can make your ...

1

One approach is to create AO maps in 3d modelling software (example in blender) and use that in your shader. Shader "Unlit/UnlitColorAO" { Properties { _Color ("Main Color", Color) = (1,1,1,1) //_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} _AOTexture ("AO Texture", 2D) = "white" {} _AOColor ("AO Color", Color) =...

1

The example you're working from is trying to use information encoded in the texture coordinates for some reason (something you didn't replicate in your version), invoking unnecessary trig. I'd just throw that out if all you want is cubes and spheres. Just remember to do your morphing in object space, before you project into clip space, not after. v2f vert (...

1

Do the vertices need to be in the [-1,1] range? No. This is only done to improve readability of the code. As long as the model you're using is a cube, and the vertices are all outside the near clip plane of the projection, everything will be fine.* Do I need to use p-c? No. The direction of the vertex, which is what you use to do the texture lookup, is ...

1

Here I'm going to assume your geometry is set up like so: It's a ribbon of quads extending from z = 0 to z = end The z = 0 line will be the outer lip of the roll, and z = end will be the part tucked deepest inside the spiral Each quad in the ribbon will span an equal angle when coiled in the roll (but not an equal length of ribbon: the quads in the tightest ...

1

If, in your case, you want to treat all even numbered vertices different from all odd numbered vertices, then you could use gl_VertexID built in GLSL variable. You could pass in two modelviewprojection matrices, one for type A and one for type B, and apply the one based on the least significant bit of gl_VertexID. if ( gl_VertexID & 1 ) ... If there ...

1

let's Implement It step by step: 1.First you need a way for accessing to color values In texture by shader. 2.Then you can modify vertex shader by color values In your colorful Height map. Step 1 : Accessing to colors In the texture test: Shader "SmkGames/ColorReplacement" { Properties { _MainTex ("Texture", 2D) = "white" {} _TH("...

1

Use a vec4 and a vec2. You can make two calls to glVertexAttribPointer to feed a float[6] from the CPU-side as a vec4 and vec2 in the shader. void glVertexAttribPointer(vec4_index, 4, GL_FLOAT, false, vertex_size, &(my_vertex.faceTextureOffsets[0])); void glVertexAttribPointer(vec2_index, 2, GL_FLOAT, false, ...

1

The use of 'shading' here is a bit off from the typical renderer meaning. The author appears to talk about how texture coordinates are computed. In the first case, texture coordinates are assigned based on the model space positions of the mesh. In the second case, texture coordinates are computed from the position of the vertices in eye space. In a ...

Only top voted, non community-wiki answers of a minimum length are eligible