@@ -126,8 +126,7 @@ RenderCacheVSOutput VS_RenderCacheTerrain(TerrainVertexInput input)
|
||||
output.WorldNormal = tangentToWorld[2];
|
||||
|
||||
// Transform lightmap UV to clip-space
|
||||
float2 texCoord = input.TexCoord;
|
||||
float2 lightmapUV = texCoord * LightmapArea.zw + LightmapArea.xy;
|
||||
float2 lightmapUV = input.TexCoord * LightmapArea.zw + LightmapArea.xy;
|
||||
lightmapUV.y = 1.0 - lightmapUV.y;
|
||||
lightmapUV.xy = lightmapUV.xy * 2.0 - 1.0;
|
||||
output.Position = float4(lightmapUV, 0, 1);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
|
||||
|
||||
#define MATERIAL 1
|
||||
#define MATERIAL_TEXCOORDS 4
|
||||
|
||||
#include "./Flax/Common.hlsl"
|
||||
#include "./Flax/MaterialCommon.hlsl"
|
||||
@@ -19,20 +20,18 @@ Texture2D GridTexture : register(t0);
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 Position : SV_Position;
|
||||
float3 WorldPosition : TEXCOORD0;
|
||||
float2 TexCoord : TEXCOORD1;
|
||||
float2 LightmapUV : TEXCOORD2;
|
||||
float3 WorldNormal : TEXCOORD3;
|
||||
float4 Position : SV_Position;
|
||||
float3 WorldPosition : TEXCOORD0;
|
||||
float2 LightmapUV : TEXCOORD1;
|
||||
float3 WorldNormal : TEXCOORD2;
|
||||
};
|
||||
|
||||
struct PixelInput
|
||||
{
|
||||
float4 Position : SV_Position;
|
||||
float3 WorldPosition : TEXCOORD0;
|
||||
float2 TexCoord : TEXCOORD1;
|
||||
float2 LightmapUV : TEXCOORD2;
|
||||
float3 WorldNormal : TEXCOORD3;
|
||||
float4 Position : SV_Position;
|
||||
float3 WorldPosition : TEXCOORD0;
|
||||
float2 LightmapUV : TEXCOORD1;
|
||||
float3 WorldNormal : TEXCOORD2;
|
||||
};
|
||||
|
||||
float3x3 RemoveScaleFromLocalToWorld(float3x3 localToWorld)
|
||||
@@ -67,7 +66,6 @@ VertexOutput VS(ModelInput input)
|
||||
VertexOutput output;
|
||||
output.WorldPosition = mul(float4(input.Position.xyz, 1), WorldMatrix).xyz;
|
||||
output.Position = mul(float4(output.WorldPosition.xyz, 1), ViewProjectionMatrix);
|
||||
output.TexCoord = input.TexCoord;
|
||||
output.LightmapUV = input.LightmapUV * LightmapArea.zw + LightmapArea.xy;
|
||||
output.WorldNormal = tangentToWorld[2];
|
||||
return output;
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
#ifndef MATERIAL_SHADING_MODEL
|
||||
#define MATERIAL_SHADING_MODEL SHADING_MODEL_LIT
|
||||
#endif
|
||||
#ifndef MATERIAL_TEXCOORDS
|
||||
#define MATERIAL_TEXCOORDS 1
|
||||
#endif
|
||||
#ifndef USE_INSTANCING
|
||||
#define USE_INSTANCING 0
|
||||
#endif
|
||||
@@ -186,10 +189,21 @@ cbuffer DrawData : register(b2)
|
||||
struct ModelInput
|
||||
{
|
||||
float3 Position : POSITION;
|
||||
float2 TexCoord : TEXCOORD0;
|
||||
#if MATERIAL_TEXCOORDS > 0
|
||||
float2 TexCoord0 : TEXCOORD0;
|
||||
#endif
|
||||
#if MATERIAL_TEXCOORDS > 1
|
||||
float2 TexCoord1 : TEXCOORD1;
|
||||
#endif
|
||||
#if MATERIAL_TEXCOORDS > 2
|
||||
float2 TexCoord2 : TEXCOORD2;
|
||||
#endif
|
||||
#if MATERIAL_TEXCOORDS > 3
|
||||
float2 TexCoord3 : TEXCOORD3;
|
||||
#endif
|
||||
float2 LightmapUV : LIGHTMAP;
|
||||
float4 Normal : NORMAL;
|
||||
float4 Tangent : TANGENT;
|
||||
float2 LightmapUV : TEXCOORD1;
|
||||
#if USE_VERTEX_COLOR
|
||||
half4 Color : COLOR;
|
||||
#endif
|
||||
@@ -209,7 +223,18 @@ struct ModelInput_PosOnly
|
||||
struct ModelInput_Skinned
|
||||
{
|
||||
float3 Position : POSITION;
|
||||
float2 TexCoord : TEXCOORD0;
|
||||
#if MATERIAL_TEXCOORDS > 0
|
||||
float2 TexCoord0 : TEXCOORD0;
|
||||
#endif
|
||||
#if MATERIAL_TEXCOORDS > 1
|
||||
float2 TexCoord1 : TEXCOORD1;
|
||||
#endif
|
||||
#if MATERIAL_TEXCOORDS > 2
|
||||
float2 TexCoord2 : TEXCOORD2;
|
||||
#endif
|
||||
#if MATERIAL_TEXCOORDS > 3
|
||||
float2 TexCoord3 : TEXCOORD3;
|
||||
#endif
|
||||
float4 Normal : NORMAL;
|
||||
float4 Tangent : TANGENT;
|
||||
uint4 BlendIndices : BLENDINDICES;
|
||||
|
||||
Reference in New Issue
Block a user