- Home /
Question by
alexander11 · Aug 18, 2017 at 09:42 PM ·
unity 5cg
How do i Intensify Red Channel on Cubemap CG Unity 5?
I am running into a problem, I want to intensify the red pixels but i cant seem to do so each time i try it brightens the majority of the pixels. How do i fix this?
Code.
Shader "Custom/Shader_12" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Cubemap("Cube Map", CUBE) = "" {}
_ReflAmount("Reflection Amount", Range(0.1, 1)) = 0.5
_CMredC("CM Red Channel", Range(0,255)) = 0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Lambert
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
samplerCUBE _Cubemap;
float _ReflAmount;
float _CMredC;
struct Input {
float2 uv_MainTex;
float3 worldRefl;
};
fixed4 _Color;
void surf (Input IN, inout SurfaceOutput o) {
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
float3 CM = texCUBE(_Cubemap, IN.worldRefl).rgb * _ReflAmount;
o.Emission = CM * _CMredC.r;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Comment
Best Answer
Answer by Destolos · Aug 19, 2017 at 07:04 AM
I think the problem is in this line o.Emission = CM * _CMredC.r;
You are multiplying _CMRed with every channel. Perhaps o.Emission = CM * float3(_CMredC.r, 1, 1);
will do it.
Your answer
Follow this Question
Related Questions
Unity5 v Unity4 Shader array errors 1 Answer
CG compiled to GLSL: hyperbolic functions not found. 0 Answers
Transparent shader disappears with multiple objects 1 Answer
Difference between pos.z and pos.w? 0 Answers
How to compare colors in Shaders? 2 Answers