Vertex Shading displays the 4th texture, but does not blend the corner

I'm trying to create a square grid and blending textures with vertex shading. The only problem is a small rectangle in the middle of 4 tiles, it mixes 3 textures, but the 4th texture is somehow "locked"

Mix textures

As you can see, one of the vertices does not match the color of the matching tile.

I suspect I messed up the shader because changing the vertex color assignments seems to work well (except for the alpha channel, which does not change the texture).

Shader "Custom / TileShader" {
Properties {
_Color ("color", color) = (1,1,1,1)
_MainTex ("Terrain Texture Array", 2DArray) = "white" {}
_Gloss ("smoothness", range (0,1)) = 0,5
Metallic ("metallic", range (0.1)) = 0.0
}
SubShader {
Tags {"RenderType" = "Opaque"}
LOD 200

CGprogram
// Physically based standard lighting model, and enable shadows for all lights
#pragma surface surf Default fullforwardshadows vertex: vert

// Use a Shader Model 3.5 Target for more beautiful lighting
#pragma target 3.5

UNITY_DECLARE_TEX2DARRAY (_MainTex);

struct Input {
float4 color: COLOR;
float3 worldPos;
float4 terrain;
};

semi-gloss;
semi-metallic;
fixed4 _Color;

// Add instance support for this shader. You must enable the Enable Instance option for materials that use the shader.
// For more information about instantiating, see https://docs.unity3d.com/Manual/GPUInstancing.html.
// #pragma instancing_options assumes an uneven scaling
UNITY_INSTANCING_BUFFER_START (props)
// set more properties per instance here
UNITY_INSTANCING_BUFFER_END (props)

void vert (inout appdata_full v, out input data) {
UNITY_INITIALIZE_OUTPUT (input, data);
data.terrain = v.texcoord2;
}

float4 GetTerrainColor (Input IN, int index) {
float3 uvw = float3 (IN.worldPos.xz * 0.02, IN.terrain[index]);
float4 c = UNITY_SAMPLE_TEX2DARRAY (_MainTex, uvw);
return c * IN.color[index];
}

Empty surf (Input IN, Inout SurfaceOutputStandard o) {
fixed4 c =
GetTerrainColor (IN, 0) +
GetTerrainColor (IN, 1) +
GetTerrainColor (IN, 2) +
GetTerrainColor (IN, 3);
o.Albedo = c.rgba;
// Metallic and Smoothness come from slider variables
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"

}

opengl – question about shading and passing of normals to shaders – beginners

Hello, I am a beginner of OpenGL. I followed this page until Tutorial 6:
http://www.opengl-tutorial.org/beginner-tutorials/tutorial-6-keyboard-and-mouse/

I am trying to make it a voxel engine, my progress is here: https://github.com/gamedev8787/shaderhelp

In particular, I pass normals in the function createCube. To build, just do `mkdir build; cd build; cmake ..; make & # 39;

But when I run that, I have no shading or anything. Can someone take a look and advise? Many Thanks.

Ask shader:

#version 330 core

uniform vec3 LightPosition_worldspace;
uniform vec3 LightColor_worldspace;
out vec3 color;

in vec3 position_worldspace;
in vec3 normal_cameraspace;
in vec3 EyeDirection_cameraspace;
in vec3 LightDirection_cameraspace;

void main () {
/ *
float ambientStrength = 0.5f;
vec3 ambient = ambientStrength * LightColor_worldspace * objectColor;
Color = ambient light;
* /
vec3 LightColor = LightColor_worldspace;
vec3 Material Ambient Color = vec3 (0.5f, 0.8f, 0.31f);
vec3 Material DiffuseColor = vec3 (1.0f, 0.8f, 0.31f);
vec3 MaterialSpecularColor = vec3 (1,0f, 1,0f, 1,0f);

Swimming distance = length (LightPosition_worldspace - Position_worldspace);
vec3 n = normalize (normal_cameraspace);
vec3 l = normalize (LightDirection_cameraspace);
float cosTheta = clamp (point (n, l), 0,1);

vec3 E = normalize (EyeDirection_cameraspace);
vec3 R = reflect (-l, n);
Float cosAlpha = clamp (point (E, R), 0,1);

Color =
Material Ambient Color +
MaterialDiffuseColor * LightColor * cosTheta / (distance * distance) +
MaterialSpecularColor * LightColor * pow (cosAlpha, 5) / (distance * distance);
}

Vertex shader:

#version 330 core

// Input of vertex data that is different for all executions of this shatter.
Layout (location = 0) in vec3 vertexPosition_modelspace;
Layout (location = 1) in vec3 vertexNormal_modelspace;

// values ​​that remain constant for the entire network.
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform vec3 LightPosition_worldspace;

out of vec3 position_worldspace;
out vec3 normal_cameraspace;
out vec3 EyeDirection_cameraspace;
out vec3 LightDirection_cameraspace;

void main () {
gl_position = P * V * M * vec4 (vertexPosition_modelspace, 1);

Position_worldspace = (M * vec4 (vertexPosition_modelspace, 1)). xyz;
vec3 vertexPosition_cameraspace = (V * M * vec4 (vertexPosition_modelspace, 1)). xyz;
EyeDirection_cameraspace = vec3 (0,0,0) - vertexPosition_cameraspace;
vec3 LightPosition_cameraspace = (V * vec4 (LightPosition_worldspace, 1)). xyz;
LightDirection_cameraspace = LightPosition_cameraspace + EyeDirection_cameraspace;
Normal_cameraspace = (V * M * vec4 (vertexNormal_modelspace, 0)). xyz; // Only correct if ModelMatrix does not scale the model! If not, use inverse transposition.
}

Create a cube

void Chunk :: createCube (GLfloat x, GLfloat y, GLfloat z) {
// Our vertices. Tree consecutive swimmers yield a 3D vertex; Three consecutive vertices result in a triangle.
// A cube has 6 faces, each with 2 triangles. This gives 6 * 2 = 12 triangles and 12 * 3 vertices
GLflat mx = float (x) + block :: BLOCK_RENDER_SIZE;
GLfloat my = float (y) + block :: BLOCK_RENDER_SIZE;
GLflat mz = float (z) + block :: BLOCK_RENDER_SIZE;
GLfloat arr[108] = {
x, y, z,
x, y, mz,
x, my, mz,
mx, my, z,
x, y, z,
x, my, z,
mx, y, mz,
x, y, z,
mx, y, z,
mx, my, z,
mx, y, z,
x, y, z,
x, y, z,
x, my, mz,
x, my, z,
mx, y, mz,
x, y, mz,
x, y, z,
x, my, mz,
x, y, mz,
mx, y, mz,
mx, my, mz,
mx, y, z,
mx, my, z,
mx, y, z,
mx, my, mz,
mx, y, mz,
mx, my, mz,
mx, my, z,
x, my, z,
mx, my, mz,
x, my, z,
x, my, mz,
mx, my, mz,
x, my, mz,
mx, y, mz
};
GLfloat n_arr[] = {
-100,
-100,
-100,
0, 0, -1,
0, 0, -1,
0, 0, -1,
0, -1, 0,
0, -1, 0,
0, -1, 0,
0, 0, -1,
0, 0, -1,
0, 0, -1,
-100,
-100,
-100,
0, -1, 0,
0, -1, 0,
0, -1, 0,
0, 0, 1,
0, 0, 1,
0, 0, 1,
100
100
100
100
100
100
0, 1, 0,
0, 1, 0,
0, 1, 0,
0, 1, 0,
0, 1, 0,
0, 1, 0,
0, 0, 1,
0, 0, 1,
0, 0, 1
};
vertices.insert (vertices.end (), std :: begin (arr), std :: end (arr));
normals.insert (normals.end (), std :: begin (n_arr), std :: end (n_arr));
}

Transfer data to GPU

        glEnableVertexAttribArray (0);
glBindBuffer (GL_ARRAY_BUFFER, m_vertexbuffer);
glVertexAttribPointer (
0, // attribute. No special reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE // normalized?
0, // step
(void *) 0 // array buffer offset
);
glDrawArrays (GL_TRIANGLES, 0, (vertices.size () / 3) * 3);
glDisableVertexAttribArray (attribute);
glEnableVertexAttribArray (1);
glBindBuffer (GL_ARRAY_BUFFER, m_normalbuffer);
glVertexAttribPointer (
1 // attribute. No special reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE // normalized?
0, // step
(void *) 0 // array buffer offset
);
glDisableVertexAttribArray (1);

`` `

Product Photography – What's the best way to avoid shading in budget with budget equipment?

first post!

I am a toy collector and like to take photos and videos of my collection. I have a lightbox and a Foldio turntable that's great for my needs because I do not have much room for backdrops and lighting.

Mostly I take quick pictures with my camera phone with automatic settings and adjust the white balance so that the background turns white. Then I choose the exposure in Lightroom.

This sometimes leads to a blue / green shimmer in the shadows (example in the appendix), which I would like to minimize in the future.Enter the image description here

What would you recommend to reduce the color fringe in this setting:

  • I have no place in the lightbox to throw more light into the scenery
  • It's hard to see how much I'm overexposed on the phone's display, but it's not worth setting up and using a DSLR
  • I'd like to minimize post-processing (if possible, I'd really like to add a watermark)

Any tips, no matter how trivial, would be appreciated. Thanks in advance for an amateur!

Illumination – Incorrect shading according to building light

Whenever I build light in Unreal, the light of objects does not seem to reflect properly. This seems to happen in basically everything that I import into the engine

(I use Blender for all my networks)

[DiesistdieLightmapUVStrahlungfüreinemeinerMaschensoweitichweißdassichdiesrichtiggemachthabeMitInselränderndurcheinandergebrachtabereshilftnicht[ThisisthelightmapUVforoneofmymeshesasfarasi'mawareIhavedonethiscorrectlyMessedaboutwithIslandmarginsbutitdoesn'thelp[DiesistdieLightmap-UV-StrahlungfüreinemeinerMaschensoweitichweißdassichdiesrichtiggemachthabeMitInselränderndurcheinandergebrachtabereshilftnicht[ThisisthelightmapUVforoneofmymeshesasfarasi’mawareIhavedonethiscorrectlyMessedaboutwithIslandmarginsbutitdoesn’thelp1

When you look at the side of the desk, the lighting just seems to randomly pick which parts of the face you want to shadeWhen you look at the side of the desk, the light only seems to randomly choose which parts of the face you want to shade.[[[[2

Some important information you might want increased the resolution of the light, and that did not help.
I've set the lightmap index to 1 to make sure Unreal uses the correct UV, but that does not help.
This lighting setup was previewed, but some objects still produce this mottling effect in production.

r – shading of a non-rectangular area in ggplot with geom_polygon

I'm having trouble shading a non-rectangular region in ggplot. I want to be able to work in the same way as a function of the rethink Package: Shadow() what does that seem to use Polygon () Function. You have to install this rethink () Package. Here are the data and the code for using the base plot, Lines () from graphic Package and shadow from the rethink package.

Library (rethinking)
Data (Howell1)
d <- Howell1
d2 <- d[d$age >= 18,]m4.3 <card (
Alist (height ~ dnorm (mu, sigma),
mu <- a + b * weight,
a ~ dnorm (178, 20),
b ~ dnorm (0, 10),
Sigma-Dunif (0, 50)),
Data = d2)
weight.seq <- seq (from = 25 to 70 = 1)
mu <- link (m4.3, data = data.frame (weight = weight.seq))
mu.mean <- true (mu, 2, mean) # Average of the distributions of the predicted heights for each of the 46 weight values
mu.HPDI <- apply (mu, 2, HPDI, prob = 0.89)

# Represent raw data
# Blanking points make line and intervals more visible
Order (height ~ weight, data = d2, column = Col.alpha (Rangi2, 0.5))

# plot the MAPS line, also known as the mean value for each weight of a candidate in weight.seq
Lines (weight.seq, mu.mean)

# Represent a shaded area for 89% HPDI
Shadow (mu.HPDI, weight.seq)

So a nice, clearly shaded area is visible.

Here's my try in ggplot use geom_polygon, which requires the creation of data frames.

meanDF <- data.frame (weight.seq = weight.seq,
mu.mean = mu.mean)

HPDIDF <- data.frame (weight.seq = weight.seq,
muHPDI_lo = mu.HPDI[1,],
muHPDI_hi = mu.HPDI[2,])
hpdiLong <- gather (HPDIDF, key = lowHi, value = predH, muHPDI_lo, muHPDI_hi) 

Now the graph was

ggplot (d2, aes (weight, height)) +
geom_point (Form = 1, color = "blue") + # represents the original data
geom_line (data = meanDF, aes (weight.seq, mu.mean), size = 1) + # best fit line based on the average of all estimates at each candidate weight value
geom_polygon (data = hpdiLong, aes (weight.seq, predH), fill = "gray") +
theme_classic ()

The resulting shaded area is really unsatisfactory compared to that Shadow() Function. Any idea how that works?

Render a selected part of the terrain with different shading

I'm trying to understand how you can change the shading of the terrain section based on a user selection. When a user selects a city or entity in a game like Civ5, that area is more illuminated than the other parts of the terrain. I try to implement this effect.

In the Civ 5 example, the selected tile has a circle and the selected city has a transparent overlay that closely follows the elevation of the terrain. Civ5 screenshot

Square shading of flower pictures – MathOverflow

I wondered if anyone could help shade these petals. It's half finished, but I just want to shade the inside of the petals.

This is the picture:

Enter the image description here

Here are my previous equations: Enter image description here

I wondered if anyone knew which domain and area restrictions I could add to just shadow the inside of the petal.

Many Thanks