मैं ग्राफिक्स इंजन के रूप में Ogre3D का उपयोग कर रहा हूं।क्या मैं इस सीजी कार्यक्रम के साथ कुछ गलत कर रहा हूं?
मैं एक जाल मैन्युअल जो ठीक काम करता है बनाने के लिए, uvs सही हैं और ग्रिड निर्देशांक प्रतिनिधित्व करने के लिए सेट कर रहे हैं (इस उदाहरण के लिए ग्रिड है एक 10 x 10)
मैं शिखर कार्यक्रम में कुछ भी नहीं है और एक बहुत है सरल टुकड़ा कार्यक्रम। मैंने व्याख्या करने के लिए दोनों कार्यक्रमों और भौतिक फ़ाइल को शामिल किया है।
मेरी समस्या यह है कि रंगों को सेट करने के साथ भी रंग मेरी मूल छवि के समान नहीं दिखता है (यह केवल एक परीक्षण छवि है जिसका उपयोग मैं कर रहा हूं क्योंकि मुझे मैन्युअल रूप से बनावट बनाने में समस्याएं थीं राक्षस)। यह पता चला है कि समस्या ogre में मेरा कोड नहीं है, लेकिन भौतिक फ़ाइल या खंड/वर्टेक्स प्रोग्राम के साथ कुछ करने की संभावना है।
मैंने बाईं ओर आउटपुट का एक स्क्रीनशॉट और दाईं ओर मूल छवि भी शामिल की है। टुकड़ा शेडर भी शीर्ष पर एक साधारण ग्रिड खींचता है ताकि मैं सुनिश्चित कर सकूं कि यूवी समन्वय सही ढंग से पारित किए जा रहे थे। जो वे प्रतीत होते हैं।
किसी भी अंतर्दृष्टि बहुत सराहना की जाएगी के रूप में मैं वास्तव में अनिश्चित क्या im गलत कर रहा हूँ।
सामग्री फ़ाइल:
// CG Vertex shader definition
vertex_program PlainTexture_VS cg
{
// Look in this source file for shader code
source GameObjStandard.cg
// Use this function for the vertex shader
entry_point main_plain_texture_vp
// Compile the shader to vs_1_1 format
profiles arbvp1
// This block saves us from manually setting parameters in code
default_params
{
// Ogre will put the worldviewproj into our 'worldViewProj' parameter for us.
param_named_auto worldViewProj worldviewproj_matrix
// Note that 'worldViewProj' is a parameter in the cg code.
}
}
// CG Pixel shader definition
fragment_program PlainTexture_PS cg
{
// Look in this source file for shader code
source GameObjStandard.cg
// Use this function for the pixel shader
entry_point main_plain_texture_fp
// Compile to ps_1_1 format
profiles arbfp1
}
material PlainTexture
{
// Material has one technique
technique
{
// This technique has one pass
pass
{
// Make this pass use the vertex shader defined above
vertex_program_ref PlainTexture_VS
{
}
// Make this pass use the pixel shader defined above
fragment_program_ref PlainTexture_PS
{
}
texture_unit 0
{
filtering none
// This pass will use this 2D texture as its input
texture test.png 2d
}
texture_unit 1
{
texture textureatlas.png 2d
tex_address_mode clamp
filtering none
}
}
}
}
तटरक्षक फ़ाइल:
void main_plain_texture_vp(
// Vertex Inputs
float4 position : POSITION, // Vertex position in model space
float2 texCoord0 : TEXCOORD0, // Texture UV set 0
// Outputs
out float4 oPosition : POSITION, // Transformed vertex position
out float2 uv0 : TEXCOORD0, // UV0
// Model Level Inputs
uniform float4x4 worldViewProj)
{
// Calculate output position
oPosition = mul(worldViewProj, position);
// Simply copy the input vertex UV to the output
uv0 = texCoord0;
}
void main_plain_texture_fp(
// Pixel Inputs
float2 uv0 : TEXCOORD0, // UV interpolated for current pixel
// Outputs
out float4 color : COLOR, // Output color we want to write
// Model Level Inputs
uniform sampler2D Tex0: TEXUNIT0,
uniform sampler2D Tex1: TEXUNIT1) // Texture we're going to use
{
//get the index position by truncating the uv coordinates
float2 flooredIndexes = floor(uv0);
if((uv0.x > 0.9 && uv0.x < 1.1)
|| (uv0.x > 1.9 && uv0.x < 2.1)
|| (uv0.x > 2.9 && uv0.x < 3.1)
|| (uv0.x > 3.9 && uv0.x < 4.1)
|| (uv0.x > 4.9 && uv0.x < 5.1)
|| (uv0.x > 5.9 && uv0.x < 6.1)
|| (uv0.x > 6.9 && uv0.x < 7.1)
|| (uv0.x > 7.9 && uv0.x < 8.1)
|| (uv0.x > 8.9 && uv0.x < 9.1)) {
float4 color1 = {1.0,0,0,0};
color = color1;
} else if((uv0.y > 0.9 && uv0.y < 1.1)
|| (uv0.y > 1.9 && uv0.y < 2.1)
|| (uv0.y > 2.9 && uv0.y < 3.1)
|| (uv0.y > 3.9 && uv0.y < 4.1)
|| (uv0.y > 4.9 && uv0.y < 5.1)
|| (uv0.y > 5.9 && uv0.y < 6.1)
|| (uv0.y > 6.9 && uv0.y < 7.1)
|| (uv0.y > 7.9 && uv0.y < 8.1)
|| (uv0.y > 8.9 && uv0.y < 9.1)) {
float4 color1 = {1.0,0,0,0};
color = color1;
} else {
//get the colour of the index texture Tex0 at this floored coordinate
float4 indexColour = tex2D(Tex0, (1.0/10)*flooredIndexes);
color = indexColour;
}
}
संपादन के लिए धन्यवाद, मुझे यकीन है कि कैसे में :) –
बदलते छवियों डाल करने के लिए 'Float4 indexColour = tex2D (Tex0, (1.0/10) * flooredIndexes) नहीं था float4 indexColour = tex2D (Tex0, (1.0/20) * फर्श इंडेक्स); समस्या को हल कर सकते हैं – hamed
सुनिश्चित नहीं है कि इससे मदद मिली या नहीं, इसने समस्या को हल नहीं किया। 1/10 वीं से गुणा करने का कारण यह है कि यूवी 0 में इंडेक्स वर्तमान में यू और वी दोनों दिशाओं में 0 - 10 से चलते हैं। मैं इस मान को फर्श करता हूं क्योंकि यह खंड कार्यक्रम में अंतरित होता है, इसलिए मुझे 5.6 जैसे मान मिलते हैं, अगर मैं इस मान को फर्श करता हूं तो मुझे 5 मिलते हैं जो टाइल्स चौड़ाई (10) की संख्या से विभाजित होते हैं, मुझे यूवी समन्वय की आवश्यकता होती है, मुझे 0.5 –