Slang actually worked.
This commit is contained in:
@ -25,28 +25,6 @@
|
||||
}
|
||||
},
|
||||
|
||||
"plane": {
|
||||
"position": [ 0, 0, 0 ],
|
||||
"components": {
|
||||
"mesh": {
|
||||
"type": "PlaneMesh",
|
||||
"size": [ 512, 512 ],
|
||||
"cells": [ 16, 16 ],
|
||||
"uv": [ 0, 0, 0.33, 0.25 ]
|
||||
},
|
||||
"renderer": {
|
||||
"type": "MeshRenderer"
|
||||
},
|
||||
"mat": {
|
||||
"type": "MapMaterial",
|
||||
"texture": "rosatext"
|
||||
},
|
||||
"map": {
|
||||
"type": "RPGMap"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"rosa": {
|
||||
"prefab": "rosa",
|
||||
"position": [ 0, 0, 0 ],
|
||||
|
BIN
assets/shaders/hello-world.glsl
Normal file
BIN
assets/shaders/hello-world.glsl
Normal file
Binary file not shown.
62
assets/shaders/hello-world.slang
Normal file
62
assets/shaders/hello-world.slang
Normal file
@ -0,0 +1,62 @@
|
||||
|
||||
// Uniform data to be passed from application -> shader.
|
||||
cbuffer Uniforms {
|
||||
float4x4 u_Projection;
|
||||
float4x4 u_View;
|
||||
float4x4 u_Model;
|
||||
float4 u_Color;
|
||||
int u_HasTexture; // Changed from bool to int for compatibility
|
||||
}
|
||||
|
||||
// Per-vertex attributes to be assembled from bound vertex buffers.
|
||||
struct AssembledVertex {
|
||||
float3 position : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
// Output of the vertex shader, and input to the fragment shader.
|
||||
struct CoarseVertex {
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 position : SV_Position; // Needed for rasterization
|
||||
};
|
||||
|
||||
// Output of the fragment shader.
|
||||
struct Fragment {
|
||||
float4 color : SV_Target; // SV_Target is required for color output
|
||||
};
|
||||
|
||||
// Combined Texture and Sampler (avoids linking issues)
|
||||
Texture2D textureMap;
|
||||
SamplerState textureSampler;
|
||||
|
||||
// Vertex Shader
|
||||
[shader("vertex")]
|
||||
CoarseVertex vertexMain(AssembledVertex assembledVertex) {
|
||||
CoarseVertex output;
|
||||
|
||||
// Transform vertex position using Model-View-Projection matrix
|
||||
float4 worldPosition = mul(u_Model, float4(assembledVertex.position, 1.0));
|
||||
float4 viewPosition = mul(u_View, worldPosition);
|
||||
output.position = mul(u_Projection, viewPosition);
|
||||
|
||||
// Pass through texture coordinates
|
||||
output.texcoord = assembledVertex.texcoord;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
// Fragment Shader
|
||||
[shader("fragment")]
|
||||
Fragment fragmentMain(CoarseVertex coarseVertex) {
|
||||
Fragment output;
|
||||
|
||||
// Sample the texture if a texture is bound
|
||||
if (u_HasTexture != 0) {
|
||||
output.color = textureMap.Sample(textureSampler, coarseVertex.texcoord);
|
||||
} else {
|
||||
// Use the uniform color if no texture is bound
|
||||
output.color = u_Color;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
Reference in New Issue
Block a user